detail.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <view class="content">
  3. <view class="content1">
  4. <view class="left">
  5. <image src="../../static/logo.png" mode="widthFix" class="img"></image>
  6. </view>
  7. <view class="right">
  8. <view class="top">
  9. <span class="">
  10. {{dataObj.circleName}}({{dataObj.cardNum}})
  11. </span>
  12. <span class="" @click="addCircle" v-if="dataObj.circleCardInfo">
  13. 加入
  14. </span>
  15. <span class="" @click="exitCircle" v-else>
  16. 退出
  17. </span>
  18. </view>
  19. <view class="bottom">
  20. <span v-for="item in dataObj.circleLabel">
  21. {{item}}
  22. </span>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="content2">
  27. <view class="top flex-between">
  28. <view class="span">
  29. <span>全部</span>
  30. <span @click="changeCardStatus(1)">已交换</span>
  31. <span @click="changeCardStatus(1)">未交换</span>
  32. </view>
  33. <view class="right" v-if="dataObj.circleCardInfo" @click="myCardClick">
  34. 我的名片
  35. </view>
  36. </view>
  37. </view>
  38. <mescroll-body ref="mescrollRef" @init="mescrollInit" @up="upCallback" @down="downCallback">
  39. <view class="content3 flex">
  40. <view class="left">
  41. <view class="top flex-row-center">
  42. <image src="../../static/uni.png" mode="widthFix" class="img"></image>
  43. </view>
  44. <view class="bottom flex flex-evenly">
  45. <uni-icons type="home" size="20"></uni-icons>
  46. <uni-icons type="redo" size="20" @click="changeCard"></uni-icons>
  47. </view>
  48. </view>
  49. <view class="right">
  50. <view class="row1 flex">
  51. <text>张三</text>
  52. <text class="line"></text>
  53. <text>总经理</text>
  54. </view>
  55. <view class="row2">
  56. 北京xxx有限公司
  57. </view>
  58. <view class="row3" @click="toMap">
  59. <uni-icons type="redo" size="20"></uni-icons>
  60. <text>北京市朝阳区幸福大街8号</text>
  61. </view>
  62. <view class="row3">
  63. <uni-icons type="redo" size="20"></uni-icons>
  64. <text>13333333333</text>
  65. </view>
  66. <view class="row3">
  67. <uni-icons type="redo" size="20"></uni-icons>
  68. <text>我是备注</text>
  69. </view>
  70. </view>
  71. </view>
  72. </mescroll-body>
  73. <u-picker :show="isShowCard" :columns="cardList" keyName="cardBusiness" @confirm="cardConfirm"></u-picker>
  74. <u-toast ref="uToast"></u-toast>
  75. <u-modal :show="show" :content='content' @confirm="$u.debounce(joinCircle, 500)" showCancelButton
  76. @cancel="show=false" @close="show=false" closeOnClickOverlay></u-modal>
  77. </view>
  78. </template>
  79. <script>
  80. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  81. export default {
  82. mixins: [MescrollMixin], // 使用mixin
  83. data() {
  84. return {
  85. dataObj: {
  86. circleName: '',
  87. cardNum: '',
  88. circleLabel: []
  89. },
  90. userInfo: {},
  91. canReset: false,
  92. cardList: [],
  93. isShowCard: false,
  94. show: false,
  95. content: '加入后其他用户查看您的名片和主页,确认加入圈子?',
  96. cardId: '',
  97. id: '',
  98. changeCardList: [],
  99. cardStatus:'',
  100. isMyCard:false
  101. };
  102. },
  103. onShow() {
  104. // this.$nextTick(function() {
  105. // this.canReset && this.mescroll.resetUpScroll() // 重置列表数据为第一页
  106. // this.canReset && this.mescroll.scrollTo(0, 0) // 重置列表数据为第一页时,建议把滚动条也重置到顶部,避免无法再次翻页的问题
  107. // this.canReset = true // 过滤第一次的onShow事件,避免初始化界面时重复触发upCallback, 无需配置auto:false
  108. // });
  109. },
  110. onLoad(options) {
  111. console.log(options)
  112. this.userInfo = uni.getStorageSync("userInfo")
  113. this.id = options.val
  114. this.init()
  115. },
  116. methods: {
  117. changeMyCard(){
  118. this.$request.baseRequest('admin.unimall.circleCardInfo', 'update', {
  119. circleCardInfo: JSON.stringify({
  120. circleId: this.dataObj.id,
  121. cardId: this.cardId,
  122. commonId: this.userInfo.id
  123. }),
  124. }, failres => {
  125. console.log('res+++++', failres.errmsg)
  126. this.$refs.uToast.show({
  127. type: 'error',
  128. message: failres.errmsg,
  129. })
  130. uni.hideLoading()
  131. }).then(res => {
  132. this.isShowCard = false
  133. this.$refs.uToast.show({
  134. type: 'success',
  135. message: "更改圈子名片成功!",
  136. })
  137. })
  138. },
  139. myCardClick(){
  140. this.isShowCard = true
  141. this.isMyCard = true
  142. },
  143. changeCardStatus(val){
  144. this.cardStatus = val
  145. this.getCardList()
  146. },
  147. exitCircle() {
  148. this.$request.baseRequest('admin.unimall.circleCardInfo', 'delete', {
  149. id: this.dataObj.circleCardInfo.id,
  150. }, failres => {
  151. console.log('res+++++', failres.errmsg)
  152. this.$refs.uToast.show({
  153. type: 'error',
  154. message: failres.errmsg,
  155. })
  156. uni.hideLoading()
  157. }).then(res => {
  158. this.isShowCard = false
  159. this.$refs.uToast.show({
  160. type: 'success',
  161. message: "退出成功!",
  162. })
  163. })
  164. },
  165. cardConfirm(e) {
  166. console.log("e", e)
  167. this.cardId = e.value[0].id
  168. if(this.isMyCard){
  169. this.changeMyCard()
  170. }else{
  171. this.joinCircle()
  172. }
  173. },
  174. joinCircle() {
  175. this.$request.baseRequest('admin.unimall.circleCardInfo', 'add', {
  176. circleCardInfo: JSON.stringify({
  177. circleId: this.dataObj.id,
  178. cardId: this.cardId,
  179. commonId: this.userInfo.id
  180. }),
  181. }, failres => {
  182. console.log('res+++++', failres.errmsg)
  183. this.$refs.uToast.show({
  184. type: 'error',
  185. message: failres.errmsg,
  186. })
  187. uni.hideLoading()
  188. }).then(res => {
  189. this.isShowCard = false
  190. this.$refs.uToast.show({
  191. type: 'success',
  192. message: "加入成功!",
  193. })
  194. })
  195. },
  196. addCircle() {
  197. if (this.cardList[0].length == 1) {
  198. this.show = true
  199. } else if (this.cardList[0].length > 1) {
  200. this.isShowCard = true
  201. } else {
  202. this.$refs.uToast.show({
  203. type: 'error',
  204. message: "您还没有自己的名片,请创建后再加入圈子",
  205. })
  206. }
  207. },
  208. init() {
  209. },
  210. getCardList(){
  211. uni.showLoading({
  212. title: '数据加载中'
  213. })
  214. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'circleCardlist', {
  215. commonId: this.userInfo.id,
  216. id: this.dataObj.id,
  217. status: this.cardStatus,
  218. pageNum: page.num,
  219. pageSize: page.size,
  220. }, failres => {
  221. console.log('res+++++', failres.errmsg)
  222. this.$refs.uToast.show({
  223. type: 'error',
  224. message: failres.errmsg,
  225. })
  226. uni.hideLoading()
  227. }).then(res => {
  228. uni.hideLoading()
  229. console.log(11)
  230. let curPageData = res.data.items;
  231. let totalPage = res.data.total;
  232. let curPageLen = curPageData.length;
  233. this.mescroll.endByPage(curPageLen, totalPage);
  234. console.log(res.data)
  235. // this.makeData(res.data)
  236. if (page.num == 1) this.changeCardList = []; //如果是第一页需手动置空列表
  237. this.changeCardList = this.changeCardList.concat(curPageData); //追加新数据
  238. })
  239. },
  240. async upCallback(page) {
  241. //获取名片
  242. await this.$request.baseRequest('admin.unimall.cardManagementInfo', 'list', {
  243. commonId: this.userInfo.id
  244. }, failres => {
  245. console.log('res+++++', failres.errmsg)
  246. this.$refs.uToast.show({
  247. type: 'error',
  248. message: failres.errmsg,
  249. })
  250. }).then(res => {
  251. this.cardList = [res.data.items]
  252. })
  253. await this.$request.baseRequest('admin.unimall.circleManagementInfo', 'get', {
  254. commonId: this.userInfo.id,
  255. id: this.id
  256. }, failres => {
  257. console.log('res+++++', failres.errmsg)
  258. this.$refs.uToast.show({
  259. type: 'error',
  260. message: failres.errmsg,
  261. })
  262. uni.hideLoading()
  263. }).then(res => {
  264. console.log(res.data)
  265. this.dataObj = res.data
  266. })
  267. this.getCardList()
  268. },
  269. changeCard() {
  270. uni.navigateTo({
  271. url: "/pages/circle/changeCard"
  272. })
  273. },
  274. }
  275. }
  276. </script>
  277. <style lang="scss">
  278. .content1 {
  279. display: flex;
  280. }
  281. .img {
  282. width: 100rpx;
  283. }
  284. .content3 {
  285. border: 1px solid #ccc;
  286. border-radius: 30rpx;
  287. padding: 40rpx;
  288. box-sizing: border-box;
  289. .left {
  290. width: 30%;
  291. .top {
  292. margin-bottom: 20rpx;
  293. }
  294. .img {
  295. width: 80%;
  296. }
  297. .bottom {}
  298. }
  299. .right {
  300. .row1 {
  301. .line {
  302. width: 1px;
  303. height: 20px;
  304. margin: 0 20rpx;
  305. background: black;
  306. }
  307. }
  308. }
  309. }
  310. </style>