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

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