circle.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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"></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">
  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. firstTitle: 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. toCreateCircle() {
  81. uni.navigateTo({
  82. url: "/pages/circle/createCirclce"
  83. })
  84. },
  85. micOpen: function() {
  86. this.$refs.asr.show();
  87. },
  88. search() {
  89. uni.navigateTo({
  90. url: "/pages/circle/search"
  91. })
  92. },
  93. toDetail(val) {
  94. uni.navigateTo({
  95. url: "/pages/circle/detail"
  96. })
  97. },
  98. upCallback(page) {
  99. uni.showLoading({
  100. title: '数据加载中'
  101. })
  102. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'list', {
  103. commonId: this.userInfo.id,
  104. pageNum: page.num,
  105. pageSize: page.size,
  106. }, failres => {
  107. console.log('res+++++', failres.errmsg)
  108. this.$refs.uToast.show({
  109. type: 'error',
  110. message: failres.errmsg,
  111. })
  112. uni.hideLoading()
  113. }).then(res => {
  114. uni.hideLoading()
  115. console.log(11)
  116. let curPageData = res.data.items;
  117. let totalPage = res.data.total;
  118. let curPageLen = curPageData.length;
  119. this.mescroll.endByPage(curPageLen, totalPage);
  120. console.log(res.data)
  121. // this.makeData(res.data)
  122. if (page.num == 1) this.circleList = []; //如果是第一页需手动置空列表
  123. this.circleList = this.circleList.concat(curPageData); //追加新数据
  124. for (let i = 0; i < this.circleList.length; i++) {
  125. if (!this.firstTitle && this.circleList[i].addedFlag == 0) {
  126. this.firstTitle = true
  127. if (i == 0) {
  128. this.circleList.unshift({
  129. name: '推荐圈子'
  130. });
  131. } else {
  132. this.circleList.splice(i - 1, 0, {
  133. name: '推荐圈子'
  134. })
  135. }
  136. console.log(this.circleList)
  137. return
  138. }
  139. }
  140. })
  141. },
  142. input(res) {
  143. console.log('----input:', res)
  144. },
  145. clear(res) {
  146. uni.showToast({
  147. title: 'clear事件,清除值为:' + res.value,
  148. icon: 'none'
  149. })
  150. },
  151. blur(res) {
  152. uni.showToast({
  153. title: 'blur事件,输入值为:' + res.value,
  154. icon: 'none'
  155. })
  156. },
  157. focus(e) {
  158. uni.showToast({
  159. title: 'focus事件,输出值为:' + e.value,
  160. icon: 'none'
  161. })
  162. },
  163. cancel(res) {
  164. uni.showToast({
  165. title: '点击取消,输入值为:' + res.value,
  166. icon: 'none'
  167. })
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="scss" scoped>
  173. .content1 {
  174. .right {
  175. /deep/.u-badge {
  176. position: absolute;
  177. top: 0;
  178. right: 6rpx;
  179. }
  180. }
  181. }
  182. .content3 {
  183. .img {
  184. width: 100rpx;
  185. }
  186. .right {
  187. display: flex;
  188. flex-direction: column;
  189. justify-content: space-between;
  190. }
  191. }
  192. </style>