index.vue 5.7 KB

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