award.vue 7.2 KB

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