integralShopping.vue 9.3 KB

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