index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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>
  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" ref="tabbarMain" :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.$refs.tabbarMain){
  156. this.$refs.tabbarMain.setcount(2);
  157. }
  158. if(this.isReady){
  159. this.init()
  160. }
  161. },
  162. components: {
  163. Tabbar
  164. },
  165. }
  166. </script>
  167. <style lang="scss" scoped>
  168. .user-cell-item{
  169. padding: 13px 15px;
  170. position: relative;
  171. border-bottom: 1px solid #f7f7f7;
  172. display: flex;
  173. justify-content: space-between;
  174. align-items: center;
  175. .user-cell-value{
  176. flex: 1;
  177. text-align: right;
  178. padding-right: 25px;
  179. color:#999;
  180. }
  181. &:after{
  182. content:'\e77c';
  183. font-family: "custom-icon" !important;
  184. font-size: 16px;
  185. position: absolute;
  186. right: 15px;
  187. top: 15px;
  188. color:#999;
  189. }
  190. .user-cell-title{
  191. span{
  192. margin-left: 5px;
  193. }
  194. }
  195. }
  196. .userHead{
  197. .userHead-top{
  198. background-color: #1677ff;
  199. height: 120px;
  200. position: relative;
  201. padding: 0 30px;
  202. .userHead-data{
  203. color:#fff;
  204. text-align: center;
  205. position: absolute;
  206. top: 35px;
  207. left: 30px;
  208. p{
  209. margin-bottom: 5px;
  210. }
  211. h2{
  212. font-weight: normal;
  213. }
  214. }
  215. .userHead-img{
  216. position: absolute;
  217. left: 50%;
  218. margin-left: -36px;
  219. top:24px ;
  220. .userHead-head{
  221. border:4px solid #5ca0ff;
  222. }
  223. }
  224. .userHead-btn{
  225. position: absolute;
  226. top: 46px;
  227. right: 20px;
  228. width: 80px;
  229. height: 28px;
  230. border-radius: 14px;
  231. display: flex;
  232. align-items: center;
  233. justify-content: center;
  234. background-color: #FFFFFF;
  235. span{
  236. margin-left: 5px;
  237. color:#1677ff;
  238. }
  239. }
  240. }
  241. .userHead-bot{
  242. background-color: #125fcc;
  243. height: 60px;
  244. display: flex;
  245. justify-content: space-around;
  246. align-items: center;
  247. .userHead-bot-item{
  248. text-align: center;
  249. color:#fff;
  250. h2{
  251. font-weight: normal;
  252. }
  253. }
  254. }
  255. }
  256. </style>