mine.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view class="container">
  3. <image class="banner" src="@/static/images/mine/back.png" mode="aspectFill" />
  4. <view class="title" :style="{ top: `${paddingTop * 2}rpx` }">我的</view>
  5. <!-- 头像区域 -->
  6. <image class="author" src="@/static/images/mine/author.png" mode="aspectFill" />
  7. <!-- 微信名区域 -->
  8. <view class="name" v-if="userInfo.username">{{ userInfo.username }}</view>
  9. <view class="name" v-else @click="handleLogin">登录</view>
  10. <!-- 电话区域 -->
  11. <view class="phone" v-if="userInfo.mobile">{{ userInfo.mobile }}</view>
  12. <!-- 全部订单区域 -->
  13. <view class="box">
  14. <view class="box_title">全部订单</view>
  15. <view class="box_list">
  16. <view v-for="(item, index) in typeList" :key="index" class="list_item" @click="clickItem(item)">
  17. <image class="item_img" :src="item.imgUrl" mode="aspectFill" />
  18. {{ item.text }}
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 常用功能区域 -->
  23. <view class="box top">
  24. <view class="box_title">常用功能</view>
  25. <view class="box_list">
  26. <view v-for="(item, index) in commonList" :key="index" class="list_item" @click="clickItem(item)">
  27. <image class="item_img" :src="item.imgUrl" mode="aspectFill" />
  28. {{ item.text }}
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 授权手机号 -->
  34. <AuthorizePopup :show="show" @close="handleClose" />
  35. </template>
  36. <script setup>
  37. import { onMounted, ref } from 'vue'
  38. import AuthorizePopup from '@/components/AuthorizePopup.vue'
  39. // 胶囊按钮距离页面顶部的距离
  40. const paddingTop = ref(0)
  41. // 用户信息
  42. const userInfo = ref({})
  43. // 授权弹窗显示隐藏控制
  44. const show = ref(false)
  45. // 全部订单数组
  46. const typeList = [
  47. {
  48. text: '待支付',
  49. imgUrl: '/static/images/mine/nopay.png',
  50. path: '',
  51. isChcek: true
  52. },
  53. {
  54. text: '未乘车',
  55. imgUrl: '/static/images/mine/noriding.png',
  56. path: '',
  57. isChcek: true
  58. },
  59. {
  60. text: '已乘车',
  61. imgUrl: '/static/images/mine/riding.png',
  62. path: '',
  63. isChcek: true
  64. },
  65. {
  66. text: '已取消',
  67. imgUrl: '/static/images/mine/cancel.png',
  68. path: '',
  69. isChcek: true
  70. }
  71. ]
  72. // 常用功能数组
  73. const commonList = [
  74. {
  75. text: '常用旅客',
  76. imgUrl: '/static/images/mine/people.png',
  77. path: '/pages/commonPeople/commonPeople',
  78. isChcek: true
  79. },
  80. {
  81. text: '优惠券',
  82. imgUrl: '/static/images/mine/coupon.png',
  83. path: '/pages/coupon/coupon',
  84. isChcek: true
  85. },
  86. {
  87. text: '联系客服',
  88. imgUrl: '/static/images/mine/service.png',
  89. path: '',
  90. isChcek: false
  91. },
  92. {
  93. text: '客服电话',
  94. imgUrl: '/static/images/mine/phone.png',
  95. path: '',
  96. isChcek: false
  97. },
  98. {
  99. text: '电子交通卡',
  100. imgUrl: '/static/images/mine/card.png',
  101. path: '/pages/transportation/transportation',
  102. isChcek: true
  103. }
  104. ]
  105. onMounted(() => {
  106. paddingTop.value = uni.getMenuButtonBoundingClientRect().top
  107. userInfo.value = uni.getStorageSync('carUserInfo')
  108. })
  109. // 点击每一个菜单的回调
  110. function clickItem(item) {
  111. if (item.isChcek) {
  112. if (userInfo.value) {
  113. if (item.path) {
  114. uni.navigateTo({
  115. url: item.path
  116. })
  117. }
  118. } else {
  119. uni.showModal({
  120. title: '提示',
  121. content: '请先登录',
  122. success: (res) => {
  123. if (res.confirm) {
  124. show.value = true
  125. }
  126. }
  127. })
  128. }
  129. } else {
  130. if (item.text === '联系客服' || item.text === '客服电话') {
  131. uni.showModal({
  132. title: '拨打客服电话',
  133. content: '工作时间:9:00:00—18:00:00',
  134. cancelText: '关闭',
  135. confirmText: '拨打',
  136. confirmColor: '#FF8205',
  137. success: (res) => {
  138. if (res.confirm) {
  139. console.log('用户点击确定')
  140. }
  141. }
  142. })
  143. }
  144. }
  145. }
  146. const handleClose = (val) => {
  147. show.value = false
  148. if (val) {
  149. userInfo.value = uni.getStorageSync('carUserInfo')
  150. }
  151. }
  152. // 点击登录的回调
  153. const handleLogin = () => {
  154. show.value = true
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .container {
  159. position: relative;
  160. height: 100vh;
  161. color: #001713;
  162. background-color: #fff;
  163. overflow-y: auto;
  164. .banner {
  165. width: 100%;
  166. height: 482rpx;
  167. }
  168. .title {
  169. position: absolute;
  170. left: 354rpx;
  171. font-size: 40rpx;
  172. }
  173. .author {
  174. position: absolute;
  175. left: 32rpx;
  176. top: 214rpx;
  177. width: 126rpx;
  178. height: 126rpx;
  179. border-radius: 50%;
  180. }
  181. .name {
  182. position: absolute;
  183. left: 178rpx;
  184. top: 232rpx;
  185. font-size: 36rpx;
  186. }
  187. .phone {
  188. position: absolute;
  189. left: 178rpx;
  190. top: 282rpx;
  191. font-size: 28rpx;
  192. color: #616267;
  193. }
  194. .box {
  195. position: absolute;
  196. top: 370rpx;
  197. left: 26rpx;
  198. box-sizing: border-box;
  199. padding: 0 30rpx;
  200. width: 700rpx;
  201. min-height: 300rpx;
  202. border-radius: 12rpx;
  203. background-color: #fff;
  204. box-shadow: 0 3rpx 6rpx #ccc;
  205. .box_title {
  206. display: flex;
  207. align-items: center;
  208. height: 134rpx;
  209. font-size: 32rpx;
  210. }
  211. .box_list {
  212. display: flex;
  213. flex-wrap: wrap;
  214. align-items: center;
  215. // height: 130rpx;
  216. .list_item {
  217. display: flex;
  218. flex-direction: column;
  219. justify-content: space-between;
  220. align-items: center;
  221. margin-bottom: 40rpx;
  222. width: 160rpx;
  223. height: 130rpx;
  224. font-size: 28rpx;
  225. .item_img {
  226. width: 68rpx;
  227. height: 68rpx;
  228. }
  229. }
  230. }
  231. }
  232. .top {
  233. top: 690rpx;
  234. }
  235. }
  236. </style>