detail.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. },
  115. methods: {
  116. changeMyCard() {
  117. this.$request.baseRequest('admin.unimall.circleCardInfo', 'update', {
  118. circleCardInfo: JSON.stringify({
  119. circleId: this.dataObj.id,
  120. cardId: this.cardId,
  121. commonId: this.userInfo.id
  122. }),
  123. }, failres => {
  124. console.log('res+++++', failres.errmsg)
  125. this.$refs.uToast.show({
  126. type: 'error',
  127. message: failres.errmsg,
  128. })
  129. uni.hideLoading()
  130. }).then(res => {
  131. this.isShowCard = false
  132. this.$refs.uToast.show({
  133. type: 'success',
  134. message: "更改圈子名片成功!",
  135. })
  136. })
  137. },
  138. myCardClick() {
  139. this.isShowCard = true
  140. this.isMyCard = true
  141. },
  142. changeCardStatus(val) {
  143. this.cardStatus = val
  144. this.getCardList()
  145. },
  146. exitCircle() {
  147. this.$request.baseRequest('admin.unimall.circleCardInfo', 'delete', {
  148. id: this.dataObj.circleCardInfo.id,
  149. }, failres => {
  150. console.log('res+++++', failres.errmsg)
  151. this.$refs.uToast.show({
  152. type: 'error',
  153. message: failres.errmsg,
  154. })
  155. uni.hideLoading()
  156. }).then(res => {
  157. this.isShowCard = false
  158. this.$refs.uToast.show({
  159. type: 'success',
  160. message: "退出成功!",
  161. })
  162. })
  163. },
  164. cardConfirm(e) {
  165. console.log("e", e)
  166. this.cardId = e.value[0].id
  167. if (this.isMyCard) {
  168. this.changeMyCard()
  169. } else {
  170. this.joinCircle()
  171. }
  172. },
  173. joinCircle() {
  174. this.$request.baseRequest('admin.unimall.circleCardInfo', 'add', {
  175. circleCardInfo: JSON.stringify({
  176. circleId: this.dataObj.id,
  177. cardId: this.cardId,
  178. commonId: this.userInfo.id
  179. }),
  180. }, failres => {
  181. console.log('res+++++', failres.errmsg)
  182. this.$refs.uToast.show({
  183. type: 'error',
  184. message: failres.errmsg,
  185. })
  186. uni.hideLoading()
  187. }).then(res => {
  188. this.isShowCard = false
  189. this.$refs.uToast.show({
  190. type: 'success',
  191. message: "加入成功!",
  192. })
  193. })
  194. },
  195. addCircle() {
  196. if (this.cardList[0].length == 1) {
  197. this.show = true
  198. } else if (this.cardList[0].length > 1) {
  199. this.isShowCard = true
  200. } else {
  201. this.$refs.uToast.show({
  202. type: 'error',
  203. message: "您还没有自己的名片,请创建后再加入圈子",
  204. })
  205. }
  206. },
  207. getCardList(page) {
  208. uni.showLoading({
  209. title: '数据加载中'
  210. })
  211. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'circleCardlist', {
  212. commonId: this.userInfo.id,
  213. id: this.dataObj.id,
  214. status: this.cardStatus,
  215. pageNum: page.num,
  216. pageSize: page.size,
  217. }, failres => {
  218. console.log('res+++++', failres.errmsg)
  219. this.$refs.uToast.show({
  220. type: 'error',
  221. message: failres.errmsg,
  222. })
  223. uni.hideLoading()
  224. }).then(res => {
  225. uni.hideLoading()
  226. console.log(11)
  227. let curPageData = res.data.items;
  228. let totalPage = res.data.total;
  229. let curPageLen = curPageData.length;
  230. this.mescroll.endByPage(curPageLen, totalPage);
  231. console.log(res.data)
  232. // this.makeData(res.data)
  233. if (page.num == 1) this.changeCardList = []; //如果是第一页需手动置空列表
  234. this.changeCardList = this.changeCardList.concat(curPageData); //追加新数据
  235. })
  236. },
  237. async upCallback(page) {
  238. //获取名片
  239. await this.$request.baseRequest('admin.unimall.cardManagementInfo', 'list', {
  240. commonId: this.userInfo.id
  241. }, failres => {
  242. console.log('res+++++', failres.errmsg)
  243. this.$refs.uToast.show({
  244. type: 'error',
  245. message: failres.errmsg,
  246. })
  247. }).then(res => {
  248. this.cardList = [res.data.items]
  249. })
  250. await this.$request.baseRequest('admin.unimall.circleManagementInfo', 'get', {
  251. commonId: this.userInfo.id,
  252. id: this.id
  253. }, failres => {
  254. console.log('res+++++', failres.errmsg)
  255. this.$refs.uToast.show({
  256. type: 'error',
  257. message: failres.errmsg,
  258. })
  259. uni.hideLoading()
  260. }).then(res => {
  261. console.log(res.data)
  262. this.dataObj = res.data
  263. })
  264. this.getCardList(page)
  265. },
  266. changeCard() {
  267. uni.navigateTo({
  268. url: "/pages/circle/changeCard"
  269. })
  270. },
  271. }
  272. }
  273. </script>
  274. <style lang="scss">
  275. .content1 {
  276. display: flex;
  277. }
  278. .img {
  279. width: 100rpx;
  280. }
  281. .content3 {
  282. border: 1px solid #ccc;
  283. border-radius: 30rpx;
  284. padding: 40rpx;
  285. box-sizing: border-box;
  286. .left {
  287. width: 30%;
  288. .top {
  289. margin-bottom: 20rpx;
  290. }
  291. .img {
  292. width: 80%;
  293. }
  294. .bottom {}
  295. }
  296. .right {
  297. .row1 {
  298. .line {
  299. width: 1px;
  300. height: 20px;
  301. margin: 0 20rpx;
  302. background: black;
  303. }
  304. }
  305. }
  306. }
  307. </style>