detail.vue 9.3 KB

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