index.vue 12 KB

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