circle.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. status:1
  124. }
  125. if (this.searchVal) {
  126. _data.circleName = this.searchVal
  127. }
  128. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'list', _data, failres => {
  129. console.log('res+++++', failres.errmsg)
  130. this.$refs.uToast.show({
  131. type: 'error',
  132. message: failres.errmsg,
  133. })
  134. uni.hideLoading()
  135. }).then(res => {
  136. uni.hideLoading()
  137. console.log(11)
  138. let curPageData = res.data.items;
  139. let totalPage = res.data.total;
  140. let curPageLen = curPageData.length;
  141. this.mescroll.endByPage(curPageLen, totalPage);
  142. console.log(res.data)
  143. // this.makeData(res.data)
  144. if (page.num == 1) this.circleList = []; //如果是第一页需手动置空列表
  145. this.circleList = this.circleList.concat(curPageData); //追加新数据
  146. for (let i = 0; i < this.circleList.length; i++) {
  147. if (this.circleList[i].addedFlag == 0) {
  148. if (i == 0) {
  149. this.circleList.unshift({
  150. name: '推荐圈子'
  151. });
  152. } else {
  153. this.circleList.splice(i, 0, {
  154. name: '推荐圈子'
  155. })
  156. }
  157. console.log(this.circleList)
  158. return
  159. }
  160. }
  161. })
  162. },
  163. input(res) {
  164. console.log('----input:', res)
  165. },
  166. clear(res) {
  167. uni.showToast({
  168. title: 'clear事件,清除值为:' + res.value,
  169. icon: 'none'
  170. })
  171. },
  172. blur(res) {
  173. uni.showToast({
  174. title: 'blur事件,输入值为:' + res.value,
  175. icon: 'none'
  176. })
  177. },
  178. focus(e) {
  179. uni.showToast({
  180. title: 'focus事件,输出值为:' + e.value,
  181. icon: 'none'
  182. })
  183. },
  184. cancel(res) {
  185. uni.showToast({
  186. title: '点击取消,输入值为:' + res.value,
  187. icon: 'none'
  188. })
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang="scss" scoped>
  194. .content1 {
  195. margin: 50rpx 25rpx 14rpx 25rpx;
  196. .search {
  197. width: 100%;
  198. .left {
  199. background: #fff;
  200. border-radius: 38rpx;
  201. padding: 18rpx;
  202. width: 100%;
  203. }
  204. .search-val {
  205. color: #B3B3B3;
  206. }
  207. }
  208. .hy-search-img {
  209. width: 38rpx;
  210. margin-left: 40rpx;
  211. }
  212. .search-img {
  213. width: 38rpx;
  214. margin-right: 40rpx;
  215. }
  216. .right {
  217. /deep/.u-badge {
  218. position: absolute;
  219. top: 0;
  220. right: -10rpx;
  221. }
  222. }
  223. }
  224. .line {
  225. width: 8rpx;
  226. height: 34rpx;
  227. background: #112253;
  228. border-radius: 3px;
  229. margin: 20rpx;
  230. }
  231. .title {
  232. margin: 20rpx 0;
  233. }
  234. .text-title {
  235. font-size: 32rpx;
  236. font-weight: bold;
  237. color: #1A1A1A;
  238. }
  239. .row-tiem {
  240. background: #fff;
  241. padding: 24rpx;
  242. margin: 0 34rpx;
  243. align-items: unset;
  244. .img {
  245. width: 122rpx;
  246. height: 122rpx;
  247. border-radius: 10px;
  248. margin-right: 30rpx;
  249. }
  250. .right {
  251. display: flex;
  252. flex-direction: column;
  253. justify-content: space-evenly;
  254. .top {
  255. font-size: 32rpx;
  256. font-weight: bold;
  257. color: #1A1A1A;
  258. }
  259. .bottom {
  260. margin-top: 10rpx;
  261. .text {
  262. background: #FAFAFA;
  263. border-radius: 20px;
  264. font-size: 26rpx;
  265. font-weight: 700;
  266. color: #666666;
  267. padding: 11rpx 40rpx;
  268. margin-right: 20rpx;
  269. }
  270. }
  271. }
  272. }
  273. .add{
  274. width:84rpx;
  275. position: fixed;
  276. bottom: 26rpx;
  277. right: 26rpx;
  278. }
  279. </style>