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.

upload-card.vue 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <view class="upload-box">
  3. <u-form :model="form" ref="myForm" :error-type="errorType">
  4. <view class="from">
  5. <view class="title"> 请填写注销原因 </view>
  6. <u-form-item prop="remark">
  7. <view class="from_item">
  8. <text><text style="color: red"></text>注销原因:</text>
  9. <view style="display: flex">
  10. <u-input v-model="form.ReasonCancellation" @click="showPicker()" class="input" disabled
  11. placeholder="请选择" />
  12. <u-icon name="arrow-right" style="margin-left: 10px;display: flex;"></u-icon>
  13. </view>
  14. </view>
  15. </u-form-item>
  16. </view>
  17. </u-form>
  18. <button class="submit" @click="toPage()">注销</button>
  19. <!-- 选择弹窗 -->
  20. <view>
  21. <!-- 原因 -->
  22. <u-select v-model="show" mode="single-column" :list="list" @confirm="confirm"></u-select>
  23. </view>
  24. </view>
  25. </template>
  26. <script lang="ts" setup>
  27. import {
  28. reactive,
  29. ref
  30. } from "vue";
  31. import {
  32. onLoad,
  33. onShow,
  34. onReady
  35. } from "@dcloudio/uni-app";
  36. import {
  37. navTo,
  38. checkStr
  39. } from "@/utils/utils";
  40. import {
  41. request
  42. } from "../../utils/network/request.js";
  43. import {
  44. writeCardBack,
  45. CardSignCancellation,
  46. confirmSignCancellation
  47. } from "../../utils/network/api.js";
  48. import {
  49. stringToJson
  50. } from "../../utils/network/encryption.js";
  51. const bluetoothUtil = require("../../static/etcUtil/index.js");
  52. // 表单数据
  53. const form = reactive({
  54. obuId: '',
  55. cardId: '',
  56. orderId: '',
  57. ReasonCancellation: "",
  58. equipmentState: ''
  59. });
  60. const list = reactive([{
  61. //原因
  62. value: "原因1",
  63. label: "原因1",
  64. },
  65. {
  66. value: "原因1",
  67. label: "原因1",
  68. },
  69. {
  70. value: "原因1",
  71. label: "原因1",
  72. },
  73. ]);
  74. // 验证提示类型(toast要版本为1.3.5才支持)
  75. const errorType = ["border-bottom", "toast"];
  76. // 设置验证规则
  77. const myForm = ref(null);
  78. onReady(() => {
  79. });
  80. onLoad((option) => {
  81. form.obuId = option.obuId;
  82. form.cardId = option.cardId;
  83. form.orderId = option.orderId
  84. form.equipmentState = option.equipmentState
  85. /*监听蓝牙回调*/
  86. uni.$on('bluetoothLink', function(status) {
  87. queryCardSignCancellation(1, 1, 1).then((item: any) => {
  88. instructAction(item).then(value => {
  89. if (value.orderStatus === 1) {
  90. instructAction(item)
  91. } else {
  92. queryConfirmSignCancellation(0).then((val: any) => {
  93. console.log(val)
  94. navTo("/after-sale/ETC-log-off/log-off-result");
  95. })
  96. }
  97. })
  98. })
  99. })
  100. });
  101. onUnload(() => {
  102. /*移除监听*/
  103. uni.$off('bluetoothLink')
  104. });
  105. const show = ref(false);
  106. const showPicker = function() {
  107. show.value = true;
  108. };
  109. // 选择物流
  110. const confirm = (e) => {
  111. console.log(e);
  112. form.ReasonCancellation = e[0].value;
  113. };
  114. const toPage = () => {
  115. //参数说明
  116. let options = {};
  117. if (form.equipmentState === '1') {
  118. navTo("/pages/bluetooth/bluetooth&&routeType=5");
  119. } else {
  120. queryCardSignCancellation(0, 0, 0).then((item: any) => {
  121. queryConfirmSignCancellation(0).then((val: any) => {
  122. console.log(val)
  123. navTo("/after-sale/ETC-log-off/log-off-result");
  124. })
  125. })
  126. }
  127. };
  128. /*指令返回*/
  129. const instructAction = (data) => {
  130. let cmdArr = data.command.split(",");
  131. console.log(cmdArr);
  132. bluetoothUtil.transCmd(cmdArr, "10", function(res) {
  133. console.log("透传");
  134. console.log(res);
  135. var arraylenth = res.length;
  136. var status = res[arraylenth - 1].substring(
  137. res[arraylenth - 1].length - 4,
  138. res[arraylenth - 1].length
  139. );
  140. console.log("打印指令状态");
  141. console.log(status);
  142. if (status === "9000") {
  143. var form = {
  144. command: data.command,
  145. response: res.toString(),
  146. cosRecordId: data.cosRecordId,
  147. cardId: form.cardId,
  148. cosType: 9 //1- 开卡. 2- 修改卡内信息 4- 卡签绑定 9- 销卡
  149. };
  150. const options = {
  151. type: 2,
  152. data: form,
  153. method: "POST",
  154. showLoading: true,
  155. };
  156. return new Promise(async (resolve, reject) => {
  157. const res = await request(writeCardBack, options);
  158. const data = stringToJson(res.bizContent);
  159. resolve(data);
  160. }).catch((error) => {
  161. reject(error);
  162. });
  163. }
  164. });
  165. };
  166. //注销
  167. const queryCardSignCancellation = (hasCard, hasObu, cosProvider) => {
  168. var options = {
  169. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  170. data: {
  171. hasCard: hasCard,
  172. hasObu: hasObu,
  173. cosProvider: cosProvider,
  174. cardId: form.cardId, //卡号
  175. obuId: form.obuId, //签号
  176. serviceType: "3", //注销类型 1-卡注销,2-签注销,3-卡签注销
  177. orderId: form.orderId, //订单编号
  178. ReasonCancellation: form.ReasonCancellation
  179. }, //请求参数
  180. method: "POST", //提交方式(默认POST)
  181. showLoading: true, //是否显示加载中(默认显示)
  182. };
  183. return new Promise(async (resolve, reject) => {
  184. const res = await request(confirmSignCancellation, options);
  185. const data = stringToJson(res.bizContent);
  186. resolve(data);
  187. }).catch((error) => {
  188. reject(error);
  189. });
  190. }
  191. //注销确认
  192. const queryConfirmSignCancellation = (hasCard: any) => {
  193. return new Promise(async (resolve, reject) => {
  194. const res = await request(confirmSignCancellation, {
  195. type: 2,
  196. data: {
  197. hasCard: hasCard,
  198. orderId: form.orderId,
  199. cardId: form.cardId
  200. },
  201. method: "POST",
  202. showLoading: true,
  203. });
  204. const data = stringToJson(res.bizContent);
  205. resolve(data);
  206. }).catch((error) => {
  207. reject(error);
  208. });
  209. }
  210. </script>
  211. <style>
  212. page {
  213. width: 100%;
  214. height: 100%;
  215. background-color: #ffffff;
  216. }
  217. </style>
  218. <style lang="scss" scoped>
  219. .upload-box {
  220. // width: 100%;
  221. padding: 30rpx;
  222. .head-tips {
  223. text-indent: 2rem;
  224. font-size: 26rpx;
  225. font-family: Microsoft YaHei;
  226. font-weight: 400;
  227. color: #666666;
  228. line-height: 50rpx;
  229. margin-bottom: 45rpx;
  230. text {
  231. color: #ff8000;
  232. }
  233. }
  234. .upload-card {
  235. margin-bottom: 70rpx;
  236. height: 260rpx;
  237. background: #ffffff;
  238. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  239. border-radius: 20rpx;
  240. padding: 30rpx;
  241. display: flex;
  242. justify-content: space-between;
  243. .card-left {
  244. .item1 {
  245. font-size: 34rpx;
  246. font-family: Microsoft YaHei;
  247. font-weight: 400;
  248. color: #000000;
  249. margin-bottom: 30rpx;
  250. }
  251. .item2 {
  252. font-size: 24rpx;
  253. font-family: Microsoft YaHei;
  254. font-weight: 400;
  255. color: #999999;
  256. margin-bottom: 30rpx;
  257. }
  258. .item3 {
  259. width: 110rpx;
  260. height: 40rpx;
  261. background: #ecfbf8;
  262. /* opacity: 0.2; */
  263. border-radius: 6rpx;
  264. font-size: 20rpx;
  265. font-family: Microsoft YaHei;
  266. font-weight: 400;
  267. text-align: center;
  268. line-height: 40rpx;
  269. color: #0a8f8a;
  270. }
  271. }
  272. image {
  273. width: 295rpx;
  274. height: 188rpx;
  275. }
  276. }
  277. .from {
  278. background-color: #fff;
  279. margin-top: 30rpx;
  280. // padding: 0 30rpx;
  281. ::v-deep .u-form-item {
  282. padding: 0;
  283. line-height: normal;
  284. .u-form-item__message {
  285. margin-bottom: 12rpx;
  286. }
  287. }
  288. .title {
  289. font-size: 30rpx;
  290. font-family: Microsoft YaHei;
  291. font-weight: 400;
  292. color: #000000;
  293. margin: 38rpx 0;
  294. }
  295. .from_item {
  296. display: flex;
  297. flex-wrap: nowrap;
  298. justify-content: space-between;
  299. align-items: center;
  300. height: 80rpx;
  301. border-bottom: 1rpx solid #dcdcdc;
  302. ::v-deep .input {
  303. text-align: right;
  304. flex: 1;
  305. input {
  306. text-align: right;
  307. }
  308. }
  309. }
  310. .from_item1 {
  311. display: flex;
  312. flex-wrap: nowrap;
  313. flex-direction: column;
  314. justify-content: space-between;
  315. padding: 30rpx;
  316. border-bottom: #dcdcdc 1px solid;
  317. input {
  318. text-align: right;
  319. }
  320. .textarea {
  321. background-color: #f1f1f1;
  322. width: 100%;
  323. border-radius: 20rpx;
  324. margin-top: 10rpx;
  325. text-indent: 1rem;
  326. height: 180rpx;
  327. padding: 20rpx;
  328. box-sizing: border-box;
  329. }
  330. }
  331. }
  332. .submit {
  333. height: 80rpx;
  334. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  335. border-radius: 40rpx;
  336. font-size: 32rpx;
  337. font-family: Microsoft YaHei;
  338. font-weight: 400;
  339. color: #ffffff;
  340. line-height: 80rpx;
  341. margin: 60rpx auto;
  342. }
  343. }
  344. </style>