index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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="gotorechargeDeatils"
  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" :id="id" ></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. id:"",
  74. src:'',
  75. isReady:false,
  76. tel:'400-8899-619',
  77. detail:{},
  78. background: {
  79. backgroundColor: '#1677ff',
  80. },
  81. }
  82. },onLoad(op){
  83. if (op.id) {
  84. this.id = op.id;
  85. this.carhelp.set("qr-default-id",op.id);
  86. }else{
  87. //用于支付后返回系统 -- 点金计划
  88. this.id =this.carhelp.get("qr-default-id");
  89. }
  90. this.init();
  91. },
  92. methods: {
  93. gotorechargeDeatils( ){
  94. uni.navigateTo({
  95. url:'/pages/user/rechargeList'
  96. })
  97. },
  98. init(){
  99. uni.showLoading({
  100. title: "加载中",
  101. mask: true,
  102. })
  103. API.personalCenter().then((res) => {
  104. this.detail = res.data
  105. this.src= res.data.regUser.headImg
  106. this.isReady=true;
  107. uni.hideLoading()
  108. }).catch(error => {
  109. uni.showToast({
  110. title: error
  111. })
  112. })
  113. },
  114. logoutApi(){
  115. uni.showLoading({
  116. title: "加载中",
  117. mask: true,
  118. })
  119. var data = {
  120. };
  121. API.logout(data).then((res) => {
  122. this.carhelp.setToken("");
  123. this.carhelp.set("token_tdate","")
  124. this.carhelp.setPersonInfo("");
  125. this.carhelp.setPersonInfoPlus("" )
  126. uni.reLaunch({
  127. url:"/pages/login/index?phone="+this.detail.regUser.phone
  128. })
  129. }).catch(error => {
  130. uni.showToast({
  131. title: error
  132. })
  133. })
  134. },
  135. logout(){
  136. uni.showModal({
  137. title: '提示',
  138. content: '确认是否退出?',
  139. success: res=> {
  140. if (res.confirm) {
  141. //付钱 改为组件
  142. this.logoutApi();
  143. } else if (res.cancel) {
  144. console.log('用户点击取消');
  145. }
  146. }
  147. });
  148. },
  149. phone(){
  150. uni.makePhoneCall({
  151. phoneNumber:this.tel //仅为示例
  152. });
  153. }
  154. },onShow() {
  155. if(this.isReady){
  156. this.init()
  157. }
  158. },
  159. components: {
  160. Tabbar
  161. },
  162. }
  163. </script>
  164. <style lang="scss" scoped>
  165. .user-cell-item{
  166. padding: 13px 15px;
  167. position: relative;
  168. border-bottom: 1px solid #f7f7f7;
  169. display: flex;
  170. justify-content: space-between;
  171. align-items: center;
  172. .user-cell-value{
  173. flex: 1;
  174. text-align: right;
  175. padding-right: 25px;
  176. color:#999;
  177. }
  178. &:after{
  179. content:'\e77c';
  180. font-family: "custom-icon" !important;
  181. font-size: 16px;
  182. position: absolute;
  183. right: 15px;
  184. top: 15px;
  185. color:#999;
  186. }
  187. .user-cell-title{
  188. span{
  189. margin-left: 5px;
  190. }
  191. }
  192. }
  193. .userHead{
  194. .userHead-top{
  195. background-color: #1677ff;
  196. height: 120px;
  197. position: relative;
  198. padding: 0 30px;
  199. .userHead-data{
  200. color:#fff;
  201. text-align: center;
  202. position: absolute;
  203. top: 35px;
  204. left: 30px;
  205. p{
  206. margin-bottom: 5px;
  207. }
  208. h2{
  209. font-weight: normal;
  210. }
  211. }
  212. .userHead-img{
  213. position: absolute;
  214. left: 50%;
  215. margin-left: -36px;
  216. top:24px ;
  217. .userHead-head{
  218. border:4px solid #5ca0ff;
  219. }
  220. }
  221. .userHead-btn{
  222. position: absolute;
  223. top: 46px;
  224. right: 20px;
  225. width: 80px;
  226. height: 28px;
  227. border-radius: 14px;
  228. display: flex;
  229. align-items: center;
  230. justify-content: center;
  231. background-color: #FFFFFF;
  232. span{
  233. margin-left: 5px;
  234. color:#1677ff;
  235. }
  236. }
  237. }
  238. .userHead-bot{
  239. background-color: #125fcc;
  240. height: 60px;
  241. display: flex;
  242. justify-content: space-around;
  243. align-items: center;
  244. .userHead-bot-item{
  245. text-align: center;
  246. color:#fff;
  247. h2{
  248. font-weight: normal;
  249. }
  250. }
  251. }
  252. }
  253. </style>