circle.vue 5.4 KB

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