mine.vue 8.2 KB

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