index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view>
  3. <u-navbar title="个人中心" :is-back="false" :background="background" title-color="#fff" :border-bottom="false"></u-navbar>
  4. <view class="userHead">
  5. <view class="userHead-top">
  6. <view class="userHead-data">
  7. <p>余额(元)</p>
  8. <h2>{{detail.balance}}</h2>
  9. </view>
  10. <view class="userHead-img">
  11. <u-avatar class="userHead-head" :src="src" size="144"></u-avatar>
  12. </view>
  13. <view class="userHead-btn"
  14. @click="gotoUrl('pages/user/recharge')" >
  15. <u-icon name="jiagebaohu" custom-prefix="custom-icon" color="#1677ff" size="32"></u-icon>
  16. <span>充值</span>
  17. </view>
  18. </view>
  19. <view class="userHead-bot">
  20. <view class="userHead-bot-item">
  21. <p>充电度数</p>
  22. <h2>{{detail.electricQuantity}}</h2>
  23. </view>
  24. <view class="userHead-bot-item">
  25. <p>充电次数</p>
  26. <h2>{{detail.chargingTimes}}</h2>
  27. </view>
  28. </view>
  29. <view class="user-cell">
  30. <view
  31. @click="gotoUrl('pages/user/rechargeList')"
  32. class="user-cell-item">
  33. <view class="user-cell-title">
  34. <u-icon name="jiagebaohu" custom-prefix="custom-icon" color="#1677ff" size="32"></u-icon>
  35. <span>充值记录</span>
  36. </view>
  37. <view class="user-cell-value"></view>
  38. </view>
  39. <view
  40. @click="gotoUrl('pages/charge/chargeList')"
  41. class="user-cell-item">
  42. <view class="user-cell-title">
  43. <u-icon name="shoujichongdian" custom-prefix="custom-icon" color="#1677ff" size="32"></u-icon>
  44. <span>充电记录</span>
  45. </view>
  46. <view class="user-cell-value"></view>
  47. </view>
  48. <view class="user-cell-item" @click="phone()">
  49. <view class="user-cell-title">
  50. <u-icon name="kefu" custom-prefix="custom-icon" color="#1677ff" size="32"></u-icon>
  51. <span>我的客服</span>
  52. </view>
  53. <view class="user-cell-value">{{tel}}</view>
  54. </view>
  55. <view class="user-cell-item" @click="logout">
  56. <view class="user-cell-title">
  57. <u-icon name="tuichu" custom-prefix="custom-icon" color="#1677ff" size="32"></u-icon>
  58. <span>退出账户</span>
  59. </view>
  60. <view class="user-cell-value"></view>
  61. </view>
  62. </view>
  63. </view>
  64. <Tabbar :current="2" ></Tabbar>
  65. </view>
  66. </template>
  67. <script>
  68. import Tabbar from '@/components/Tabbar.vue'
  69. import * as API from '@/apis/index.js'
  70. export default {
  71. data() {
  72. return {
  73. src:'',
  74. isReady:false,
  75. tel:'400-8899-619',
  76. detail:{},
  77. background: {
  78. backgroundColor: '#1677ff',
  79. },
  80. }
  81. },onLoad(op){
  82. this.init();
  83. },
  84. methods: {
  85. init(){
  86. uni.showLoading({
  87. title: "加载中",
  88. mask: true,
  89. })
  90. API.personalCenter().then((res) => {
  91. this.detail = res.data
  92. this.src= res.data.regUser.headImg
  93. this.isReady=true;
  94. uni.hideLoading()
  95. }).catch(error => {
  96. uni.showToast({
  97. title: error
  98. })
  99. })
  100. },
  101. logoutApi(){
  102. uni.showLoading({
  103. title: "加载中",
  104. mask: true,
  105. })
  106. var data = {
  107. };
  108. API.logout(data).then((res) => {
  109. this.carhelp.setToken("");
  110. this.carhelp.set("token_tdate","")
  111. this.carhelp.setPersonInfo("");
  112. uni.reLaunch({
  113. url:"/pages/login/index?phone="+this.detail.regUser.phone
  114. })
  115. }).catch(error => {
  116. uni.showToast({
  117. title: error
  118. })
  119. })
  120. },
  121. logout(){
  122. uni.showModal({
  123. title: '提示',
  124. content: '确认是否退出?',
  125. success: res=> {
  126. if (res.confirm) {
  127. //付钱 改为组件
  128. this.logoutApi();
  129. } else if (res.cancel) {
  130. console.log('用户点击取消');
  131. }
  132. }
  133. });
  134. },
  135. phone(){
  136. uni.makePhoneCall({
  137. phoneNumber:this.tel //仅为示例
  138. });
  139. }
  140. },onShow() {
  141. if(this.isReady){
  142. this.init()
  143. }
  144. },
  145. components: {
  146. Tabbar
  147. },
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .user-cell-item{
  152. padding: 13px 15px;
  153. position: relative;
  154. border-bottom: 1px solid #f7f7f7;
  155. display: flex;
  156. justify-content: space-between;
  157. align-items: center;
  158. .user-cell-value{
  159. flex: 1;
  160. text-align: right;
  161. padding-right: 25px;
  162. color:#999;
  163. }
  164. &:after{
  165. content:'\e77c';
  166. font-family: "custom-icon" !important;
  167. font-size: 16px;
  168. position: absolute;
  169. right: 15px;
  170. top: 15px;
  171. color:#999;
  172. }
  173. .user-cell-title{
  174. span{
  175. margin-left: 5px;
  176. }
  177. }
  178. }
  179. .userHead{
  180. .userHead-top{
  181. background-color: #1677ff;
  182. height: 120px;
  183. position: relative;
  184. padding: 0 30px;
  185. .userHead-data{
  186. color:#fff;
  187. text-align: center;
  188. position: absolute;
  189. top: 35px;
  190. left: 30px;
  191. p{
  192. margin-bottom: 5px;
  193. }
  194. h2{
  195. font-weight: normal;
  196. }
  197. }
  198. .userHead-img{
  199. position: absolute;
  200. left: 50%;
  201. margin-left: -36px;
  202. top:24px ;
  203. .userHead-head{
  204. border:4px solid #5ca0ff;
  205. }
  206. }
  207. .userHead-btn{
  208. position: absolute;
  209. top: 46px;
  210. right: 20px;
  211. width: 80px;
  212. height: 28px;
  213. border-radius: 14px;
  214. display: flex;
  215. align-items: center;
  216. justify-content: center;
  217. background-color: #FFFFFF;
  218. span{
  219. margin-left: 5px;
  220. color:#1677ff;
  221. }
  222. }
  223. }
  224. .userHead-bot{
  225. background-color: #125fcc;
  226. height: 60px;
  227. display: flex;
  228. justify-content: space-around;
  229. align-items: center;
  230. .userHead-bot-item{
  231. text-align: center;
  232. color:#fff;
  233. h2{
  234. font-weight: normal;
  235. }
  236. }
  237. }
  238. }
  239. </style>