index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <view class="money_name money">
  6. <image class="top-img" :src="userInfo.ext_info.photo || userInfo.avatar"></image>
  7. </view>
  8. <view class="money_name">{{userInfo.ext_info.name}}</view>
  9. </view>
  10. <view class="flex buttom-box">
  11. <view class="buttom">
  12. <view class="money">{{ userInfo.spread_num || 0}}</view>
  13. <text class="text">推荐人数(人)</text>
  14. </view>
  15. <view class="interval"></view>
  16. <view class="buttom">
  17. <view class="money">{{userInfo.brokerage || 0.00}}</view>
  18. <text class="text">推荐奖励(元)</text>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="swiper-box">
  23. <scroll-view scroll-y class="cate-list" @scrolltolower="loadData">
  24. <view v-for="(item, index) in List" :key="index" class="order-item flex">
  25. <view class="title-box flex_item">
  26. <view class="title-avatar"><image :src="item.avatar"></image></view>
  27. <view class="list_tpl">
  28. <view class="title flex_item">
  29. <view class="name">{{ item.nickname }}</view>
  30. <text class="" v-if="item.type == 1"></text>
  31. <text class="type-item" v-if="item.type == 2">医生</text>
  32. <text class="type-item" v-if="item.type == 3">机构</text>
  33. </view>
  34. <view class="time">
  35. <text>{{ item.add_time }}</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <uni-load-more :status="loadingType"></uni-load-more>
  41. </scroll-view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import { mapState, mapMutations } from 'vuex';
  47. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  48. import empty from '@/components/empty';
  49. import {spread_people} from '@/api/recommend.js';
  50. import { getTime } from '@/utils/rocessor.js';
  51. export default {
  52. components: {
  53. empty,
  54. uniLoadMore,
  55. },
  56. onReady() {
  57. // 初始化获取页面宽度
  58. uni.createSelectorQuery()
  59. .select('.content')
  60. .fields(
  61. {
  62. size: true
  63. },
  64. data => {
  65. // console.log(data);
  66. // console.log(Math.floor((data.width / 750) * 300));
  67. // 保存头部高度
  68. this.maxheight = data.height - Math.floor((data.width / 750) * 570);
  69. // console.log(this.maxheight);
  70. }
  71. )
  72. .exec();
  73. },
  74. data() {
  75. return {
  76. // 头部图高度
  77. List:[],
  78. limit: 10, //每次加载数据条数
  79. page: 1, //当前页数
  80. loadingType: 'more', //加载更多状态
  81. loading:0
  82. };
  83. },
  84. onShow() {
  85. this.loadData();
  86. },
  87. //下拉刷新
  88. onPullDownRefresh() {
  89. this.loadData('refresh');
  90. },
  91. computed: {
  92. ...mapState(['userInfo'])
  93. },
  94. methods: {
  95. async loadData(source) {
  96. let obj = this;
  97. if (source != 'refresh') {
  98. //没有更多数据直接跳出方法
  99. if (obj.loadingType === 'nomore') {
  100. return;
  101. } else {
  102. // 设置当前为数据载入中
  103. obj.loadingType = 'loading';
  104. }
  105. } else {
  106. //当重新加载数据时更新状态为可继续添加数据
  107. obj.loadingType = 'more';
  108. }
  109. spread_people({
  110. page: obj.page,
  111. limit: obj.limit
  112. })
  113. .then(({ data }) => {
  114. if (source === 'refresh') {
  115. obj.List = [];
  116. }
  117. let arr = data.users_layer_1.map(e => {
  118. e.add_time = getTime(e.add_time);
  119. return e;
  120. });
  121. obj.List = obj.List.concat(arr);
  122. //判断是否还有下一页,有是more 没有是nomore
  123. if (obj.limit == arr.length) {
  124. obj.page++;
  125. obj.loadingType = 'more';
  126. } else {
  127. obj.loadingType = 'nomore';
  128. }
  129. // 判断是否为刷新数据
  130. if (source == 'refresh') {
  131. // 判断是否为点击搜索按钮跳转加载
  132. if (obj.loading == 1) {
  133. uni.hideLoading();
  134. } else {
  135. uni.stopPullDownRefresh();
  136. }
  137. }
  138. })
  139. .catch(e => {
  140. obj.loadingType = 'nomore';
  141. uni.stopPullDownRefresh();
  142. uni.hideLoading();
  143. });
  144. },
  145. }
  146. };
  147. </script>
  148. <style lang="scss">
  149. page {
  150. height: 100%;
  151. .content{
  152. height: 100%;
  153. }
  154. }
  155. .content-money {
  156. padding-bottom: 30rpx;
  157. background: $page-color-base;
  158. .buttom-box {
  159. background-color: #ffffff;
  160. text-align: center;
  161. margin: 0 30rpx;
  162. padding: 30rpx 0;
  163. border-radius: $border-radius-sm;
  164. margin-top: -60rpx;
  165. .buttom {
  166. font-size: $font-lg;
  167. flex-grow: 1;
  168. .money{
  169. font-weight: bold;
  170. font-size: 32rpx;
  171. color: $font-color;
  172. }
  173. }
  174. .text {
  175. color: #666666;
  176. }
  177. .interval {
  178. width: 2rpx;
  179. height: 60rpx;
  180. background-color: #eeeeee;
  181. }
  182. .icon {
  183. height: 50rpx;
  184. width: 48rpx;
  185. margin: 0 auto;
  186. .icon-img {
  187. width: 100%;
  188. height: 100%;
  189. }
  190. }
  191. }
  192. }
  193. .money-box {
  194. background:linear-gradient(52deg,rgba(126,153,254,1),rgba(151,143,250,1));
  195. height: 320rpx;
  196. color: #ffffff;
  197. text-align: center;
  198. padding-top: 50rpx;
  199. .money_name{
  200. width: 100%;
  201. text-align: center;
  202. font-size: $font-base;
  203. font-weight: 500;
  204. .top-img {
  205. width: 120rpx;
  206. height: 120rpx;
  207. border-radius: 50%;
  208. margin-bottom: 15rpx;
  209. // border: 2rpx solid #FFFFFF;
  210. }
  211. }
  212. }
  213. .navbar {
  214. display: flex;
  215. height: 40px;
  216. padding: 0 5px;
  217. background: #fff;
  218. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  219. position: relative;
  220. z-index: 10;
  221. .nav-item {
  222. flex: 1;
  223. display: flex;
  224. justify-content: center;
  225. align-items: center;
  226. height: 100%;
  227. font-size: 15px;
  228. color: $font-color-dark;
  229. position: relative;
  230. &.current {
  231. color: $font-color;
  232. &:after {
  233. content: '';
  234. position: absolute;
  235. left: 50%;
  236. bottom: 0;
  237. transform: translateX(-50%);
  238. width: 44px;
  239. height: 0;
  240. border-bottom: 2px solid $font-color;
  241. }
  242. }
  243. }
  244. }
  245. // 列表
  246. .swiper-box {
  247. background: #FFFFFF;
  248. height:65%;
  249. .cate-list{
  250. height: 100%;
  251. .order-item {
  252. margin: 0 24rpx;
  253. padding: 20rpx 0;
  254. line-height: 1.5;
  255. border-bottom: 1px solid #F0F0F0;
  256. .title-box {
  257. width: 100%;
  258. .title-avatar{
  259. width:80rpx;
  260. height:80rpx;
  261. border-radius:50%;
  262. margin-right: 20rpx;
  263. image{
  264. width: 100%;
  265. height: 100%;
  266. border-radius: 100%;
  267. }
  268. }
  269. .list_tpl{
  270. width: 85%;
  271. .title {
  272. font-size: $font-base + 2rpx;
  273. color: $font-color-base;
  274. font-weight: 500;
  275. .name{
  276. max-width: 80%;
  277. }
  278. .type-item{
  279. margin-left: 25rpx;
  280. background:rgba(103,134,251,0.18);
  281. color:rgba(103,134,251,1);
  282. font-size: 24rpx;
  283. padding: 4rpx 15rpx;
  284. border-radius: 10rpx;
  285. }
  286. }
  287. .time {
  288. font-size: 22rpx;
  289. color: $font-color-light;
  290. }
  291. }
  292. }
  293. }
  294. }
  295. }
  296. </style>