index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view>
  3. <top-box :userinfo="userinfo" :days="days" key="2"></top-box>
  4. <view class="ucenter">
  5. <view class="mydata">我的数据(累计)</view>
  6. <view class="data-box">
  7. <view class="datashow">
  8. <view class="icon"><image src="../../static/ucenter/icon3.png"></image></view>
  9. <view class="num">{{ucenter.exchangeCnt || '-'}}</view>
  10. <view>换电次数<text>/次</text></view>
  11. </view>
  12. <view class="datashow">
  13. <view class="icon"><image src="../../static/ucenter/icon4.png"></image></view>
  14. <view class="num">{{(ucenter.exchangePower*1).toFixed(1) || '-'}}</view>
  15. <view class="unit">换电量<text>/(kW/h)</text></view>
  16. </view>
  17. <view class="datashow">
  18. <view class="icon"><image src="../../static/ucenter/icon5.png"></image></view>
  19. <view class="num">{{(ucenter.powerFee*1).toFixed(1) || '-'}}</view>
  20. <view class="unit">预估费用<text>/元</text></view>
  21. </view>
  22. </view>
  23. <view class="common">
  24. <view class="title">常用功能</view>
  25. <view class="list" @click="getqrcode">
  26. <view><image src="../../static/ucenter/icon6.png"></image></view>
  27. <view>下载换电二维码</view>
  28. <view>></view>
  29. </view>
  30. <view class="list" @click="toCar">
  31. <view><image src="../../static/ucenter/icon7.png"></image></view>
  32. <view>我的车辆</view>
  33. <view>></view>
  34. </view>
  35. <view class="list" @click="toRecord">
  36. <view><image src="../../static/ucenter/icon8.png"></image></view>
  37. <view>换电记录</view>
  38. <view>></view>
  39. </view>
  40. <view class="list" @click="contact">
  41. <view><image src="../../static/ucenter/icon9.png"></image></view>
  42. <view>联系客服</view>
  43. <view>></view>
  44. </view>
  45. </view>
  46. </view>
  47. <uni-popup ref="popup" background-color="#fff" type="bottom">
  48. <view class="popuplist">
  49. <view><image src="../../static/code.jpg"></image></view>
  50. <view><text>车牌:</text> 渝AUU998</view>
  51. <view><text>车辆识别码:</text> LSPR********8273</view>
  52. <view>保存至相册</view>
  53. </view>
  54. </uni-popup>
  55. <tab-bar></tab-bar>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. qrcode:'../../static/code.jpg',
  63. token:this.$store.state.users.token,
  64. userinfo:this.$store.state.users,
  65. serviceTel:null,//客服电话
  66. ucenter:{},
  67. days:0,
  68. }
  69. },
  70. onShow() {
  71. // this.$store.dispatch("usersStatus").then(()=>{
  72. // //微信用户第二次登录
  73. // this.isAuthShow = false;
  74. // this.token=this.$store.state.users.token
  75. // this.userinfo=this.$store.state.users
  76. // }).catch(()=>{
  77. // //微信用户首次登录
  78. // this.isAuthShow = true;
  79. // });
  80. },
  81. mounted() {
  82. this.getServiceTel()
  83. this.getUcenterData()
  84. this.getUserDays()
  85. },
  86. methods: {
  87. //获取加入天数
  88. getUserDays(){
  89. this.$http.getDays().then(res=>{
  90. if(res.code === 0){
  91. this.days=res.data
  92. }else{
  93. this.$utils.msg(res.msg);
  94. }
  95. })
  96. },
  97. getUcenterData(){
  98. this.$http.ucenterData().then(rs=>{
  99. console.log(rs)
  100. if(rs.code === 0){
  101. this.ucenter=rs.data
  102. }else{
  103. this.$utils.msg(rs.msg);
  104. }
  105. }).catch(error=>{
  106. this.$utils.msg(error);
  107. });
  108. },
  109. //获取客服电话
  110. getServiceTel(){
  111. this.$http.getService().then(rs=>{
  112. if(rs.code === 0){
  113. this.serviceTel=rs.data
  114. }else{
  115. this.$utils.msg(rs.msg);
  116. }
  117. }).catch(error=>{
  118. this.$utils.msg(error);
  119. });
  120. },
  121. //更新头部信息
  122. updatetopinfo(data){
  123. if(this.$storage.getJson("token") && this.$store.state.users){
  124. this.token=data.token
  125. this.userinfo=data
  126. }
  127. },
  128. //联系电话
  129. contact(){
  130. let that=this;
  131. uni.showActionSheet({
  132. itemList: [`呼叫:${that.serviceTel}`],
  133. success: function (res) {
  134. if(!res.tapIndex){
  135. uni.makePhoneCall({
  136. phoneNumber:that.serviceTel,
  137. })
  138. }
  139. },
  140. });
  141. },
  142. //保存二维码到相册
  143. getqrcode(){
  144. this.$refs.popup.open('bottom')
  145. },
  146. toCar(){
  147. uni.navigateTo({
  148. url:'../ucenter/car'
  149. })
  150. },
  151. toRecord(){
  152. uni.navigateTo({
  153. url:'../ucenter/record'
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang="scss" scoped>
  160. .popuplist{
  161. display: flex;
  162. flex-direction: column;
  163. text-align: center;
  164. image{
  165. width: 347rpx;
  166. height: 347rpx;
  167. margin-top: 20rpx;
  168. }
  169. text{
  170. color: #888e9c;
  171. }
  172. view{
  173. margin-top: 15rpx;
  174. }
  175. view:last-child{
  176. padding: 25rpx 0;
  177. border-top: 10rpx solid rgba(149, 150, 151, 0.5);
  178. }
  179. }
  180. .ucenter{
  181. padding: 0 30rpx;
  182. .mydata{
  183. color: #1d2129;
  184. font-size: 32rpx;
  185. font-weight: bold;
  186. margin: 40rpx 0;
  187. text-indent:10rpx;
  188. }
  189. .data-box{
  190. display: flex;
  191. justify-content: space-between;
  192. background-color: #fff;
  193. padding: 25rpx;
  194. box-sizing: border-box;
  195. border-radius: 30rpx;
  196. .icon{
  197. height: 100rpx;
  198. }
  199. .num{
  200. color: #1d2129;
  201. font-weight: bold;
  202. font-size: 32rpx;
  203. height: 50rpx;
  204. }
  205. .unit{
  206. color: #666666;
  207. font-size: 30rpx;
  208. }
  209. image{
  210. width: 80rpx;
  211. height: 80rpx;
  212. }
  213. text{
  214. color: #86909c;
  215. font-size: 28rpx;
  216. }
  217. }
  218. .common{
  219. display: flex;
  220. margin-top: 20rpx;
  221. background-color: #fff;
  222. padding: 25rpx 35rpx;
  223. box-sizing: border-box;
  224. border-radius: 30rpx;
  225. flex-direction: column;
  226. height: 518rpx;
  227. justify-content:space-between;
  228. .title{
  229. color: #1d2129;
  230. font-size: 32rpx;
  231. font-weight: bold;
  232. }
  233. .list{
  234. display: flex;
  235. image{
  236. width: 36rpx;
  237. height: 36rpx;
  238. }
  239. view:first-child{
  240. width: 56rpx;
  241. padding-top: 5rpx;
  242. }
  243. view:nth-child(2){
  244. color: #1d2129;
  245. font-size: 30rpx;
  246. font-weight: 500;
  247. width: 558rpx;
  248. }
  249. view:last-child{
  250. color: #959ea8;
  251. font-weight: bold;
  252. font-size: 32rpx;
  253. }
  254. }
  255. }
  256. }
  257. </style>