You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

consumption-record.vue 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view class='content'>
  3. <view class='item' v-for="(item,index) in state.newList">
  4. <view>ETC卡号:{{item.cardId}}<text class="payStatus">{{item.payStatusC}}</text></view>
  5. <view>充值金额:¥{{item.rechargeMoney/100}}</view>
  6. <view>申请时间:{{item.insertTime}}</view>
  7. <view>圈存状态:{{item.statusC}}</view>
  8. <!-- 支付成功和未圈存 -->
  9. <view class="but-wrap" v-if="item.statusC =='待支付'">
  10. <text @click="pay(item.rechargeMoney,item.orderNum)">去支付</text>
  11. </view>
  12. <view class="but-wrap" v-else-if="item.statusC =='已支付' && item.chargeStatus=='未圈存'">
  13. <text @click="toTrap(item.rechargeMoney)">修复</text>
  14. <text @click="queryRefound(item.cardId,item.orderNum)">退款</text>
  15. </view>
  16. </view>
  17. <view style="text-align: center;margin: 20rpx;" v-if="state.flags">我是有底线的~</view>
  18. </view>
  19. <view class="noContent" v-if="!state.newList.length">暂无消费明细</view>
  20. </template>
  21. <script lang="ts" setup>
  22. import { reactive } from "vue";
  23. import { request } from "@/utils/network/request.js";
  24. import { queryCardRecord, refundQuan, queryRefoundResult } from "@/utils/network/api.js";
  25. import { stringToJson } from "@/utils/network/encryption.js";
  26. import { onLoad, onReachBottom, onShow } from "@dcloudio/uni-app";
  27. import { getItem, StorageKeys } from "@/utils/storage";
  28. import { getCodeName } from "@/datas/queryKey.js";
  29. import {
  30. navTo, msg, timesDiff
  31. } from "@/utils/utils";
  32. const state = reactive({
  33. list: '', //所有数据
  34. newList: '', //最终展示的
  35. cardId: '',
  36. value: '',//input框里的值
  37. pageNo: 1,
  38. pageSize: 16,
  39. flags: false,
  40. })
  41. onLoad((option : any) => {
  42. console.log("option", option)
  43. state.cardId = option.cardId;
  44. getList();
  45. })
  46. onShow(() => {
  47. state.pageNo = 1
  48. state.newList = []
  49. getList();
  50. })
  51. const getList = () => {
  52. const options = {
  53. type: 2,
  54. data: {
  55. 'cardId': state.cardId,
  56. // 'cardId': "52011328220202137230",
  57. 'openId': getItem('openId'),
  58. 'pageNo': state.pageNo,
  59. 'pageSize': state.pageSize
  60. },
  61. method: "POST",
  62. showLoading: true,
  63. };
  64. request(queryCardRecord, options).then((res) => {
  65. let data = [...state.newList, ...stringToJson(res.bizContent).data]
  66. for (var i = 0; i < data.length; i++) {
  67. console.log("getCodeName", getCodeName('VCR_ORDER_STATUS', data[i]['status']))
  68. data[i]['payStatusC'] = getCodeName('VCR_ORDER_PAY_STATUS', data[i]['payStatus'])
  69. // 大于5分钟就不能去支付了
  70. data[i]['statusC'] = getCodeName('VCR_ORDER_STATUS', data[i]['status'])
  71. }
  72. state.newList = data
  73. console.log("交易记录", state.newList)
  74. })
  75. }
  76. // 触底加载
  77. onReachBottom(() => {
  78. if (state.newList.length < state.pageNo * 16) return state.flags = true
  79. console.log("触底了")
  80. state.pageNo++
  81. getList()
  82. })
  83. const toTrap = (rechargeMoney) => {
  84. uni.navigateTo({
  85. url: `/subpackage/personal-center/trapping-and-repairing/recharge-pay?rechargeMoney=${rechargeMoney}&&payMoney=0`
  86. })
  87. }
  88. // 退款代码
  89. const queryRefound = (cardId, orderId) => {
  90. const options = {
  91. type: 2,
  92. data: {
  93. "orderId": orderId,
  94. "cardId": cardId,
  95. "openId": getItem(StorageKeys.OpenId),
  96. },
  97. method: 'POST',
  98. showLoading: true,
  99. }
  100. console.log("refundQuan", refundQuan, options)
  101. request(refundQuan, options).then((res) => {
  102. const data = stringToJson(res.bizContent);
  103. refoundResult(cardId, orderId);
  104. console.log("222", data)
  105. })
  106. }
  107. const refoundResult = (cardId, orderId) => {
  108. const options = {
  109. type: 2,
  110. data: {
  111. "orderId": orderId,
  112. "cardId": cardId,
  113. },
  114. method: 'POST',
  115. showLoading: true,
  116. }
  117. console.log("queryRefoundResult", queryRefoundResult, options)
  118. request(queryRefoundResult, options).then((res) => {
  119. const data = stringToJson(res.bizContent);
  120. console.log("data", data)
  121. if (data.refundStatus == "SUCCESS") {
  122. // 刷新列表
  123. state.pageNo == 1
  124. getList();
  125. } else if (data.refundStatus == "CLOSED") {
  126. msg('退款关闭')
  127. } else if (data.refundStatus == "HANDLING") {
  128. msg('退款处理中')
  129. } else if (data.refundStatus == "EXCEPTION") {
  130. msg('退款异常')
  131. }
  132. })
  133. }
  134. // 退款代码完成
  135. // 去支付
  136. const pay = (rechargeMoney, orderNum) => {
  137. uni.navigateTo({
  138. url: `/subpackage/personal-center/trapping-and-repairing/recharge-pay?rechargeMoney=${rechargeMoney}&&payMoney=1&&orderNum=${orderNum}`
  139. })
  140. }
  141. </script>
  142. <style scoped>
  143. .noContent {
  144. text-align: center;
  145. margin-top: 100rpx;
  146. }
  147. .content {
  148. background-color: #EEF7F7;
  149. padding: 0 30rpx;
  150. overflow: hidden;
  151. font-size: 32rpx;
  152. min-height: 100vh;
  153. }
  154. .search_wrap {
  155. display: flex;
  156. margin: 20rpx 0;
  157. }
  158. .search_wrap>input {
  159. background-color: white;
  160. width: 76%;
  161. height: 40rpx;
  162. line-height: 40rpx;
  163. padding: 10rpx 10rpx;
  164. border-radius: 10rpx 0 0 10rpx;
  165. }
  166. .item {
  167. width: 100%;
  168. border-radius: 10rpx;
  169. box-sizing: border-box;
  170. padding: 30rpx 20rpx;
  171. margin-top: 30rpx;
  172. /* background:linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%); */
  173. background: white;
  174. color: black;
  175. }
  176. .time {
  177. display: flex;
  178. margin-bottom: 16rpx;
  179. justify-content: space-between;
  180. }
  181. .payStatus {
  182. color: red;
  183. float: right;
  184. }
  185. .but-wrap {
  186. display: flex;
  187. justify-content: flex-end;
  188. margin-top: 10rpx;
  189. }
  190. .but-wrap>text {
  191. border: 1px solid #00b38b;
  192. color: #00b38b;
  193. height: 50rpx;
  194. line-height: 50rpx;
  195. border-radius: 30rpx;
  196. padding: 0 24rpx;
  197. font-size: 28rpx;
  198. box-sizing: border-box;
  199. margin-left: 12rpx;
  200. }
  201. </style>