index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <template>
  2. <view>
  3. <view class="userHead" @click="toData">
  4. <view class="userHead-img">
  5. <u-avatar :src="userId ? headImg : '../../assets/img/head.png'" size="96"></u-avatar>
  6. </view>
  7. <view class="userHead-text oldTextjp2" >
  8. <h3>{{userId ? userPhone : '点击登录/注册'}}</h3>
  9. </view>
  10. </view>
  11. <view class="userData">
  12. <view class="userData-num" @click="toBalance">
  13. <view class="userData-data">¥{{personAccount.availableAmount != null ? personAccount.availableAmount.toFixed(2) : '0.00'}}</view>
  14. <view class="userData-foot">可用余额</view>
  15. </view>
  16. <view class="line">
  17. </view>
  18. <view class="userData-num" @click="toMyCoupon">
  19. <view class="userData-data">{{myCouponList.length}}</view>
  20. <view class="userData-foot">优惠券</view>
  21. </view>
  22. </view>
  23. <view class="userBanner">
  24. <u-image width="100%" height="80px" src="../../static/img/banner.jpg" border-radius="16"></u-image>
  25. </view>
  26. <view class="userIcon">
  27. <view class="userIcon-tit">
  28. <h3>常用功能</h3>
  29. </view>
  30. <view class="userIcon-main">
  31. <view class="userIcon-item" @click="getScanCode">
  32. <view class="userIcon-icon userIcon-icon1">
  33. <u-icon name="qr-scan-2-line" custom-prefix="custom-icon" color="#fff" size="36"></u-icon>
  34. </view>
  35. <p>扫码充电</p>
  36. </view>
  37. <view class="userIcon-item" @click="fastRecharge">
  38. <view class="userIcon-icon userIcon-icon2">
  39. <u-icon name="wallet-3-line" custom-prefix="custom-icon" color="#fff" size="36"></u-icon>
  40. </view>
  41. <p>快速充值</p>
  42. </view>
  43. <view class="userIcon-item" @click="chargingRecord">
  44. <view class="userIcon-icon userIcon-icon3">
  45. <u-icon name="todo-line" custom-prefix="custom-icon" color="#fff" size="36"></u-icon>
  46. </view>
  47. <p>充电记录</p>
  48. </view>
  49. <view class="userIcon-item" @click="toSearchPile">
  50. <view class="userIcon-icon userIcon-icon4">
  51. <u-icon name="road-map-line" custom-prefix="custom-icon" color="#fff" size="36"></u-icon>
  52. </view>
  53. <p>附近站点</p>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="userCell">
  58. <view class="userCell-item" @click="carManage">
  59. <view class="userCell-title">
  60. <u-icon name="menu_cwcl" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  61. <p>车辆管理</p>
  62. </view>
  63. <view class="">
  64. <text class="add">添加车牌号</text>
  65. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  66. </view>
  67. </view>
  68. <view class="userCell-item" @click="gotoUrl('pages/user/help')">
  69. <view class="userCell-title">
  70. <u-icon name="compass-3-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  71. <p>操作指南</p>
  72. </view>
  73. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  74. </view>
  75. <view class="userCell-item" @click="feedback">
  76. <view class="userCell-title">
  77. <u-icon name="feedback-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  78. <p>意见反馈</p>
  79. </view>
  80. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  81. </view>
  82. <view class="userCell-item" @click="gotoUrl('pages/user/about')">
  83. <view class="userCell-title">
  84. <u-icon name="information-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  85. <p>关于我们</p>
  86. </view>
  87. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  88. </view>
  89. <view class="userCell-item" @click="openModal">
  90. <view class="userCell-title">
  91. <u-icon name="customer-service-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  92. <p>联系客服</p>
  93. </view>
  94. <span>{{content}}</span>
  95. </view>
  96. <view>
  97. <u-modal v-model="show" @confirm="confirmPhone" :confirm-text="confirmText" confirm-color="#606266" :show-cancel-button="true" ref="uModal"
  98. :asyncClose="true" :title="title" :content="content"></u-modal>
  99. </view>
  100. <view class="userCell-item" @click="setUp">
  101. <view class="userCell-title">
  102. <u-icon name="settings-4-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  103. <p>设置</p>
  104. </view>
  105. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  106. </view>
  107. </view>
  108. <Tabbar :current="2"></Tabbar>
  109. </view>
  110. </template>
  111. <script>
  112. import * as API from '@/apis/index.js'
  113. import * as userApi from '@/apis/user.js'
  114. import * as loginApi from '@/apis/login.js'
  115. import * as WxJsApi from '@/utils/wxJsApi.js'
  116. import Tabbar from '@/components/Tabbar.vue'
  117. export default {
  118. components: {
  119. Tabbar
  120. },
  121. data() {
  122. return {
  123. myCouponList: [],
  124. elderStatus: false,
  125. personAccount: {},
  126. userId: '',
  127. headImg: '',
  128. userPhone: '',
  129. show: false,
  130. title: '联系客服',
  131. content: '400-8899-619',
  132. confirmText: '拨打电话',
  133. background:{
  134. background: 'none'
  135. },
  136. }
  137. },
  138. onShow() {
  139. if(this.carhelp.getPersonInfo()) {
  140. this.userId = this.carhelp.getPersonInfo().id;
  141. this.getCarPersonAccount();
  142. this.getUserInfo();
  143. this.getCouponList();
  144. }
  145. this.elderStatus=this.carhelp.get("getElderModeClass");
  146. },
  147. onReady() {
  148. WxJsApi.getWxConfig(['getLocation', 'addEventListener', 'scanQRCode']).then((res) => {
  149. // console.log(res)
  150. }).catch(error => {
  151. console.log(res)
  152. })
  153. var consumerPhone=this.carhelp.getConfig().consumerPhone
  154. // img="https://yktwechat.xiaoxinda.com/config/xxd2021.jpg"
  155. if(consumerPhone){
  156. this.content=consumerPhone
  157. }
  158. },
  159. methods: {
  160. getCouponList() {
  161. uni.showLoading({
  162. title: "加载中",
  163. mask: true,
  164. })
  165. userApi.couponList({
  166. status: '0'
  167. }).then((res) => {
  168. uni.hideLoading();
  169. this.myCouponList = res.data.data;
  170. }).catch(error => {
  171. uni.showToast({
  172. title: error,
  173. icon: "none"
  174. })
  175. })
  176. },
  177. //微信扫二维码
  178. getScanCode() {
  179. if (this.userId) {
  180. WxJsApi.scanQRCode(1).then(res => {
  181. if(res) {
  182. API.scanCode(res).then((response) => {
  183. }).catch(error => {
  184. uni.showToast({
  185. title: error,
  186. icon: "none"
  187. })
  188. })
  189. }
  190. }).catch(error => {
  191. })
  192. } else {
  193. uni.navigateTo({
  194. url: '/pages/login/login'
  195. })
  196. }
  197. },
  198. fastRecharge() {
  199. if (this.userId) {
  200. uni.navigateTo({
  201. url: '/pages/user/finance/recharge'
  202. })
  203. } else {
  204. uni.navigateTo({
  205. url: '/pages/login/login'
  206. })
  207. }
  208. },
  209. chargingRecord() {
  210. if (this.userId) {
  211. uni.navigateTo({
  212. url: '/pages/record/index'
  213. })
  214. } else {
  215. uni.navigateTo({
  216. url: '/pages/login/login'
  217. })
  218. }
  219. },
  220. toSearchPile() {
  221. uni.navigateTo({
  222. url: '/pages/searchPile/searchPile'
  223. })
  224. },
  225. getUserInfo() {
  226. uni.showLoading({
  227. title: "加载中",
  228. mask: true,
  229. })
  230. loginApi.findByOpenId({
  231. openId: this.carhelp.getOpenId()
  232. }).then((res) => {
  233. uni.hideLoading();
  234. this.headImg = res.data.regUser.headImg;
  235. var phone = res.data.regUser.phone;
  236. var phone1 = phone.slice(0,3);
  237. var phone2 = phone.slice(-4);
  238. this.userPhone = phone1 + '****' + phone2;
  239. }).catch(error => {
  240. uni.showToast({
  241. title: error,
  242. icon: "none"
  243. })
  244. })
  245. },
  246. toData() {
  247. if(this.userId) {
  248. uni.navigateTo({
  249. url: '/pages/user/data'
  250. })
  251. } else {
  252. uni.navigateTo({
  253. url: '/pages/login/login'
  254. })
  255. }
  256. },
  257. toBalance() {
  258. if(this.userId) {
  259. uni.navigateTo({
  260. url: '/pages/user/finance/balance'
  261. })
  262. } else {
  263. uni.navigateTo({
  264. url: '/pages/login/login'
  265. })
  266. }
  267. },
  268. toMyCoupon() {
  269. if(this.userId) {
  270. uni.navigateTo({
  271. url: '/pages/user/coupon/myCoupon'
  272. })
  273. } else {
  274. uni.navigateTo({
  275. url: '/pages/login/login'
  276. })
  277. }
  278. },
  279. toRecharge() {
  280. if(this.userId) {
  281. uni.navigateTo({
  282. url: '/pages/user/finance/recharge'
  283. })
  284. } else {
  285. uni.navigateTo({
  286. url: '/pages/login/login'
  287. })
  288. }
  289. },
  290. carManage() {
  291. if(this.userId) {
  292. uni.navigateTo({
  293. url: '/pages/user/car/index'
  294. })
  295. } else {
  296. uni.navigateTo({
  297. url: '/pages/login/login'
  298. })
  299. }
  300. },
  301. feedback() {
  302. if(this.userId) {
  303. uni.navigateTo({
  304. url: '/pages/user/message'
  305. })
  306. } else {
  307. uni.navigateTo({
  308. url: '/pages/login/login'
  309. })
  310. }
  311. },
  312. setUp() {
  313. if(this.userId) {
  314. uni.navigateTo({
  315. url: '/pages/user/setting'
  316. })
  317. } else {
  318. uni.navigateTo({
  319. url: '/pages/login/login'
  320. })
  321. }
  322. },
  323. openModal() {
  324. this.show = true;
  325. },
  326. confirmPhone(){
  327. this.show = false;
  328. uni.makePhoneCall({
  329. phoneNumber:this.content //仅为示例
  330. });
  331. },
  332. getCarPersonAccount() {
  333. uni.showLoading({
  334. title: "加载中",
  335. mask: true,
  336. })
  337. userApi.carPersonAccount().then((res) => {
  338. uni.hideLoading();
  339. this.personAccount = res.data;
  340. }).catch(error => {
  341. uni.showToast({
  342. title: error,
  343. icon: "none"
  344. })
  345. })
  346. }
  347. }
  348. }
  349. </script>
  350. <style>
  351. page{
  352. background:url(../../assets/img/index_header_bg.png) no-repeat top center #f7f7f7;
  353. background-size: 100%;
  354. }
  355. </style>
  356. <style lang="scss" scoped>
  357. .userBanner{
  358. margin: 16px;
  359. }
  360. .userIcon{
  361. background-color: #fff;
  362. margin: 16px;
  363. border-radius: 8px;
  364. padding: 16px;
  365. }
  366. .userIcon-item{
  367. display: flex;
  368. flex-direction: column;
  369. align-items: center;
  370. }
  371. .userIcon-main{
  372. margin-top: 16px;
  373. display: flex;
  374. justify-content: space-between;
  375. }
  376. .userIcon-icon{
  377. display: flex;
  378. flex-direction: column;
  379. align-items: center;
  380. justify-content: center;
  381. height: 40px;
  382. width: 40px;
  383. border-radius: 50%;
  384. margin-bottom: 6px;
  385. }
  386. .userIcon-icon1{background-color: #59D96E;}
  387. .userIcon-icon2{background-color: #4BD2C0;}
  388. .userIcon-icon3{background-color: #6FA5FF;}
  389. .userIcon-icon4{background-color: #9D9FFF;}
  390. .userCell{
  391. background-color: #fff;
  392. border-radius: 8px;
  393. margin: 16px;
  394. .userCell-item{
  395. display: flex;
  396. justify-content: space-between;
  397. align-items: center;
  398. padding: 16px;
  399. .userCell-title{
  400. display: flex;
  401. align-items: center;
  402. p{
  403. margin-left: 8px;
  404. }
  405. }
  406. span{
  407. color:#999;
  408. }
  409. }
  410. }
  411. .userHead{
  412. display: flex;
  413. align-items: center;
  414. align-items: center;
  415. padding:40px 20px 0;
  416. .userHead-img{
  417. }
  418. .userHead-text{
  419. margin-left: 12px;
  420. h3{
  421. font-size: 20px;
  422. color:#fff;
  423. font-weight: normal;
  424. }
  425. }
  426. }
  427. .userData{
  428. background-color: #fff;
  429. margin: 16px;
  430. padding: 16px ;
  431. border-radius: 8px;
  432. display: flex;
  433. align-items: center;
  434. justify-content: space-around;
  435. }
  436. .userData-num{
  437. width: 50%;
  438. display: flex;
  439. flex-direction: column;
  440. align-items: center;
  441. justify-content:space-between;
  442. padding-right: 5px;
  443. .userData-data{
  444. font-size: 24px;
  445. font-weight: 600;
  446. }
  447. .userData-name{
  448. font-size: 16px;
  449. }
  450. .userData-foot{
  451. margin-top: 4px;
  452. color:#999;
  453. font-size: 12px;
  454. }
  455. }
  456. .userInfo-btn{
  457. padding: 6px 30px;
  458. // background-color: #00B962;
  459. // color:#fff;
  460. // border-radius: 15px;
  461. }
  462. .line{
  463. width: 0px;
  464. height: 36px;
  465. border: 1px solid rgba(237, 237, 237, 100);
  466. }
  467. </style>