focusme.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="pages">
  3. <mescroll-body class="wrap" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  4. <view class="focusme">
  5. <view v-for="(item,index) in focusmelist" :key="index" class="focusme-item">
  6. <view class="focusme-item-photo">
  7. <image class="focusme-item-photo-img" :src="item.headimgurl" mode=""></image>
  8. </view>
  9. <view class="focusme-item-text">
  10. <view class="focusme-item-name">{{item.memberNickname}} <text class="type">{{item.type}}</text></view>
  11. <view class="focusme-item-addr">{{item.addr}}</view>
  12. <view class="focusme-item-care">关心:{{item.productName}}</view>
  13. <!-- <view class="focusme-item-care">关心:<text v-for="(careitem,careindex) in item.care" :key="careindex">{{careitem}},</text></view> -->
  14. </view>
  15. <view class="focusme-item-call" @click="callnumber(item.phonenumber)">
  16. <svg class="icon focusme-item-call-icon" aria-hidden="true">
  17. <use xlink:href="#icondianhua"></use>
  18. </svg>
  19. </view>
  20. </view>
  21. </view>
  22. </mescroll-body>
  23. </view>
  24. </template>
  25. <script>
  26. // 引入mescroll-mixins.js
  27. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  28. // 引入mescroll-body组件 (如已在main.js注册全局组件,则省略此步骤)
  29. import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"; // 注意.vue后缀不能省
  30. export default {
  31. mixins: [MescrollMixin], // 使用mixin
  32. components: {
  33. MescrollBody,
  34. },
  35. data() {
  36. return {
  37. mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
  38. // 下拉刷新的配置(可选, 绝大部分情况无需配置)
  39. downOption: {
  40. // ...
  41. },
  42. // 上拉加载的配置(可选, 绝大部分情况无需配置)
  43. upOption: {
  44. page: {
  45. size: 10 // 每页数据的数量,默认10
  46. },
  47. noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  48. empty: {
  49. tip: '暂无相关数据'
  50. }
  51. },
  52. params:{
  53. tokenhead:'',
  54. token:'',
  55. },
  56. focusmelist:[
  57. // {
  58. // img:"http://placekitten.com/90/90",
  59. // name:'周飞向',
  60. // type:'养殖大户',
  61. // addr:'贵州大亨油茶科技有限公司',
  62. // care:["油茶","茶","芝麻"],
  63. // phonenumber:'13655544126',
  64. // },
  65. // {
  66. // img:"http://placekitten.com/90/90",
  67. // name:'张永清',
  68. // type:'农户',
  69. // addr:'贵州毕节',
  70. // care:["林下食用菌"],
  71. // phonenumber:'13655544126',
  72. // },
  73. ],
  74. }
  75. },
  76. onShow() {
  77. let serf = this;
  78. //检查登录,获取token
  79. // let loginRes = this.checkLogin('/pages/index/index', '2');
  80. // if(!loginRes){return false;}
  81. // serf.params.token=loginRes[0];
  82. },
  83. onLoad() {
  84. let self = this;
  85. uni.getStorage({
  86. key:'token',
  87. success: function (res) {
  88. self.params.token = res.data;
  89. // console.log(res.data);
  90. }
  91. });
  92. uni.getStorage({
  93. key:'tokenhead',
  94. success: function (res) {
  95. self.params.tokenhead = res.data;
  96. // console.log(res.data);
  97. }
  98. });
  99. },
  100. methods: {
  101. /*mescroll组件初始化的回调,可获取到mescroll对象 (此处可删,mixins已默认)*/
  102. mescrollInit(mescroll) {
  103. this.mescroll = mescroll;
  104. },
  105. /*下拉刷新的回调, 有三种处理方式:*/
  106. downCallback(){
  107. // 第2种: 下拉刷新和上拉加载调同样的接口, 那么不用第1种方式, 直接mescroll.resetUpScroll()即可
  108. this.mescroll.resetUpScroll(); // 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  109. },
  110. /*上拉加载的回调*/
  111. upCallback(page) {
  112. let pageNum = page.num; // 页码, 默认从1开始
  113. let pageSize = page.size; // 页长, 默认每页10条
  114. this.params = Object.assign(this.params,{pageNum:pageNum,pageSize:pageSize});
  115. let thetoken = this.params.tokenhead + this.params.token;
  116. console.log('thetoken',thetoken);
  117. this.$api.http.get(this.config.apiBaseurl+'/pre/own',{params:this.params,header: {Authorization:thetoken}}).then(data => {
  118. console.log('1111111111',data);
  119. if(data.data.code=='1001'){
  120. // uni.redirectTo({
  121. // url:'/pages/login/login?backpage=/pages/index/index'+'&backtype='+2,
  122. // });
  123. };
  124. console.log(data);
  125. // 接口返回的当前页数据列表 (数组)
  126. let curPageData = data.data.data.list;
  127. // console.log('curPageData',curPageData);
  128. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  129. let curPageLen = curPageData.length;
  130. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  131. // let totalPage = data.xxx;
  132. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  133. let totalSize = data.data.data.total;
  134. // this.mescrollList = curPageData;
  135. // 接口返回的是否有下一页 (true/false)
  136. // let hasNext = data.xxx;
  137. //设置列表数据
  138. if(page.num == 1) this.focusmelist = []; //如果是第一页需手动置空列表
  139. this.focusmelist = this.focusmelist.concat(curPageData); //追加新数据
  140. // console.log('page.num',page.num);
  141. console.log('this.focusmelist',JSON.parse(JSON.stringify(this.focusmelist)));
  142. //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
  143. this.mescroll.endBySize(curPageLen, totalSize);
  144. // setTimeout(()=>{
  145. // this.mescroll.endSuccess(curPageLen)
  146. // },20)
  147. }).catch(err => {
  148. this.mescroll.endErr()
  149. console.log(err)
  150. });
  151. },
  152. //打电话
  153. callnumber(number){
  154. uni.makePhoneCall({
  155. phoneNumber: number
  156. });
  157. },
  158. }
  159. }
  160. </script>
  161. <style scoped>
  162. /* @import url("../usercenter.css"); */
  163. .focusme-item{display: flex;position: relative;align-items: center;background-color: #fff;padding: 24rpx 24rpx 17rpx 24rpx;margin-bottom: 8rpx;}
  164. .focusme-item::after{content: '';width: calc( 100% - 24rpx );height: 1px;background-color: #eee;position: absolute;right: 0;bottom: 0;}
  165. .focusme-item-photo{width: 90rpx;height: 90rpx;overflow: hidden;border-radius: 50%;margin-right: 30rpx;}
  166. .focusme-item-photo-img{width: 100%;height: 100%;}
  167. .focusme-item-text{flex: 1;}
  168. .focusme-item-name{margin-bottom: 4rpx;font-size: 34rpx;font-weight: 500;color: #333;line-height: 48rpx;}
  169. .focusme-item-name .type{margin-left: 24rpx;font-size: 24rpx;font-weight: 400;color: #6BBC6D;line-height: 33rpx;}
  170. .focusme-item-care,
  171. .focusme-item-addr{font-size: 28rpx;font-weight: 400;color: #666;line-height: 40rpx;}
  172. .focusme-item-call-icon{width: 58rpx;height: 58rpx;}
  173. </style>