index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="container" v-if="!isLoading">
  3. <view class="space-upper">
  4. <view class="wallet-image">
  5. <image src="/static/wallet.png" mode="widthFix"></image>
  6. </view>
  7. <view class="wallet-account">
  8. <view class="wallet-account_balance">
  9. <text>{{ userInfo.balance }}</text>
  10. </view>
  11. <view class="wallet-account_lable">
  12. <text>账户余额(元)</text>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="space-lower">
  17. <view v-if="setting.is_entrance" class="space-lower_item btn-recharge">
  18. <view class="btn-submit" @click="onTargetRecharge()">充 值</view>
  19. </view>
  20. <view class="space-lower_item item-lable dis-flex flex-x-around">
  21. <view class="lable-text" @click="onTargetRechargeOrder()">
  22. <text>充值记录</text>
  23. </view>
  24. <view class="lable-text" @click="onTargetBalanceLog()">
  25. <text>账单详情</text>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import * as UserApi from '@/api/user'
  33. import SettingModel from '@/common/model/Setting'
  34. import SettingKeyEnum from '@/common/enum/setting/Key'
  35. export default {
  36. data() {
  37. return {
  38. // 正在加载
  39. isLoading: true,
  40. // 会员信息
  41. userInfo: {},
  42. // 充值设置
  43. setting: {},
  44. }
  45. },
  46. /**
  47. * 生命周期函数--监听页面加载
  48. */
  49. onShow(options) {
  50. // 获取页面数据
  51. this.getPageData()
  52. },
  53. methods: {
  54. // 获取页面数据
  55. getPageData() {
  56. const app = this
  57. app.isLoading = true
  58. Promise.all([app.getUserInfo(), app.getSetting()])
  59. .then(() => app.isLoading = false)
  60. },
  61. // 获取会员信息
  62. getUserInfo() {
  63. const app = this
  64. return new Promise((resolve, reject) => {
  65. UserApi.info()
  66. .then(result => {
  67. app.userInfo = result.data.userInfo
  68. resolve(app.userInfo)
  69. })
  70. })
  71. },
  72. // 获取充值设置
  73. getSetting() {
  74. const app = this
  75. return new Promise((resolve, reject) => {
  76. SettingModel.item(SettingKeyEnum.RECHARGE.value, false)
  77. .then(data => {
  78. app.setting = data
  79. resolve(data)
  80. })
  81. })
  82. },
  83. // 跳转充值页面
  84. onTargetRecharge() {
  85. this.$navTo('pages/wallet/recharge/index')
  86. },
  87. // 跳转充值记录页面
  88. onTargetRechargeOrder() {
  89. this.$navTo('pages/wallet/recharge/order')
  90. },
  91. // 跳转账单详情页面
  92. onTargetBalanceLog() {
  93. this.$navTo('pages/wallet/balance/log')
  94. }
  95. }
  96. }
  97. </script>
  98. <style>
  99. page {
  100. background: #fff;
  101. }
  102. </style>
  103. <style lang="scss" scoped>
  104. .container {
  105. background: #fff;
  106. }
  107. .space-upper {
  108. padding: 150rpx 0;
  109. text-align: center;
  110. }
  111. .wallet-image image {
  112. width: 360rpx;
  113. height: 261.72rpx;
  114. }
  115. .wallet-account {
  116. margin-top: 20rpx;
  117. }
  118. .wallet-account_balance {
  119. font-size: 56rpx;
  120. }
  121. .wallet-account_lable {
  122. margin-top: 14rpx;
  123. color: #cec1c1;
  124. font-size: 26rpx;
  125. }
  126. .space-lower {
  127. margin-top: 30rpx;
  128. padding: 0 110rpx;
  129. }
  130. .btn-recharge .btn-submit {
  131. width: 460rpx;
  132. height: 84rpx;
  133. margin: 0 auto;
  134. border-radius: 50rpx;
  135. background: #786cff;
  136. color: white;
  137. font-size: 30rpx;
  138. display: flex;
  139. justify-content: center;
  140. align-items: center;
  141. }
  142. .item-lable {
  143. margin-top: 80rpx;
  144. font-size: 28rpx;
  145. color: rgb(94, 94, 94);
  146. padding: 0 100rpx;
  147. }
  148. </style>