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.

order-confirm-receipt.vue 6.5KB

1 년 전
1 년 전
1 년 전
1 년 전
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <!-- 订单详情-确认收货 -->
  2. <template>
  3. <view class="card-box">
  4. <view class="as-layout-horizontal as-gravity-center-start title">
  5. <image :src="`${$imgUrl}order/icon-star-green.png`" class="icon"></image>
  6. <text class="txt-title">{{ state.orderInfo.productName }}</text>
  7. </view>
  8. <view style="border-bottom: 1px solid #dcdcdc" />
  9. <!-- 订单信息 -->
  10. <view class="order-box">
  11. <view class="order-item" v-for="(item, index) in state.list" :key="index">
  12. <order-info-item :label="item.label" :value="item.value"></order-info-item>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="hint">请核对实收货物与上述货物编号是否一致!</view>
  17. <view class="btn">
  18. <submit-button title="确认收货" @submit="$util.confirm('是否确认收到货?', confirmReceiptClick, '收货确认')"></submit-button>
  19. </view>
  20. </template>
  21. <script setup lang="ts">
  22. import orderInfoItem from "./components/order-info-item";
  23. import { reactive } from "vue";
  24. import { onLoad, onUnload, onShow } from "@dcloudio/uni-app";
  25. import { request } from "@/utils/network/request.js";
  26. import { msg, confirm, getOrderStatusName, navTo } from "@/utils/utils";
  27. import { orderDetail, receiveOrder } from "@/utils/network/api";
  28. import { getItem, StorageKeys } from "@/utils/storage";
  29. import { stringToJson } from "@/utils/network/encryption";
  30. const bluetoothUtil = require("../../static/etcUtil/index.js");
  31. const cmd = require("../../static/etcUtil/cmdConfig.js");
  32. const tools = require("../../static/etcUtil/tools.js");
  33. const state = reactive({
  34. //订单信息
  35. orderInfo: {} as any,
  36. //显示订单信息
  37. list: [
  38. {
  39. label: "订单编号:",
  40. value: "",
  41. },
  42. {
  43. label: "订单车牌:",
  44. value: "",
  45. },
  46. {
  47. label: "订单状态:",
  48. value: "",
  49. },
  50. {
  51. label: "发货卡号:",
  52. value: "",
  53. },
  54. {
  55. label: "发货签号:",
  56. value: "",
  57. },
  58. ],
  59. readCardId: "",//蓝牙读取的
  60. readObuId: "",//蓝牙读取的
  61. });
  62. onShow((option) => {
  63. uni.$on('bluetoothLink', res => {
  64. console.log(res);
  65. if (res.status) {
  66. getCardId()
  67. }
  68. })
  69. })
  70. /**
  71. * 获取卡号 读卡
  72. */
  73. const getCardId = () => {
  74. console.log('======获取卡信息======')
  75. let cmdArr = [
  76. cmd.HOME_DIRECTORY,
  77. //选择主目
  78. cmd.APPLICATION_DIRECTORY,
  79. //选择文件1001--DF01联网收费应用目录
  80. cmd.CMD_READBINARY,
  81. //15文件--卡片发行基本数据文件
  82. cmd.CMD_GETBALANCE
  83. //钱包
  84. ];
  85. tools.showLoadingAlert("正在执行指令");
  86. bluetoothUtil.transCmd(cmdArr, "10", function (res) {
  87. tools.hideLoadingAlert();
  88. //10:写卡 20:写OBU
  89. let str = res[2].substring(res[2].length - 4, res[2].length);
  90. let str3 = res[3].substring(res[3].length - 4, res[3].length);
  91. if (str == "9000" || str3 == "9000") {
  92. if (res[2].length > 86 || res[3] >= 12) {
  93. state.readCardId = res[2].substring(20, 40); //卡号
  94. if (state.orderInfo.cardId != state.readCardId) {
  95. uni.showModal({
  96. title: '提示',
  97. content: '卡号不一致,前往订单管理页面申请退货',
  98. showCancel: false,
  99. success: function (res) {
  100. if (res.confirm) {
  101. console.log('用户点击确定');
  102. uni.switchTab({
  103. url: "/pages/order/order"
  104. })
  105. } else if (res.cancel) {
  106. console.log('用户点击取消');
  107. }
  108. }
  109. });
  110. } else {
  111. getObuId()
  112. }
  113. } else {
  114. console.error("CMD_READBINARY指令长度不符" + res[2])
  115. tools.hideLoadingAlert();
  116. }
  117. }
  118. tools.hideLoadingAlert();
  119. });
  120. };
  121. /**
  122. * 获取OBU号 读OBU
  123. */
  124. const getObuId = () => {
  125. console.log('======获取OBU号======')
  126. let cmdArray = [cmd.HOME_DIRECTORY, cmd.OBU_SYSTEM_FILE, cmd.RANDOM_NUMBER];
  127. tools.showLoadingAlert("正在执行指令");
  128. bluetoothUtil.transCmd(cmdArray, "20", function (res) {
  129. tools.hideLoadingAlert();
  130. var status = res[1].substring(res[1].length - 4, res[1].length);
  131. console.log('获取OBU号执行结果' + status, res)
  132. //第一次获取随机数
  133. if (status == "9000") {
  134. state.readObuId = res[1].substring(20, 36);
  135. if (state.orderInfo.obuId != state.readObuId) {
  136. uni.showModal({
  137. title: '提示',
  138. content: '签号不一致,前往订单管理页面申请退货',
  139. showCancel: false,
  140. success: function (res) {
  141. if (res.confirm) {
  142. console.log('用户点击确定');
  143. uni.switchTab({
  144. url: "/pages/order/order"
  145. })
  146. } else if (res.cancel) {
  147. console.log('用户点击取消');
  148. }
  149. }
  150. });
  151. } else {
  152. // 确认收货
  153. confirmReceipt()
  154. }
  155. }
  156. });
  157. };
  158. const confirmReceipt = () => {
  159. const options = {
  160. type: 2,
  161. data: {
  162. id: state.orderInfo.id,
  163. source: "WECHAT",
  164. opId: getItem(StorageKeys.OpenId),
  165. },
  166. method: "POST",
  167. showLoading: true,
  168. };
  169. request(receiveOrder, options).then((res) => {
  170. confirm(
  171. "您已完成订单收货",
  172. () => {
  173. uni.$emit("refreshOrder");
  174. uni.navigateBack();
  175. },
  176. "收货完成",
  177. false
  178. );
  179. });
  180. }
  181. onUnload(() => {
  182. //移除监听
  183. uni.$off('bluetoothLink')
  184. })
  185. //确认收货
  186. const confirmReceiptClick = (e) => {
  187. navTo("/pages/bluetooth/bluetooth?routeType=5"); //去连接蓝牙
  188. };
  189. //获取订单详情
  190. const getOrderDetails = (id) => {
  191. const options = {
  192. type: 2,
  193. data: { id: id },
  194. method: "POST",
  195. showLoading: true,
  196. };
  197. request(orderDetail, options).then((res) => {
  198. state.orderInfo = stringToJson(res.bizContent);
  199. state.list[0].value = state.orderInfo.orderId;
  200. state.list[1].value = state.orderInfo.vehiclePlate;
  201. state.list[2].value = getOrderStatusName(state.orderInfo.orderStep);
  202. state.list[3].value = state.orderInfo.cardId ? state.orderInfo.cardId : "";
  203. state.list[4].value = state.orderInfo.obuId ? state.orderInfo.obuId : "";
  204. });
  205. };
  206. onLoad((options) => {
  207. getOrderDetails(options.id);
  208. });
  209. </script>
  210. <style>
  211. page {
  212. background-color: #eef7f7;
  213. }
  214. </style>
  215. <style lang="scss" scoped>
  216. .card-box {
  217. background-color: white;
  218. border-radius: 20rpx;
  219. box-shadow: 0px 0px 6rpx 2rpx rgba(223, 223, 223, 0.3);
  220. margin: 30rpx;
  221. padding: 20rpx 0;
  222. .title {
  223. padding: 0 20rpx 20rpx;
  224. }
  225. .icon {
  226. width: 48rpx;
  227. height: 48rpx;
  228. margin-right: 10rpx;
  229. }
  230. .txt-title {
  231. font-size: 30rpx;
  232. color: #333333;
  233. }
  234. .order-box {
  235. padding: 0px 30rpx 10rpx;
  236. .order-item {
  237. padding: 28rpx 0px 0px;
  238. }
  239. }
  240. }
  241. .hint {
  242. font-size: 28rpx;
  243. color: #ff8000;
  244. margin-top: 60rpx;
  245. text-align: center;
  246. }
  247. .btn {
  248. margin: 500rpx 40rpx 50rpx;
  249. }
  250. </style>