index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  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" oldstyle="font-size: 28px;">
  8. <h3 class="oldTextjp2" oldstyle="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 oldTextjp2" oldstyle="font-size: 28px;">{{personAccount.availableAmount != null ? personAccount.availableAmount.toFixed(2) : '0.00'}}元</view>
  14. <view class="userData-foot oldTextjp2" oldstyle="font-size: 16px;">可用余额</view>
  15. </view>
  16. <view class="line">
  17. </view>
  18. <view class="userData-num" @click="toMyCoupon">
  19. <view class="userData-data oldTextjp2" oldstyle="font-size: 28px;">{{recordsTotal}}张</view>
  20. <view class="userData-foot oldTextjp2" oldstyle="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 oldTextjp2" oldstyle="font-size: 20px;">
  32. <h3>常用功能</h3>
  33. </view>
  34. <view class="userIcon-main oldTextjp2" oldstyle="font-size: 18px;">
  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>扫码充电</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>快速充值</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>充电记录</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>附近站点</p>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="userCell">
  62. <view class="userCell-item" @click="carManage">
  63. <view class="userCell-title">
  64. <u-icon name="menu_cwcl" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  65. <p>车辆管理</p>
  66. </view>
  67. <view class="">
  68. <text class="add">添加车牌号</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">
  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">
  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">
  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">
  95. <u-icon name="customer-service-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  96. <p>联系客服</p>
  97. </view>
  98. <span>{{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"></u-modal>
  103. </view>
  104. <view class="userCell-item" @click="setUp">
  105. <view class="userCell-title">
  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. this.elderStatus=this.carhelp.get("getElderModeClass");
  156. },
  157. onReady() {
  158. WxJsApi.getWxConfig(['getLocation', 'addEventListener', 'scanQRCode']).then((res) => {
  159. // console.log(res)
  160. }).catch(error => {
  161. console.log(res)
  162. })
  163. var consumerPhone=this.carhelp.getConfig().consumerPhone
  164. // img="https://yktwechat.xiaoxinda.com/config/xxd2021.jpg"
  165. if(consumerPhone){
  166. this.content=consumerPhone
  167. }
  168. this.getBannerInfo("userinfo")
  169. },
  170. methods: {
  171. clickBanner(index){
  172. var mod= this.bannerList[index]
  173. if(mod.linkUrl.indexOf('http')==0){
  174. window.location=mod.linkUrl;
  175. }
  176. else if(mod.linkUrl.indexOf('#/')==0){
  177. if(mod.linkUrl.indexOf("?")==-1){
  178. mod.linkUrl+='?';
  179. }
  180. //window.location=mod.linkUrl;
  181. var url=mod.linkUrl.split("#")[1]
  182. //window.location = mod.clickUrl;
  183. uni.navigateTo({
  184. url: url
  185. })
  186. }
  187. else if(mod.linkUrl=='#'||mod.linkUrl==''){
  188. }
  189. else{
  190. uni.navigateTo({
  191. url:mod.linkUrl
  192. })
  193. }
  194. },
  195. getBannerInfo(code){
  196. uni.showLoading({
  197. title: "加载中",
  198. mask: true,
  199. })
  200. newsApi.getBannerInfo(code).then((res) => {
  201. this.bannerList =res.data;
  202. // document.getElementsByClassName("uni-swiper-wrapper")[0].parentNode.style="background-color: rgb(255, 255, 255); height: 300px;"
  203. }).catch(error => {
  204. uni.showToast({
  205. title: error,icon: "none"
  206. })
  207. })
  208. },
  209. getCouponList() {
  210. uni.showLoading({
  211. title: "加载中",
  212. mask: true,
  213. })
  214. userApi.couponList({
  215. status: '0'
  216. }).then((res) => {
  217. uni.hideLoading();
  218. this.myCouponList = res.data.data;
  219. this.recordsTotal = res.data.recordsTotal;
  220. }).catch(error => {
  221. uni.showToast({
  222. title: error,
  223. icon: "none"
  224. })
  225. })
  226. },
  227. //微信扫二维码
  228. getScanCode() {
  229. if (this.userId) {
  230. WxJsApi.scanQRCode(1).then(res => {
  231. if(res) {
  232. API.scanCode(res).then((response) => {
  233. }).catch(error => {
  234. uni.showToast({
  235. title: error,
  236. icon: "none"
  237. })
  238. })
  239. }
  240. }).catch(error => {
  241. })
  242. } else {
  243. uni.navigateTo({
  244. url: '/pages/login/login'
  245. })
  246. }
  247. },
  248. fastRecharge() {
  249. if (this.userId) {
  250. uni.navigateTo({
  251. url: '/pages/user/finance/recharge'
  252. })
  253. } else {
  254. uni.navigateTo({
  255. url: '/pages/login/login'
  256. })
  257. }
  258. },
  259. chargingRecord() {
  260. if (this.userId) {
  261. uni.navigateTo({
  262. url: '/pages/record/index'
  263. })
  264. } else {
  265. uni.navigateTo({
  266. url: '/pages/login/login'
  267. })
  268. }
  269. },
  270. toSearchPile() {
  271. uni.navigateTo({
  272. url: '/pages/searchPile/searchPile'
  273. })
  274. },
  275. getUserInfo() {
  276. uni.showLoading({
  277. title: "加载中",
  278. mask: true,
  279. })
  280. loginApi.findByOpenId({
  281. openId: this.carhelp.getOpenId()
  282. }).then((res) => {
  283. uni.hideLoading();
  284. this.headImg = res.data.regUser.headImg;
  285. var phone = res.data.regUser.phone;
  286. var phone1 = phone.slice(0,3);
  287. var phone2 = phone.slice(-4);
  288. this.userPhone = phone1 + '****' + phone2;
  289. }).catch(error => {
  290. uni.showToast({
  291. title: error,
  292. icon: "none"
  293. })
  294. })
  295. },
  296. toData() {
  297. if(this.userId) {
  298. uni.navigateTo({
  299. url: '/pages/user/data'
  300. })
  301. } else {
  302. uni.navigateTo({
  303. url: '/pages/login/login'
  304. })
  305. }
  306. },
  307. toBalance() {
  308. if(this.userId) {
  309. uni.navigateTo({
  310. url: '/pages/user/finance/balance'
  311. })
  312. } else {
  313. uni.navigateTo({
  314. url: '/pages/login/login'
  315. })
  316. }
  317. },
  318. toMyCoupon() {
  319. if(this.userId) {
  320. uni.navigateTo({
  321. url: '/pages/user/coupon/myCoupon'
  322. })
  323. } else {
  324. uni.navigateTo({
  325. url: '/pages/login/login'
  326. })
  327. }
  328. },
  329. toRecharge() {
  330. if(this.userId) {
  331. uni.navigateTo({
  332. url: '/pages/user/finance/recharge'
  333. })
  334. } else {
  335. uni.navigateTo({
  336. url: '/pages/login/login'
  337. })
  338. }
  339. },
  340. carManage() {
  341. if(this.userId) {
  342. uni.navigateTo({
  343. url: '/pages/user/car/index'
  344. })
  345. } else {
  346. uni.navigateTo({
  347. url: '/pages/login/login'
  348. })
  349. }
  350. },
  351. feedback() {
  352. if(this.userId) {
  353. uni.navigateTo({
  354. url: '/pages/user/message'
  355. })
  356. } else {
  357. uni.navigateTo({
  358. url: '/pages/login/login'
  359. })
  360. }
  361. },
  362. setUp() {
  363. if(this.userId) {
  364. uni.navigateTo({
  365. url: '/pages/user/setting'
  366. })
  367. } else {
  368. uni.navigateTo({
  369. url: '/pages/login/login'
  370. })
  371. }
  372. },
  373. openModal() {
  374. this.show = true;
  375. },
  376. confirmPhone(){
  377. this.show = false;
  378. uni.makePhoneCall({
  379. phoneNumber:this.content //仅为示例
  380. });
  381. },
  382. getCarPersonAccount() {
  383. uni.showLoading({
  384. title: "加载中",
  385. mask: true,
  386. })
  387. userApi.carPersonAccount().then((res) => {
  388. uni.hideLoading();
  389. this.personAccount = res.data;
  390. }).catch(error => {
  391. uni.showToast({
  392. title: error,
  393. icon: "none"
  394. })
  395. })
  396. }
  397. }
  398. }
  399. </script>
  400. <style>
  401. page{
  402. background:url(../../assets/img/index_header_bg.png) no-repeat top center #f7f7f7;
  403. background-size: 100%;
  404. }
  405. </style>
  406. <style lang="scss" scoped>
  407. .userBanner{
  408. margin: 16px;
  409. }
  410. .userIcon{
  411. background-color: #fff;
  412. margin: 16px;
  413. border-radius: 8px;
  414. padding: 16px;
  415. }
  416. .userIcon-item{
  417. display: flex;
  418. flex-direction: column;
  419. align-items: center;
  420. }
  421. .userIcon-main{
  422. margin-top: 16px;
  423. display: flex;
  424. justify-content: space-between;
  425. font-size: 16px;
  426. }
  427. .userIcon-icon{
  428. display: flex;
  429. flex-direction: column;
  430. align-items: center;
  431. justify-content: center;
  432. height: 40px;
  433. width: 40px;
  434. border-radius: 50%;
  435. margin-bottom: 6px;
  436. }
  437. .userIcon-icon1{background-color: #59D96E;}
  438. .userIcon-icon2{background-color: #4BD2C0;}
  439. .userIcon-icon3{background-color: #6FA5FF;}
  440. .userIcon-icon4{background-color: #9D9FFF;}
  441. .userCell{
  442. background-color: #fff;
  443. border-radius: 8px;
  444. margin: 16px;
  445. .userCell-item{
  446. display: flex;
  447. justify-content: space-between;
  448. align-items: center;
  449. padding: 16px;
  450. .userCell-title{
  451. font-size: 16px;
  452. display: flex;
  453. align-items: center;
  454. p{
  455. margin-left: 8px;
  456. }
  457. }
  458. span{
  459. color:#999;
  460. }
  461. }
  462. }
  463. .userHead{
  464. display: flex;
  465. align-items: center;
  466. align-items: center;
  467. padding:40px 20px 0;
  468. .userHead-img{
  469. }
  470. .userHead-text{
  471. margin-left: 12px;
  472. h3{
  473. font-size: 20px;
  474. color:#fff;
  475. font-weight: normal;
  476. }
  477. }
  478. }
  479. .userData{
  480. background-color: #fff;
  481. margin: 16px;
  482. padding: 16px ;
  483. border-radius: 8px;
  484. display: flex;
  485. align-items: center;
  486. justify-content: space-around;
  487. }
  488. .userData-num{
  489. width: 50%;
  490. display: flex;
  491. flex-direction: column;
  492. align-items: center;
  493. justify-content:space-between;
  494. padding-right: 5px;
  495. .userData-data{
  496. font-size: 24px;
  497. font-weight: 600;
  498. }
  499. .userData-name{
  500. font-size: 16px;
  501. }
  502. .userData-foot{
  503. margin-top: 4px;
  504. color:#999;
  505. font-size: 12px;
  506. }
  507. }
  508. .userInfo-btn{
  509. padding: 6px 30px;
  510. // background-color: #00B962;
  511. // color:#fff;
  512. // border-radius: 15px;
  513. }
  514. .line{
  515. width: 0px;
  516. height: 36px;
  517. border: 1px solid rgba(237, 237, 237, 100);
  518. }
  519. </style>