circle.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. onLoad(options) {
  71. this.searchVal = options.val
  72. },
  73. onShow() {
  74. // this.searchVal = uni.getStorageSync("cirlce_search_val") ? uni.getStorageSync("cirlce_search_val") : ''
  75. this.userInfo = uni.getStorageSync("userInfo")
  76. this.$nextTick(function() {
  77. this.canReset && this.mescroll.resetUpScroll() // 重置列表数据为第一页
  78. this.canReset && this.mescroll.scrollTo(0, 0) // 重置列表数据为第一页时,建议把滚动条也重置到顶部,避免无法再次翻页的问题
  79. this.canReset = true // 过滤第一次的onShow事件,避免初始化界面时重复触发upCallback, 无需配置auto:false
  80. });
  81. },
  82. methods: {
  83. toChangeCard(){
  84. uni.navigateTo({
  85. url: "/pages/circle/changeCard"
  86. })
  87. },
  88. toCreateCircle() {
  89. uni.navigateTo({
  90. url: "/pages/circle/createCirclce"
  91. })
  92. },
  93. micOpen: function() {
  94. this.$refs.asr.show();
  95. },
  96. search() {
  97. uni.navigateTo({
  98. url: "/pages/circle/search"
  99. })
  100. },
  101. toDetail(val) {
  102. uni.navigateTo({
  103. url: "/pages/circle/detail?val="+val
  104. })
  105. },
  106. upCallback(page) {
  107. uni.showLoading({
  108. title: '数据加载中'
  109. })
  110. let _data = {
  111. commonId: this.userInfo.id,
  112. page: page.num,
  113. limit: page.size,
  114. }
  115. if(this.searchVal){
  116. _data.circleName = this.searchVal
  117. }
  118. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'list', _data, failres => {
  119. console.log('res+++++', failres.errmsg)
  120. this.$refs.uToast.show({
  121. type: 'error',
  122. message: failres.errmsg,
  123. })
  124. uni.hideLoading()
  125. }).then(res => {
  126. uni.hideLoading()
  127. console.log(11)
  128. let curPageData = res.data.items;
  129. let totalPage = res.data.total;
  130. let curPageLen = curPageData.length;
  131. this.mescroll.endByPage(curPageLen, totalPage);
  132. console.log(res.data)
  133. // this.makeData(res.data)
  134. if (page.num == 1) this.circleList = []; //如果是第一页需手动置空列表
  135. this.circleList = this.circleList.concat(curPageData); //追加新数据
  136. for (let i = 0; i < this.circleList.length; i++) {
  137. if (this.circleList[i].addedFlag == 0) {
  138. if (i == 0) {
  139. this.circleList.unshift({
  140. name: '推荐圈子'
  141. });
  142. } else {
  143. this.circleList.splice(i, 0, {
  144. name: '推荐圈子'
  145. })
  146. }
  147. console.log(this.circleList)
  148. return
  149. }
  150. }
  151. })
  152. },
  153. input(res) {
  154. console.log('----input:', res)
  155. },
  156. clear(res) {
  157. uni.showToast({
  158. title: 'clear事件,清除值为:' + res.value,
  159. icon: 'none'
  160. })
  161. },
  162. blur(res) {
  163. uni.showToast({
  164. title: 'blur事件,输入值为:' + res.value,
  165. icon: 'none'
  166. })
  167. },
  168. focus(e) {
  169. uni.showToast({
  170. title: 'focus事件,输出值为:' + e.value,
  171. icon: 'none'
  172. })
  173. },
  174. cancel(res) {
  175. uni.showToast({
  176. title: '点击取消,输入值为:' + res.value,
  177. icon: 'none'
  178. })
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .content1 {
  185. .right {
  186. /deep/.u-badge {
  187. position: absolute;
  188. top: 0;
  189. right: 6rpx;
  190. }
  191. }
  192. }
  193. .content3 {
  194. .img {
  195. width: 100rpx;
  196. }
  197. .right {
  198. display: flex;
  199. flex-direction: column;
  200. justify-content: space-between;
  201. }
  202. }
  203. </style>