index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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="userCell">
  19. <view class="userCell-item" @click="carManage">
  20. <view class="userCell-title">
  21. <u-icon name="menu_cwcl" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  22. <p>车辆管理</p>
  23. </view>
  24. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  25. </view>
  26. <view class="userCell-item" @click="gotoUrl('pages/user/help')">
  27. <view class="userCell-title">
  28. <u-icon name="compass-3-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  29. <p>操作指南</p>
  30. </view>
  31. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  32. </view>
  33. <view class="userCell-item" @click="feedback">
  34. <view class="userCell-title">
  35. <u-icon name="feedback-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  36. <p>意见反馈</p>
  37. </view>
  38. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  39. </view>
  40. <view class="userCell-item" @click="gotoUrl('pages/user/about')">
  41. <view class="userCell-title">
  42. <u-icon name="information-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  43. <p>关于我们</p>
  44. </view>
  45. <u-icon name="arrow-right-s-line" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  46. </view>
  47. <view class="userCell-item" @click="openModal">
  48. <view class="userCell-title">
  49. <u-icon name="customer-service-fill" custom-prefix="custom-icon" color="#6BC6A7" size="36"></u-icon>
  50. <p>联系客服</p>
  51. </view>
  52. <span>{{content}}</span>
  53. </view>
  54. <view>
  55. <u-modal v-model="show" @confirm="confirmPhone" :confirm-text="confirmText" confirm-color="#606266" :show-cancel-button="true" ref="uModal"
  56. :asyncClose="true" :title="title" :content="content"></u-modal>
  57. </view>
  58. <view class="userCell-item" @click="setUp">
  59. <view class="userCell-title">
  60. <u-icon name="settings-4-fill" 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>
  66. <Tabbar :current="2"></Tabbar>
  67. </view>
  68. </template>
  69. <script>
  70. import * as userApi from '@/apis/user.js'
  71. import * as loginApi from '@/apis/login.js'
  72. import Tabbar from '@/components/Tabbar.vue'
  73. export default {
  74. components: {
  75. Tabbar
  76. },
  77. data() {
  78. return {
  79. personAccount: {},
  80. userId: '',
  81. headImg: '',
  82. userPhone: '',
  83. show: false,
  84. title: '联系客服',
  85. content: '0716-8123456',
  86. confirmText: '拨打电话',
  87. background:{
  88. background: 'none'
  89. },
  90. }
  91. },
  92. onShow() {
  93. if(this.carhelp.getPersonInfo()) {
  94. this.userId = this.carhelp.getPersonInfo().id;
  95. this.getCarPersonAccount();
  96. this.getUserInfo();
  97. }
  98. },
  99. onReady() {
  100. var consumerPhone=this.carhelp.getConfig().consumerPhone
  101. // img="https://yktwechat.xiaoxinda.com/config/xxd2021.jpg"
  102. if(consumerPhone){
  103. this.content=consumerPhone
  104. }
  105. },
  106. methods: {
  107. getUserInfo() {
  108. uni.showLoading({
  109. title: "加载中",
  110. mask: true,
  111. })
  112. loginApi.findByOpenId({
  113. openId: this.carhelp.getOpenId()
  114. }).then((res) => {
  115. uni.hideLoading();
  116. this.headImg = res.data.regUser.headImg;
  117. var phone = res.data.regUser.phone;
  118. var phone1 = phone.slice(0,3);
  119. var phone2 = phone.slice(-4);
  120. this.userPhone = phone1 + '****' + phone2;
  121. }).catch(error => {
  122. uni.showToast({
  123. title: error,
  124. icon: "none"
  125. })
  126. })
  127. },
  128. toData() {
  129. if(this.userId) {
  130. uni.navigateTo({
  131. url: '/pages/user/data'
  132. })
  133. } else {
  134. uni.navigateTo({
  135. url: '/pages/login/login'
  136. })
  137. }
  138. },
  139. toBalance() {
  140. if(this.userId) {
  141. uni.navigateTo({
  142. url: '/pages/user/finance/balance'
  143. })
  144. } else {
  145. uni.navigateTo({
  146. url: '/pages/login/login'
  147. })
  148. }
  149. },
  150. toRecharge() {
  151. if(this.userId) {
  152. uni.navigateTo({
  153. url: '/pages/user/finance/recharge'
  154. })
  155. } else {
  156. uni.navigateTo({
  157. url: '/pages/login/login'
  158. })
  159. }
  160. },
  161. carManage() {
  162. if(this.userId) {
  163. uni.navigateTo({
  164. url: '/pages/user/car/index'
  165. })
  166. } else {
  167. uni.navigateTo({
  168. url: '/pages/login/login'
  169. })
  170. }
  171. },
  172. feedback() {
  173. if(this.userId) {
  174. uni.navigateTo({
  175. url: '/pages/user/message'
  176. })
  177. } else {
  178. uni.navigateTo({
  179. url: '/pages/login/login'
  180. })
  181. }
  182. },
  183. setUp() {
  184. if(this.userId) {
  185. uni.navigateTo({
  186. url: '/pages/user/setting'
  187. })
  188. } else {
  189. uni.navigateTo({
  190. url: '/pages/login/login'
  191. })
  192. }
  193. },
  194. openModal() {
  195. this.show = true;
  196. },
  197. confirmPhone(){
  198. this.show = false;
  199. uni.makePhoneCall({
  200. phoneNumber:this.content //仅为示例
  201. });
  202. },
  203. getCarPersonAccount() {
  204. uni.showLoading({
  205. title: "加载中",
  206. mask: true,
  207. })
  208. userApi.carPersonAccount().then((res) => {
  209. uni.hideLoading();
  210. this.personAccount = res.data;
  211. }).catch(error => {
  212. uni.showToast({
  213. title: error,
  214. icon: "none"
  215. })
  216. })
  217. }
  218. }
  219. }
  220. </script>
  221. <style>
  222. page{
  223. background:url(../../assets/img/index_header_bg.png) no-repeat top center #f7f7f7;
  224. background-size: 100%;
  225. padding-bottom: 95px;
  226. }
  227. </style>
  228. <style lang="scss" scoped>
  229. .userCell{
  230. background-color: #fff;
  231. border-radius: 8px;
  232. margin: 16px;
  233. .userCell-item{
  234. display: flex;
  235. justify-content: space-between;
  236. align-items: center;
  237. padding: 16px;
  238. .userCell-title{
  239. display: flex;
  240. align-items: center;
  241. p{
  242. margin-left: 8px;
  243. }
  244. }
  245. span{
  246. color:#999;
  247. }
  248. }
  249. }
  250. .userHead{
  251. display: flex;
  252. align-items: center;
  253. align-items: center;
  254. padding:40px 20px 0;
  255. .userHead-img{
  256. }
  257. .userHead-text{
  258. margin-left: 12px;
  259. h3{
  260. font-size: 20px;
  261. color:#fff;
  262. font-weight: normal;
  263. }
  264. }
  265. }
  266. .userData{
  267. background-color: #fff;
  268. margin: 16px;
  269. padding: 16px 24px;
  270. border-radius: 8px;
  271. display: flex;
  272. align-items: center;
  273. justify-content: space-between;
  274. }
  275. .userData-num{
  276. display: flex;
  277. flex-direction: column;
  278. align-items: center;
  279. justify-content:space-between;
  280. padding-left: 5px;
  281. .userData-data{
  282. font-size: 24px;
  283. }
  284. .userData-name{
  285. font-size: 16px;
  286. }
  287. .userData-foot{
  288. margin-top: 4px;
  289. color:#999;
  290. font-size: 12px;
  291. }
  292. }
  293. .userInfo-btn{
  294. padding: 6px 30px;
  295. background-color: #00B962;
  296. color:#fff;
  297. border-radius: 15px;
  298. }
  299. </style>