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 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <view class='content'>
  3. <view class="top-content">
  4. <view class="input">
  5. <text>车牌号:</text>
  6. <input placeholder="请输入车牌号" v-model="state.vehiclePlate" />
  7. </view>
  8. <view class="last input">
  9. <text>车牌颜色:</text>
  10. <uni-data-select v-model="state.vehiclePlateColor" :localdata="state.colorRange" @change="changeColor"
  11. :clear="false"></uni-data-select>
  12. </view>
  13. <view class="example-body">
  14. <uni-datetime-picker v-model="state.range" type="daterange" />
  15. <button size="mini" style="color: #ffffff;
  16. backgroundColor: rgb(118, 200, 77);
  17. borderColor: rgb(118, 200, 77);
  18. font-size: 26rpx;
  19. flex-shrink: 0;margin-left: 20rpx;" @click="search()">搜索</button>
  20. </view>
  21. </view>
  22. <view style="margin-top: 250rpx;">
  23. <view class='item' v-for="(item,index) in state.newList">
  24. <view>ETC卡号:{{item.cardId}}<text class="payStatus">{{item.statusC}}</text></view>
  25. <view>充值金额:¥{{item.rechargeMoney/100}}</view>
  26. <view>车牌号:{{item.vehiclePlate}}</view>
  27. <view>车牌颜色:{{item.vehiclePlateColorC}}</view>
  28. <view>创建时间:{{item.insertTime}}</view>
  29. <view>圈存状态:{{item.chargeStatus}}</view>
  30. <!-- 支付成功和未圈存 -->
  31. <view class="but-wrap" v-if="item.statusC =='待支付'">
  32. <text @click="pay(item.rechargeMoney,item.orderNum)">去支付</text>
  33. </view>
  34. <view class="but-wrap" v-else-if="item.statusC =='已支付' && item.chargeStatus=='未圈存'">
  35. <text @click="toTrap(item.rechargeMoney)">修复</text>
  36. <text @click="queryRefound(item.cardId,item.orderNum)">退款</text>
  37. </view>
  38. </view>
  39. <view style="text-align: center;margin: 20rpx;" v-if="state.flags">我是有底线的~</view>
  40. <view class="noContent" v-if="!state.newList.length">暂无消费明细</view>
  41. </view>
  42. </view>
  43. </template>
  44. <script lang="ts" setup>
  45. import { reactive } from "vue";
  46. import { request } from "@/utils/network/request.js";
  47. import { queryCardRecord, refundQuan, queryRefoundResult } from "@/utils/network/api.js";
  48. import { stringToJson } from "@/utils/network/encryption.js";
  49. import { onLoad, onReachBottom, onShow } from "@dcloudio/uni-app";
  50. import { getItem, StorageKeys } from "@/utils/storage";
  51. import { getCodeName } from "@/datas/queryKey.js";
  52. import {
  53. navTo, msg, timesDiff
  54. } from "@/utils/utils";
  55. import { getVehiclePlateColor } from "@/datas/vehiclePlateColor";
  56. const state = reactive({
  57. list: '', //所有数据
  58. newList: '', //最终展示的
  59. cardId: '',
  60. value: '',//input框里的值
  61. pageNo: 1,
  62. pageSize: 16,
  63. flags: false,
  64. vehiclePlate: "",
  65. vehiclePlateColor: "",
  66. colorRange: [],
  67. range: ['', ''],
  68. })
  69. onLoad((option : any) => {
  70. console.log("option", option)
  71. state.cardId = option.cardId;
  72. let getColor = getItem('key')['VEHICLE_COLOR_TYPE'];
  73. for (var k = 0; k < getColor.length; k++) {
  74. let obj = {};
  75. obj['value'] = getColor[k]['code']
  76. obj['text'] = getColor[k]['name']
  77. state.colorRange.push(obj)
  78. }
  79. })
  80. onShow(() => {
  81. state.pageNo = 1
  82. state.newList = []
  83. getList();
  84. })
  85. const search = () => {
  86. state.pageNo = 1
  87. state.newList = []
  88. getList();
  89. }
  90. const changeColor = (e) => {
  91. state.vehiclePlateColor = e
  92. console.log(e)
  93. }
  94. const getList = () => {
  95. if (state.vehiclePlate) {
  96. if (!state.vehiclePlateColor) {
  97. msg('请选择车牌颜色')
  98. return;
  99. }
  100. }
  101. const options = {
  102. type: 2,
  103. data: {
  104. 'openId': getItem('openId'),
  105. 'pageNo': state.pageNo,
  106. 'pageSize': state.pageSize,
  107. 'vehicleId': state.vehiclePlate ? state.vehiclePlate + "_" + state.vehiclePlateColor : "",
  108. 'insertTimeStart': state.range[0] ? state.range[0] + ' 00:00:00' : state.range[0],
  109. 'insertTimeEnd': state.range[1] ? state.range[1] + ' 00:00:00' : state.range[1],
  110. 'cardId': state.cardId
  111. },
  112. method: "POST",
  113. showLoading: true,
  114. };
  115. console.log("data", state.vehiclePlate, state.vehiclePlateColor, state.range)
  116. request(queryCardRecord, options).then((res) => {
  117. let data = [...state.newList, ...stringToJson(res.bizContent).data]
  118. for (var i = 0; i < data.length; i++) {
  119. console.log("getCodeName", getCodeName('VCR_ORDER_STATUS', data[i]['status']))
  120. data[i]['payStatusC'] = getCodeName('VCR_ORDER_PAY_STATUS', data[i]['payStatus'])
  121. // 大于5分钟就不能去支付了
  122. data[i]['statusC'] = getCodeName('VCR_ORDER_STATUS', data[i]['status'])
  123. data[i]['vehiclePlateColorC'] = getVehiclePlateColor(data[i]['vehiclePlateColor'])
  124. }
  125. state.newList = data
  126. console.log("交易记录", state.newList)
  127. })
  128. }
  129. // 触底加载
  130. onReachBottom(() => {
  131. if (state.newList.length < state.pageNo * 16) return state.flags = true
  132. console.log("触底了")
  133. state.pageNo++
  134. getList()
  135. })
  136. const toTrap = (rechargeMoney) => {
  137. uni.navigateTo({
  138. url: `/subpackage/personal-center/trapping-and-repairing/recharge-pay?rechargeMoney=${rechargeMoney}&&payMoney=0`
  139. })
  140. }
  141. // 退款代码
  142. const queryRefound = (cardId, orderId) => {
  143. const options = {
  144. type: 2,
  145. data: {
  146. "orderId": orderId,
  147. "cardId": cardId,
  148. "openId": getItem(StorageKeys.OpenId),
  149. },
  150. method: 'POST',
  151. showLoading: true,
  152. }
  153. console.log("refundQuan", refundQuan, options)
  154. request(refundQuan, options).then((res) => {
  155. const data = stringToJson(res.bizContent);
  156. refoundResult(cardId, orderId);
  157. console.log("222", data)
  158. })
  159. }
  160. const refoundResult = (cardId, orderId) => {
  161. const options = {
  162. type: 2,
  163. data: {
  164. "orderId": orderId,
  165. "cardId": cardId,
  166. },
  167. method: 'POST',
  168. showLoading: true,
  169. }
  170. console.log("queryRefoundResult", queryRefoundResult, options)
  171. request(queryRefoundResult, options).then((res) => {
  172. const data = stringToJson(res.bizContent);
  173. console.log("data", data)
  174. if (data.refundStatus == "SUCCESS") {
  175. } else if (data.refundStatus == "CLOSED") {
  176. msg('退款关闭')
  177. } else if (data.refundStatus == "HANDLING") {
  178. msg('退款处理中')
  179. } else if (data.refundStatus == "EXCEPTION") {
  180. msg('退款异常')
  181. }
  182. setTimeout(() => {
  183. console.log("刷新")
  184. // 刷新列表
  185. state.pageNo == 1
  186. getList();
  187. }, 1500)
  188. })
  189. }
  190. // 退款代码完成
  191. // 去支付
  192. const pay = (rechargeMoney, orderNum) => {
  193. uni.navigateTo({
  194. url: `/subpackage/personal-center/trapping-and-repairing/recharge-pay?rechargeMoney=${rechargeMoney}&&payMoney=1&&orderNum=${orderNum}`
  195. })
  196. }
  197. </script>
  198. <style scoped>
  199. .noContent {
  200. text-align: center;
  201. margin-top: 100rpx;
  202. }
  203. .content {
  204. background-color: #EEF7F7;
  205. padding: 0 30rpx;
  206. overflow: hidden;
  207. font-size: 32rpx;
  208. min-height: 100vh;
  209. }
  210. .search_wrap {
  211. display: flex;
  212. margin: 20rpx 0;
  213. }
  214. .search_wrap>input {
  215. background-color: white;
  216. width: 76%;
  217. height: 40rpx;
  218. line-height: 40rpx;
  219. padding: 10rpx 10rpx;
  220. border-radius: 10rpx 0 0 10rpx;
  221. }
  222. .item {
  223. width: 100%;
  224. border-radius: 10rpx;
  225. box-sizing: border-box;
  226. padding: 30rpx 20rpx;
  227. margin-top: 30rpx;
  228. background: white;
  229. color: black;
  230. }
  231. .time {
  232. display: flex;
  233. margin-bottom: 16rpx;
  234. justify-content: space-between;
  235. }
  236. .payStatus {
  237. color: red;
  238. float: right;
  239. }
  240. .but-wrap {
  241. display: flex;
  242. justify-content: flex-end;
  243. margin-top: 10rpx;
  244. }
  245. .but-wrap>text {
  246. border: 1px solid #00b38b;
  247. color: #00b38b;
  248. height: 50rpx;
  249. line-height: 50rpx;
  250. border-radius: 30rpx;
  251. padding: 0 24rpx;
  252. font-size: 28rpx;
  253. box-sizing: border-box;
  254. margin-left: 12rpx;
  255. }
  256. .top-content {
  257. position: fixed;
  258. left: 0;
  259. top: 0;
  260. background-color: white;
  261. width: 100%;
  262. padding: 0 20rpx 20rpx 20rpx;
  263. box-sizing: border-box;
  264. z-index: 999999;
  265. }
  266. input,
  267. .uni-input {
  268. border: 1rpx solid #ccc;
  269. padding: 0 10rpx;
  270. height: 28rpx;
  271. line-height: 28rpx;
  272. }
  273. .input {
  274. display: flex;
  275. align-items: center;
  276. margin-bottom: 16rpx;
  277. }
  278. .input>text {
  279. display: inline-block;
  280. width: 24%;
  281. }
  282. .input>input {
  283. width: 47%;
  284. margin-top: 10rpx;
  285. font-size: 30rpx;
  286. }
  287. /deep/.last .uni-stat__select {
  288. width: 360rpx;
  289. }
  290. .example-body {
  291. display: flex;
  292. align-items: center;
  293. }
  294. /deep/.uni-date {
  295. width: 73% !important;
  296. }
  297. /deep/.uni-date__x-input,
  298. /deep/.uni-select {
  299. font-size: 13px;
  300. height: 24px;
  301. line-height: 24px;
  302. }
  303. /deep/.uni-date-x {
  304. height: 56rpx !important;
  305. }
  306. </style>