transportation.vue 11 KB

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