index.vue 11 KB

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