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 9.0KB

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