index.vue 11 KB

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