您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

upload-card.vue 8.6KB

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