index.vue 14 KB

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