index.vue 11 KB

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