選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

upgrade-confirm.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <template>
  2. <view class="selectCar-box">
  3. <view class="details">
  4. <view class="title"> 基础信息 </view>
  5. <view class="details-item">
  6. <view> 订单编号: </view>
  7. <text>{{ orderInfos.orderId }}</text>
  8. </view>
  9. <view class="details-item">
  10. <view> 用户名称: </view>
  11. <text>{{ orderInfos.ownerName }}</text>
  12. </view>
  13. <view class="details-item">
  14. <view> 用户证件类型: </view>
  15. <text>{{ getCodeName('CERTIFICATE_TYPE',orderInfos.ownerIdtype) }}</text>
  16. </view>
  17. <view class="details-item">
  18. <view> 用户证件号: </view>
  19. <text>{{ orderInfos.ownerIdnum }}</text>
  20. </view>
  21. <view class="details-item">
  22. <view> 订单车牌号: </view>
  23. <text style="color: #00b38b">{{ orderInfos.vehiclePlate }}</text>
  24. </view>
  25. <view class="details-item">
  26. <view> 车牌颜色: </view>
  27. <text style="color: #00b38b">{{
  28. orderInfos.vehiclePlateColorStr
  29. }}</text>
  30. </view>
  31. <view class="details-item">
  32. <view> 收费车型: </view>
  33. <text>{{ orderInfos.vehicleType }}</text>
  34. </view>
  35. </view>
  36. <view class="title"> 卡信息 </view>
  37. <view class="card">
  38. <view class="card-left">
  39. <image :src="`${$imgUrl}card2.png`" mode=""></image>
  40. <view class="card-center">
  41. <view class="card-center-head"> {{orderInfos.cardId}} </view>
  42. <view class="tips">
  43. <text>储蓄卡</text>
  44. <text class="tips-card">{{getCodeName('CARD_STATE_TYPE',orderInfos.cardStatus)}}</text>
  45. </view>
  46. <view class="choose-item"> 有效期:{{orderInfos.cardEnableTime }}</view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="title"> OBU设备信息 </view>
  51. <view class="card">
  52. <view class="card-left">
  53. <image :src="`${$imgUrl}card1.png`" mode=""></image>
  54. <view class="card-center">
  55. <view class="card-center-head"> {{orderInfos.obuId}} </view>
  56. <view class="tips">
  57. <!-- <text>储蓄卡</text> -->
  58. <text class="tips-card">{{getCodeName('OBU_STATE_TYPE',orderInfos.obuStatus)}}</text>
  59. </view>
  60. <view class="choose-item"> 有效期:{{orderInfos.obuEnableTime }} </view>
  61. </view>
  62. </view>
  63. </view>
  64. <button class="submit" @click="toPage" v-if="!state.flag" :disabled="state.disabled">设备升级</button>
  65. <button class="submit" @click="toBack" v-else>返回服务中心</button>
  66. <view class="mask" v-show="state.showPopup">
  67. <view class="main">
  68. <view class="top">
  69. <image class="icon-close" :src="`${$imgUrl}common/icon-close.png`" @click="cancel"></image>
  70. </view>
  71. <image class="icon-success" :src="`${$imgUrl}bluetooth/card-success.png`"></image>
  72. <view class="title">设备升级成功!</view>
  73. </view>
  74. </view>
  75. </view>
  76. </template>
  77. <script setup>
  78. import {
  79. reactive
  80. } from "vue";
  81. import {
  82. navTo,
  83. getFormatDate
  84. } from "@/utils/utils";
  85. import {
  86. onLoad,
  87. onUnload,
  88. onShow
  89. } from "@dcloudio/uni-app";
  90. import {
  91. request
  92. } from "@/utils/network/request.js";
  93. import {
  94. orderDetail,
  95. deviceUpgrade,
  96. writeCardBack,
  97. cardModifyConfirm
  98. } from "@/utils/network/api.js";
  99. import {
  100. getCodeName
  101. } from "@/datas/queryKey.js";
  102. import {
  103. stringToJson
  104. } from "@/utils/network/encryption";
  105. const tools = require("../../../static/etcUtil/tools.js");
  106. const bluetoothUtil = require("../../../static/etcUtil/index.js");
  107. const state = reactive({
  108. showPopup: false,
  109. flag: false,
  110. disabled: false,
  111. })
  112. const orderInfos = reactive({
  113. orderId: "",
  114. ownerName: "",
  115. ownerIdtype: "",
  116. ownerIdnum: "",
  117. vehiclePlate: "",
  118. vehiclePlateColorStr: "",
  119. vehiclePlateColor: "",
  120. vehicleType: "",
  121. cardId: "",
  122. cardStatus: "",
  123. obuId: "",
  124. obuStatus: "",
  125. cardEnableTime: "",
  126. obuEnableTime: "",
  127. });
  128. onLoad((option) => {
  129. //请求订单详情
  130. queryOrderDetail(option.id);
  131. });
  132. onShow((option) => {
  133. uni.$on('bluetoothLink', res => {
  134. console.log(res);
  135. if (res.status) {
  136. tools.showLoadingAlert("正在执行指令");
  137. state.disabled = true;
  138. getDeviceUpgrade()
  139. }
  140. })
  141. })
  142. onUnload(() => {
  143. //移除监听
  144. uni.$off('bluetoothLink')
  145. })
  146. //获取订单详情
  147. const queryOrderDetail = (id) => {
  148. const options = {
  149. type: 2,
  150. data: {
  151. id: id,
  152. },
  153. method: "POST",
  154. showLoading: true,
  155. };
  156. request(orderDetail, options).then((res) => {
  157. let orderInfo = JSON.parse(res.bizContent);
  158. console.log(orderInfo);
  159. orderInfos.orderId = orderInfo.orderId;
  160. orderInfos.ownerName = orderInfo.ownerName;
  161. orderInfos.ownerIdtype = orderInfo.ownerIdtype;
  162. orderInfos.ownerIdnum = orderInfo.ownerIdnum;
  163. orderInfos.vehiclePlate = orderInfo.vehiclePlate;
  164. orderInfos.vehiclePlateColorStr = orderInfo.vehiclePlateColorStr;
  165. orderInfos.vehiclePlateColor = orderInfo.vehiclePlateColor;
  166. orderInfos.vehicleType = orderInfo.vehicleType;
  167. orderInfos.cardId = orderInfo.cardId;
  168. orderInfos.cardStatus = orderInfo.cardStatus;
  169. orderInfos.obuId = orderInfo.obuId;
  170. orderInfos.obuStatus = orderInfo.obuStatus;
  171. orderInfos.cardEnableTime = orderInfo.cardEnableTime.substring(0, 10);
  172. orderInfos.obuEnableTime = orderInfo.obuEnableTime.substring(0, 10);
  173. });
  174. };
  175. //设备升级 请求
  176. const getDeviceUpgrade = () => {
  177. const options = {
  178. type: 2,
  179. data: {
  180. cardId: orderInfos.cardId,
  181. orderId: orderInfos.orderId
  182. },
  183. method: "POST",
  184. showLoading: true,
  185. };
  186. request(deviceUpgrade, options).then((res) => {
  187. tools.hideLoadingAlert();
  188. let result = stringToJson(res.bizContent);
  189. console.log("&&&&&&&&&&&&", result);
  190. let cmdArray = result.command ? result.command.split(",") : "";
  191. if (cmdArray.length > 0) {
  192. tools.showLoadingAlert("正在执行指令");
  193. bluetoothUtil.transCmd(cmdArray, "10", function(res) {
  194. tools.hideLoadingAlert();
  195. let status = res[cmdArray.length - 1].substring(res[cmdArray.length - 1].length -
  196. 4, res[cmdArray.length - 1].length);
  197. if (status == "9000") {
  198. getCommandBack(result.command, result.cosRecordId, res.toString());
  199. }
  200. })
  201. }
  202. })
  203. };
  204. /**
  205. * 写卡指令返回 请求
  206. */
  207. const getCommandBack = (command, cosRecordId, response) => {
  208. console.log('======循环写卡指令中======')
  209. tools.showLoadingAlert("加载中");
  210. let options = {
  211. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  212. data: {
  213. cardId: orderInfos.cardId,
  214. orderId: orderInfos.orderId,
  215. command: command,
  216. response: response,
  217. cosRecordId: cosRecordId,
  218. cosType: 2
  219. }, //请求参数
  220. method: "POST", //提交方式(默认POST)
  221. showLoading: true, //是否显示加载中(默认显示)
  222. };
  223. //调用方式
  224. request(writeCardBack, options)
  225. .then((res) => {
  226. tools.hideLoadingAlert();
  227. let result = JSON.parse(res.bizContent);
  228. if (result.orderStatus == 1 || result.orderStatus == "1") {
  229. tools.showLoadingAlert("执行指令中");
  230. bluetoothUtil.transCmd(result.command.split(","), "10", function(res) {
  231. tools.hideLoadingAlert();
  232. let response = res.toString();
  233. getCommandBack(result.command, cosRecordId, response);
  234. });
  235. } else {
  236. getCardModifyConfirm(cosRecordId);
  237. }
  238. })
  239. };
  240. //卡信息变更确认
  241. const getCardModifyConfirm = (cosRecordId) => {
  242. const options = {
  243. type: 2,
  244. data: {
  245. cardId: orderInfos.cardId,
  246. operation: 4,
  247. cosRecordId: cosRecordId
  248. },
  249. method: "POST",
  250. showLoading: true,
  251. };
  252. request(cardModifyConfirm, options).then((res) => {
  253. console.log(res);
  254. state.showPopup = true;
  255. })
  256. };
  257. //去连接蓝牙
  258. const toPage = () => {
  259. // getDeviceUpgrade()
  260. navTo("/pages/bluetooth/bluetooth?routeType=5"); //去连接蓝牙
  261. };
  262. //返回列表
  263. const toBack = () => {
  264. uni.navigateBack({
  265. delta: 2
  266. })
  267. }
  268. //关闭弹窗
  269. const cancel = () => {
  270. state.flag = true;
  271. state.showPopup = false;
  272. uni.navigateTo({
  273. url: `/subpackage/after-sale/deviceInfo/deviceInfo`
  274. })
  275. }
  276. </script>
  277. <style>
  278. page {
  279. width: 100%;
  280. height: 100%;
  281. background-color: #fff;
  282. }
  283. </style>
  284. <style lang="scss" scoped>
  285. .mask {
  286. background: rgba(0, 0, 0, .35);
  287. position: fixed;
  288. left: 0;
  289. top: 0;
  290. bottom: 0;
  291. right: 0;
  292. }
  293. .main {
  294. width: 560rpx;
  295. padding: 25rpx 20rpx 55rpx;
  296. text-align: center;
  297. background: #fff;
  298. position: absolute;
  299. left: 50%;
  300. top: 50%;
  301. transform: translate(-50%, -50%);
  302. border-radius: 20rpx;
  303. .top {
  304. text-align: right;
  305. .icon-close {
  306. width: 48rpx;
  307. height: 48rpx;
  308. }
  309. }
  310. .icon-success {
  311. width: 500rpx;
  312. height: 320rpx;
  313. margin-top: 22rpx;
  314. }
  315. .title {
  316. color: #333333;
  317. font-size: 40rpx;
  318. font-weight: 600;
  319. text-align: center;
  320. margin-top: 55rpx;
  321. }
  322. }
  323. .selectCar-box {
  324. // width: 100%;
  325. // height: 100%;
  326. padding: 30rpx;
  327. .title {
  328. font-size: 30rpx;
  329. font-family: Microsoft YaHei UI;
  330. font-weight: 400;
  331. color: #333333;
  332. margin-bottom: 30rpx;
  333. }
  334. .details {
  335. .title {
  336. font-size: 30rpx;
  337. font-family: Microsoft YaHei UI;
  338. font-weight: 400;
  339. color: #333333;
  340. margin-bottom: 30rpx;
  341. }
  342. .details-item {
  343. display: flex;
  344. font-size: 26rpx;
  345. font-family: Noto Sans S Chinese;
  346. font-weight: 400;
  347. color: #999999;
  348. margin-bottom: 30rpx;
  349. text {
  350. font-size: 26rpx;
  351. font-family: Noto Sans S Chinese;
  352. font-weight: 400;
  353. color: #333333;
  354. }
  355. }
  356. }
  357. .card {
  358. height: 150rpx;
  359. background: #ffffff;
  360. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  361. border-radius: 20rpx;
  362. padding: 30rpx;
  363. display: flex;
  364. justify-content: space-between;
  365. align-items: center;
  366. margin-bottom: 60rpx;
  367. .card-left {
  368. display: flex;
  369. align-items: center;
  370. image {
  371. width: 100rpx;
  372. height: 90rpx;
  373. }
  374. .card-center {
  375. margin-left: 30rpx;
  376. .card-center-head {
  377. font-size: 32rpx;
  378. font-family: Noto Sans S Chinese;
  379. font-weight: 400;
  380. color: #333333;
  381. }
  382. .tips {
  383. font-size: 26rpx;
  384. font-family: Noto Sans S Chinese;
  385. font-weight: 400;
  386. color: #666666;
  387. .tips-card {
  388. width: 70rpx;
  389. height: 40rpx;
  390. background: #d3f2ef;
  391. border-radius: 6rpx;
  392. font-size: 20rpx;
  393. font-family: Noto Sans S Chinese;
  394. font-weight: 400;
  395. color: #0a8f8a;
  396. padding: 5rpx 10rpx;
  397. margin-left: 20rpx;
  398. }
  399. }
  400. }
  401. }
  402. .choose-item {
  403. margin-right: 20rpx;
  404. height: 50rpx;
  405. border-radius: 50%;
  406. display: flex;
  407. justify-content: flex-start;
  408. align-items: center;
  409. font-size: 25rpx;
  410. align-self: end;
  411. .active {
  412. width: 38rpx;
  413. height: 38rpx;
  414. background: #00b38b;
  415. border-radius: 50%;
  416. }
  417. }
  418. }
  419. .remark {
  420. font-size: 26rpx;
  421. font-family: Microsoft YaHei UI;
  422. font-weight: 400;
  423. color: #666666;
  424. text-indent: 30rpx;
  425. margin-bottom: 30rpx;
  426. }
  427. .submit {
  428. margin-top: 100rpx;
  429. width: 670rpx;
  430. height: 80rpx;
  431. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  432. border-radius: 40rpx;
  433. font-size: 32rpx;
  434. font-family: Noto Sans S Chinese;
  435. font-weight: 400;
  436. color: #ffffff;
  437. line-height: 80rpx;
  438. }
  439. .submit::after {
  440. border: 0;
  441. }
  442. .submit[disabled] {
  443. background: #f0f0f0;
  444. color: #333;
  445. }
  446. }
  447. </style>