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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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. if (state.vehiclePlateColor) {
  102. if (!state.vehiclePlate) {
  103. msg('请输入车牌')
  104. return;
  105. }
  106. }
  107. const options = {
  108. type: 2,
  109. data: {
  110. 'openId': getItem('openId'),
  111. 'pageNo': state.pageNo,
  112. 'pageSize': state.pageSize,
  113. 'vehicleId': state.vehiclePlate ? state.vehiclePlate + "_" + state.vehiclePlateColor : "",
  114. 'insertTimeStart': state.range[0] ? state.range[0] + ' 00:00:00' : state.range[0],
  115. 'insertTimeEnd': state.range[1] ? state.range[1] + ' 00:00:00' : state.range[1],
  116. 'cardId': state.cardId
  117. },
  118. method: "POST",
  119. showLoading: true,
  120. };
  121. console.log("data", state.vehiclePlate, state.vehiclePlateColor, state.range)
  122. request(queryCardRecord, options).then((res) => {
  123. let data = [...state.newList, ...stringToJson(res.bizContent).data]
  124. for (var i = 0; i < data.length; i++) {
  125. console.log("getCodeName", getCodeName('VCR_ORDER_STATUS', data[i]['status']))
  126. data[i]['payStatusC'] = getCodeName('VCR_ORDER_PAY_STATUS', data[i]['payStatus'])
  127. // 大于5分钟就不能去支付了
  128. data[i]['statusC'] = getCodeName('VCR_ORDER_STATUS', data[i]['status'])
  129. data[i]['vehiclePlateColorC'] = getVehiclePlateColor(data[i]['vehiclePlateColor'])
  130. }
  131. state.newList = data
  132. console.log("交易记录", state.newList)
  133. })
  134. }
  135. // 触底加载
  136. onReachBottom(() => {
  137. if (state.newList.length < state.pageNo * 16) return state.flags = true
  138. console.log("触底了")
  139. state.pageNo++
  140. getList()
  141. })
  142. const toTrap = (rechargeMoney) => {
  143. uni.navigateTo({
  144. url: `/subpackage/personal-center/trapping-and-repairing/recharge-pay?rechargeMoney=${rechargeMoney}&&payMoney=0`
  145. })
  146. }
  147. // 退款代码
  148. const queryRefound = (cardId, orderId) => {
  149. const options = {
  150. type: 2,
  151. data: {
  152. "orderId": orderId,
  153. "cardId": cardId,
  154. "openId": getItem(StorageKeys.OpenId),
  155. },
  156. method: 'POST',
  157. showLoading: true,
  158. }
  159. console.log("refundQuan", refundQuan, options)
  160. request(refundQuan, options).then((res) => {
  161. const data = stringToJson(res.bizContent);
  162. refoundResult(cardId, orderId);
  163. console.log("222", data)
  164. })
  165. }
  166. const refoundResult = (cardId, orderId) => {
  167. const options = {
  168. type: 2,
  169. data: {
  170. "orderId": orderId,
  171. "cardId": cardId,
  172. },
  173. method: 'POST',
  174. showLoading: true,
  175. }
  176. console.log("queryRefoundResult", queryRefoundResult, options)
  177. request(queryRefoundResult, options).then((res) => {
  178. const data = stringToJson(res.bizContent);
  179. console.log("data", data)
  180. if (data.refundStatus == "SUCCESS") {
  181. } else if (data.refundStatus == "CLOSED") {
  182. msg('退款关闭')
  183. } else if (data.refundStatus == "HANDLING") {
  184. msg('退款处理中')
  185. } else if (data.refundStatus == "EXCEPTION") {
  186. msg('退款异常')
  187. }
  188. setTimeout(() => {
  189. console.log("刷新")
  190. // 刷新列表
  191. state.pageNo == 1
  192. state.newList = []
  193. getList();
  194. }, 1500)
  195. })
  196. }
  197. // 退款代码完成
  198. // 去支付
  199. const pay = (rechargeMoney, orderNum) => {
  200. uni.navigateTo({
  201. url: `/subpackage/personal-center/trapping-and-repairing/recharge-pay?rechargeMoney=${rechargeMoney}&&payMoney=1&&orderNum=${orderNum}`
  202. })
  203. }
  204. </script>
  205. <style scoped>
  206. .noContent {
  207. text-align: center;
  208. margin-top: 100rpx;
  209. }
  210. .content {
  211. background-color: #EEF7F7;
  212. padding: 0 30rpx;
  213. overflow: hidden;
  214. font-size: 32rpx;
  215. min-height: 100vh;
  216. }
  217. .search_wrap {
  218. display: flex;
  219. margin: 20rpx 0;
  220. }
  221. .search_wrap>input {
  222. background-color: white;
  223. width: 76%;
  224. height: 40rpx;
  225. line-height: 40rpx;
  226. padding: 10rpx 10rpx;
  227. border-radius: 10rpx 0 0 10rpx;
  228. }
  229. .item {
  230. width: 100%;
  231. border-radius: 10rpx;
  232. box-sizing: border-box;
  233. padding: 30rpx 20rpx;
  234. margin-top: 30rpx;
  235. background: white;
  236. color: black;
  237. }
  238. .time {
  239. display: flex;
  240. margin-bottom: 16rpx;
  241. justify-content: space-between;
  242. }
  243. .payStatus {
  244. color: red;
  245. float: right;
  246. }
  247. .but-wrap {
  248. display: flex;
  249. justify-content: flex-end;
  250. margin-top: 10rpx;
  251. }
  252. .but-wrap>text {
  253. border: 1px solid #00b38b;
  254. color: #00b38b;
  255. height: 50rpx;
  256. line-height: 50rpx;
  257. border-radius: 30rpx;
  258. padding: 0 24rpx;
  259. font-size: 28rpx;
  260. box-sizing: border-box;
  261. margin-left: 12rpx;
  262. }
  263. .top-content {
  264. position: fixed;
  265. left: 0;
  266. top: 0;
  267. background-color: white;
  268. width: 100%;
  269. padding: 0 20rpx 20rpx 20rpx;
  270. box-sizing: border-box;
  271. z-index: 999999;
  272. }
  273. input,
  274. .uni-input {
  275. border: 1rpx solid #ccc;
  276. padding: 0 10rpx;
  277. height: 28rpx;
  278. line-height: 28rpx;
  279. }
  280. .input {
  281. display: flex;
  282. align-items: center;
  283. margin-bottom: 16rpx;
  284. }
  285. .input>text {
  286. display: inline-block;
  287. width: 24%;
  288. }
  289. .input>input {
  290. width: 47%;
  291. margin-top: 10rpx;
  292. font-size: 30rpx;
  293. }
  294. /deep/.last .uni-stat__select {
  295. width: 360rpx;
  296. }
  297. .example-body {
  298. display: flex;
  299. align-items: center;
  300. }
  301. /deep/.uni-date {
  302. width: 73% !important;
  303. }
  304. /deep/.uni-date__x-input,
  305. /deep/.uni-select {
  306. font-size: 13px;
  307. height: 24px;
  308. line-height: 24px;
  309. }
  310. /deep/.uni-date-x {
  311. height: 56rpx !important;
  312. }
  313. </style>