circle.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="content">
  3. <view class="content1 flex">
  4. <view class="search flex flex-between" @click="search">
  5. <view class="left flex">
  6. <uni-icons type="search" size="24"></uni-icons>
  7. <text class="search-val"> {{searchVal?searchVal:'搜索名片'}}</text>
  8. </view>
  9. <view class="right">
  10. <uni-icons type="mic" size="24" @click.stop="micOpen"></uni-icons>
  11. </view>
  12. </view>
  13. <view class="right flex relative">
  14. <uni-icons type="personadd-filled" size="30" @click="toChangeCard"></uni-icons>
  15. <u-badge :isDot="true" type="error" class="point"></u-badge>
  16. </view>
  17. </view>
  18. <mescroll-body ref="mescrollRef" @init="mescrollInit" @up="upCallback" @down="downCallback">
  19. <view class="content2 flex flex-between">
  20. <view class="left">
  21. 我得圈子
  22. </view>
  23. <view class="right">
  24. <uni-icons type="personadd-filled" size="30" @click="toCreateCircle"></uni-icons>
  25. </view>
  26. </view>
  27. <view class="" v-for="(item,index) in circleList" :key="index">
  28. <view class="" v-if="item.name">
  29. {{item.name}}
  30. </view>
  31. <view class="content3 flex" v-if="!item.name">
  32. <view class="row-tiem" @click="toDetail(item.id)">
  33. <view class="left">
  34. <image src="../../static/logo.png" mode="widthFix" class="img"></image>
  35. </view>
  36. <view class="right">
  37. <view class="top">{{item.circleName}}({{item.cardNum}})</view>
  38. <view class="bottom">
  39. <span v-for="item1 in item.circleLabel.split(',')">
  40. {{item1}}
  41. </span>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </mescroll-body>
  48. <u-toast ref="uToast"></u-toast>
  49. </view>
  50. </template>
  51. <script>
  52. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  53. import {
  54. mapState,
  55. mapMutations
  56. } from 'vuex';
  57. export default {
  58. mixins: [MescrollMixin], // 使用mixin
  59. computed: {
  60. ...mapState(['hasLogin'])
  61. },
  62. data() {
  63. return {
  64. searchVal: '',
  65. circleList: [],
  66. userInfo: {},
  67. canReset:false,
  68. };
  69. },
  70. onShow() {
  71. this.searchVal = uni.getStorageSync("cirlce_search_val") ? uni.getStorageSync("cirlce_search_val") : ''
  72. this.userInfo = uni.getStorageSync("userInfo")
  73. this.$nextTick(function() {
  74. this.canReset && this.mescroll.resetUpScroll() // 重置列表数据为第一页
  75. this.canReset && this.mescroll.scrollTo(0, 0) // 重置列表数据为第一页时,建议把滚动条也重置到顶部,避免无法再次翻页的问题
  76. this.canReset = true // 过滤第一次的onShow事件,避免初始化界面时重复触发upCallback, 无需配置auto:false
  77. });
  78. },
  79. methods: {
  80. toChangeCard(){
  81. uni.navigateTo({
  82. url: "/pages/circle/changeCard"
  83. })
  84. },
  85. toCreateCircle() {
  86. uni.navigateTo({
  87. url: "/pages/circle/createCirclce"
  88. })
  89. },
  90. micOpen: function() {
  91. this.$refs.asr.show();
  92. },
  93. search() {
  94. uni.navigateTo({
  95. url: "/pages/circle/search"
  96. })
  97. },
  98. toDetail(val) {
  99. uni.navigateTo({
  100. url: "/pages/circle/detail?val="+val
  101. })
  102. },
  103. upCallback(page) {
  104. uni.showLoading({
  105. title: '数据加载中'
  106. })
  107. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'list', {
  108. commonId: this.userInfo.id,
  109. pageNum: page.num,
  110. pageSize: page.size,
  111. }, failres => {
  112. console.log('res+++++', failres.errmsg)
  113. this.$refs.uToast.show({
  114. type: 'error',
  115. message: failres.errmsg,
  116. })
  117. uni.hideLoading()
  118. }).then(res => {
  119. uni.hideLoading()
  120. console.log(11)
  121. let curPageData = res.data.items;
  122. let totalPage = res.data.total;
  123. let curPageLen = curPageData.length;
  124. this.mescroll.endByPage(curPageLen, totalPage);
  125. console.log(res.data)
  126. // this.makeData(res.data)
  127. if (page.num == 1) this.circleList = []; //如果是第一页需手动置空列表
  128. this.circleList = this.circleList.concat(curPageData); //追加新数据
  129. for (let i = 0; i < this.circleList.length; i++) {
  130. if (this.circleList[i].addedFlag == 0) {
  131. if (i == 0) {
  132. this.circleList.unshift({
  133. name: '推荐圈子'
  134. });
  135. } else {
  136. this.circleList.splice(i, 0, {
  137. name: '推荐圈子'
  138. })
  139. }
  140. console.log(this.circleList)
  141. return
  142. }
  143. }
  144. })
  145. },
  146. input(res) {
  147. console.log('----input:', res)
  148. },
  149. clear(res) {
  150. uni.showToast({
  151. title: 'clear事件,清除值为:' + res.value,
  152. icon: 'none'
  153. })
  154. },
  155. blur(res) {
  156. uni.showToast({
  157. title: 'blur事件,输入值为:' + res.value,
  158. icon: 'none'
  159. })
  160. },
  161. focus(e) {
  162. uni.showToast({
  163. title: 'focus事件,输出值为:' + e.value,
  164. icon: 'none'
  165. })
  166. },
  167. cancel(res) {
  168. uni.showToast({
  169. title: '点击取消,输入值为:' + res.value,
  170. icon: 'none'
  171. })
  172. }
  173. }
  174. }
  175. </script>
  176. <style lang="scss" scoped>
  177. .content1 {
  178. .right {
  179. /deep/.u-badge {
  180. position: absolute;
  181. top: 0;
  182. right: 6rpx;
  183. }
  184. }
  185. }
  186. .content3 {
  187. .img {
  188. width: 100rpx;
  189. }
  190. .right {
  191. display: flex;
  192. flex-direction: column;
  193. justify-content: space-between;
  194. }
  195. }
  196. </style>