charge.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="content">
  3. <view class="bg">
  4. <image src="../../static/user/bg.png" mode=""></image>
  5. </view>
  6. <view class="header">
  7. <view class="header-left" @click="toBack()">
  8. <image class="goback" src="../../static/user/fanhui.png" mode=""></image>
  9. </view>
  10. <view class="header-title">
  11. 电费
  12. </view>
  13. </view>
  14. <view class="box-title">
  15. <view class="yue">
  16. 电费余额
  17. </view>
  18. <view class="yuan">
  19. {{yue}}元
  20. </view>
  21. </view>
  22. <view class="box-content">
  23. <view class="content-title">
  24. <view class="left">
  25. 电费明细
  26. </view>
  27. <view class="right" @click="navTo()">
  28. 立即充值
  29. </view>
  30. </view>
  31. <view class="box">
  32. <view class="content-content" v-for="item in list">
  33. <view class="money">
  34. {{item.pm>0?'+':'-'}}{{item.number}}
  35. </view>
  36. <view class="time">
  37. {{item.add_time}}
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import { mapMutations } from 'vuex';
  46. import { getUserInfo } from '@/api/user.js';
  47. import {
  48. charge
  49. } from '../../api/user.js'
  50. import {
  51. mapState
  52. } from 'vuex';
  53. export default {
  54. data() {
  55. return {
  56. pm: 1, //收入
  57. yue: 0, //电费余额
  58. list: [] //电费订单列表
  59. };
  60. },
  61. computed: {
  62. ...mapState('user', ['userInfo'])
  63. },
  64. onLoad() {
  65. this.loadData()
  66. },
  67. onShow() {
  68. this.loadData()
  69. getUserInfo().then(res=>{
  70. this.setUserInfo(res.data);
  71. })
  72. },
  73. methods: {
  74. ...mapMutations('user', ['setUserInfo', 'login']),
  75. toBack() {
  76. uni.switchTab({
  77. url: "/pages/user/user"
  78. })
  79. },
  80. navTo() {
  81. uni.navigateTo({
  82. url: "recharge"
  83. })
  84. },
  85. loadData() {
  86. let obj = this
  87. charge().then(res => {
  88. obj.list = res.data
  89. console.log(res, '2222');
  90. obj.yue = obj.userInfo.electric_fee
  91. console.log(obj.yue);
  92. console.log(obj.userInfo, '2222');
  93. })
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss">
  99. page,
  100. .content {
  101. margin: 0;
  102. padding: 0;
  103. height: 100%;
  104. }
  105. .bg {
  106. width: 750rpx;
  107. height: 357rpx;
  108. image {
  109. height: 100%;
  110. width: 100%;
  111. }
  112. }
  113. .header {
  114. width: 100%;
  115. z-index: 99;
  116. position: absolute;
  117. left: 0;
  118. top: 0;
  119. z-index: 99;
  120. margin: 30rpx auto;
  121. display: flex;
  122. justify-content: center;
  123. .header-left {
  124. position: absolute;
  125. left: 25rpx;
  126. top: 0;
  127. height: 60rpx;
  128. display: flex;
  129. align-items: center;
  130. }
  131. .goback {
  132. z-index: 100;
  133. width: 34rpx;
  134. height: 34rpx;
  135. }
  136. .header-title {
  137. font-size: 36rpx;
  138. font-weight: bold;
  139. color: #FFFFFF;
  140. }
  141. }
  142. .box-title {
  143. position: absolute;
  144. margin-top: -200rpx;
  145. // margin: 0 auto;
  146. display: flex;
  147. margin: -200rpx auto;
  148. left: 72.5rpx;
  149. justify-content: center;
  150. flex-direction: column;
  151. align-items: center;
  152. width: 605rpx;
  153. height: 225rpx;
  154. background: #FFFFFF;
  155. border-radius: 20rpx 20rpx 0 0;
  156. .yue {
  157. font-size: 38rpx;
  158. font-weight: 500;
  159. color: #333333;
  160. line-height: 54rpx;
  161. }
  162. .yuan {
  163. margin-top: 15rpx;
  164. font-size: 38rpx;
  165. font-weight: bold;
  166. color: #FF6600;
  167. line-height: 54rpx;
  168. }
  169. }
  170. .box-content {
  171. margin: 0 25rpx;
  172. .content-title {
  173. margin-top: 100rpx;
  174. justify-content: space-between;
  175. display: flex;
  176. .left {
  177. font-size: 32rpx;
  178. font-weight: 500;
  179. color: #141E47;
  180. }
  181. .right {
  182. font-size: 26rpx;
  183. text-align: center;
  184. line-height: 48rpx;
  185. font-weight: 500;
  186. color: #141E47;
  187. width: 138rpx;
  188. height: 48rpx;
  189. background: #F7F6FB;
  190. border: 2rpx solid #141E47;
  191. border-radius: 10rpx;
  192. }
  193. }
  194. }
  195. .box {}
  196. .content-content {
  197. padding: 0 20rpx;
  198. display: flex;
  199. justify-content: space-between;
  200. border-bottom: 1rpx solid #E1E1E1;
  201. line-height: 100rpx;
  202. .money {}
  203. .time {}
  204. }
  205. </style>