checkApp.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <view class="page" :style="{'min-height':(h)+'px','padding-top':mt+'px'}">
  3. <c-nav-bar title="核销" @goBack="back()"></c-nav-bar>
  4. <view class="types">
  5. <view class="item bg2" @tap="scanCode(0)">
  6. <view class="n">扫码核销</view>
  7. <u-icon name="arrow-right" color="#fff" size="26" label="点击扫描" label-color="#fff" label-size="28" cu
  8. label-pos="left"></u-icon>
  9. </view>
  10. <view class="item bg1" @tap="scanCode(1)">
  11. <view class="n">扫身份证</view>
  12. <u-icon name="arrow-right" color="#fff" size="26" label="点击扫描" label-color="#fff" label-size="28"
  13. label-pos="left"></u-icon>
  14. </view>
  15. </view>
  16. <view class="orderInfo">
  17. <view class="tit">
  18. 订单详情
  19. </view>
  20. <view class="time">{{orderInfo.playDate}} {{orderInfo.playTime}}出发</view>
  21. <view class="bottom">
  22. <text>{{orderInfo.num}}人</text>
  23. <text>出游·{{orderInfo.playLength||0}}小时</text>
  24. <text>¥{{orderInfo.realPrice}}</text>
  25. </view>
  26. </view>
  27. <view class="list">
  28. <view class="tit">{{boatNo}} 共({{data.length}})人</view>
  29. <view class="item" v-for="(i,index) in data" :key="index">
  30. <text class="type" :class="i.remark=='book'?'t1':'t2'">{{i.remark=='book'?'预订单':'现场单'}}</text>
  31. <view class="personInfo">
  32. <view class="name">{{i.touristName|handle(1)}}</view>
  33. <view class="code">
  34. 身份证 {{i.touristCode|handle(3)}}
  35. </view>
  36. </view>
  37. <u-icon name="minus-circle" size="36" color="#FEA400" @tap="jian(index)"
  38. v-if="i.remark!='book'"></u-icon>
  39. </view>
  40. </view>
  41. <view class="list">
  42. <view class="tit">选择渔船</view>
  43. <view class="typeItem">
  44. <view class="txt" v-for="(t,i) in types" :key="i" @click="typeIndex=i" :class="typeIndex==i?'on':''">
  45. {{t.boatNo}}
  46. <image v-if="typeIndex==i"
  47. src="https://i.ringzle.com/file/20240320/b458b03f8f654a51a921656b8aa955de.png"></image>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="btn">
  52. <text @click="hexiao">开始发船</text>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import {
  58. encrypt,
  59. decrypt,
  60. tuomin
  61. } from '../../utils/aes.js'
  62. var that;
  63. const lcReader = uni.requireNativePlugin('LcReader');
  64. const modal = uni.requireNativePlugin('modal');
  65. var globalEvent = uni.requireNativePlugin('globalEvent');
  66. // 依赖引入
  67. const Intent = plus.android.importClass('android.content.Intent')
  68. const IntentFilter = plus.android.importClass('android.content.IntentFilter')
  69. const main = plus.android.runtimeMainActivity()
  70. // pda广播名称
  71. const SCANACTION = "scan.rcv.message"//扫描名称
  72. export default {
  73. data() {
  74. return {
  75. typeIndex: null,
  76. types: [],
  77. date: new Date().Format('yyyy-MM-dd'),
  78. show: false,
  79. data: [],
  80. merchantId: uni.getStorageSync('merchantId'),
  81. playTime: '',
  82. boatNo: '',
  83. type: '',
  84. orderInfo: {},
  85. keyName: ''
  86. }
  87. },
  88. onLoad(opt) {
  89. that = this;
  90. this.playTime = opt.playTime || '';
  91. this.boatNo = opt.boatNo || '';
  92. this.getOrderInfo();
  93. this.getTypes();
  94. this.initSDK();
  95. globalEvent.addEventListener('readInfo', function(e) {
  96. if(e.Id&&e.Name) that.handleScanResult(e.Id,1,e.Name);
  97. });
  98. },
  99. filters: {
  100. handle(val, type) {
  101. return tuomin(val, type);
  102. }
  103. },
  104. destroyed() {
  105. this.keyName = this.orderInfo.playDate + this.orderInfo.playTime + this.boatNo;
  106. uni.setStorageSync(this.keyName, JSON.stringify(this.data));
  107. },
  108. methods: {
  109. initSDK() {
  110. // 调用异步方法
  111. lcReader.initSDK({
  112. 'name': 'unimp',
  113. 'age': 1
  114. });
  115. },
  116. getTypes() {
  117. this.$api.get('/scenic/api/boat/page', {
  118. page: -1
  119. }).then(res => {
  120. if (res.data.code == 0) {
  121. this.types = res.data.data.list;
  122. }
  123. })
  124. },
  125. getOrderInfo() {
  126. this.$api.post('/scenic/api/order/queryStartOrderInfo', {
  127. merchantId: this.merchantId,
  128. boatNo: this.boatNo
  129. }).then(res => {
  130. if (res.data.code == 0) {
  131. this.orderInfo = res.data.data;
  132. this.keyName = this.orderInfo.playDate + this.orderInfo.playTime + this.boatNo;
  133. if (uni.getStorageSync(this.keyName)) {
  134. this.data = JSON.parse(uni.getStorageSync(this.keyName)) || [];
  135. }
  136. }
  137. })
  138. },
  139. scanCode(type) {
  140. let mg = '请按下按钮进行二维码扫描';
  141. if(type==1) mg = '请放置身份证进行读取';
  142. this.$showToast(mg);
  143. if(type==0) this.scanCodeByEwm();
  144. else if(type==1){
  145. // lcReader.sigleRead();//单次读卡
  146. lcReader.cycleReadCard();//循环读卡
  147. }
  148. },
  149. //扫二维码或条形码
  150. scanCodeByEwm(){
  151. var filter = new IntentFilter();
  152. filter.addAction(SCANACTION);
  153. // 接收
  154. let that = this;
  155. var receiver = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
  156. onReceive: (context, intent)=>{
  157. if (intent.getAction() === SCANACTION) {
  158. // 扫描信息处理
  159. let scanCode = intent.getStringExtra("barcodeData");
  160. // 接收信息处理
  161. if(scanCode) that.handleScanResult(scanCode,0,'');
  162. }
  163. }
  164. })
  165. main.registerReceiver(receiver, filter);
  166. },
  167. // 处理扫码结果的函数,可以根据实际需求进行扩展
  168. handleScanResult(result, type, name) {
  169. // 例如:导航到某个页面,或者处理其他业务逻辑
  170. let sendData = {};
  171. sendData.playDate = this.orderInfo.playDate;
  172. sendData.playTime = this.orderInfo.playTime;
  173. sendData.playLength = this.orderInfo.playLength || 1;
  174. sendData.merchantId = this.orderInfo.merchantId;
  175. sendData.orderType = this.orderInfo.orderType;
  176. sendData.type = type;
  177. sendData.boatNo = this.boatNo;
  178. if(type==0) sendData.writeOffCode = result;
  179. else if(type==1){
  180. sendData.touristCode = encrypt(result);
  181. sendData.touristName = encrypt(name);
  182. }
  183. this.$api.post('/scenic/api/order/scanCode', sendData).then(res => {
  184. if (res.data.code == 0) {
  185. if (this.data.findIndex((item) => {
  186. return item.touristCode == res.data.data.touristCode
  187. }) > -1) {
  188. let mg = '该核验码已扫';
  189. if(type==1) mg = '该身份证已扫';
  190. this.$showToast(mg);
  191. } else {
  192. this.data.push(res.data.data);
  193. }
  194. if(type==1) lcReader.cancelCycle();//关闭循环读卡
  195. } else {
  196. this.$showToast(res.data.msg)
  197. if(type==1) lcReader.cancelCycle();//关闭循环读卡
  198. }
  199. })
  200. },
  201. check() {
  202. uni.navigateTo({
  203. url: '/pagesHouse/Verification/check'
  204. })
  205. },
  206. hexiao() {
  207. if (this.data.length == 0) {
  208. return this.$showToast('请选择核销人')
  209. }
  210. if (this.typeIndex == null) {
  211. return this.$showToast('请选择渔船')
  212. }
  213. let boatCode = this.types[this.typeIndex].boatNo;
  214. let newData = JSON.parse(JSON.stringify(this.data));
  215. newData.forEach(d=>{
  216. d.touristCode = encrypt(d.touristCode);
  217. d.touristName = encrypt(d.touristName);
  218. })
  219. this.$api.post('/scenic/api/order/sailWriteOff', {
  220. playDate:this.orderInfo.playDate,
  221. playTime:this.orderInfo.playTime,
  222. playLength:this.orderInfo.playLength,
  223. orderType: this.orderInfo.orderType,
  224. touristList: newData,
  225. boatCode: boatCode
  226. }).then(res => {
  227. if (res.data.code == 0) {
  228. uni.navigateTo({
  229. url: "/pagesHouse/Verification/success?boatNo=" + this.boatNo + '&price=' +
  230. this.orderInfo.realPrice
  231. })
  232. }else this.$showToast(res.data.msg)
  233. })
  234. uni.removeStorageSync(this.keyName);
  235. },
  236. jian(index){
  237. if(this.data.length>index) this.data.splice(index,1);
  238. }
  239. }
  240. }
  241. </script>
  242. <style lang="less" scoped>
  243. /deep/.u-icon {
  244. justify-content: flex-end;
  245. }
  246. .btn {
  247. position: fixed;
  248. bottom: 0;
  249. left: 0;
  250. z-index: 1;
  251. padding: 16rpx 30rpx 36rpx 30rpx;
  252. width: 100%;
  253. box-sizing: border-box;
  254. background: #fff;
  255. text {
  256. display: block;
  257. background-color: #007A69;
  258. color: #007A69;
  259. color: #fff;
  260. height: 88rpx;
  261. line-height: 88rpx;
  262. border-radius: 44rpx;
  263. text-align: center;
  264. font-size: 32rp;
  265. font-weight: bold;
  266. box-sizing: border-box;
  267. }
  268. }
  269. .page {
  270. background: #F5F8FA;
  271. padding: 20rpx 24rpx 160rpx;
  272. box-sizing: border-box;
  273. .types {
  274. display: flex;
  275. gap: 36rpx;
  276. justify-content: space-between;
  277. .n {
  278. margin-bottom: 20rpx;
  279. color: #fff;
  280. }
  281. .item {
  282. width: 330rpx;
  283. height: 156rpx;
  284. padding: 34rpx 24rpx;
  285. font-size: 36rpx;
  286. font-weight: bold;
  287. box-sizing: border-box;
  288. }
  289. .bg2 {
  290. background: url('https://i.ringzle.com/file/20240316/3fc9f6a78557492e98caa50392411e3a.png') no-repeat center;
  291. background-size: 100%;
  292. }
  293. .bg1 {
  294. background: url('https://i.ringzle.com/file/20240316/8a927d5d4da84728b6bb0896541baccf.png') no-repeat center;
  295. background-size: 100%;
  296. }
  297. }
  298. .orderInfo {
  299. background-color: #fff;
  300. color: #333;
  301. padding: 0 24rpx 36rpx;
  302. margin: 20rpx 0 0;
  303. background: #fff;
  304. border-radius: 16rpx;
  305. .tit {
  306. padding: 32rpx 0 24rpx;
  307. font-size: 32rpx;
  308. }
  309. .time {
  310. font-size: 36rpx;
  311. font-weight: bold;
  312. margin-bottom: 32rpx;
  313. }
  314. .bottom {
  315. display: flex;
  316. align-items: center;
  317. text {
  318. &:first-child {
  319. width: 88rpx;
  320. height: 54rpx;
  321. background-color: #007A69;
  322. color: #fff;
  323. font-size: 34rpx;
  324. font-weight: bold;
  325. margin-right: 10rpx;
  326. text-align: center;
  327. border-radius: 12rpx;
  328. }
  329. &:nth-child(2) {
  330. width: 200rpx;
  331. flex: 1;
  332. }
  333. &:last-child {
  334. font-size: 30rpx;
  335. font-weight: bold;
  336. }
  337. }
  338. }
  339. }
  340. }
  341. .list {
  342. box-sizing: border-box;
  343. padding: 0 24rpx 0;
  344. border-radius: 16rpx;
  345. background-color: #fff;
  346. margin-top: 20rpx;
  347. .tit {
  348. font-size: 36rpx;
  349. font-weight: bold;
  350. color: #111;
  351. padding: 36rpx 0 17rpx;
  352. }
  353. .typeItem {
  354. display: flex;
  355. justify-content: space-between;
  356. flex-wrap: wrap;
  357. gap: 20rpx 0;
  358. padding-bottom: 50rpx;
  359. .txt {
  360. display: inline-block;
  361. width: 316rpx;
  362. height: 80rpx;
  363. background: #fff;
  364. border-radius: 16rpx;
  365. text-align: center;
  366. line-height: 80rpx;
  367. border: 2rpx solid #EFEFEF;
  368. color: #333;
  369. position: relative;
  370. &.on {
  371. color: #007A69;
  372. background: rgba(0, 122, 105, 0.06);
  373. border: 2rpx solid #007A69;
  374. image {
  375. position: absolute;
  376. bottom: 0;
  377. right: 0;
  378. width: 34rpx;
  379. height: 26rpx;
  380. z-index: 11;
  381. }
  382. }
  383. }
  384. }
  385. .item {
  386. display: flex;
  387. justify-content: space-between;
  388. padding: 24rpx 0;
  389. align-items: center;
  390. .type {
  391. width: 110rpx;
  392. height: 48rpx;
  393. text-align: center;
  394. display: inline-block;
  395. line-height: 48rpx;
  396. border-radius: 11rpx;
  397. font-size: 26rpx;
  398. font-weight: bold;
  399. color: #111;
  400. margin-right: 16rpx;
  401. }
  402. .t1 {
  403. background-color: #F0F8F6;
  404. color: #007A69;
  405. }
  406. .t2 {
  407. background-color: #E8EFFD;
  408. color: #326EE0;
  409. }
  410. .personInfo {
  411. flex: 1;
  412. .name {
  413. font-size: 30rpx;
  414. color: #111;
  415. margin-bottom: 16rpx;
  416. }
  417. .code {
  418. color: #666;
  419. font-size: 28rpx;
  420. }
  421. }
  422. }
  423. }
  424. </style>