circle.vue 7.5 KB

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