circle.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <view class="content">
  3. <view class="content1 flex flex-between">
  4. <view class="search flex">
  5. <view class="left flex" @click="search">
  6. <image src="../../static/imgs/cirlce/search.png" mode="widthFix" class="search-img"></image>
  7. <text class="search-val"> {{searchVal?searchVal:'搜索圈子'}}</text>
  8. <uni-icons type="closeempty" size="24" @click.native.stop="delSearchVal"
  9. v-if="searchVal"></uni-icons>
  10. </view>
  11. </view>
  12. <view class="right relative">
  13. <image src="../../static/imgs/cirlce/hy.png" mode="widthFix" class="hy-search-img"
  14. @click="toChangeCard"></image>
  15. <u-badge :isDot="true" type="error" class="point position"></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 flex title">
  21. <view class="line"></view>
  22. <view class="text-title">
  23. 我得圈子
  24. </view>
  25. </view>
  26. <!-- <view class="right">
  27. <uni-icons type="personadd-filled" size="30" @click="toCreateCircle"></uni-icons>
  28. </view> -->
  29. </view>
  30. <view class="" v-for="(item,index) in circleList" :key="index">
  31. <view class="flex title" v-if="item.name">
  32. <view class="line"></view>
  33. <view class="text-title">
  34. {{item.name}}
  35. </view>
  36. </view>
  37. <view class="row-tiem flex" v-if="!item.name" @click="toDetail(item.id)">
  38. <view class="left">
  39. <image src="../../static/imgs/scirlce.png" mode="widthFix" class="img"></image>
  40. </view>
  41. <view class="right">
  42. <view class="top">{{item.circleName}}({{item.cardNum}})</view>
  43. <view class="bottom">
  44. <span v-for="item1 in item.circleLabel.split(',')" class="text">
  45. {{item1}}
  46. </span>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </mescroll-body>
  52. <image src="../../static/imgs/cirlce/add.png" mode="widthFix" class="add" @click="toCreateCircle"></image>
  53. <u-toast ref="uToast"></u-toast>
  54. </view>
  55. </template>
  56. <script>
  57. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  58. import {
  59. mapState,
  60. mapMutations
  61. } from 'vuex';
  62. export default {
  63. mixins: [MescrollMixin], // 使用mixin
  64. computed: {
  65. ...mapState(['hasLogin'])
  66. },
  67. data() {
  68. return {
  69. searchVal: '',
  70. circleList: [],
  71. userInfo: {},
  72. canReset: false,
  73. };
  74. },
  75. onLoad(options) {
  76. this.searchVal = options.val
  77. },
  78. onShow() {
  79. // this.searchVal = uni.getStorageSync("cirlce_search_val") ? uni.getStorageSync("cirlce_search_val") : ''
  80. this.userInfo = uni.getStorageSync("userInfo")
  81. this.$nextTick(function() {
  82. this.canReset && this.mescroll.resetUpScroll() // 重置列表数据为第一页
  83. this.canReset && this.mescroll.scrollTo(0, 0) // 重置列表数据为第一页时,建议把滚动条也重置到顶部,避免无法再次翻页的问题
  84. this.canReset = true // 过滤第一次的onShow事件,避免初始化界面时重复触发upCallback, 无需配置auto:false
  85. });
  86. },
  87. methods: {
  88. delSearchVal() {
  89. this.searchVal = ""
  90. this.mescroll.resetUpScroll()
  91. },
  92. toChangeCard() {
  93. uni.navigateTo({
  94. url: "/pages/circle/changeCard"
  95. })
  96. },
  97. toCreateCircle() {
  98. uni.navigateTo({
  99. url: "/pages/circle/createCirclce"
  100. })
  101. },
  102. micOpen: function() {
  103. this.$refs.asr.show();
  104. },
  105. search() {
  106. uni.navigateTo({
  107. url: "/pages/circle/search"
  108. })
  109. },
  110. toDetail(val) {
  111. uni.navigateTo({
  112. url: "/pages/circle/detail?val=" + val
  113. })
  114. },
  115. upCallback(page) {
  116. uni.showLoading({
  117. title: '数据加载中'
  118. })
  119. let _data = {
  120. commonId: this.userInfo.id,
  121. page: page.num,
  122. limit: page.size,
  123. }
  124. if (this.searchVal) {
  125. _data.circleName = this.searchVal
  126. }
  127. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'list', _data, failres => {
  128. console.log('res+++++', failres.errmsg)
  129. this.$refs.uToast.show({
  130. type: 'error',
  131. message: failres.errmsg,
  132. })
  133. uni.hideLoading()
  134. }).then(res => {
  135. uni.hideLoading()
  136. console.log(11)
  137. let curPageData = res.data.items;
  138. let totalPage = res.data.total;
  139. let curPageLen = curPageData.length;
  140. this.mescroll.endByPage(curPageLen, totalPage);
  141. console.log(res.data)
  142. // this.makeData(res.data)
  143. if (page.num == 1) this.circleList = []; //如果是第一页需手动置空列表
  144. this.circleList = this.circleList.concat(curPageData); //追加新数据
  145. for (let i = 0; i < this.circleList.length; i++) {
  146. if (this.circleList[i].addedFlag == 0) {
  147. if (i == 0) {
  148. this.circleList.unshift({
  149. name: '推荐圈子'
  150. });
  151. } else {
  152. this.circleList.splice(i, 0, {
  153. name: '推荐圈子'
  154. })
  155. }
  156. console.log(this.circleList)
  157. return
  158. }
  159. }
  160. })
  161. },
  162. input(res) {
  163. console.log('----input:', res)
  164. },
  165. clear(res) {
  166. uni.showToast({
  167. title: 'clear事件,清除值为:' + res.value,
  168. icon: 'none'
  169. })
  170. },
  171. blur(res) {
  172. uni.showToast({
  173. title: 'blur事件,输入值为:' + res.value,
  174. icon: 'none'
  175. })
  176. },
  177. focus(e) {
  178. uni.showToast({
  179. title: 'focus事件,输出值为:' + e.value,
  180. icon: 'none'
  181. })
  182. },
  183. cancel(res) {
  184. uni.showToast({
  185. title: '点击取消,输入值为:' + res.value,
  186. icon: 'none'
  187. })
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. .content1 {
  194. margin: 50rpx 25rpx 14rpx 25rpx;
  195. .search {
  196. width: 100%;
  197. .left {
  198. background: #fff;
  199. border-radius: 38rpx;
  200. padding: 18rpx;
  201. width: 100%;
  202. }
  203. .search-val {
  204. color: #B3B3B3;
  205. }
  206. }
  207. .hy-search-img {
  208. width: 38rpx;
  209. margin-left: 40rpx;
  210. }
  211. .search-img {
  212. width: 38rpx;
  213. margin-right: 40rpx;
  214. }
  215. .right {
  216. /deep/.u-badge {
  217. position: absolute;
  218. top: 0;
  219. right: -10rpx;
  220. }
  221. }
  222. }
  223. .line {
  224. width: 8rpx;
  225. height: 34rpx;
  226. background: #112253;
  227. border-radius: 3px;
  228. margin: 20rpx;
  229. }
  230. .title {
  231. margin: 20rpx 0;
  232. }
  233. .text-title {
  234. font-size: 32rpx;
  235. font-weight: bold;
  236. color: #1A1A1A;
  237. }
  238. .row-tiem {
  239. background: #fff;
  240. padding: 24rpx;
  241. margin: 0 34rpx;
  242. align-items: unset;
  243. .img {
  244. width: 122rpx;
  245. height: 122rpx;
  246. border-radius: 10px;
  247. margin-right: 30rpx;
  248. }
  249. .right {
  250. display: flex;
  251. flex-direction: column;
  252. justify-content: space-evenly;
  253. .top {
  254. font-size: 32rpx;
  255. font-weight: bold;
  256. color: #1A1A1A;
  257. }
  258. .bottom {
  259. margin-top: 10rpx;
  260. .text {
  261. background: #FAFAFA;
  262. border-radius: 20px;
  263. font-size: 26rpx;
  264. font-weight: 700;
  265. color: #666666;
  266. padding: 11rpx 40rpx;
  267. margin-right: 20rpx;
  268. }
  269. }
  270. }
  271. }
  272. .add{
  273. width:84rpx;
  274. position: fixed;
  275. bottom: 26rpx;
  276. right: 26rpx;
  277. }
  278. </style>