index.vue 11 KB

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