index.vue 6.0 KB

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