myAttention.vue 5.3 KB

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