transportation.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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` }">
  5. <view class="title_back" @click="handleBack">
  6. <wd-icon name="thin-arrow-left" color="#001713" size="18"></wd-icon>
  7. </view>
  8. 电子交通卡
  9. </view>
  10. <view class="body">
  11. <!-- 交通卡区域 -->
  12. <view class="body_card" :class="[{ excellent: cardType == '优行卡' }, { teacher: cardType == '教师卡' }, { warm: cardType == '暖心卡' }]">
  13. <view class="card_type">
  14. <view class="type_name">
  15. <image v-if="cardType == '优行卡'" class="img" src="/static/images/transportation/logo.png" mode="aspectFill"></image>
  16. <image v-if="cardType == '教师卡'" class="img" src="/static/images/transportation/logo2.png" mode="aspectFill"></image>
  17. <image v-if="cardType == '暖心卡'" class="img" src="/static/images/transportation/logo3.png" mode="aspectFill"></image>
  18. {{ cardType }}
  19. </view>
  20. <view class="type_au" @click="goPage()">
  21. <text class="text">身份认证</text>
  22. <wd-icon name="arrow-right" color="#376477" size="8"></wd-icon>
  23. </view>
  24. </view>
  25. <view class="card_num">
  26. 可用余额:
  27. <text class="text">{{freePay}}元</text>
  28. </view>
  29. <!-- <view class="">充值余额:{{chongPay}}元 补贴金额度:{{buPay}}元</view> -->
  30. <view
  31. class="card_btn"
  32. :class="[{ btn_excellent: cardType == '优行卡' }, { btn_teacher: cardType == '教师卡' }, { btn_warm: cardType == '暖心卡' }]"
  33. @click="handleDetail"
  34. >
  35. 查看使用明细
  36. </view>
  37. <view class="card_line" :class="[{ line_excellent: cardType == '优行卡' }, { line_teacher: cardType == '教师卡' }, { line_warm: cardType == '暖心卡' }]"></view>
  38. </view>
  39. <!-- 按钮区域 -->
  40. <view class="body_btns">
  41. <view class="btn pull" @click="handlePull">点击充值</view>
  42. <view class="btn refund" @click="handleRefund">点击退款</view>
  43. </view>
  44. <!-- 使用规则区域 -->
  45. <view class="body_rule">交通卡使用规则</view>
  46. <image class="body_rule_img" :src="rulesImg">交通卡使用规则</image>
  47. </view>
  48. </view>
  49. <!-- 退款弹窗区域 -->
  50. <wd-popup v-model="popShow" position="bottom" safe-area-inset-bottom :close-on-click-modal="false">
  51. <view class="pop">
  52. <view class="pop_title">
  53. <view class="title_close" @click="closePop">
  54. <wd-icon name="close" size="16"></wd-icon>
  55. </view>
  56. </view>
  57. <view class="pop_tips" v-if="freePay==0">暂无提现余额</view>
  58. <view class="pop_tips" v-if="freePay>0">可退款余额为{{freePay}}</view>
  59. <view class="pop_msg" v-if="freePay>0">退款后可用余额为0
  60. <!-- ,主余额为0补贴余额为0 -->
  61. </view>
  62. <view class="pop_btn" @click="tuikuan" v-if="freePay>0">立即退款</view>
  63. </view>
  64. </wd-popup>
  65. </template>
  66. <script setup>
  67. import { onMounted, ref } from 'vue'
  68. import { myRequest } from '@/utils/api.ts'
  69. // 胶囊按钮距离页面顶部的距离
  70. const paddingTop = ref(0)
  71. // 用户信息
  72. const userInfo = uni.getStorageSync('carUserInfo')
  73. // 交通卡类型
  74. const cardType = ref('优行卡')
  75. // 交通卡类型数字
  76. const cardTypeNum = ref(0)
  77. //可用余额
  78. const freePay = ref(0)
  79. //充值余额
  80. const chongPay = ref(0)
  81. //补贴余额
  82. const buPay = ref(0)
  83. // 退款弹窗显示隐藏控制
  84. const popShow = ref(false)
  85. // 卡片规则图片
  86. const rulesImg = ref('')
  87. const rulesImg1= ref('')
  88. const rulesImg2= ref('')
  89. const rulesImg3= ref('')
  90. // 查看我的认证信息
  91. async function getMyVetry() {
  92. const res = await myRequest({
  93. url: '/vertifyqueryOwn.action',
  94. data: {
  95. mobile: userInfo.mobile ,
  96. }
  97. })
  98. console.log(res.value ,res.code==205)
  99. if(res.code==200){
  100. if(res.data[0].type==1){
  101. cardType.value = '教师卡'
  102. cardTypeNum.value=1
  103. }else if(res.data[0].type==2){
  104. cardType.value = '暖心卡'
  105. cardTypeNum.value=2
  106. }
  107. getYougui()
  108. }else if(res.code==205){
  109. cardType.value = '优行卡'
  110. cardTypeNum.value=0
  111. getYougui()
  112. }
  113. }
  114. //查看规则
  115. async function getYougui() {
  116. const res = await myRequest({
  117. url: '/fileslist.action',
  118. data: {
  119. }
  120. })
  121. if(res.code==200){
  122. for(var i=0;i<res.data.length;i++){
  123. if(res.data[i].name=='优行卡规则内容'){
  124. rulesImg1.value=res.data[i].url
  125. }else if(res.data[i].name=='教师卡规则内容'){
  126. rulesImg2.value=res.data[i].url
  127. }else if(res.data[i].name=='暖心卡规则内容'){
  128. rulesImg3.value=res.data[i].url
  129. }
  130. }
  131. if(cardTypeNum.value==1){
  132. rulesImg.value=rulesImg2.value
  133. }else if(cardTypeNum.value==1){
  134. rulesImg.value=rulesImg3.value
  135. }else if(cardTypeNum.value==0){
  136. rulesImg.value=rulesImg1.value
  137. }
  138. }
  139. }
  140. //查看交通卡余额汇总
  141. async function getKaYue() {
  142. const res = await myRequest({
  143. url: '/tAppsummary.action',
  144. data: {
  145. mobile: userInfo.mobile ,
  146. // nickname:userInfo.username,
  147. // type:cardTypeNum,
  148. }
  149. })
  150. if(res.code==200){
  151. freePay.value = res.data.freeBalance.money
  152. chongPay.value = res.data.mainBalance.money
  153. buPay.value = res.data.allowanceBalance.money
  154. }
  155. }
  156. onMounted(() => {
  157. paddingTop.value = uni.getMenuButtonBoundingClientRect().top
  158. getMyVetry()
  159. getKaYue()
  160. getYougui()
  161. })
  162. // 查看使用明细按钮回调
  163. const handleDetail = () => {
  164. uni.navigateTo({
  165. url: '/pages/useDetail/useDetail'
  166. })
  167. }
  168. // 点击充值按钮回调
  169. const handlePull = () => {
  170. uni.navigateTo({
  171. url: '/pages/pay/pay'
  172. })
  173. }
  174. // 跳转页面
  175. const goPage = (url) => {
  176. uni.navigateTo({
  177. url:'/pages/identity/identity',
  178. })
  179. }
  180. // 点击退款按钮回调
  181. const handleRefund = () => {
  182. popShow.value = true
  183. }
  184. // 弹窗关闭按钮回调
  185. const closePop = () => {
  186. popShow.value = false
  187. }
  188. //退款
  189. const tuikuan = async () => {
  190. const res = await myRequest({
  191. url: '/cardrefund.action',
  192. // method: 'POST', // 明确指定请求方法为POST
  193. data: {
  194. id: userInfo.id,
  195. refundAccount: freePay.value,
  196. }
  197. })
  198. if(res.code==200){
  199. uni.showToast({
  200. title: res.message,
  201. icon: 'none'
  202. });
  203. }else{
  204. uni.showToast({
  205. title: res.message,
  206. icon: 'none'
  207. });
  208. }
  209. popShow.value = false
  210. }
  211. // 顶部返回图标回调
  212. const handleBack = () => {
  213. uni.navigateBack()
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. .container {
  218. position: relative;
  219. height: 100vh;
  220. color: #001713;
  221. background-color: #fff;
  222. overflow-y: auto;
  223. .banner {
  224. width: 100%;
  225. height: 482rpx;
  226. }
  227. .title {
  228. position: absolute;
  229. display: flex;
  230. align-items: center;
  231. width: 100vh;
  232. font-size: 40rpx;
  233. .title_back {
  234. margin-left: 26rpx;
  235. margin-right: 232rpx;
  236. }
  237. }
  238. .body {
  239. position: absolute;
  240. top: 160rpx;
  241. box-sizing: border-box;
  242. padding: 0 40rpx;
  243. width: 100%;
  244. .body_card {
  245. box-sizing: border-box;
  246. padding: 40rpx 50rpx 30rpx;
  247. width: 100%;
  248. height: 316rpx;
  249. font-size: 24rpx;
  250. border-radius: 60rpx;
  251. border-radius: 30px;
  252. box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
  253. .card_type {
  254. display: flex;
  255. align-items: center;
  256. font-weight: bold;
  257. .type_name {
  258. display: flex;
  259. align-items: center;
  260. font-size: 40rpx;
  261. .img {
  262. margin-right: 10rpx;
  263. width: 40rpx;
  264. height: 40rpx;
  265. }
  266. }
  267. .type_au {
  268. display: flex;
  269. align-items: center;
  270. margin-left: 40rpx;
  271. font-size: 24rpx;
  272. .text {
  273. margin-right: 5rpx;
  274. }
  275. }
  276. }
  277. .card_num {
  278. margin-top: 22rpx;
  279. margin-bottom: 18rpx;
  280. .text {
  281. font-weight: bold;
  282. }
  283. }
  284. .card_btn {
  285. display: flex;
  286. align-items: center;
  287. justify-content: center;
  288. margin-top: 20rpx;
  289. margin-left: auto;
  290. width: 234rpx;
  291. height: 50rpx;
  292. font-size: 28rpx;
  293. font-weight: bold;
  294. border-radius: 8rpx;
  295. }
  296. .btn_excellent {
  297. color: #2b507a;
  298. border: 2rpx solid #2d537d;
  299. background-color: #cfe0eb;
  300. }
  301. .btn_teacher {
  302. color: #a46509;
  303. border: 2rpx solid #c77417;
  304. background-color: #fddb9f;
  305. }
  306. .btn_warm {
  307. color: #1580ed;
  308. border: 2rpx solid #0d71fb;
  309. background-color: #e2eef9;
  310. }
  311. .card_line {
  312. margin-top: 16rpx;
  313. width: 100%;
  314. height: 8rpx;
  315. border-radius: 10rpx;
  316. }
  317. .line_excellent {
  318. background: linear-gradient(90deg, #72a8d2 0%, #2b507a 100%);
  319. }
  320. .line_teacher {
  321. background: linear-gradient(90deg, #f1a045 0%, #bf6c0f 100%);
  322. }
  323. .line_warm {
  324. background: linear-gradient(90deg, #218dfb 0%, #0c70fb 100%);
  325. }
  326. }
  327. .excellent {
  328. color: #2b507a;
  329. background: linear-gradient(146.58deg, rgba(243, 245, 245, 0.5) 0%, rgba(229, 240, 244, 0.5) 100%);
  330. }
  331. .teacher {
  332. color: #9f5300;
  333. background: linear-gradient(148.48deg, rgba(254, 228, 182, 0.5) 0%, rgba(253, 205, 121, 0.5) 59.21%, rgba(248, 212, 140, 0.5) 100%);
  334. }
  335. .warm {
  336. color: #1580ed;
  337. background: linear-gradient(146.58deg, rgba(243, 245, 245, 0.5) 0%, rgba(201, 229, 255, 0.5) 100%);
  338. }
  339. .body_btns {
  340. display: flex;
  341. justify-content: space-between;
  342. align-items: center;
  343. margin: 40rpx 0;
  344. .btn {
  345. display: flex;
  346. align-items: center;
  347. justify-content: center;
  348. width: 310rpx;
  349. height: 72rpx;
  350. font-size: 32rpx;
  351. border-radius: 16rpx;
  352. }
  353. .pull {
  354. color: #fff;
  355. background-color: #ff8205;
  356. }
  357. .refund {
  358. color: #ff8205;
  359. border: 2rpx solid #ff8205;
  360. }
  361. }
  362. .body_rule {
  363. font-size: 36rpx;
  364. }
  365. .body_rule_img{
  366. width: 353rpx;
  367. height: 438rpx;
  368. background-size: 100%;
  369. }
  370. }
  371. }
  372. .pop {
  373. display: flex;
  374. flex-direction: column;
  375. align-items: center;
  376. box-sizing: border-box;
  377. padding-bottom: 60rpx;
  378. font-size: 32rpx;
  379. color: #001713;
  380. line-height: 46rpx;
  381. .pop_title {
  382. position: relative;
  383. height: 60rpx;
  384. width: 100%;
  385. background-color: #ff8205;
  386. .title_close {
  387. position: absolute;
  388. top: 6rpx;
  389. right: 30rpx;
  390. }
  391. }
  392. .pop_tips {
  393. margin-top: 24rpx;
  394. }
  395. .pop_msg {
  396. margin: 50rpx 0;
  397. width: 456rpx;
  398. }
  399. .pop_btn {
  400. display: flex;
  401. align-items: center;
  402. justify-content: center;
  403. width: 480rpx;
  404. height: 72rpx;
  405. color: #ff8205;
  406. border-radius: 16rpx;
  407. border: 2rpx solid #ff8205;
  408. }
  409. }
  410. </style>