myAttention.vue 5.7 KB

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