award.vue 7.7 KB

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