mallPoints.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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/myShang.png" mode=""></image></view>
  10. <view class="money-box">
  11. <view class="money"> {{ money }} </view>
  12. </view>
  13. </view>
  14. <view class="navbar">
  15. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  16. </view>
  17. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab">
  18. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  19. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  20. <!-- 空白页 -->
  21. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  22. <!-- 订单列表 -->
  23. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  24. <view class="title-box">
  25. <view class="title">
  26. <text>{{ item.title }}</text>
  27. </view>
  28. <view class="time">
  29. <text>{{ item.add_time }}</text>
  30. </view>
  31. </view>
  32. <view class="money">
  33. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  34. </view>
  35. </view>
  36. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  37. </scroll-view>
  38. </swiper-item>
  39. </swiper>
  40. </view>
  41. </template>
  42. <script>
  43. import { moneyLog, recharge, wallet } from '@/api/finance.js';
  44. import { mapState, mapMutations } from 'vuex';
  45. import uniLoadMore from '@/uview-ui/components/u-loadmore/u-loadmore.vue';
  46. import empty from '@/uview-ui/components/u-empty/u-empty.vue';
  47. export default {
  48. components: {
  49. empty,
  50. uniLoadMore
  51. },
  52. onReady(res) {
  53. var _this = this;
  54. uni.getSystemInfo({
  55. success: resu => {
  56. const query = uni.createSelectorQuery();
  57. query.select('.swiper-box').boundingClientRect();
  58. query.exec(function(res) {
  59. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  60. console.log('打印页面的剩余高度', _this.height);
  61. });
  62. },
  63. fail: res => {}
  64. });
  65. },
  66. data() {
  67. return {
  68. // 头部图高度
  69. maxheight: '',
  70. tabCurrentIndex: 0,
  71. navList: [
  72. {
  73. state: 1,
  74. text: '收入',
  75. loadingType: 'more',
  76. orderList: [],
  77. page: 1, //当前页面
  78. limit: 10 //每次信息条数
  79. },
  80. {
  81. state: 2,
  82. text: '支出',
  83. loadingType: 'more',
  84. orderList: [],
  85. page: 1, //当前页面
  86. limit: 10 //每次信息条数
  87. }
  88. ],
  89. money: 0
  90. };
  91. },
  92. onLoad(options) {},
  93. onShow() {
  94. wallet({}).then(({ data }) => {
  95. const obj = this
  96. const arr = Object.keys(data.back);
  97. console.log(arr);
  98. arr.forEach(e => {
  99. if(e == 'SCJF'){
  100. obj.money = (data.back[e].money.money*1)
  101. }
  102. });
  103. });
  104. this.loadData();
  105. },
  106. methods: {
  107. async loadData(source) {
  108. //这里时将订单挂载到tab列表下
  109. let index = this.tabCurrentIndex;
  110. let navItem = this.navList[index];
  111. let state = navItem.state + 3;
  112. if (source === 'tabChange' && navItem.loaded === true) {
  113. //tab切换只有第一次需要加载数据
  114. return;
  115. }
  116. if (navItem.loadingType === 'loading') {
  117. //防止重复加载
  118. return;
  119. }
  120. //修改当前对象状态为加载中
  121. navItem.loadingType = 'loading';
  122. moneyLog(
  123. {
  124. page: navItem.page,
  125. limit: navItem.limit,
  126. pm:navItem.state
  127. },
  128. 'SCJF'
  129. )
  130. .then(({ data }) => {
  131. if (data.length > 0) {
  132. navItem.orderList = navItem.orderList.concat(data[0].list);
  133. console.log(navItem.orderList);
  134. navItem.page++;
  135. }
  136. //判断是否还有数据, 有改为more, 没有改为noMore
  137. if (navItem.limit == data.length) {
  138. navItem.loadingType = 'more';
  139. return;
  140. } else {
  141. navItem.loadingType = 'noMore';
  142. }
  143. uni.hideLoading();
  144. this.$set(navItem, 'loaded', true);
  145. })
  146. .catch(e => {
  147. console.log(e);
  148. });
  149. },
  150. // 点击返回 我的页面
  151. toBack() {
  152. uni.navigateBack({});
  153. },
  154. //swiper 切换
  155. changeTab(e) {
  156. this.tabCurrentIndex = e.target.current;
  157. this.loadData('tabChange');
  158. },
  159. //顶部tab点击
  160. tabClick(index) {
  161. this.tabCurrentIndex = index;
  162. }
  163. }
  164. };
  165. </script>
  166. <style lang="scss">
  167. page {
  168. background: #f1f1f1;
  169. height: 100%;
  170. }
  171. .status_bar {
  172. height: var(--status-bar-height);
  173. width: 100%;
  174. }
  175. .content-money {
  176. padding-bottom: 30rpx;
  177. position: relative;
  178. height: 400rpx;
  179. .content-bg {
  180. position: absolute;
  181. top: 0;
  182. left: 0;
  183. right: 0;
  184. width: 750rpx;
  185. height: 400rpx;
  186. image {
  187. width: 100%;
  188. height: 100%;
  189. }
  190. }
  191. .body-title {
  192. height: 80rpx;
  193. text-align: center;
  194. font-size: 35rpx;
  195. position: relative;
  196. .header {
  197. position: absolute;
  198. left: 0;
  199. top: 0;
  200. width: 100%;
  201. font-size: 36rpx;
  202. font-family: PingFang SC;
  203. font-weight: bold;
  204. color: #fffeff;
  205. height: 80rpx;
  206. font-size: 36rpx;
  207. font-weight: 700;
  208. z-index: 2;
  209. display: flex;
  210. justify-content: center;
  211. align-items: center;
  212. }
  213. .goback-box {
  214. position: absolute;
  215. left: 18rpx;
  216. top: 0;
  217. height: 80rpx;
  218. display: flex;
  219. align-items: center;
  220. }
  221. .goback {
  222. z-index: 100;
  223. width: 34rpx;
  224. height: 34rpx;
  225. }
  226. }
  227. }
  228. .money-box {
  229. position: relative;
  230. z-index: 100;
  231. padding-top: 80rpx;
  232. color: #ffffff;
  233. text-align: center;
  234. .money {
  235. font-size: 86rpx;
  236. font-family: PingFang SC;
  237. font-weight: bold;
  238. color: #FFFFFF;
  239. }
  240. }
  241. .navbar {
  242. margin-top: 20rpx;
  243. display: flex;
  244. height: 88rpx;
  245. padding: 0 5px;
  246. background: #fff;
  247. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  248. position: relative;
  249. z-index: 10;
  250. .nav-item {
  251. flex: 1;
  252. display: flex;
  253. justify-content: center;
  254. align-items: center;
  255. height: 100%;
  256. font-size: 15px;
  257. color: $font-color-dark;
  258. position: relative;
  259. &.current {
  260. color: $base-color;
  261. &:after {
  262. content: '';
  263. position: absolute;
  264. left: 50%;
  265. bottom: 0;
  266. transform: translateX(-50%);
  267. width: 44px;
  268. height: 0;
  269. border-bottom: 2px solid $base-color;
  270. }
  271. }
  272. }
  273. }
  274. //列表
  275. .swiper-box {
  276. .order-item {
  277. padding: 20rpx 30rpx;
  278. line-height: 1.5;
  279. .title-box {
  280. .title {
  281. font-size: $font-lg;
  282. color: $font-color-base;
  283. }
  284. .time {
  285. font-size: $font-base;
  286. color: $font-color-light;
  287. }
  288. }
  289. .money {
  290. color: #EF3A55;
  291. font-size: $font-lg + 5rpx;
  292. }
  293. }
  294. }
  295. .list-scroll-content {
  296. background: #ffffff;
  297. height: 100%;
  298. }
  299. .content {
  300. height: 100%;
  301. .empty-content {
  302. background-color: #ffffff;
  303. }
  304. }
  305. .btn-box {
  306. width: 674rpx;
  307. height: 88rpx;
  308. background: linear-gradient(0deg, #2E58FF, #32C6FF);
  309. border-radius: 44rpx;
  310. font-size: 36rpx;
  311. font-family: PingFang SC;
  312. font-weight: 500;
  313. color: #FFFFFF;
  314. text-align: center;
  315. line-height: 88rpx;
  316. position: fixed;
  317. bottom: 48rpx;
  318. left: 0;
  319. right: 0;
  320. margin: 0 auto;
  321. }
  322. </style>