circle.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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. uni.showToast({
  89. icon:"none",
  90. title: failres.errmsg,
  91. duration: 3000
  92. });
  93. uni.hideLoading()
  94. }).then(res => {
  95. uni.hideLoading()
  96. this.cardList = res.data.items.filter((item)=>{return item.status==0})
  97. console.log(this.cardList)
  98. })
  99. },
  100. onShow() {
  101. this.searchVal = uni.getStorageSync("cirlce_search_val") ? uni.getStorageSync("cirlce_search_val") : ''
  102. if(this.searchVal) this.mescroll.resetUpScroll();
  103. },
  104. methods: {
  105. delSearchVal() {
  106. this.searchVal = ""
  107. uni.removeStorageSync('cirlce_search_val')
  108. this.mescroll.resetUpScroll()
  109. },
  110. toChangeCard() {
  111. uni.navigateTo({
  112. url: "/pages/circle/changeCard"
  113. })
  114. },
  115. toCreateCircle() {
  116. uni.navigateTo({
  117. url: "/pages/circle/createCirclce"
  118. })
  119. },
  120. micOpen: function() {
  121. this.$refs.asr.show();
  122. },
  123. search() {
  124. uni.navigateTo({
  125. url: "/pages/circle/search"
  126. })
  127. },
  128. toDetail(val) {
  129. uni.navigateTo({
  130. url: "/pages/circle/detail?val=" + val
  131. })
  132. },
  133. upCallback(page) {
  134. uni.showLoading({
  135. title: '数据加载中'
  136. })
  137. let _data = {
  138. commonId: this.userInfo.id,
  139. page: page.num,
  140. limit: page.size,
  141. status:1
  142. }
  143. if (this.searchVal) {
  144. _data.circleName = this.searchVal
  145. }
  146. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'list', _data, failres => {
  147. console.log('res+++++', failres.errmsg)
  148. uni.showToast({
  149. icon:"none",
  150. title: failres.errmsg,
  151. duration: 3000
  152. });
  153. uni.hideLoading()
  154. }).then(res => {
  155. uni.hideLoading()
  156. console.log(11)
  157. let curPageData = res.data.items;
  158. let totalPage = res.data.total;
  159. let curPageLen = curPageData.length;
  160. this.mescroll.endByPage(curPageLen, totalPage);
  161. console.log(res.data)
  162. // this.makeData(res.data)
  163. if (page.num == 1) this.circleList = []; //如果是第一页需手动置空列表
  164. this.circleList = this.circleList.concat(curPageData); //追加新数据
  165. for (let i = 0; i < this.circleList.length; i++) {
  166. if(this.circleList[i].circleLabel){
  167. if(this.circleList[i].circleLabel.split(',').length>=3){
  168. var arr=this.circleList[i].circleLabel.split(',')
  169. console.log(arr)
  170. this.circleList[i].circleLabelArray=arr.filter((item,index)=>{return index<=2})
  171. }else{
  172. this.circleList[i].circleLabelArray=this.circleList[i].circleLabel.split(',')
  173. }
  174. }
  175. }
  176. for (let i = 0; i < this.circleList.length; i++) {
  177. if (this.circleList[i].addedFlag == 0) {
  178. if (i == 0) {
  179. this.circleList.unshift({
  180. name: '推荐圈子'
  181. });
  182. } else {
  183. this.circleList.splice(i, 0, {
  184. name: '推荐圈子'
  185. })
  186. }
  187. console.log(this.circleList)
  188. return
  189. }
  190. }
  191. })
  192. },
  193. input(res) {
  194. console.log('----input:', res)
  195. },
  196. clear(res) {
  197. uni.showToast({
  198. title: 'clear事件,清除值为:' + res.value,
  199. icon: 'none'
  200. })
  201. },
  202. blur(res) {
  203. uni.showToast({
  204. title: 'blur事件,输入值为:' + res.value,
  205. icon: 'none'
  206. })
  207. },
  208. focus(e) {
  209. uni.showToast({
  210. title: 'focus事件,输出值为:' + e.value,
  211. icon: 'none'
  212. })
  213. },
  214. cancel(res) {
  215. uni.showToast({
  216. title: '点击取消,输入值为:' + res.value,
  217. icon: 'none'
  218. })
  219. }
  220. }
  221. }
  222. </script>
  223. <style lang="scss" scoped>
  224. .content1 {
  225. margin: 50rpx 25rpx 14rpx 25rpx;
  226. .search {
  227. width: 100%;
  228. .left {
  229. background: #F0F0F0;
  230. border-radius: 38rpx;
  231. padding: 18rpx;
  232. width: 100%;
  233. position:relative;
  234. }
  235. .search-val {
  236. color: #B3B3B3;
  237. }
  238. .search-del{
  239. position:absolute;
  240. right:10px;
  241. }
  242. }
  243. .hy-search-img {
  244. width: 38rpx;
  245. height: auto;
  246. margin-left: 40rpx;
  247. }
  248. .search-img {
  249. width: 38rpx;
  250. margin-right: 40rpx;
  251. height: auto;
  252. }
  253. .right {
  254. /deep/.u-badge {
  255. position: absolute;
  256. top: 0;
  257. right: -10rpx;
  258. }
  259. }
  260. }
  261. .line {
  262. width: 8rpx;
  263. height: 34rpx;
  264. background: #112253;
  265. border-radius: 3px;
  266. margin: 20rpx;
  267. }
  268. .title {
  269. margin: 20rpx 0;
  270. }
  271. .text-title {
  272. font-size: 32rpx;
  273. font-weight: bold;
  274. color: #1A1A1A;
  275. }
  276. .row-tiem {
  277. background: #fff;
  278. padding: 24rpx;
  279. margin: 0 34rpx;
  280. align-items: unset;
  281. .img {
  282. width: 122rpx;
  283. height: 122rpx;
  284. border-radius: 10px;
  285. margin-right: 30rpx;
  286. }
  287. .right {
  288. display: flex;
  289. flex-direction: column;
  290. justify-content: space-evenly;
  291. .top {
  292. font-size: 32rpx;
  293. color: #1A1A1A;
  294. font-family: PingFang SC;
  295. font-weight: bold;
  296. }
  297. .bottom {
  298. margin-top: 10rpx;
  299. .text {
  300. background: #FAFAFA;
  301. border-radius: 10rpx;
  302. font-size: 26rpx;
  303. font-weight: 700;
  304. color: #666666;
  305. padding: 10rpx 20rpx;
  306. margin:0px 10rpx 10rpx 0;
  307. }
  308. }
  309. }
  310. }
  311. .add{
  312. width:84rpx;
  313. height: auto;
  314. position: fixed;
  315. bottom: 26rpx;
  316. right: 26rpx;
  317. height: auto;
  318. }
  319. </style>