myAttention.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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="../../static/img/face/27.png" mode="aspectFill" class="head-img"></image>
  13. <view class="name">
  14. 李师傅1334248520
  15. </view>
  16. </view>
  17. <view class="right">
  18. <u-icon name="plus" color="#333333" size="17" bold></u-icon><text class="case">关注</text>
  19. </view>
  20. <view class="right" @click="follow(item)">
  21. <text class="case" style="color:#878C9C;">已关注</text>
  22. </view>
  23. </view>
  24. </view>
  25. </mescroll-body>
  26. <u-modal v-model="show" :content="content" :show-title='false' :show-cancel-button='true'
  27. :content-style="contentStyle"></u-modal>
  28. </view>
  29. </template>
  30. <script>
  31. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  32. import {
  33. apiGoods
  34. } from "@/api/mock.js"
  35. export default {
  36. components: {
  37. },
  38. mixins: [MescrollMixin], // 使用mixin
  39. data() {
  40. return {
  41. selectItem: {},
  42. contentStyle: {
  43. "font-weight": 700
  44. },
  45. show: false,
  46. content: '确定不在关注?',
  47. keyword: '',
  48. inputStyle: {
  49. // "padding-left": '30rpx'
  50. },
  51. upOption: {
  52. // page: {
  53. // num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  54. // size: 10 // 每页数据的数量
  55. // },
  56. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  57. empty: {
  58. tip: '~ 搜索无数据 ~', // 提示
  59. btnText: '去看看'
  60. }
  61. },
  62. goods: [], //列表数据
  63. }
  64. },
  65. onShow() {
  66. uni.showTabBar()
  67. uni.hideKeyboard()
  68. var userInfo = uni.getStorageSync("userInfo")
  69. var that = this
  70. console.log("userInfo", userInfo)
  71. // setTimeout(function() {
  72. // that.$api.doRequest('get', '/appVersion/test', {
  73. // userId: "7e83070d05fc4d50aaa46e00a3ee03d8"
  74. // }).then(res => {
  75. // })
  76. // }, 500);
  77. uni.removeTabBarBadge({
  78. index: 4
  79. })
  80. this.$api.doRequest('get', '/newNoticeTask/query/noticeTasks').then(res => {
  81. if (res.data.data) {
  82. let name = 'myTip';
  83. let value = res.data.data.total;
  84. that.$store.commit('$uStore', {
  85. name,
  86. value
  87. });
  88. if (value != 0 && value) {
  89. uni.setTabBarBadge({
  90. index: 4,
  91. text: value + ""
  92. })
  93. }
  94. name = 'taskTip';
  95. value = res.data.data.total;
  96. that.$store.commit('$uStore', {
  97. name,
  98. value
  99. });
  100. }
  101. })
  102. },
  103. onLoad(options) {},
  104. methods: {
  105. follow(val) {
  106. this.selectItem = val
  107. this.show = true
  108. },
  109. edit() {},
  110. del() {},
  111. selectAddress(val) {
  112. console.log(val)
  113. },
  114. release() {
  115. uni.navigateTo({
  116. url: 'release'
  117. })
  118. },
  119. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  120. upCallback(page) {
  121. apiGoods(page.num, page.size).then(res => {
  122. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  123. this.mescroll.endSuccess(res.list.length);
  124. //设置列表数据
  125. if (page.num == 1) this.goods = []; //如果是第一页需手动制空列表
  126. this.goods = this.goods.concat(res.list); //追加新数据
  127. this.co
  128. }).catch(() => {
  129. //联网失败, 结束加载
  130. this.mescroll.endErr();
  131. })
  132. },
  133. //点击空布局按钮的回调
  134. emptyClick() {
  135. uni.showToast({
  136. title: '点击了按钮,具体逻辑自行实现'
  137. })
  138. },
  139. // 切换菜单
  140. tabChange() {
  141. this.goods = [] // 先置空列表,显示加载进度
  142. this.mescroll.resetUpScroll() // 再刷新列表数据
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang='scss'>
  148. .head-img {
  149. width: 76rpx;
  150. height: 76rpx;
  151. background: red;
  152. border-radius: 50%;
  153. }
  154. page {
  155. background: #fff !important;
  156. }
  157. .content1 {
  158. padding: 20rpx;
  159. }
  160. .list {
  161. padding: 0 22rpx;
  162. .left {
  163. display: flex;
  164. align-items: center;
  165. .name {
  166. font-size: 32rpx;
  167. font-weight: 400;
  168. color: #262626;
  169. margin-left: 26rpx;
  170. }
  171. }
  172. .right {
  173. width: 124rpx;
  174. height: 58rpx;
  175. background: #FFFFFF;
  176. border-radius: 29rpx;
  177. border: 1px solid #CDCDCD;
  178. line-height: 58rpx;
  179. text-align: center;
  180. .case {
  181. font-weight: 700;
  182. }
  183. }
  184. .list-item {
  185. display: flex;
  186. justify-content: space-between;
  187. align-items: center;
  188. padding: 34rpx 0;
  189. border-bottom: 1px solid #E6E6E6;
  190. }
  191. }
  192. </style>