mine.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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. const res = await myRequest({
  241. url: '/tAppvertifyTicket.action',
  242. data: {
  243. id:saoNum.value
  244. }
  245. })
  246. if(res.code==200){
  247. uni.showToast({
  248. title: '扫码成功',
  249. icon: 'none'
  250. });
  251. }else{
  252. uni.showToast({
  253. title: res.message,
  254. icon: 'none'
  255. });
  256. }
  257. }
  258. const onShareAppMessage = (res) => { //发送给朋友
  259. return {
  260. // title: this.tuiguang,
  261. path: '/pages/home/home',
  262. // imageUrl: this.tuiguangImg,
  263. }
  264. }
  265. </script>
  266. <style lang="scss" scoped>
  267. .container {
  268. position: relative;
  269. height: 100vh;
  270. color: #001713;
  271. background-color: #fff;
  272. overflow-y: auto;
  273. .banner {
  274. width: 100%;
  275. height: 482rpx;
  276. }
  277. .title {
  278. position: absolute;
  279. left: 354rpx;
  280. font-size: 40rpx;
  281. }
  282. .author {
  283. position: absolute;
  284. left: 32rpx;
  285. top: 214rpx;
  286. width: 126rpx;
  287. height: 126rpx;
  288. border-radius: 50%;
  289. }
  290. .name {
  291. position: absolute;
  292. left: 178rpx;
  293. top: 232rpx;
  294. font-size: 36rpx;
  295. }
  296. .phone {
  297. position: absolute;
  298. left: 178rpx;
  299. top: 282rpx;
  300. font-size: 28rpx;
  301. color: #616267;
  302. }
  303. .saoma{
  304. position: absolute;
  305. left: 578rpx;
  306. top: 232rpx;
  307. font-size: 36rpx;
  308. }
  309. .box {
  310. position: absolute;
  311. top: 370rpx;
  312. left: 26rpx;
  313. box-sizing: border-box;
  314. padding: 0 30rpx;
  315. width: 700rpx;
  316. min-height: 300rpx;
  317. border-radius: 12rpx;
  318. background-color: #fff;
  319. box-shadow: 0 3rpx 6rpx #ccc;
  320. .box_title {
  321. display: flex;
  322. align-items: center;
  323. height: 134rpx;
  324. font-size: 32rpx;
  325. }
  326. .box_list {
  327. display: flex;
  328. flex-wrap: wrap;
  329. align-items: center;
  330. // height: 130rpx;
  331. .list_item {
  332. display: flex;
  333. flex-direction: column;
  334. justify-content: space-between;
  335. align-items: center;
  336. margin-bottom: 40rpx;
  337. width: 160rpx;
  338. height: 130rpx;
  339. font-size: 28rpx;
  340. .item_img {
  341. width: 68rpx;
  342. height: 68rpx;
  343. }
  344. }
  345. }
  346. }
  347. .top {
  348. top: 690rpx;
  349. }
  350. }
  351. </style>