mine.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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="saoma" v-if="roleType==0" @click="saomaH">扫一扫</view>
  14. <!-- 全部订单区域 -->
  15. <view class="box">
  16. <view class="box_title">全部订单</view>
  17. <view class="box_list">
  18. <view v-for="(item, index) in typeList" :key="index" class="list_item" @click="clickItem(item)">
  19. <image class="item_img" :src="item.imgUrl" mode="aspectFill" />
  20. {{ item.text }}
  21. </view>
  22. </view>
  23. </view>
  24. <!-- 常用功能区域 -->
  25. <view class="box top">
  26. <view class="box_title">常用功能</view>
  27. <view class="box_list">
  28. <view v-for="(item, index) in commonList" :key="index" class="list_item" @click="clickItem(item)">
  29. <image class="item_img" :src="item.imgUrl" mode="aspectFill" />
  30. {{ item.text }}
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 授权手机号 -->
  36. <AuthorizePopup :show="show" @close="handleClose" />
  37. </template>
  38. <script setup>
  39. import { onMounted, ref } from 'vue'
  40. import AuthorizePopup from '@/components/AuthorizePopup.vue'
  41. import { myRequest } from '@/utils/api.ts'
  42. import { useTabParamStore } from '@/utils/tabParams.js';
  43. const tabParamStore = useTabParamStore();
  44. // 用户信息
  45. const userInfo1 = uni.getStorageSync('carUserInfo')
  46. // 胶囊按钮距离页面顶部的距离
  47. const paddingTop = ref(0)
  48. // 用户信息
  49. const userInfo = ref({})
  50. // 授权弹窗显示隐藏控制
  51. const show = ref(false)
  52. // 全部订单数组
  53. const typeList = [
  54. {
  55. text: '待支付',
  56. imgUrl: '/static/images/mine/nopay.png',
  57. path: '/pages/order/order',
  58. type:6,
  59. isChcek: true
  60. },
  61. {
  62. text: '未乘车',
  63. imgUrl: '/static/images/mine/noriding.png',
  64. path: '/pages/order/order',
  65. type:3,
  66. isChcek: true
  67. },
  68. {
  69. text: '已乘车',
  70. imgUrl: '/static/images/mine/riding.png',
  71. path: '/pages/order/order',
  72. type:2,
  73. isChcek: true
  74. },
  75. {
  76. text: '已取消',
  77. imgUrl: '/static/images/mine/cancel.png',
  78. path: '/pages/order/order',
  79. type:4,
  80. isChcek: true
  81. }
  82. ]
  83. // 常用功能数组
  84. const commonList = [
  85. {
  86. text: '常用旅客',
  87. imgUrl: '/static/images/mine/people.png',
  88. path: '/pages/commonPeople/commonPeople',
  89. isChcek: true
  90. },
  91. {
  92. text: '优惠券',
  93. imgUrl: '/static/images/mine/coupon.png',
  94. path: '/pages/coupon/coupon',
  95. isChcek: true
  96. },
  97. {
  98. text: '联系客服',
  99. imgUrl: '/static/images/mine/service.png',
  100. path: '',
  101. isChcek: false
  102. },
  103. {
  104. text: '客服电话',
  105. imgUrl: '/static/images/mine/phone.png',
  106. path: '',
  107. isChcek: false
  108. },
  109. {
  110. text: '电子交通卡',
  111. imgUrl: '/static/images/mine/card.png',
  112. path: '/pages/transportation/transportation',
  113. isChcek: true
  114. }
  115. ]
  116. //客服信息
  117. const worktime = ref('')
  118. const workTele = ref('')
  119. //人员身份
  120. const roleType = ref(1)
  121. //扫码参数
  122. const saoNum = ref('')
  123. onMounted(() => {
  124. paddingTop.value = uni.getMenuButtonBoundingClientRect().top
  125. userInfo.value = uni.getStorageSync('carUserInfo')
  126. getTuigai()
  127. getShen()
  128. })
  129. // 点击每一个菜单的回调
  130. function clickItem(item) {
  131. if (item.isChcek) {
  132. if (userInfo.value) {
  133. if (item.type) {
  134. // 1. 存储参数到全局状态
  135. tabParamStore.setType(item.type); // 替换为实际要传递的type值
  136. uni.switchTab({
  137. url: item.path
  138. })
  139. }else{
  140. uni.navigateTo({
  141. url: item.path
  142. })
  143. }
  144. } else {
  145. uni.showModal({
  146. title: '提示',
  147. content: '请先登录',
  148. success: (res) => {
  149. if (res.confirm) {
  150. show.value = true
  151. }
  152. }
  153. })
  154. }
  155. } else {
  156. if (item.text === '联系客服' || item.text === '客服电话') {
  157. uni.showModal({
  158. title: '拨打客服电话:'+workTele.value,
  159. content: '工作时间:'+worktime.value,
  160. cancelText: '关闭',
  161. confirmText: '拨打',
  162. confirmColor: '#FF8205',
  163. success: (res) => {
  164. if (res.confirm) {
  165. uni.makePhoneCall({
  166. phoneNumber: workTele.value, // 仅支持数字,固定号码需加引号
  167. success: () => console.log("拨号功能调用成功"),
  168. fail: (err) => console.error("拨号失败:", err)
  169. });
  170. }
  171. }
  172. })
  173. }
  174. }
  175. }
  176. //客服电话
  177. async function getTuigai() {
  178. const res = await myRequest({
  179. url: '/carBook/cnqueryHb.action',
  180. data: {
  181. }
  182. })
  183. if(res.code==200){
  184. worktime.value=res.data.workTime
  185. workTele.value=res.data.workMobile
  186. }else{
  187. uni.showToast({
  188. title: res.message,
  189. icon: 'none'
  190. });
  191. }
  192. }
  193. const handleClose = (val) => {
  194. show.value = false
  195. if (val) {
  196. userInfo.value = uni.getStorageSync('carUserInfo')
  197. }
  198. }
  199. // 点击登录的回调
  200. const handleLogin = () => {
  201. show.value = true
  202. }
  203. //查询人员身份
  204. async function getShen() {
  205. const res = await myRequest({
  206. url: '/tAppgetUserByMobile.action',
  207. data: {
  208. mobile:userInfo1.mobile
  209. }
  210. })
  211. if(res.code==200){
  212. roleType.value=res.data.type
  213. }else{
  214. uni.showToast({
  215. title: res.message,
  216. icon: 'none'
  217. });
  218. }
  219. }
  220. //扫码核销
  221. const saomaH = (val) => {
  222. uni.showLoading({
  223. title: '扫码中...',
  224. mask: true // 是否显示透明蒙层,防止触摸穿透
  225. })
  226. wx.scanCode({
  227. onlyFromCamera: false, // 只允许从相机扫码
  228. success(res) {
  229. console.log('扫码成功:' + JSON.stringify(res) + res.result)
  230. saoNum.value = res.result
  231. setTimeout(function () {
  232. saomaCha()
  233. }, 700)
  234. }
  235. })
  236. uni.hideLoading()
  237. }
  238. //查询人员身份
  239. async function saomaCha() {
  240. console.log('oo')
  241. const res = await myRequest({
  242. url: '/tAppvertifyTicket.action',
  243. data: {
  244. id:saoNum.value,
  245. vertifyManMobile:userInfo1.mobile
  246. }
  247. })
  248. if(res.code==200){
  249. uni.showToast({
  250. title: '扫码成功',
  251. icon: 'none'
  252. });
  253. }else{
  254. uni.showToast({
  255. title: res.message,
  256. icon: 'none'
  257. });
  258. }
  259. }
  260. const onShareAppMessage = (res) => { //发送给朋友
  261. return {
  262. // title: this.tuiguang,
  263. path: '/pages/home/home',
  264. // imageUrl: this.tuiguangImg,
  265. }
  266. }
  267. </script>
  268. <style lang="scss" scoped>
  269. .container {
  270. position: relative;
  271. height: 100vh;
  272. color: #001713;
  273. background-color: #fff;
  274. overflow-y: auto;
  275. .banner {
  276. width: 100%;
  277. height: 482rpx;
  278. }
  279. .title {
  280. position: absolute;
  281. left: 354rpx;
  282. font-size: 40rpx;
  283. }
  284. .author {
  285. position: absolute;
  286. left: 32rpx;
  287. top: 214rpx;
  288. width: 126rpx;
  289. height: 126rpx;
  290. border-radius: 50%;
  291. }
  292. .name {
  293. position: absolute;
  294. left: 178rpx;
  295. top: 232rpx;
  296. font-size: 36rpx;
  297. }
  298. .phone {
  299. position: absolute;
  300. left: 178rpx;
  301. top: 282rpx;
  302. font-size: 28rpx;
  303. color: #616267;
  304. }
  305. .saoma{
  306. position: absolute;
  307. left: 578rpx;
  308. top: 232rpx;
  309. font-size: 36rpx;
  310. }
  311. .box {
  312. position: absolute;
  313. top: 370rpx;
  314. left: 26rpx;
  315. box-sizing: border-box;
  316. padding: 0 30rpx;
  317. width: 700rpx;
  318. min-height: 300rpx;
  319. border-radius: 12rpx;
  320. background-color: #fff;
  321. box-shadow: 0 3rpx 6rpx #ccc;
  322. .box_title {
  323. display: flex;
  324. align-items: center;
  325. height: 134rpx;
  326. font-size: 32rpx;
  327. }
  328. .box_list {
  329. display: flex;
  330. flex-wrap: wrap;
  331. align-items: center;
  332. // height: 130rpx;
  333. .list_item {
  334. display: flex;
  335. flex-direction: column;
  336. justify-content: space-between;
  337. align-items: center;
  338. margin-bottom: 40rpx;
  339. width: 160rpx;
  340. height: 130rpx;
  341. font-size: 28rpx;
  342. .item_img {
  343. width: 68rpx;
  344. height: 68rpx;
  345. }
  346. }
  347. }
  348. }
  349. .top {
  350. top: 690rpx;
  351. }
  352. }
  353. </style>