circle.vue 8.2 KB

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