index.vue 6.7 KB

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