integralShopping.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <view class="content">
  3. <view class="status_bar"><!-- 这里是状态栏 --></view>
  4. <view class="content-money">
  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-integralP.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: 0,
  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. userBalance({}).then(({ data }) => {
  116. this.money = data.commissionCount;
  117. });
  118. },
  119. computed: {
  120. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  121. },
  122. methods: {
  123. navto(e) {
  124. uni.navigateTo({
  125. url: e
  126. });
  127. },
  128. // 点击返回 我的页面
  129. toBack() {
  130. uni.navigateBack({});
  131. },
  132. async loadData(source) {
  133. //这里时将订单挂载到tab列表下
  134. let index = this.tabCurrentIndex;
  135. let navItem = this.navList[index];
  136. let state = navItem.state + 3;
  137. if (source === 'tabChange' && navItem.loaded === true) {
  138. //tab切换只有第一次需要加载数据
  139. return;
  140. }
  141. if (navItem.loadingType === 'loading') {
  142. //防止重复加载
  143. return;
  144. }
  145. //修改当前对象状态为加载中
  146. navItem.loadingType = 'loading';
  147. spreadCommission(
  148. {
  149. page: navItem.page,
  150. limit: navItem.limit
  151. },
  152. state
  153. )
  154. .then(({ data }) => {
  155. if (data.length > 0) {
  156. navItem.orderList = navItem.orderList.concat(data[0].list);
  157. console.log(navItem.orderList);
  158. navItem.page++;
  159. }
  160. //判断是否还有数据, 有改为more, 没有改为noMore
  161. if (navItem.limit == data.length) {
  162. navItem.loadingType = 'more';
  163. return;
  164. } else {
  165. navItem.loadingType = 'noMore';
  166. }
  167. uni.hideLoading();
  168. this.$set(navItem, 'loaded', true);
  169. })
  170. .catch(e => {
  171. console.log(e);
  172. });
  173. },
  174. //swiper 切换
  175. changeTab(e) {
  176. this.tabCurrentIndex = e.target.current;
  177. this.loadData('tabChange');
  178. },
  179. //顶部tab点击
  180. tabClick(index) {
  181. this.tabCurrentIndex = index;
  182. },
  183. open() {
  184. this.$refs.popup.open();
  185. },
  186. close() {
  187. this.$refs.popup.close();
  188. },
  189. }
  190. };
  191. </script>
  192. <style lang="scss">
  193. page {
  194. background: #f1f1f1;
  195. height: 100%;
  196. }
  197. .status_bar {
  198. height: var(--status-bar-height);
  199. width: 100%;
  200. }
  201. .content-money {
  202. padding-bottom: 30rpx;
  203. position: relative;
  204. height: 400rpx;
  205. .content-bg {
  206. position: absolute;
  207. top: 0;
  208. left: 0;
  209. right: 0;
  210. width: 750rpx;
  211. height: 400rpx;
  212. image {
  213. width: 100%;
  214. height: 100%;
  215. }
  216. }
  217. .body-title {
  218. height: 80rpx;
  219. text-align: center;
  220. font-size: 35rpx;
  221. position: relative;
  222. .header {
  223. position: absolute;
  224. left: 0;
  225. top: 0;
  226. width: 100%;
  227. font-size: 36rpx;
  228. font-family: PingFang SC;
  229. font-weight: bold;
  230. color: #fffeff;
  231. height: 80rpx;
  232. font-size: 36rpx;
  233. font-weight: 700;
  234. z-index: 2;
  235. display: flex;
  236. justify-content: center;
  237. align-items: center;
  238. }
  239. .goback-box {
  240. position: absolute;
  241. left: 18rpx;
  242. top: 0;
  243. height: 80rpx;
  244. display: flex;
  245. align-items: center;
  246. }
  247. .goback {
  248. z-index: 100;
  249. width: 34rpx;
  250. height: 34rpx;
  251. }
  252. }
  253. .rule {
  254. z-index: 11;
  255. position: absolute;
  256. top: 130rpx;
  257. right: 0;
  258. width: 140rpx;
  259. height: 50rpx;
  260. background: #ffffff;
  261. border-top-left-radius: 8rpx;
  262. border-bottom-left-radius: 8rpx;
  263. text-align: center;
  264. line-height: 50rpx;
  265. font-size: 26rpx;
  266. font-family: PingFang SC;
  267. font-weight: bold;
  268. color: #2e58ff;
  269. }
  270. }
  271. .btn {
  272. justify-content: center;
  273. align-items: center;
  274. position: relative;
  275. z-index: 10;
  276. .btn-item {
  277. margin: 0 15rpx;
  278. width: 330rpx;
  279. height: 100rpx;
  280. background: #ffffff;
  281. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  282. border-radius: 10rpx;
  283. text-align: center;
  284. line-height: 100rpx;
  285. font-size: 34rpx;
  286. font-family: PingFang SC;
  287. font-weight: bold;
  288. color: #3c77ff;
  289. margin-top: -50rpx;
  290. }
  291. }
  292. .money-box {
  293. position: relative;
  294. z-index: 10;
  295. padding-top: 100rpx;
  296. color: #ffffff;
  297. text-align: center;
  298. .money {
  299. font-size: 86rpx;
  300. font-family: PingFang SC;
  301. font-weight: bold;
  302. color: #ffffff;
  303. }
  304. }
  305. .navbar {
  306. margin-top: 20rpx;
  307. display: flex;
  308. height: 88rpx;
  309. padding: 0 5px;
  310. background: #fff;
  311. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  312. position: relative;
  313. z-index: 10;
  314. .nav-item {
  315. flex: 1;
  316. display: flex;
  317. justify-content: center;
  318. align-items: center;
  319. height: 100%;
  320. font-size: 15px;
  321. color: $font-color-dark;
  322. position: relative;
  323. &.current {
  324. color: $base-color;
  325. &:after {
  326. content: '';
  327. position: absolute;
  328. left: 50%;
  329. bottom: 0;
  330. transform: translateX(-50%);
  331. width: 44px;
  332. height: 0;
  333. border-bottom: 2px solid $base-color;
  334. }
  335. }
  336. }
  337. }
  338. //列表
  339. .swiper-box {
  340. .order-item {
  341. padding: 20rpx 30rpx;
  342. line-height: 1.5;
  343. .title-box {
  344. .title {
  345. font-size: $font-lg;
  346. color: $font-color-base;
  347. }
  348. .time {
  349. font-size: $font-base;
  350. color: $font-color-light;
  351. }
  352. }
  353. .money {
  354. color: #fd5b23;
  355. font-size: $font-lg;
  356. }
  357. }
  358. }
  359. .list-scroll-content {
  360. background: #ffffff;
  361. height: 100%;
  362. }
  363. .content {
  364. height: 100%;
  365. .empty-content {
  366. background-color: #ffffff;
  367. }
  368. }
  369. .btn-box{
  370. position: fixed;
  371. bottom: 48rpx;
  372. left: 0;
  373. right: 0;
  374. margin: auto;
  375. width: 674rpx;
  376. height: 88rpx;
  377. background: linear-gradient(0deg, #2E58FF, #32C6FF);
  378. border-radius: 44rpx;
  379. text-align: center;
  380. line-height: 88rpx;
  381. font-size: 36rpx;
  382. font-family: PingFang SC;
  383. font-weight: 500;
  384. color: #FFFFFF;
  385. }
  386. .popup-box {
  387. background: #FFFFFF;
  388. border-radius: 10rpx;
  389. width: 580rpx;
  390. padding: 43rpx 60rpx 56rpx 34rpx;
  391. .popup-title {
  392. width: 100%;
  393. text-align: center;
  394. font-size: 36rpx;
  395. font-family: PingFang SC;
  396. font-weight: bold;
  397. color: #333333;
  398. }
  399. .popup-main {
  400. margin-top: 48rpx;
  401. .popup-little {
  402. padding-top: 18rpx;
  403. font-size: 30rpx;
  404. font-family: PingFang SC;
  405. font-weight: 500;
  406. color: #333333;
  407. }
  408. .popup-text {
  409. padding-left: 60rpx;
  410. padding-top: 18rpx;
  411. font-size: 28rpx;
  412. font-family: PingFang SC;
  413. font-weight: 500;
  414. color: #666666;
  415. }
  416. }
  417. }
  418. .close {
  419. margin: 70rpx auto 0;
  420. width: 84rpx;
  421. height: 84rpx;
  422. image {
  423. width: 100%;
  424. height: 100%;
  425. }
  426. }
  427. </style>