mallPoints.vue 7.1 KB

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