account.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view class="my-account">
  3. <!--账户信息面板-->
  4. <view class="header">
  5. <view class="account">
  6. <view class="assets">
  7. <view>总资产(元)</view>
  8. <view class="money">
  9. {{ userInfo && userInfo.account && userInfo.account.user_money || '0.00' }}
  10. </view>
  11. </view>
  12. <text @tap="navTo('/pages/user/account/recharge')" class="recharge" >充值</text>
  13. </view>
  14. <view class="cumulative">
  15. <view class="item">
  16. <view>累计充值(元)</view>
  17. <view class="money">
  18. {{ userInfo && userInfo.account && userInfo.account.accumulate_money || '0.00' }}
  19. </view>
  20. </view>
  21. <view class="item">
  22. <view>累计消费(元)</view>
  23. <view class="money">
  24. {{ -(userInfo && userInfo.account && userInfo.account.consume_money) || '0.00' }}
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <!--余额/积分导航-->
  30. <view class="nav">
  31. <view class="item" v-for="item in navList" :key="item.title" @tap="navTo(item.url)">
  32. <text class="iconfont" :class="item.icon"></text>
  33. <text>{{ item.title }}</text>
  34. </view>
  35. </view>
  36. <!--广告-->
  37. <view class="advert">
  38. <view
  39. class="item on"
  40. @tap="navTo('/pages/user/coupon/list')"
  41. >
  42. <view class="text">
  43. <view class="name">领取优惠券</view>
  44. <text class="desc">满减享优惠</text>
  45. </view>
  46. <text class="iconfont iconwodeyouhuiquan"></text>
  47. </view>
  48. </view>
  49. <!--加载动画-->
  50. <rf-loading v-if="loading"></rf-loading>
  51. </view>
  52. </template>
  53. <script>/**
  54. * @des 用户账户中心
  55. *
  56. * @author stav stavyan@qq.com
  57. * @date 2020-01-10 15:17
  58. * @copyright 2019
  59. */
  60. import { memberInfo } from '@/api/userInfo';
  61. export default {
  62. data() {
  63. return {
  64. userInfo: {},
  65. loading: true,
  66. navList: [
  67. {title: '账单记录', icon: 'icondaifukuan', url: '/pages/user/account/bill'},
  68. {title: '充值记录', icon: 'iconchongzhijilu', url: '/pages/user/account/bill?state=2'},
  69. {title: '消费记录', icon: 'iconzuheduozhongxiaofeifangshizuhexiaofei', url: '/pages/user/account/bill?state=3'},
  70. {title: '积分中心', icon: 'iconjifenqia', url: '/pages/user/account/integral'}
  71. ]
  72. }
  73. },
  74. onShow() {
  75. this.initData();
  76. },
  77. methods: {
  78. // 初始化数据
  79. initData() {
  80. this.getMemberInfo();
  81. },
  82. // 获取用户信息
  83. async getMemberInfo() {
  84. await this.$http.get(memberInfo).then(async r => {
  85. this.loading = false;
  86. this.userInfo = r.data;
  87. }).catch(() => {
  88. this.loading = false;
  89. });
  90. },
  91. navTo(route) {
  92. this.$mRouter.push({route})
  93. }
  94. }
  95. }
  96. </script>
  97. <style scoped lang="scss">
  98. page {
  99. background-color: $color-white;
  100. }
  101. .my-account {
  102. padding: 32upx 20upx;
  103. width: 100%;
  104. .header {
  105. padding: 30upx;
  106. height: 320upx;
  107. background-color: $base-color;
  108. opacity: 0.9;
  109. border-radius: 20upx;
  110. color: rgba(255, 255, 255, 0.6);
  111. font-size: $font-sm;
  112. position: relative;
  113. .account {
  114. width: calc(100% - 60upx);
  115. display: flex;
  116. position: absolute;
  117. z-index: 2;
  118. justify-content: space-between;
  119. .assets {
  120. .money {
  121. color: #fff;
  122. font-size: $font-lg + 10upx;
  123. margin: 0;
  124. }
  125. }
  126. .recharge {
  127. font-size: $font-base;
  128. width: 150upx;
  129. height: 54upx;
  130. line-height: 54upx;
  131. border-radius: $font-base;
  132. background-color: #fff9f8;
  133. text-align: center;
  134. color: $base-color;
  135. margin-top: 10upx;
  136. }
  137. }
  138. .cumulative {
  139. width: calc(100% - 240upx);
  140. position: absolute;
  141. bottom: 20upx;
  142. display: flex;
  143. justify-content: space-between;
  144. .money {
  145. color: #fff;
  146. font-size: $font-lg + 4upx;
  147. margin: 0;
  148. }
  149. }
  150. .header-bg {
  151. position: absolute;
  152. width: 100%;
  153. height: 320upx;
  154. z-index: 1;
  155. top: 0;
  156. image {
  157. width: 100%;
  158. height: 320upx
  159. }
  160. }
  161. }
  162. .nav{
  163. border-bottom:1px solid #f5f5f5;
  164. display: flex;
  165. .item{
  166. flex:1;
  167. margin: 20upx;
  168. font-size: $font-base - 4upx;
  169. display: inline-block;
  170. text-align:center;
  171. color:#999;
  172. .iconfont {
  173. display: block;
  174. margin: 0 auto;
  175. font-size: $font-lg + 20upx;
  176. color: $base-color;
  177. }
  178. }
  179. }
  180. .advert{
  181. display: flex;
  182. .item{
  183. background-color:#fff6d1;
  184. flex: 1;
  185. border-radius: 24upx;
  186. padding: 10upx 0;
  187. margin: 20upx 10upx;
  188. color: $base-color;
  189. display: flex;
  190. justify-content: space-between;
  191. .iconfont {
  192. font-size: $font-lg + 20upx;
  193. margin-right: 20upx;
  194. }
  195. .text {
  196. margin-left: 20upx;
  197. .name{
  198. font-size: $font-base;
  199. font-weight: bold;
  200. height: 40upx;
  201. color: $base-color;
  202. }
  203. .desc {
  204. font-size: $font-sm - 2upx;
  205. }
  206. }
  207. }
  208. .on{
  209. background-color:#fff3f3;
  210. }
  211. }
  212. }
  213. </style>