index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  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">
  8. <h3 :style="elderStatus ? 'font-size: 28px;' : ''">{{userId ? userPhone : '点击登录/注册'}}</h3>
  9. </view>
  10. </view>
  11. <view class="userData">
  12. <view class="userData-num" @click="toBalance">
  13. <view class="userData-data oldTextjp" oldstyle="font-size: 28px;">{{personAccount.availableAmount != null ? personAccount.availableAmount.toFixed(2) : '0.00'}}元</view>
  14. <view class="userData-foot" :style="elderStatus ? 'font-size: 16px;' : ''">可用余额{{" "}}<span class="userData-foot-look">查看</span></view>
  15. </view>
  16. <view class="line">
  17. </view>
  18. <view class="userData-num" @click="toMyCoupon">
  19. <view class="userData-data oldTextjp" oldstyle="font-size: 28px;">{{recordsTotal}}张</view>
  20. <view class="userData-foot" :style="elderStatus ? 'font-size: 16px;' : ''">优惠券{{" "}}<span class="userData-foot-look">查看</span></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. --> <u-swiper bg-color="#fff"
  26. :img-mode="'scaleToFill'" height="160"
  27. :list="bannerList" @click="clickBanner" :name="'picUrl'" >
  28. </u-swiper>
  29. </view>
  30. <view class="userIcon">
  31. <view class="userIcon-tit" :style="elderStatus ? 'font-size: 20px;' : ''">
  32. <h3>我的服务</h3>
  33. </view>
  34. <!-- <view class="userIcon-main">
  35. <view class="userIcon-item" @click="getScanCode">
  36. <view class="userIcon-icon userIcon-icon1">
  37. <u-icon name="qr-scan-2-line" custom-prefix="custom-icon" " size="36"></u-icon>
  38. </view>
  39. <p :style="elderStatus ? 'font-size: 18px;' : ''">扫码充电</p>
  40. </view>
  41. <view class="userIcon-item" @click="fastRecharge">
  42. <view class="userIcon-icon userIcon-icon2">
  43. <u-icon name="wallet-3-line" custom-prefix="custom-icon" color="#fff" size="36"></u-icon>
  44. </view>
  45. <p :style="elderStatus ? 'font-size: 18px;' : ''">快速充值</p>
  46. </view>
  47. <view class="userIcon-item" @click="chargingRecord">
  48. <view class="userIcon-icon userIcon-icon3">
  49. <u-icon name="todo-line" custom-prefix="custom-icon" color="#fff" size="36"></u-icon>
  50. </view>
  51. <p :style="elderStatus ? 'font-size: 18px;' : ''">充电记录</p>
  52. </view>
  53. <view class="userIcon-item" @click="toSearchPile">
  54. <view class="userIcon-icon userIcon-icon4">
  55. <u-icon name="road-map-line" custom-prefix="custom-icon" color="#fff" size="36"></u-icon>
  56. </view>
  57. <p :style="elderStatus ? 'font-size: 18px;' : ''">附近站点</p>
  58. </view>
  59. </view> -->
  60. <view class="userIcon-main">
  61. <view class="userIcon-item" @click="chargingRecord">
  62. <view class="userIcon-icon">
  63. <img src="../../static/img/riFill-file-list-3-fill@1x.png" alt="">
  64. </view>
  65. <p :style="elderStatus ? 'font-size: 18px;' : ''">充电记录</p>
  66. </view>
  67. <view class="userIcon-item" @click="carManage">
  68. <view class="userIcon-icon">
  69. <img src="../../static/img/riFill-car-fill@1x.png" alt="">
  70. </view>
  71. <p :style="elderStatus ? 'font-size: 18px;' : ''">车辆管理</p>
  72. </view>
  73. <view class="userIcon-item" @click="myAppointment">
  74. <view class="userIcon-icon">
  75. <img src="../../static/img/riFill-map-pin-time-fill.svg" alt="">
  76. </view>
  77. <p :style="elderStatus ? 'font-size: 18px;' : ''">我的预约</p>
  78. </view>
  79. <view class="userIcon-item" @click="toFreeInstallation">
  80. <view class="userIcon-icon">
  81. <img src="../../static/img/riFill-file-add-fill.svg" alt="">
  82. </view>
  83. <p :style="elderStatus ? 'font-size: 18px;' : ''">免费安桩</p>
  84. </view>
  85. <view class="userIcon-item" @click="toJoin">
  86. <view class="userIcon-icon">
  87. <img src="../../static/img/riFill-service-fill.svg" alt="">
  88. </view>
  89. <p :style="elderStatus ? 'font-size: 18px;' : ''">我要加盟</p>
  90. </view>
  91. <view class="userIcon-item lucency" >
  92. <view class="userIcon-icon">
  93. <img src="../../static/img/riFill-tools-fill.svg" alt="">
  94. </view>
  95. <p :style="elderStatus ? 'font-size: 18px;' : ''">我要报修</p>
  96. </view>
  97. <view class="userIcon-item lucency" >
  98. <view class="userIcon-icon">
  99. <img src="../../static/img/riFill-money-cny-box-fill.svg" alt="">
  100. </view>
  101. <p :style="elderStatus ? 'font-size: 18px;' : ''">我的发票</p>
  102. </view>
  103. <view class="userIcon-item lucency" >
  104. <view class="userIcon-icon">
  105. <img src="../../static/img/riFill-shield-user-fill.svg" alt="">
  106. </view>
  107. <p :style="elderStatus ? 'font-size: 18px;' : ''">实名认证</p>
  108. </view>
  109. </view>
  110. </view>
  111. <view class="userCell">
  112. <!-- <view class="userCell-item" @click="carManage">
  113. <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
  114. <u-icon name="menu_cwcl" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  115. <p>车辆管理</p>
  116. </view>
  117. <view>
  118. <text class="add" :style="elderStatus ? 'font-size: 16px;' : ''">添加车牌号</text>
  119. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  120. </view>
  121. </view> -->
  122. <view class="userCell-item" @click="gotoUrl('pages/user/help')">
  123. <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
  124. <u-icon name="compass-3-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  125. <p>操作指南</p>
  126. </view>
  127. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  128. </view>
  129. <view class="userCell-item" @click="feedback">
  130. <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
  131. <u-icon name="feedback-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  132. <p>意见反馈</p>
  133. </view>
  134. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  135. </view>
  136. <view class="userCell-item" @click="gotoUrl('pages/user/about')">
  137. <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
  138. <u-icon name="information-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  139. <p>关于我们</p>
  140. </view>
  141. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  142. </view>
  143. <view class="userCell-item" @click="openModal">
  144. <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
  145. <u-icon name="customer-service-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  146. <p>联系客服</p>
  147. </view>
  148. <span :style="elderStatus ? 'font-size: 16px;' : ''">{{content}}</span>
  149. </view>
  150. <view>
  151. <u-modal v-model="show" @confirm="confirmPhone" :confirm-text="confirmText" confirm-color="#606266" :show-cancel-button="true" ref="uModal"
  152. :asyncClose="true" :title="title" :content="content" :content-style="{fontSize: '24px',color: '#101010'}"></u-modal>
  153. </view>
  154. <view class="userCell-item" @click="setUp">
  155. <view class="userCell-title oldTextjp" oldstyle="font-size: 20px;">
  156. <u-icon name="settings-4-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  157. <p>设置</p>
  158. </view>
  159. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  160. </view>
  161. </view>
  162. <Tabbar :current="2" ref="tabbarMain" :elderStatus="elderStatus"></Tabbar>
  163. </view>
  164. </template>
  165. <script>
  166. import * as API from '@/apis/index.js'
  167. import * as userApi from '@/apis/user.js'
  168. import * as loginApi from '@/apis/login.js'
  169. import * as WxJsApi from '@/utils/wxJsApi.js'
  170. import Tabbar from '@/components/Tabbar.vue'
  171. import * as newsApi from '@/apis/news.js'
  172. export default {
  173. components: {
  174. Tabbar
  175. },
  176. data() {
  177. return {
  178. recordsTotal: 0,
  179. myCouponList: [],
  180. elderStatus: false,
  181. personAccount: {},
  182. userId: '',
  183. headImg: '',
  184. userPhone: '',
  185. show: false,
  186. title: '联系客服',
  187. content: '400-8899-619',
  188. confirmText: '拨打电话',
  189. bannerList:[],
  190. background:{
  191. background: 'none'
  192. },
  193. }
  194. },
  195. onShow() {
  196. if(this.carhelp.getPersonInfo()) {
  197. this.userId = this.carhelp.getPersonInfo().id;
  198. this.getCarPersonAccount();
  199. this.getUserInfo();
  200. this.getCouponList();
  201. }
  202. if(this.$refs.tabbarMain){
  203. this.$refs.tabbarMain.setcount(2);
  204. }
  205. if(this.carhelp.get("getElderModeClass") == "长辈模式") {
  206. this.elderStatus = true;
  207. } else {
  208. this.elderStatus = false;
  209. }
  210. },
  211. onReady() {
  212. WxJsApi.getWxConfig(['getLocation', 'addEventListener', 'scanQRCode']).then((res) => {
  213. // console.log(res)
  214. }).catch(error => {
  215. console.log(error)
  216. })
  217. var consumerPhone=this.carhelp.getConfig().consumerPhone
  218. // img="https://yktwechat.xiaoxinda.com/config/xxd2021.jpg"
  219. if(consumerPhone){
  220. this.content=consumerPhone
  221. }
  222. this.getBannerInfo("userinfo")
  223. },
  224. methods: {
  225. clickBanner(index){
  226. var mod= this.bannerList[index]
  227. if(mod.linkUrl.indexOf('http')==0){
  228. window.location=mod.linkUrl;
  229. }
  230. else if(mod.linkUrl.indexOf('#/')==0){
  231. if(mod.linkUrl.indexOf("?")==-1){
  232. mod.linkUrl+='?';
  233. }
  234. //window.location=mod.linkUrl;
  235. var url=mod.linkUrl.split("#")[1]
  236. //window.location = mod.clickUrl;
  237. uni.navigateTo({
  238. url: url
  239. })
  240. }
  241. else if(mod.linkUrl=='#'||mod.linkUrl==''){
  242. }
  243. else{
  244. uni.navigateTo({
  245. url:mod.linkUrl
  246. })
  247. }
  248. },
  249. getBannerInfo(code){
  250. uni.showLoading({
  251. title: "加载中",
  252. mask: true,
  253. })
  254. newsApi.getBannerInfo(code).then((res) => {
  255. uni.hideLoading();
  256. this.bannerList =res.data;
  257. // document.getElementsByClassName("uni-swiper-wrapper")[0].parentNode.style="background-color: rgb(255, 255, 255); height: 300px;"
  258. }).catch(error => {
  259. uni.showToast({
  260. title: error,icon: "none"
  261. })
  262. })
  263. },
  264. getCouponList() {
  265. uni.showLoading({
  266. title: "加载中",
  267. mask: true,
  268. })
  269. userApi.couponList({
  270. status: '0'
  271. }).then((res) => {
  272. uni.hideLoading();
  273. this.myCouponList = res.data.data;
  274. this.recordsTotal = res.data.recordsTotal;
  275. }).catch(error => {
  276. uni.showToast({
  277. title: error,
  278. icon: "none"
  279. })
  280. })
  281. },
  282. //微信扫二维码
  283. getScanCode() {
  284. if (this.userId) {
  285. WxJsApi.scanQRCode(1).then(res => {
  286. if(res) {
  287. API.scanCode(res).then((response) => {
  288. }).catch(error => {
  289. uni.showToast({
  290. title: error,
  291. icon: "none"
  292. })
  293. })
  294. }
  295. }).catch(error => {
  296. })
  297. } else {
  298. uni.navigateTo({
  299. url: '/pages/login/login'
  300. })
  301. }
  302. },
  303. fastRecharge() {
  304. if (this.userId) {
  305. uni.navigateTo({
  306. url: '/pages/user/finance/recharge'
  307. })
  308. } else {
  309. uni.navigateTo({
  310. url: '/pages/login/login'
  311. })
  312. }
  313. },
  314. chargingRecord() {
  315. if (this.userId) {
  316. uni.navigateTo({
  317. url: '/pages/record/index'
  318. })
  319. } else {
  320. uni.navigateTo({
  321. url: '/pages/login/login'
  322. })
  323. }
  324. },
  325. toSearchPile() {
  326. uni.navigateTo({
  327. url: '/pages/searchPile/searchPile'
  328. })
  329. },
  330. getUserInfo() {
  331. uni.showLoading({
  332. title: "加载中",
  333. mask: true,
  334. })
  335. loginApi.findByOpenId({
  336. openId: this.carhelp.getOpenId()
  337. }).then((res) => {
  338. uni.hideLoading();
  339. this.headImg = res.data.regUser.headImg;
  340. var phone = res.data.regUser.phone;
  341. var phone1 = phone.slice(0,3);
  342. var phone2 = phone.slice(-4);
  343. this.userPhone = phone1 + '****' + phone2;
  344. }).catch(error => {
  345. uni.showToast({
  346. title: error,
  347. icon: "none"
  348. })
  349. })
  350. },
  351. toData() {
  352. if(this.userId) {
  353. uni.navigateTo({
  354. url: '/pages/user/data'
  355. })
  356. } else {
  357. uni.navigateTo({
  358. url: '/pages/login/login'
  359. })
  360. }
  361. },
  362. toBalance() {
  363. if(this.userId) {
  364. uni.navigateTo({
  365. url: '/pages/user/finance/balance'
  366. })
  367. } else {
  368. uni.navigateTo({
  369. url: '/pages/login/login'
  370. })
  371. }
  372. },
  373. toMyCoupon() {
  374. if(this.userId) {
  375. uni.navigateTo({
  376. url: '/pages/user/coupon/myCoupon'
  377. })
  378. } else {
  379. uni.navigateTo({
  380. url: '/pages/login/login'
  381. })
  382. }
  383. },
  384. toRecharge() {
  385. if(this.userId) {
  386. uni.navigateTo({
  387. url: '/pages/user/finance/recharge'
  388. })
  389. } else {
  390. uni.navigateTo({
  391. url: '/pages/login/login'
  392. })
  393. }
  394. },
  395. carManage() {
  396. if(this.userId) {
  397. uni.navigateTo({
  398. url: '/pages/user/car/index'
  399. })
  400. } else {
  401. uni.navigateTo({
  402. url: '/pages/login/login'
  403. })
  404. }
  405. },
  406. myAppointment() {
  407. if(this.userId) {
  408. uni.navigateTo({
  409. url: '/pages/user/myReservation/myReservation'
  410. })
  411. } else {
  412. uni.navigateTo({
  413. url: '/pages/login/login'
  414. })
  415. }
  416. },
  417. toFreeInstallation() {
  418. if(this.userId) {
  419. uni.navigateTo({
  420. url: '/pages/user/freeInstallment'
  421. })
  422. } else {
  423. uni.navigateTo({
  424. url: '/pages/login/login'
  425. })
  426. }
  427. },
  428. toJoin() {
  429. if(this.userId) {
  430. uni.navigateTo({
  431. url: '/pages/user/toJoin'
  432. })
  433. } else {
  434. uni.navigateTo({
  435. url: '/pages/login/login'
  436. })
  437. }
  438. },
  439. feedback() {
  440. if(this.userId) {
  441. uni.navigateTo({
  442. url: '/pages/user/message'
  443. })
  444. } else {
  445. uni.navigateTo({
  446. url: '/pages/login/login'
  447. })
  448. }
  449. },
  450. setUp() {
  451. if(this.userId) {
  452. uni.navigateTo({
  453. url: '/pages/user/setting'
  454. })
  455. } else {
  456. uni.navigateTo({
  457. url: '/pages/login/login'
  458. })
  459. }
  460. },
  461. openModal() {
  462. this.show = true;
  463. },
  464. confirmPhone(){
  465. this.show = false;
  466. uni.makePhoneCall({
  467. phoneNumber:this.content //仅为示例
  468. });
  469. },
  470. getCarPersonAccount() {
  471. uni.showLoading({
  472. title: "加载中",
  473. mask: true,
  474. })
  475. userApi.carPersonAccount().then((res) => {
  476. uni.hideLoading();
  477. this.personAccount = res.data;
  478. }).catch(error => {
  479. uni.showToast({
  480. title: error,
  481. icon: "none"
  482. })
  483. })
  484. }
  485. }
  486. }
  487. </script>
  488. <style>
  489. page{
  490. background:url(../../assets/img/index_header_bg.png) no-repeat top center #f7f7f7;
  491. background-size: 100%;
  492. }
  493. </style>
  494. <style lang="scss" scoped>
  495. .userBanner{
  496. margin: 16px;
  497. }
  498. .userIcon{
  499. background-color: #fff;
  500. margin: 16px;
  501. border-radius: 8px;
  502. padding: 16px;
  503. }
  504. .userIcon-item{
  505. display: flex;
  506. flex-direction: column;
  507. align-items: center;
  508. margin-top: 18px;
  509. width: 25%;
  510. font-size: 14px
  511. }
  512. .lucency{
  513. opacity: 0.5;
  514. }
  515. .userIcon-main{
  516. display: flex;
  517. justify-content: space-between;
  518. flex-wrap: wrap;
  519. font-size: 16px;
  520. }
  521. .userIcon-icon{
  522. display: flex;
  523. flex-direction: column;
  524. align-items: center;
  525. justify-content: center;
  526. height: 40px;
  527. width: 40px;
  528. border-radius: 50%;
  529. margin-bottom: 6px;
  530. }
  531. .userIcon-icon1{background-color: #59D96E;}
  532. .userIcon-icon2{background-color: #4BD2C0;}
  533. .userIcon-icon3{background-color: #6FA5FF;}
  534. .userIcon-icon4{background-color: #9D9FFF;}
  535. .userCell{
  536. background-color: #fff;
  537. border-radius: 8px;
  538. margin: 16px;
  539. .userCell-item{
  540. display: flex;
  541. justify-content: space-between;
  542. align-items: center;
  543. padding: 16px;
  544. .userCell-title{
  545. font-size: 16px;
  546. display: flex;
  547. align-items: center;
  548. p{
  549. margin-left: 8px;
  550. }
  551. }
  552. span{
  553. color:#999;
  554. }
  555. .add{
  556. color:#999;
  557. }
  558. }
  559. }
  560. .userHead{
  561. display: flex;
  562. align-items: center;
  563. align-items: center;
  564. padding:40px 20px 0;
  565. .userHead-img{
  566. }
  567. .userHead-text{
  568. margin-left: 12px;
  569. h3{
  570. font-size: 20px;
  571. color:#fff;
  572. font-weight: normal;
  573. }
  574. }
  575. }
  576. .userData{
  577. background-color: #fff;
  578. margin: 16px;
  579. padding: 16px ;
  580. border-radius: 8px;
  581. display: flex;
  582. align-items: center;
  583. justify-content: space-around;
  584. }
  585. .userData-num{
  586. width: 50%;
  587. display: flex;
  588. flex-direction: column;
  589. align-items: center;
  590. justify-content:space-between;
  591. padding-right: 5px;
  592. .userData-data{
  593. font-size: 24px;
  594. font-weight: 600;
  595. }
  596. .userData-name{
  597. font-size: 16px;
  598. }
  599. .userData-foot{
  600. margin-top: 4px;
  601. color:#999;
  602. font-size: 12px;
  603. .userData-foot-look {
  604. color: #00B962;
  605. }
  606. }
  607. }
  608. .userInfo-btn{
  609. padding: 6px 30px;
  610. // background-color: #00B962;
  611. // color:#fff;
  612. // border-radius: 15px;
  613. }
  614. .line{
  615. width: 0px;
  616. height: 36px;
  617. border: 1px solid rgba(237, 237, 237, 100);
  618. }
  619. </style>