award.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view class="content">
  3. <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  5. </view>
  6. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  7. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  8. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  9. <!-- 空白页 -->
  10. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  11. <!-- 订单列表 -->
  12. <template v-for="(ls, index) in tabItem.orderList">
  13. <view class="order-item flex" v-if="tabCurrentIndex == 0">
  14. <view class="title-box">
  15. <view class="title">
  16. <text>{{ ls.title }}</text>
  17. </view>
  18. <view class="time">
  19. <text>{{ ls.add_time }}</text>
  20. </view>
  21. </view>
  22. <view class="money">
  23. <text>{{ '+' + ls.number }}</text>
  24. </view>
  25. </view>
  26. <view class="order-item flex" v-if="tabCurrentIndex == 1">
  27. <view class="title-box">
  28. <view class="title">
  29. <text>{{ ls.title }}</text>
  30. </view>
  31. <view class="time">
  32. <text>{{ ls.add_time }}</text>
  33. </view>
  34. </view>
  35. <view class="money">
  36. <text>{{ '-' + ls.number }}</text>
  37. </view>
  38. </view>
  39. </template>
  40. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  41. </scroll-view>
  42. </swiper-item>
  43. </swiper>
  44. </view>
  45. </template>
  46. <script>
  47. import { getCommissionInfo } from '@/api/user.js';
  48. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  49. import empty from '@/components/empty';
  50. export default {
  51. components: {
  52. empty,
  53. uniLoadMore
  54. },
  55. onReady() {
  56. // 初始化获取页面宽度
  57. uni.createSelectorQuery()
  58. .select('.content')
  59. .fields(
  60. {
  61. size: true
  62. },
  63. data => {
  64. // 保存头部高度
  65. this.maxheight = data.height - Math.floor((data.width / 750) * 570);
  66. }
  67. )
  68. .exec();
  69. },
  70. data() {
  71. return {
  72. // 头部图高度
  73. maxheight: '',
  74. tabCurrentIndex: 0,
  75. navList: [
  76. {
  77. state: 3,
  78. text: '返佣',
  79. loadingType: 'more',
  80. orderList: [],
  81. page: 1, //当前页数
  82. limit: 10 //每次信息条数
  83. },
  84. {
  85. state: 4,
  86. text: '提现',
  87. loadingType: 'more',
  88. orderList: [],
  89. page: 1, //当前页数
  90. limit: 10 //每次信息条数
  91. },
  92. ],
  93. money: '', // 总余额
  94. recharge: '', // 累计充值
  95. orderStatusSum: '', // 累计消费
  96. };
  97. },
  98. onLoad(options) {},
  99. onShow() {
  100. this.loadData();
  101. },
  102. methods: {
  103. // 页面跳转
  104. navto(e) {
  105. uni.navigateTo({
  106. url: e
  107. });
  108. },
  109. //获取信息
  110. async loadData(source) {
  111. //这里是将订单挂载到tab列表下
  112. let index = this.tabCurrentIndex;
  113. let navItem = this.navList[index];
  114. let state = navItem.state;
  115. if (source === 'tabChange' && navItem.loaded === true) {
  116. //tab切换只有第一次需要加载数据
  117. return;
  118. }
  119. if (navItem.loadingType === 'loading') {
  120. //防止重复加载
  121. return;
  122. }
  123. // 修改当前对象状态为加载中
  124. navItem.loadingType = 'loading';
  125. getCommissionInfo(
  126. {
  127. page: navItem.page,
  128. limit: navItem.limit
  129. },
  130. state
  131. )
  132. .then(({ data }) => {
  133. if (data.length > 0) {
  134. navItem.orderList = navItem.orderList.concat(data);
  135. console.log(navItem.orderList,'navItem.orderList');
  136. navItem.page++;
  137. }
  138. if (navItem.limit == data.length) {
  139. //判断是否还有数据, 有改为 more, 没有改为noMore
  140. navItem.loadingType = 'more';
  141. return;
  142. } else {
  143. //判断是否还有数据, 有改为 more, 没有改为noMore
  144. navItem.loadingType = 'noMore';
  145. }
  146. uni.hideLoading();
  147. this.$set(navItem, 'loaded', true);
  148. })
  149. .catch(e => {
  150. console.log(e);
  151. });
  152. },
  153. //swiper 切换
  154. changeTab(e) {
  155. this.tabCurrentIndex = e.target.current;
  156. this.loadData('tabChange');
  157. },
  158. //顶部tab点击
  159. tabClick(index) {
  160. this.tabCurrentIndex = index;
  161. }
  162. }
  163. };
  164. </script>
  165. <style lang="scss">
  166. page {
  167. background: #ffffff;
  168. height: 100%;
  169. }
  170. .content-money {
  171. padding-bottom: 30rpx;
  172. background: $page-color-base;
  173. // border: 2px solid #ffffff;
  174. .moneyTx {
  175. position: absolute;
  176. top: 150rpx;
  177. right: 0rpx;
  178. width: 150rpx;
  179. padding: 10rpx 30rpx;
  180. border: 2px solid #ffffff;
  181. border-top-left-radius: 99rpx;
  182. border-bottom-left-radius: 99rpx;
  183. color: #ffffff;
  184. line-height: 1;
  185. font-size: $font-base;
  186. }
  187. .buttom-box {
  188. background-color: #ffffff;
  189. text-align: center;
  190. margin: 0 30rpx;
  191. padding: 20rpx 0;
  192. border-radius: $border-radius-sm;
  193. margin-top: -60rpx;
  194. .buttom {
  195. font-size: $font-lg;
  196. flex-grow: 1;
  197. }
  198. .interval {
  199. width: 2px;
  200. height: 60rpx;
  201. background-color: #eeeeee;
  202. }
  203. .icon {
  204. height: 50rpx;
  205. width: 48rpx;
  206. margin: 0 auto;
  207. .icon-img {
  208. width: 100%;
  209. height: 100%;
  210. }
  211. }
  212. }
  213. }
  214. .money-box {
  215. background: $base-color;
  216. padding-top: var(--status-bar-height);
  217. height: 410rpx;
  218. color: #ffffff;
  219. text-align: center;
  220. position: relative;
  221. .text {
  222. // padding-top: 80rpx;
  223. font-size: $font-lg;
  224. }
  225. .money {
  226. padding-top: 120rpx;
  227. font-size: 45rpx;
  228. font-weight: 500;
  229. }
  230. .money-accum {
  231. display: flex;
  232. align-items: center;
  233. justify-content: space-around;
  234. margin-top: 44rpx;
  235. .money-frame {
  236. .money-num {
  237. font-size: 45rpx;
  238. font-weight: 500;
  239. color: rgba(255,255,255,1);
  240. }
  241. .mon-text {
  242. font-size: 30rpx;
  243. font-weight: 500;
  244. color: rgba(255,255,255,1);
  245. }
  246. }
  247. }
  248. .money-loca {
  249. width: 140rpx;
  250. height: 50rpx;
  251. background: #FFFFFF;
  252. color: #FA2740;
  253. font-size: $font-base;
  254. line-height: 50rpx;
  255. border-radius: 10rpx 0 0 10rpx;
  256. }
  257. // 立即提现
  258. .draw {
  259. position: absolute;
  260. right: 0;
  261. top: 64rpx;
  262. }
  263. // 余额支付
  264. .rech {
  265. position: absolute;
  266. right: 0;
  267. top: 134rpx;
  268. }
  269. }
  270. .navbar {
  271. display: flex;
  272. height: 40px;
  273. padding: 0 5px;
  274. background: #fff;
  275. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  276. position: relative;
  277. z-index: 10;
  278. .nav-item {
  279. flex: 1;
  280. display: flex;
  281. justify-content: center;
  282. align-items: center;
  283. height: 100%;
  284. font-size: 15px;
  285. color: $font-color-dark;
  286. position: relative;
  287. &.current {
  288. color: $font-color-spec;
  289. &:after {
  290. content: '';
  291. position: absolute;
  292. left: 50%;
  293. bottom: 0;
  294. transform: translateX(-50%);
  295. width: 44px;
  296. height: 0;
  297. border-bottom: 2px solid $font-color-spec;
  298. }
  299. }
  300. }
  301. }
  302. // 列表
  303. .swiper-box {
  304. height: calc(100% - 45rpx);
  305. padding-top: 10rpx;
  306. .order-item {
  307. padding: 20rpx 30rpx;
  308. line-height: 1.5;
  309. .title-box {
  310. .title {
  311. font-size: $font-lg;
  312. color: $font-color-base;
  313. }
  314. .time {
  315. font-size: $font-base;
  316. color: $font-color-light;
  317. }
  318. }
  319. .money {
  320. color: #fd5b23;
  321. font-size: $font-lg;
  322. }
  323. }
  324. }
  325. .list-scroll-content {
  326. height: 100%;
  327. }
  328. .content {
  329. height: 100%;
  330. .empty-content {
  331. background-color: #ffffff;
  332. }
  333. }
  334. </style>