extension.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <!-- <view class="goback-box" @click="toBack">
  6. <image class="goback" src="https://zhibo.liuniu946.com/img/fanhui.png" mode=""></image>
  7. </view> -->
  8. <!-- <view class="header">我的推广</view> -->
  9. <image class="tuiguang_bg" src="https://zhibo.liuniu946.com/img/img009.png"></image>
  10. <!-- <view class="money_img"><image :src="list.avatar || img"></image></view> -->
  11. <view class="money-frame">
  12. <!-- <view class="money_name">我的推广</view> -->
  13. <view class="money_num">
  14. {{all || '0'}}
  15. <text class="money_ren">人</text>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="flex buttom-box">
  20. <view class="buttom">
  21. <view class="money">{{total || 0}}</view>
  22. <text class="text">直接推荐</text>
  23. </view>
  24. <view class="interval"></view>
  25. <view class="buttom">
  26. <view class="money">{{totalLevel || 0}}</view>
  27. <text class="text">间接推荐</text>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="navbar">
  32. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  33. </view>
  34. <swiper :current="tabCurrentIndex" :style="{ height: maxheight + 'px' }" class="swiper-box" duration="300" @change="changeTab">
  35. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  36. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  37. <!-- 空白页 -->
  38. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  39. <!-- 订单列表 -->
  40. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  41. <view class="title-box flex_item">
  42. <view class="title-avatar"><image :src="item.avatar"></image></view>
  43. <view class="list_tpl">
  44. <view class="title">
  45. <text>{{ item.nickname }}</text>
  46. </view>
  47. <view class="time">
  48. <text>{{ item.time }}</text>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  54. </scroll-view>
  55. </swiper-item>
  56. </swiper>
  57. </view>
  58. </template>
  59. <script>
  60. import { spread_people } from '@/api/team.js';
  61. import { mapState, mapMutations } from 'vuex';
  62. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  63. import empty from '@/components/empty';
  64. export default {
  65. components: {
  66. empty,
  67. uniLoadMore,
  68. },
  69. onReady() {
  70. // 初始化获取页面宽度
  71. uni.createSelectorQuery()
  72. .select('.content')
  73. .fields(
  74. {
  75. size: true
  76. },
  77. data => {
  78. // console.log(data);
  79. // console.log(Math.floor((data.width / 750) * 300));
  80. // 保存头部高度
  81. this.maxheight = data.height - Math.floor((data.width / 750) * 470) - 44;
  82. // console.log(this.maxheight);
  83. }
  84. )
  85. .exec();
  86. },
  87. data() {
  88. return {
  89. // 头部图高度
  90. maxheight: '',
  91. tabCurrentIndex: 0,
  92. navList: [
  93. {
  94. state: 0,
  95. text: '直接推荐',
  96. loadingType: 'more',
  97. orderList: [],
  98. page: 1, //当前页数
  99. limit: 10 //每次信息条数
  100. },
  101. {
  102. state: 1,
  103. text: '间接推荐',
  104. loadingType: 'more',
  105. orderList: [],
  106. page: 1, //当前页数
  107. limit: 10 //每次信息条数
  108. }
  109. ],
  110. all:'',
  111. list:'',
  112. total:'',
  113. totalLevel:'',
  114. img:'http://kaifa.crmeb.net/uploads/attach/2019/08/20190807/723adbdd4e49a0f9394dfc700ab5dba3.png'
  115. };
  116. },
  117. onLoad(options) {},
  118. onShow() {
  119. this.loadData();
  120. },
  121. methods: {
  122. // 页面跳转
  123. navto(e) {
  124. uni.navigateTo({
  125. url: e
  126. });
  127. },
  128. //获取收入支出信息
  129. async loadData(source) {
  130. //这里是将订单挂载到tab列表下
  131. let index = this.tabCurrentIndex;
  132. let navItem = this.navList[index];
  133. let state = navItem.state;
  134. if (source === 'tabChange' && navItem.loaded === true) {
  135. //tab切换只有第一次需要加载数据
  136. return;
  137. }
  138. if (navItem.loadingType === 'loading') {
  139. //防止重复加载
  140. return;
  141. }
  142. if (navItem.loadingType === 'noMore') {
  143. //防止重复加载
  144. return;
  145. }
  146. // 修改当前对象状态为加载中
  147. navItem.loadingType = 'loading';
  148. spread_people(
  149. {
  150. page: navItem.page,
  151. limit: navItem.limit,
  152. keyword:'',
  153. sort:'uid desc',
  154. grade:state
  155. },
  156. )
  157. .then(({ data }) => {
  158. this.total = data.total;
  159. this.totalLevel =data.totalLevel;
  160. this.all = this.total + this.totalLevel;
  161. if (data.list.length > 0) {
  162. this.list = data.list;
  163. navItem.orderList = navItem.orderList.concat(data.list);
  164. navItem.page++;
  165. }
  166. this.$nextTick(function(){
  167. if (navItem.limit == data.list.length) {
  168. //判断是否还有数据, 有改为 more, 没有改为noMore
  169. navItem.loadingType = 'more';
  170. return;
  171. } else {
  172. //判断是否还有数据, 有改为 more, 没有改为noMore
  173. navItem.loadingType = 'noMore';
  174. }
  175. })
  176. this.$set(navItem, 'loaded', true);
  177. })
  178. .catch(e => {
  179. console.log(e);
  180. });
  181. },
  182. //swiper 切换
  183. changeTab(e) {
  184. this.tabCurrentIndex = e.target.current;
  185. this.loadData('tabChange');
  186. },
  187. //顶部tab点击
  188. tabClick(index) {
  189. this.tabCurrentIndex = index;
  190. },
  191. // 点击返回 我的页面
  192. toBack(){
  193. uni.switchTab({
  194. url:'/pages/user/user'
  195. })
  196. }
  197. }
  198. };
  199. </script>
  200. <style lang="scss">
  201. page {
  202. background: #ffffff;
  203. height: 100%;
  204. }
  205. .content-money {
  206. padding-bottom: 30rpx;
  207. background: $page-color-base;
  208. .buttom-box {
  209. position: relative;
  210. background-color: #ffffff;
  211. text-align: center;
  212. margin: 0 30rpx;
  213. padding: 30rpx 0;
  214. border-radius: $border-radius-sm;
  215. margin-top: -80rpx;
  216. .buttom {
  217. font-size: $font-lg;
  218. flex-grow: 1;
  219. .money{
  220. font-weight: bold;
  221. font-size: 32rpx;
  222. color: #FF0000;
  223. }
  224. }
  225. .text {
  226. color: #666666;
  227. }
  228. .interval {
  229. width: 2rpx;
  230. height: 60rpx;
  231. background-color: #eeeeee;
  232. }
  233. .icon {
  234. height: 50rpx;
  235. width: 48rpx;
  236. margin: 0 auto;
  237. .icon-img {
  238. width: 100%;
  239. height: 100%;
  240. }
  241. }
  242. }
  243. }
  244. .money-box {
  245. // background: $base-color;
  246. height: 380rpx;
  247. color: #ffffff;
  248. text-align: center;
  249. font-size: 35rpx;
  250. position: relative;
  251. // padding-top: 60rpx;
  252. .header{
  253. position: absolute;
  254. left: 0;
  255. top: 0;
  256. width: 100%;
  257. height: 80rpx;
  258. font-size: 32rpx;
  259. font-weight: 700;
  260. z-index: 99;
  261. display: flex;
  262. justify-content: center;
  263. align-items: center;
  264. }
  265. .goback-box{
  266. position: absolute;
  267. left: 18rpx;
  268. top: 0;
  269. height: 80rpx;
  270. display: flex;
  271. align-items: center;
  272. }
  273. .goback{
  274. z-index: 100;
  275. width: 34rpx;
  276. height: 34rpx;
  277. }
  278. .tuiguang_bg {
  279. width: 100%;
  280. height: 400rpx;
  281. position: relative;
  282. }
  283. .money_img{
  284. width: 100%;
  285. height: 120rpx;
  286. text-align: center;
  287. padding-top: 50rpx;
  288. padding-bottom: 135rpx;
  289. image{
  290. width:120rpx;
  291. height: 120rpx;
  292. border: 4rpx solid #FD5F6F;
  293. border-radius: 50%;
  294. }
  295. }
  296. .money-frame {
  297. position: absolute;
  298. top: 0;
  299. width: 100%;
  300. padding-top: 120rpx;
  301. // left: 30rpx;
  302. // height: 460rpx;
  303. // display: flex;
  304. // align-items: flex-start;
  305. // flex-direction: column;
  306. // justify-content: center;
  307. }
  308. .money_name{
  309. width: 100%;
  310. text-align: center;
  311. font-size: 32rpx;
  312. font-family: PingFang SC;
  313. font-weight: bold;
  314. color: #FFFFFF;
  315. }
  316. .money_num {
  317. font-size: 72rpx;
  318. font-family: PingFang SC;
  319. font-weight: bold;
  320. color: #FFFFFF;
  321. .money_ren {
  322. font-size: 36rpx;
  323. }
  324. }
  325. }
  326. .navbar {
  327. display: flex;
  328. height: 40px;
  329. padding: 0 5px;
  330. background: #fff;
  331. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  332. position: relative;
  333. z-index: 10;
  334. .nav-item {
  335. flex: 1;
  336. display: flex;
  337. justify-content: center;
  338. align-items: center;
  339. height: 100%;
  340. font-size: 15px;
  341. color: $font-color-dark;
  342. position: relative;
  343. &.current {
  344. color: #FF0000;
  345. &:after {
  346. content: '';
  347. position: absolute;
  348. left: 50%;
  349. bottom: 0;
  350. transform: translateX(-50%);
  351. width: 44px;
  352. height: 0;
  353. border-bottom: 2px solid #FF0000;
  354. }
  355. }
  356. }
  357. }
  358. // 列表
  359. .swiper-box {
  360. padding-top: 10rpx;
  361. .order-item {
  362. padding: 20rpx 30rpx;
  363. line-height: 1.5;
  364. .title-box {
  365. width: 100%;
  366. .title-avatar{
  367. width: 100rpx;
  368. height: 100rpx;
  369. margin-right: 25rpx;
  370. image{
  371. width: 100%;
  372. height: 100%;
  373. border-radius: 100%;
  374. }
  375. }
  376. .list_tpl{
  377. width: 85%;
  378. .title {
  379. font-size: $font-lg;
  380. color: $font-color-base;
  381. overflow:hidden; //超出的文本隐藏
  382. text-overflow:ellipsis; //溢出用省略号显示
  383. white-space:nowrap;
  384. }
  385. .time {
  386. font-size: $font-base;
  387. color: $font-color-light;
  388. }
  389. }
  390. }
  391. .money {
  392. color: #DB1935;
  393. font-size: $font-lg;
  394. }
  395. }
  396. }
  397. .list-scroll-content {
  398. height: 100%;
  399. }
  400. .content {
  401. height: 100%;
  402. .empty-content {
  403. background-color: #ffffff;
  404. }
  405. }
  406. </style>