integralShopping.vue 9.2 KB

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