integralShopping.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="status_bar"><!-- 这里是状态栏 --></view>
  5. <view class="body-title">
  6. <view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view>
  7. <view class="header">我的货款</view>
  8. </view>
  9. <view class="content-bg"><image src="../../static/img/user-wallet.png" mode=""></image></view>
  10. <view class="money-box"><view class="money">{{ userInfo.now_money*1 }}</view></view>
  11. </view>
  12. <view class="navbar">
  13. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  14. </view>
  15. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab">
  16. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  17. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  18. <!-- 空白页 -->
  19. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  20. <!-- 订单列表 -->
  21. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  22. <view class="title-box">
  23. <view class="title">
  24. <text>{{ item.title }}</text>
  25. </view>
  26. <view class="time">
  27. <text>{{ item.add_time }}</text>
  28. </view>
  29. </view>
  30. <view class="money">
  31. <view>{{ (item.pm == 0 ? '-' : '+') + item.number }}</view>
  32. <view v-if="item.status == 0" class="status">待发放</view>
  33. </view>
  34. </view>
  35. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  36. </scroll-view>
  37. </swiper-item>
  38. </swiper>
  39. <view class="btn-box" @click="navto('/pages/money/huodai')">
  40. 货款充值
  41. </view>
  42. <uni-popup ref="popup" type="center">
  43. <view class="popup-box">
  44. <view class="popup-title">转赠规则</view>
  45. <view class="popup-main">
  46. <view class="popup-little">一、活动时间</view>
  47. <view class="popup-text">xxxx年xx月xx日xx时举办活动</view>
  48. <view class="popup-little">二、规则</view>
  49. <view class="popup-text">本次活动奖励共二挡,活动奖励按 最高档发放</view>
  50. <view class="popup-little">一、活动时间</view>
  51. <view class="popup-text">xxxx年xx月xx日xx时举办活动</view>
  52. <view class="popup-little">二、规则</view>
  53. <view class="popup-text">本次活动奖励共二挡,活动奖励按 最高档发放</view>
  54. </view>
  55. </view>
  56. <view class="close" @click="close"><image src="../../static/img/Close.png" mode=""></image></view>
  57. </uni-popup>
  58. </view>
  59. </template>
  60. <script>
  61. import { spreadCommission, userBalance } from '@/api/wallet.js';
  62. import { mapState, mapMutations } from 'vuex';
  63. import uniLoadMore from '@/uview-ui/components/u-loadmore/u-loadmore.vue';
  64. import empty from '@/uview-ui/components/u-empty/u-empty.vue';
  65. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  66. export default {
  67. components: {
  68. empty,
  69. uniLoadMore,
  70. uniPopup
  71. },
  72. onReady(res) {
  73. var _this = this;
  74. uni.getSystemInfo({
  75. success: resu => {
  76. const query = uni.createSelectorQuery();
  77. query.select('.swiper-box').boundingClientRect();
  78. query.exec(function(res) {
  79. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  80. console.log('打印页面的剩余高度', _this.height);
  81. });
  82. },
  83. fail: res => {}
  84. });
  85. },
  86. data() {
  87. return {
  88. // 头部图高度
  89. maxheight: '',
  90. tabCurrentIndex: 0,
  91. navList: [
  92. {
  93. state: 2,
  94. text: '收入',
  95. loadingType: 'more',
  96. orderList: [],
  97. page: 1, //当前页面
  98. limit: 10 //每次信息条数
  99. },
  100. {
  101. state: 1,
  102. text: '支出',
  103. loadingType: 'more',
  104. orderList: [],
  105. page: 1, //当前页面
  106. limit: 10 //每次信息条数
  107. }
  108. ],
  109. money: 0,
  110. };
  111. },
  112. onLoad(options) {},
  113. onShow() {
  114. this.loadData();
  115. },
  116. computed: {
  117. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  118. },
  119. methods: {
  120. navto(e) {
  121. uni.navigateTo({
  122. url: e
  123. });
  124. },
  125. // 点击返回 我的页面
  126. toBack() {
  127. uni.navigateBack({});
  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. //修改当前对象状态为加载中
  143. navItem.loadingType = 'loading';
  144. spreadCommission(
  145. {
  146. page: navItem.page,
  147. limit: navItem.limit
  148. },
  149. state
  150. )
  151. .then(({ data }) => {
  152. if (data.length > 0) {
  153. navItem.orderList = navItem.orderList.concat(data[0].list);
  154. console.log(navItem.orderList);
  155. navItem.page++;
  156. }
  157. //判断是否还有数据, 有改为more, 没有改为noMore
  158. if (navItem.limit == data.length) {
  159. navItem.loadingType = 'more';
  160. return;
  161. } else {
  162. navItem.loadingType = 'noMore';
  163. }
  164. uni.hideLoading();
  165. this.$set(navItem, 'loaded', true);
  166. })
  167. .catch(e => {
  168. console.log(e);
  169. });
  170. },
  171. //swiper 切换
  172. changeTab(e) {
  173. this.tabCurrentIndex = e.target.current;
  174. this.loadData('tabChange');
  175. },
  176. //顶部tab点击
  177. tabClick(index) {
  178. this.tabCurrentIndex = index;
  179. },
  180. open() {
  181. this.$refs.popup.open();
  182. },
  183. close() {
  184. this.$refs.popup.close();
  185. },
  186. }
  187. };
  188. </script>
  189. <style lang="scss">
  190. page {
  191. background: #f1f1f1;
  192. height: 100%;
  193. }
  194. .status_bar {
  195. height: var(--status-bar-height);
  196. width: 100%;
  197. }
  198. .content-money {
  199. padding-bottom: 30rpx;
  200. position: relative;
  201. height: 400rpx;
  202. .content-bg {
  203. position: absolute;
  204. top: 0;
  205. left: 0;
  206. right: 0;
  207. width: 750rpx;
  208. height: 400rpx;
  209. image {
  210. width: 100%;
  211. height: 100%;
  212. }
  213. }
  214. .body-title {
  215. height: 80rpx;
  216. text-align: center;
  217. font-size: 35rpx;
  218. position: relative;
  219. .header {
  220. position: absolute;
  221. left: 0;
  222. top: 0;
  223. width: 100%;
  224. font-size: 36rpx;
  225. font-family: PingFang SC;
  226. font-weight: bold;
  227. color: #fffeff;
  228. height: 80rpx;
  229. font-size: 36rpx;
  230. font-weight: 700;
  231. z-index: 2;
  232. display: flex;
  233. justify-content: center;
  234. align-items: center;
  235. }
  236. .goback-box {
  237. position: absolute;
  238. left: 18rpx;
  239. top: 0;
  240. height: 80rpx;
  241. display: flex;
  242. align-items: center;
  243. }
  244. .goback {
  245. z-index: 100;
  246. width: 34rpx;
  247. height: 34rpx;
  248. }
  249. }
  250. .rule {
  251. z-index: 11;
  252. position: absolute;
  253. top: 130rpx;
  254. right: 0;
  255. width: 140rpx;
  256. height: 50rpx;
  257. background: #ffffff;
  258. border-top-left-radius: 8rpx;
  259. border-bottom-left-radius: 8rpx;
  260. text-align: center;
  261. line-height: 50rpx;
  262. font-size: 26rpx;
  263. font-family: PingFang SC;
  264. font-weight: bold;
  265. color: #2e58ff;
  266. }
  267. }
  268. .btn {
  269. justify-content: center;
  270. align-items: center;
  271. position: relative;
  272. z-index: 10;
  273. .btn-item {
  274. margin: 0 15rpx;
  275. width: 330rpx;
  276. height: 100rpx;
  277. background: #ffffff;
  278. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  279. border-radius: 10rpx;
  280. text-align: center;
  281. line-height: 100rpx;
  282. font-size: 34rpx;
  283. font-family: PingFang SC;
  284. font-weight: bold;
  285. color: #3c77ff;
  286. margin-top: -50rpx;
  287. }
  288. }
  289. .money-box {
  290. position: relative;
  291. z-index: 10;
  292. padding-top: 100rpx;
  293. color: #ffffff;
  294. text-align: center;
  295. .money {
  296. font-size: 86rpx;
  297. font-family: PingFang SC;
  298. font-weight: bold;
  299. color: #ffffff;
  300. }
  301. }
  302. .navbar {
  303. margin-top: 20rpx;
  304. display: flex;
  305. height: 88rpx;
  306. padding: 0 5px;
  307. background: #fff;
  308. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  309. position: relative;
  310. z-index: 10;
  311. .nav-item {
  312. flex: 1;
  313. display: flex;
  314. justify-content: center;
  315. align-items: center;
  316. height: 100%;
  317. font-size: 15px;
  318. color: $font-color-dark;
  319. position: relative;
  320. &.current {
  321. color: $base-color;
  322. &:after {
  323. content: '';
  324. position: absolute;
  325. left: 50%;
  326. bottom: 0;
  327. transform: translateX(-50%);
  328. width: 44px;
  329. height: 0;
  330. border-bottom: 2px solid $base-color;
  331. }
  332. }
  333. }
  334. }
  335. //列表
  336. .swiper-box {
  337. .order-item {
  338. padding: 20rpx 30rpx;
  339. line-height: 1.5;
  340. .title-box {
  341. .title {
  342. font-size: $font-lg;
  343. color: $font-color-base;
  344. }
  345. .time {
  346. font-size: $font-base;
  347. color: $font-color-light;
  348. }
  349. }
  350. .money {
  351. color: #fd5b23;
  352. font-size: $font-lg;
  353. text-align: right;
  354. .status {
  355. color: $font-color-light;
  356. color: $font-color-light - 2rpx;
  357. }
  358. }
  359. }
  360. }
  361. .list-scroll-content {
  362. background: #ffffff;
  363. height: 100%;
  364. }
  365. .content {
  366. height: 100%;
  367. .empty-content {
  368. background-color: #ffffff;
  369. }
  370. }
  371. .btn-box{
  372. position: fixed;
  373. bottom: 48rpx;
  374. left: 0;
  375. right: 0;
  376. margin: auto;
  377. width: 674rpx;
  378. height: 88rpx;
  379. background: linear-gradient(0deg, #2E58FF, #32C6FF);
  380. border-radius: 44rpx;
  381. text-align: center;
  382. line-height: 88rpx;
  383. font-size: 36rpx;
  384. font-family: PingFang SC;
  385. font-weight: 500;
  386. color: #FFFFFF;
  387. }
  388. .popup-box {
  389. background: #FFFFFF;
  390. border-radius: 10rpx;
  391. width: 580rpx;
  392. padding: 43rpx 60rpx 56rpx 34rpx;
  393. .popup-title {
  394. width: 100%;
  395. text-align: center;
  396. font-size: 36rpx;
  397. font-family: PingFang SC;
  398. font-weight: bold;
  399. color: #333333;
  400. }
  401. .popup-main {
  402. margin-top: 48rpx;
  403. .popup-little {
  404. padding-top: 18rpx;
  405. font-size: 30rpx;
  406. font-family: PingFang SC;
  407. font-weight: 500;
  408. color: #333333;
  409. }
  410. .popup-text {
  411. padding-left: 60rpx;
  412. padding-top: 18rpx;
  413. font-size: 28rpx;
  414. font-family: PingFang SC;
  415. font-weight: 500;
  416. color: #666666;
  417. }
  418. }
  419. }
  420. .close {
  421. margin: 70rpx auto 0;
  422. width: 84rpx;
  423. height: 84rpx;
  424. image {
  425. width: 100%;
  426. height: 100%;
  427. }
  428. }
  429. </style>