detail.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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" v-for="(item,index) in changeCardList" :key="index">
  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" v-if="item.lookPage==1"></uni-icons>
  46. <uni-icons type="redo" size="20" @click="changeCard(item)"
  47. v-if="item.notDisplay!=1"></uni-icons>
  48. </view>
  49. </view>
  50. <view class="right">
  51. <view class="row1 flex">
  52. <text>{{item.name}}</text>
  53. <text class="line"></text>
  54. <text>{{item.post}}</text>
  55. </view>
  56. <view class="row2">
  57. {{item.companyName}}
  58. </view>
  59. <view class="row3">
  60. <uni-icons type="redo" size="20"></uni-icons>
  61. <text>{{item.scopeOfBusiness}}</text>
  62. </view>
  63. </view>
  64. </view>
  65. </mescroll-body>
  66. <u-picker :show="isShowCard" :columns="cardList" keyName="cardBusiness" @confirm="cardConfirm"></u-picker>
  67. <u-toast ref="uToast"></u-toast>
  68. <u-modal :show="show" :content='content' @confirm="$u.debounce(joinCircle, 500)" showCancelButton
  69. @cancel="show=false" @close="show=false" closeOnClickOverlay></u-modal>
  70. <u-modal :show="isShowChangeCard" content='确定交换名片?' @confirm="$u.debounce(confirmChangeSubmit, 500)"
  71. showCancelButton @cancel="isShowChangeCard=false" @close="isShowChangeCard=false"
  72. closeOnClickOverlay></u-modal>
  73. </view>
  74. </template>
  75. <script>
  76. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  77. export default {
  78. mixins: [MescrollMixin], // 使用mixin
  79. data() {
  80. return {
  81. isShowChangeCard: false,
  82. dataObj: {
  83. circleName: '',
  84. cardNum: '',
  85. circleLabel: []
  86. },
  87. userInfo: {},
  88. canReset: false,
  89. cardList: [],
  90. isShowCard: false,
  91. show: false,
  92. content: '加入后其他用户查看您的名片和主页,确认加入圈子?',
  93. cardId: '',
  94. id: '',
  95. changeCardList: [],
  96. cardStatus: '',
  97. isMyCard: false,
  98. swapNameCards: false,
  99. selectMycard: {},
  100. selectRowCard: {}
  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. confirmChangeSubmit() {
  117. debugger
  118. this.$request.baseRequest('admin.unimall.cardExchangeInfo', 'add', {
  119. cardExchangeInfo: JSON.stringify({
  120. sendId: this.userInfo.id,
  121. receiveId: this.selectRowCard.receiveId,
  122. sendCardId: this.selectMycard.id,
  123. receiveCardId: this.selectRowCard.id,
  124. circleName: this.dataObj.circleName
  125. }),
  126. }, failres => {
  127. console.log('res+++++', failres.errmsg)
  128. this.$refs.uToast.show({
  129. type: 'error',
  130. message: failres.errmsg,
  131. })
  132. uni.hideLoading()
  133. }).then(res => {
  134. this.isShowChangeCard = false
  135. this.$refs.uToast.show({
  136. type: 'success',
  137. message: "操作成功!"
  138. })
  139. setTimeout(()=>{
  140. this.mescroll.resetUpScroll()
  141. },500)
  142. this.mescroll.resetUpScroll()
  143. })
  144. },
  145. changeMyCard() {
  146. this.$request.baseRequest('admin.unimall.circleCardInfo', 'update', {
  147. circleCardInfo: JSON.stringify({
  148. circleId: this.dataObj.id,
  149. cardId: this.cardId,
  150. commonId: this.userInfo.id
  151. }),
  152. }, failres => {
  153. console.log('res+++++', failres.errmsg)
  154. this.$refs.uToast.show({
  155. type: 'error',
  156. message: failres.errmsg,
  157. })
  158. uni.hideLoading()
  159. }).then(res => {
  160. this.isShowCard = false
  161. this.$refs.uToast.show({
  162. type: 'success',
  163. message: "更改圈子名片成功!",
  164. })
  165. })
  166. },
  167. myCardClick() {
  168. this.isShowCard = true
  169. this.isMyCard = true
  170. },
  171. changeCardStatus(val) {
  172. this.cardStatus = val
  173. this.getCardList()
  174. },
  175. exitCircle() {
  176. this.$request.baseRequest('admin.unimall.circleCardInfo', 'delete', {
  177. id: this.dataObj.circleCardInfo.id,
  178. }, failres => {
  179. console.log('res+++++', failres.errmsg)
  180. this.$refs.uToast.show({
  181. type: 'error',
  182. message: failres.errmsg,
  183. })
  184. uni.hideLoading()
  185. }).then(res => {
  186. this.isShowCard = false
  187. this.$refs.uToast.show({
  188. type: 'success',
  189. message: "退出成功!",
  190. })
  191. })
  192. },
  193. cardConfirm(e) {
  194. console.log("e", e)
  195. this.cardId = e.value[0].id
  196. if (this.isMyCard) {
  197. this.changeMyCard()
  198. } else if (this.swapNameCards) {
  199. this.selectMycard = e.value[0]
  200. this.isShowCard = false
  201. this.isShowChangeCard = true
  202. } else {
  203. this.joinCircle()
  204. }
  205. },
  206. joinCircle() {
  207. this.$request.baseRequest('admin.unimall.circleCardInfo', 'add', {
  208. circleCardInfo: JSON.stringify({
  209. circleId: this.dataObj.id,
  210. cardId: this.cardId,
  211. commonId: this.userInfo.id
  212. }),
  213. }, failres => {
  214. console.log('res+++++', failres.errmsg)
  215. this.$refs.uToast.show({
  216. type: 'error',
  217. message: failres.errmsg,
  218. })
  219. uni.hideLoading()
  220. }).then(res => {
  221. this.isShowCard = false
  222. this.$refs.uToast.show({
  223. type: 'success',
  224. message: "加入成功!",
  225. })
  226. })
  227. },
  228. addCircle() {
  229. if (this.cardList[0].length == 1) {
  230. this.show = true
  231. } else if (this.cardList[0].length > 1) {
  232. this.isShowCard = true
  233. } else {
  234. this.$refs.uToast.show({
  235. type: 'error',
  236. message: "您还没有自己的名片,请创建后再加入圈子",
  237. })
  238. }
  239. },
  240. getCardList(page) {
  241. uni.showLoading({
  242. title: '数据加载中'
  243. })
  244. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'circleCardlist', {
  245. commonId: this.userInfo.id,
  246. id: this.dataObj.id,
  247. status: this.cardStatus,
  248. pageNum: page.num,
  249. pageSize: page.size,
  250. }, failres => {
  251. console.log('res+++++', failres.errmsg)
  252. this.$refs.uToast.show({
  253. type: 'error',
  254. message: failres.errmsg,
  255. })
  256. uni.hideLoading()
  257. }).then(res => {
  258. uni.hideLoading()
  259. console.log(11)
  260. let curPageData = res.data.items;
  261. let totalPage = res.data.total;
  262. let curPageLen = curPageData.length;
  263. this.mescroll.endByPage(curPageLen, totalPage);
  264. console.log(res.data)
  265. // this.makeData(res.data)
  266. if (page.num == 1) this.changeCardList = []; //如果是第一页需手动置空列表
  267. this.changeCardList = this.changeCardList.concat(curPageData); //追加新数据
  268. })
  269. },
  270. async upCallback(page) {
  271. //获取名片
  272. await this.$request.baseRequest('admin.unimall.cardManagementInfo', 'list', {
  273. commonId: this.userInfo.id
  274. }, failres => {
  275. console.log('res+++++', failres.errmsg)
  276. this.$refs.uToast.show({
  277. type: 'error',
  278. message: failres.errmsg,
  279. })
  280. }).then(res => {
  281. this.cardList = [res.data.items]
  282. })
  283. await this.$request.baseRequest('admin.unimall.circleManagementInfo', 'get', {
  284. commonId: this.userInfo.id,
  285. id: this.id
  286. }, failres => {
  287. console.log('res+++++', failres.errmsg)
  288. this.$refs.uToast.show({
  289. type: 'error',
  290. message: failres.errmsg,
  291. })
  292. uni.hideLoading()
  293. }).then(res => {
  294. console.log(res.data)
  295. this.dataObj = res.data
  296. })
  297. this.getCardList(page)
  298. },
  299. changeCard(val) {
  300. this.selectRowCard = val
  301. this.swapNameCards = true
  302. this.isShowCard = true
  303. },
  304. }
  305. }
  306. </script>
  307. <style lang="scss">
  308. .content1 {
  309. display: flex;
  310. }
  311. .img {
  312. width: 100rpx;
  313. }
  314. .content3 {
  315. border: 1px solid #ccc;
  316. border-radius: 30rpx;
  317. padding: 40rpx;
  318. box-sizing: border-box;
  319. .left {
  320. width: 30%;
  321. .top {
  322. margin-bottom: 20rpx;
  323. }
  324. .img {
  325. width: 80%;
  326. }
  327. .bottom {}
  328. }
  329. .right {
  330. .row1 {
  331. .line {
  332. width: 1px;
  333. height: 20px;
  334. margin: 0 20rpx;
  335. background: black;
  336. }
  337. }
  338. }
  339. }
  340. </style>