extension.vue 8.7 KB

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