Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

upload-card.vue 9.1KB

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