index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  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 style=" border-radius: 8px;" width="100%" height="80px" src="../../static/img/9999.png"></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">
  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">
  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">
  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">
  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 userApi from '@/apis/user.js'
  105. import * as loginApi from '@/apis/login.js'
  106. import Tabbar from '@/components/Tabbar.vue'
  107. export default {
  108. components: {
  109. Tabbar
  110. },
  111. data() {
  112. return {
  113. personAccount: {},
  114. userId: '',
  115. headImg: '',
  116. userPhone: '',
  117. show: false,
  118. title: '联系客服',
  119. content: '0716-8123456',
  120. confirmText: '拨打电话',
  121. background:{
  122. background: 'none'
  123. },
  124. }
  125. },
  126. onShow() {
  127. if(this.carhelp.getPersonInfo()) {
  128. this.userId = this.carhelp.getPersonInfo().id;
  129. this.getCarPersonAccount();
  130. this.getUserInfo();
  131. }
  132. },
  133. onReady() {
  134. var consumerPhone=this.carhelp.getConfig().consumerPhone
  135. // img="https://yktwechat.xiaoxinda.com/config/xxd2021.jpg"
  136. if(consumerPhone){
  137. this.content=consumerPhone
  138. }
  139. },
  140. methods: {
  141. getUserInfo() {
  142. uni.showLoading({
  143. title: "加载中",
  144. mask: true,
  145. })
  146. loginApi.findByOpenId({
  147. openId: this.carhelp.getOpenId()
  148. }).then((res) => {
  149. uni.hideLoading();
  150. this.headImg = res.data.regUser.headImg;
  151. var phone = res.data.regUser.phone;
  152. var phone1 = phone.slice(0,3);
  153. var phone2 = phone.slice(-4);
  154. this.userPhone = phone1 + '****' + phone2;
  155. }).catch(error => {
  156. uni.showToast({
  157. title: error,
  158. icon: "none"
  159. })
  160. })
  161. },
  162. toData() {
  163. if(this.userId) {
  164. uni.navigateTo({
  165. url: '/pages/user/data'
  166. })
  167. } else {
  168. uni.navigateTo({
  169. url: '/pages/login/login'
  170. })
  171. }
  172. },
  173. toBalance() {
  174. if(this.userId) {
  175. uni.navigateTo({
  176. url: '/pages/user/finance/balance'
  177. })
  178. } else {
  179. uni.navigateTo({
  180. url: '/pages/login/login'
  181. })
  182. }
  183. },
  184. toRecharge() {
  185. if(this.userId) {
  186. uni.navigateTo({
  187. url: '/pages/user/finance/recharge'
  188. })
  189. } else {
  190. uni.navigateTo({
  191. url: '/pages/login/login'
  192. })
  193. }
  194. },
  195. carManage() {
  196. if(this.userId) {
  197. uni.navigateTo({
  198. url: '/pages/user/car/index'
  199. })
  200. } else {
  201. uni.navigateTo({
  202. url: '/pages/login/login'
  203. })
  204. }
  205. },
  206. feedback() {
  207. if(this.userId) {
  208. uni.navigateTo({
  209. url: '/pages/user/message'
  210. })
  211. } else {
  212. uni.navigateTo({
  213. url: '/pages/login/login'
  214. })
  215. }
  216. },
  217. setUp() {
  218. if(this.userId) {
  219. uni.navigateTo({
  220. url: '/pages/user/setting'
  221. })
  222. } else {
  223. uni.navigateTo({
  224. url: '/pages/login/login'
  225. })
  226. }
  227. },
  228. openModal() {
  229. this.show = true;
  230. },
  231. confirmPhone(){
  232. this.show = false;
  233. uni.makePhoneCall({
  234. phoneNumber:this.content //仅为示例
  235. });
  236. },
  237. getCarPersonAccount() {
  238. uni.showLoading({
  239. title: "加载中",
  240. mask: true,
  241. })
  242. userApi.carPersonAccount().then((res) => {
  243. uni.hideLoading();
  244. this.personAccount = res.data;
  245. }).catch(error => {
  246. uni.showToast({
  247. title: error,
  248. icon: "none"
  249. })
  250. })
  251. }
  252. }
  253. }
  254. </script>
  255. <style>
  256. page{
  257. background:url(../../assets/img/index_header_bg.png) no-repeat top center #f7f7f7;
  258. background-size: 100%;
  259. }
  260. </style>
  261. <style lang="scss" scoped>
  262. .userBanner{
  263. margin: 16px;
  264. }
  265. .userIcon{
  266. background-color: #fff;
  267. margin: 16px;
  268. border-radius: 8px;
  269. padding: 16px;
  270. }
  271. .userIcon-item{
  272. display: flex;
  273. flex-direction: column;
  274. align-items: center;
  275. }
  276. .userIcon-main{
  277. margin-top: 16px;
  278. display: flex;
  279. justify-content: space-between;
  280. }
  281. .userIcon-icon{
  282. display: flex;
  283. flex-direction: column;
  284. align-items: center;
  285. justify-content: center;
  286. height: 40px;
  287. width: 40px;
  288. border-radius: 50%;
  289. margin-bottom: 6px;
  290. }
  291. .userIcon-icon1{background-color: #59D96E;}
  292. .userIcon-icon2{background-color: #4BD2C0;}
  293. .userIcon-icon3{background-color: #6FA5FF;}
  294. .userIcon-icon4{background-color: #9D9FFF;}
  295. .userCell{
  296. background-color: #fff;
  297. border-radius: 8px;
  298. margin: 16px;
  299. .userCell-item{
  300. display: flex;
  301. justify-content: space-between;
  302. align-items: center;
  303. padding: 16px;
  304. .userCell-title{
  305. display: flex;
  306. align-items: center;
  307. p{
  308. margin-left: 8px;
  309. }
  310. }
  311. span{
  312. color:#999;
  313. }
  314. }
  315. }
  316. .userHead{
  317. display: flex;
  318. align-items: center;
  319. align-items: center;
  320. padding:40px 20px 0;
  321. .userHead-img{
  322. }
  323. .userHead-text{
  324. margin-left: 12px;
  325. h3{
  326. font-size: 20px;
  327. color:#fff;
  328. font-weight: normal;
  329. }
  330. }
  331. }
  332. .userData{
  333. background-color: #fff;
  334. margin: 16px;
  335. padding: 16px 24px;
  336. border-radius: 8px;
  337. display: flex;
  338. align-items: center;
  339. justify-content: space-between;
  340. }
  341. .userData-num{
  342. display: flex;
  343. flex-direction: column;
  344. align-items: center;
  345. justify-content:space-between;
  346. padding-left: 30px;
  347. .userData-data{
  348. font-size: 24px;
  349. }
  350. .userData-name{
  351. font-size: 16px;
  352. }
  353. .userData-foot{
  354. margin-top: 4px;
  355. color:#999;
  356. font-size: 12px;
  357. }
  358. }
  359. .userInfo-btn{
  360. padding: 6px 30px;
  361. background-color: #00B962;
  362. color:#fff;
  363. border-radius: 15px;
  364. }
  365. </style>