myAttention.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view>
  3. <view class="content1">
  4. <u-search placeholder="搜索用户名称" v-model="keyword" :show-action='false' bg-color="#F5F6FA"></u-search>
  5. </view>
  6. <mescroll-body ref="mescrollRef" @init="mescrollInit" top="0" @down="downCallback" :up="upOption"
  7. @up="upCallback" @emptyclick="emptyClick">
  8. <!-- 数据列表 -->
  9. <view class="list" v-if="goods.length!=0">
  10. <view class="list-item" v-for="(item,index) in goods">
  11. <view class="left">
  12. <image :src="item.commonUser.avatarUrl?item.commonUser.avatarUrl:'../../static/img/face/27.png'"
  13. mode="aspectFill" class="head-img"></image>
  14. <view class="name">
  15. {{item.commonUser.wechatNo}}
  16. </view>
  17. </view>
  18. <!-- <view class="right">
  19. <u-icon name="plus" color="#333333" size="17" bold></u-icon><text class="case">关注</text>
  20. </view> -->
  21. <view class="right" @click="follow(item)">
  22. <text class="case" style="color:#878C9C;">已关注</text>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="total" v-if="goods.length>=10">
  27. 共关注{{goods.length}}人
  28. </view>
  29. </mescroll-body>
  30. <u-modal v-model="show" :content="content" :show-title='false' :show-cancel-button='true'
  31. :content-style="contentStyle" showCancelButton='true' @confirm="cancelFollow" @cancel="show=false">
  32. </u-modal>
  33. <u-toast ref="uToast" />
  34. </view>
  35. </template>
  36. <script>
  37. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  38. import {
  39. apiGoods
  40. } from "@/api/mock.js"
  41. export default {
  42. components: {
  43. },
  44. mixins: [MescrollMixin], // 使用mixin
  45. data() {
  46. return {
  47. selectItem: {},
  48. contentStyle: {
  49. "font-weight": 700
  50. },
  51. show: false,
  52. content: '确定不在关注?',
  53. keyword: '',
  54. inputStyle: {
  55. // "padding-left": '30rpx'
  56. },
  57. upOption: {
  58. // page: {
  59. // num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  60. // size: 10 // 每页数据的数量
  61. // },
  62. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  63. empty: {
  64. icon: '/static/empty.png',
  65. tip: '暂无内容', // 提示
  66. // btnText: '去看看'
  67. }
  68. },
  69. goods: [], //列表数据
  70. }
  71. },
  72. onShow() {
  73. uni.showTabBar()
  74. uni.hideKeyboard()
  75. var userInfo = uni.getStorageSync("userInfo")
  76. var that = this
  77. console.log("userInfo", userInfo)
  78. },
  79. onLoad(options) {},
  80. methods: {
  81. cancelFollow() {
  82. let _obj = {
  83. id: this.selectItem.id
  84. }
  85. console.log()
  86. this.$api.doRequest('post', '/followInformation/api/deleteInfo', _obj).then(res => {
  87. console.log(res.data)
  88. if (res.data.code == 200) {
  89. this.$refs.uToast.show({
  90. title: '取关成功',
  91. type: 'success',
  92. })
  93. this.mescroll.resetUpScroll()
  94. }
  95. uni.hideLoading()
  96. })
  97. },
  98. follow(val) {
  99. this.selectItem = val
  100. this.show = true
  101. },
  102. edit() {},
  103. del() {},
  104. selectAddress(val) {
  105. console.log(val)
  106. },
  107. release() {
  108. uni.navigateTo({
  109. url: 'release'
  110. })
  111. },
  112. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  113. upCallback(page) {
  114. uni.showLoading({
  115. title: '数据加载中',
  116. mask: true
  117. })
  118. console.log("this.selectPlace", this.selectPlace)
  119. console.log("this.selectType", this.selectType)
  120. let _obj = {
  121. }
  122. if (this.selectType == '关注') {
  123. _obj = {
  124. pageSize: page.size,
  125. currentPage: page.num,
  126. placeDelivery: this.selectPlace,
  127. tranType: this.selectType,
  128. userIdFollow: this.userInfo.id,
  129. nowUserId: this.userInfo.id
  130. }
  131. } else {
  132. _obj = {
  133. pageSize: page.size,
  134. currentPage: page.num,
  135. userId: this.userInfo.id,
  136. }
  137. }
  138. this.$api.doRequest('get', '/followInformation/getInfo', _obj).then(res => {
  139. console.log(res.data.data.records)
  140. if (res.data.code == 200) {
  141. let curPageData = res.data.data.records;
  142. let curPageLen = curPageData.length;
  143. let totalPage = res.data.data.total;
  144. if (page.num == 1) this.goods = [];
  145. this.goods = this.goods.concat(curPageData);
  146. console.log(curPageLen, totalPage)
  147. this.mescroll.endByPage(curPageLen, totalPage);
  148. }
  149. uni.hideLoading()
  150. })
  151. },
  152. //点击空布局按钮的回调
  153. emptyClick() {
  154. uni.showToast({
  155. title: '点击了按钮,具体逻辑自行实现'
  156. })
  157. },
  158. // 切换菜单
  159. tabChange() {
  160. this.goods = [] // 先置空列表,显示加载进度
  161. this.mescroll.resetUpScroll() // 再刷新列表数据
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang='scss'>
  167. .head-img {
  168. width: 76rpx;
  169. height: 76rpx;
  170. border-radius: 50%;
  171. }
  172. page {
  173. background: #fff !important;
  174. }
  175. .content1 {
  176. padding: 20rpx;
  177. }
  178. .list {
  179. padding: 0 22rpx;
  180. .left {
  181. display: flex;
  182. align-items: center;
  183. .name {
  184. font-size: 32rpx;
  185. font-weight: 400;
  186. color: #262626;
  187. margin-left: 26rpx;
  188. }
  189. }
  190. .right {
  191. width: 124rpx;
  192. height: 58rpx;
  193. background: #FFFFFF;
  194. border-radius: 29rpx;
  195. border: 1px solid #CDCDCD;
  196. line-height: 58rpx;
  197. text-align: center;
  198. .case {
  199. font-weight: 700;
  200. }
  201. }
  202. .list-item {
  203. display: flex;
  204. justify-content: space-between;
  205. align-items: center;
  206. padding: 34rpx 31rpx;
  207. border-bottom: 1px solid #E6E6E6;
  208. }
  209. }
  210. .total {
  211. display: flex;
  212. justify-content: center;
  213. margin: 40rpx 0;
  214. }
  215. </style>