猎豆优选小程序

friendList.vue 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="pageBox">
  3. <!-- 头部栏-->
  4. <u-navbar class="navbar-wrap" title="我的好友" title-color="#fff" back-icon-color="#fff" :background="background" ></u-navbar>
  5. <view class="stickBox" :style="{top:statusBarHeight + navigationBarHeight + 'px'}">
  6. <!-- 提示-->
  7. <view v-show="showNotice">
  8. <notice :text="topNaiv.top_message" name="arrow-right" @clickNotice="clickNotice"></notice>
  9. </view>
  10. <!-- 切换栏-->
  11. <view class="typeBox">
  12. <view v-for="item in topNaiv.top_friend" :key="item.top_name" :class="item.top_type == typeAc ? 'active' : ''" @click="switchType(item.top_type)">
  13. <view class="num">{{item.count}}</view>
  14. <view class="name">{{item.top_name}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. <!-- 好友列表 -->
  19. <view class="friends-item" v-for="item in listProp" :key="item.id">
  20. <view class="fixed-center">
  21. <image class="friends-head" :src="item.img" mode="widthFix"></image>
  22. <view class="friends-con">
  23. <view class="friends-title-block">
  24. <view class="friends-title">{{item.name}}</view>
  25. <image v-if="item.level == 3" class="friend-tag-img" src="https://ld.726p.com/ldyx_static/imgs/tag-yys.png" mode="widthFix"></image>
  26. <image v-if="item.level == 2" class="friend-tag-img" src="https://ld.726p.com/ldyx_static/imgs/tag-svip.png" mode="widthFix"></image>
  27. <image v-if="item.level == 1" class="friend-tag-img" src="https://ld.726p.com/ldyx_static/imgs/tag-vip.png" mode="widthFix"></image>
  28. </view>
  29. <view class="friends-other">{{item.phone}} {{item.regist_at}}</view>
  30. </view>
  31. </view>
  32. <button class="inviteFriend" open-type="share" data-source="inviteFriend" v-if="typeAc == 5">邀请注册</button>
  33. </view>
  34. <view class="loadinfo" v-if="listProp.length > 0 && !loading && isEnd">没有更多了</view>
  35. <!-- 无数据展示 -->
  36. <view class="no-data-blcok" v-if="listProp.length <= 0 && !loading" style="margin-top: 200rpx;">
  37. <image class="no-data-img" src="https://ld.726p.com/ldyx_static/imgs/no-order.png" mode="widthFix"></image>
  38. <view class="no-data-hint">您还没有好友~</view>
  39. </view>
  40. <!-- 回到顶部 -->
  41. <u-back-top :scroll-top="scrollTop"></u-back-top>
  42. </view>
  43. </template>
  44. <script>
  45. import notice from "../../commonMoudle/notice";
  46. import orderList from "../../commonMoudle/orderList";
  47. const app = getApp()
  48. export default {
  49. components:{
  50. notice,
  51. orderList,
  52. },
  53. data(){
  54. return{
  55. background: app.globalData.navbarBackground,
  56. statusBarHeight: app.globalData.statusBarHeight,
  57. navigationBarHeight: app.globalData.navigationBarHeight,
  58. showNotice:true,
  59. topNaiv:{},
  60. typeAc:2,
  61. listProp:[],
  62. loading:true,
  63. page:1,
  64. isEnd: false, // 数据加载到最后一页
  65. scrollTop: 0,
  66. }
  67. },
  68. onPageScroll(e) {
  69. this.scrollTop = e.scrollTop;
  70. },
  71. onLoad() {
  72. this.getTopNaiv()
  73. this.getFriendlist()
  74. },
  75. //上拉加载
  76. onReachBottom() {
  77. if (this.isEnd || this.loading) return; // 到达最后一页 或者 次页正在加载中,不允许再上拉加载
  78. this.loading = true;
  79. this.page++;
  80. this.getFriendlist()
  81. },
  82. //下拉刷新
  83. async onPullDownRefresh(){
  84. await this.getTopNaiv()
  85. this.page = 1;
  86. await this.getFriendlist()
  87. uni.stopPullDownRefresh()
  88. },
  89. methods: {
  90. // 好友类型获取
  91. async getTopNaiv() {
  92. try {
  93. const url = this.$api.adzoneCreate_getTopNaiv
  94. const params = {}
  95. uni.showLoading({ title: '加载中...', mask: true })
  96. const { data: res } = await this.$postJSON(url, params)
  97. if (res && res.errno == 0) {
  98. this.topNaiv = res.rst.data;
  99. } else {
  100. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  101. }
  102. } catch (error) {
  103. uni.showToast({ title: '服务器错误', icon: 'none' })
  104. } finally {
  105. uni.hideLoading()
  106. }
  107. },
  108. // 订单明细
  109. async getFriendlist() {
  110. // 第一页列表数据加载前,页面回到顶部
  111. if (this.page == 1) {
  112. uni.pageScrollTo({
  113. scrollTop: 0
  114. });
  115. }
  116. try {
  117. const url = this.$api.adzoneCreate_getTypeOperate
  118. const params = {
  119. page: this.page,
  120. type: this.typeAc,
  121. }
  122. uni.showLoading({ title: '加载中...', mask: true })
  123. const { data: res } = await this.$postJSON(url, params)
  124. this.loading = false;
  125. if (res && res.errno == 0) {
  126. // 判断数据是否是最后一页
  127. if (res.rst.data.length <= 0) {
  128. this.isEnd = true
  129. } else {
  130. this.isEnd = false
  131. }
  132. // 获得数据
  133. if(this.page == 1) {
  134. this.listProp = res.rst.data;
  135. } else {
  136. this.listProp = this.listProp.concat(res.rst.data)
  137. }
  138. } else {
  139. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  140. }
  141. } catch (error) {
  142. this.loading = false;
  143. uni.showToast({ title: '服务器错误', icon: 'none' })
  144. } finally {
  145. this.loading = false;
  146. uni.hideLoading()
  147. }
  148. },
  149. //关闭提示
  150. clickNotice(){
  151. if(this.topNaiv.top_level != 3){ // 非运营商,去特权介绍页
  152. uni.navigateTo({
  153. url: '/pages/subPackages/my/tqjs'
  154. })
  155. }else{ // 运营商
  156. let url = encodeURIComponent(this.topNaiv.url)
  157. $router.navigateTo({
  158. url: `/pages/webView/webView?url=${url}&title=运营商后台`
  159. })
  160. }
  161. },
  162. //切换type
  163. switchType(type){
  164. this.typeAc = type
  165. this.page = 1;
  166. this.getFriendlist()
  167. },
  168. },
  169. }
  170. </script>
  171. <style lang="scss" scoped>
  172. .pageBox{
  173. background-color: #F5F5F5;
  174. position: relative;
  175. .navbar_name{
  176. color: #fff;
  177. font-size: 36rpx;
  178. padding-left:40%;
  179. display:flex;
  180. align-items: center;
  181. .lMar10{
  182. margin-left: 10rpx;
  183. }
  184. }
  185. .stickBox{
  186. position: sticky;
  187. background-color: #F5F5F5;
  188. padding-top: 1rpx;
  189. z-index: 9999;
  190. }
  191. .typeBox{
  192. background-color: #fff;
  193. color: #333;
  194. font-size: 32rpx;
  195. padding: 20rpx 50rpx;
  196. border-bottom: 2rpx solid #f1f1f1;
  197. display: flex;
  198. align-items: center;
  199. justify-content: space-between;
  200. text-align: center;
  201. position: relative;
  202. z-index: 10;
  203. .name{
  204. margin-top: 15rpx;
  205. font-size: 30rpx;
  206. }
  207. .active{
  208. color:#f13641;
  209. font-weight: 600;
  210. }
  211. }
  212. }
  213. .friends-item{
  214. display: flex;
  215. align-items: center;
  216. justify-content: space-between;
  217. background-color: #fff;
  218. padding: 20rpx 40rpx;
  219. border-bottom: 4rpx solid #f5f5f5;
  220. .friends-head{
  221. width: 100rpx;
  222. height: 100rpx;
  223. border-radius: 8rpx;
  224. margin-right: 40rpx;
  225. }
  226. .friends-con{
  227. .friends-title-block{
  228. display: flex;
  229. align-items: center;
  230. .friends-title{
  231. color: #333;
  232. font-size: 30rpx;
  233. line-height: 40rpx;
  234. }
  235. .friend-tag-img{
  236. width: 120rpx;
  237. height: 40rpx;
  238. margin-left: 6rpx;
  239. }
  240. }
  241. .friends-other{
  242. font-size: 26rpx;
  243. line-height: 40rpx;
  244. color: #999;
  245. margin-top: 10rpx;
  246. }
  247. }
  248. }
  249. .fixed-center{
  250. display: flex;
  251. align-items: center;
  252. }
  253. .loadinfo{
  254. text-align: center;
  255. color: #666;
  256. font-size: 28rpx;
  257. margin: 20rpx 0;
  258. }
  259. .inviteFriend{
  260. font-size: 22rpx;
  261. color: #f13641;
  262. border: 2rpx solid #f13641;
  263. line-height: 46rpx;
  264. padding: 0 20rpx;
  265. border-radius: 46rpx;
  266. background: transparent;
  267. margin: 0;
  268. }
  269. </style>