checkApp.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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. that.handleScanResult(e.Id,1,e.Name);
  97. });
  98. },
  99. filters: {
  100. handle(val, type) {
  101. return tuomin(val, type);
  102. }
  103. },
  104. methods: {
  105. initSDK() {
  106. // 调用异步方法
  107. lcReader.initSDK({
  108. 'name': 'unimp',
  109. 'age': 1
  110. });
  111. },
  112. getTypes() {
  113. this.$api.get('/scenic/api/boat/page', {
  114. page: -1
  115. }).then(res => {
  116. if (res.data.code == 0) {
  117. this.types = res.data.data.list;
  118. }
  119. })
  120. },
  121. back() {
  122. this.keyName = this.orderInfo.playDate + this.orderInfo.playTime + this.boatNo;
  123. uni.setStorageSync(this.keyName, JSON.stringify(this.data));
  124. //decodeURIComponent
  125. },
  126. getOrderInfo() {
  127. this.$api.post('/scenic/api/order/queryStartOrderInfo', {
  128. merchantId: this.merchantId,
  129. boatNo: this.boatNo
  130. }).then(res => {
  131. if (res.data.code == 0) {
  132. this.orderInfo = res.data.data;
  133. this.keyName = this.orderInfo.playDate + this.orderInfo.playTime + this.boatNo;
  134. if (uni.getStorageSync(this.keyName)) {
  135. this.data = JSON.parse(uni.getStorageSync(this.keyName)) || [];
  136. }
  137. }
  138. })
  139. },
  140. scanCode(type) {
  141. let mg = '请按下按钮进行二维码扫描';
  142. if(type==1) mg = '请放置身份证进行读取';
  143. this.$showToast(mg);
  144. if(type==0) this.scanCodeByEwm();
  145. else if(type==1){
  146. // lcReader.sigleRead();//单次读卡
  147. lcReader.cycleReadCard();//循环读卡
  148. }
  149. },
  150. //扫二维码或条形码
  151. scanCodeByEwm(){
  152. var filter = new IntentFilter();
  153. filter.addAction(SCANACTION);
  154. // 接收
  155. let that = this;
  156. var receiver = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
  157. onReceive: (context, intent)=>{
  158. if (intent.getAction() === SCANACTION) {
  159. // 扫描信息处理
  160. let scanCode = intent.getStringExtra("barcodeData");
  161. // 接收信息处理
  162. that.handleScanResult(scanCode,0,'')
  163. }
  164. }
  165. })
  166. main.registerReceiver(receiver, filter);
  167. },
  168. // 处理扫码结果的函数,可以根据实际需求进行扩展
  169. handleScanResult(result, type, name) {
  170. // 例如:导航到某个页面,或者处理其他业务逻辑
  171. let sendData = {};
  172. sendData.playDate = this.orderInfo.playDate;
  173. sendData.playTime = this.orderInfo.playTime;
  174. sendData.playLength = this.orderInfo.playLength || 1;
  175. sendData.merchantId = this.orderInfo.merchantId;
  176. sendData.orderType = this.orderInfo.orderType;
  177. sendData.type = type;
  178. sendData.boatNo = this.boatNo;
  179. if(type==0) sendData.writeOffCode = result;
  180. else if(type==1){
  181. sendData.touristCode = encrypt(result);
  182. sendData.touristName = encrypt(name);
  183. }
  184. this.$api.post('/scenic/api/order/scanCode', sendData).then(res => {
  185. if (res.data.code == 0) {
  186. if (this.data.findIndex((item) => {
  187. return item.touristCode == res.data.data.touristCode
  188. }) > -1) {
  189. let mg = '该核验码已扫';
  190. if(type==1) mg = '该身份证已扫';
  191. this.$showToast(mg);
  192. } else {
  193. this.data.push(res.data.data);
  194. }
  195. if(type==1) lcReader.cancelCycle();//关闭循环读卡
  196. } else {
  197. this.$showToast(res.data.msg)
  198. if(type==1) lcReader.cancelCycle();//关闭循环读卡
  199. }
  200. })
  201. },
  202. check() {
  203. uni.navigateTo({
  204. url: '/pagesHouse/Verification/check'
  205. })
  206. },
  207. hexiao() {
  208. if (this.data.length == 0) {
  209. return this.$showToast('请选择核销人')
  210. }
  211. if (this.typeIndex == null) {
  212. return this.$showToast('请选择渔船')
  213. }
  214. let boatCode = this.types[this.typeIndex].boatNo;
  215. this.$api.post('/scenic/api/order/sailWriteOff', {
  216. playDate:this.orderInfo.playDate,
  217. playTime:this.orderInfo.playTime,
  218. playLength:this.orderInfo.playLength,
  219. orderType: this.orderInfo.orderType,
  220. touristList: this.data,
  221. boatCode: boatCode
  222. }).then(res => {
  223. if (res.data.code == 0) {
  224. uni.redirectTo({
  225. url: "/pagesHouse/Verification/success?boatNo=" + this.boatNo + '&price=' +
  226. this.orderInfo.realPrice
  227. })
  228. }
  229. })
  230. uni.removeStorageSync(this.keyName);
  231. },
  232. jian(index){
  233. if(this.data.length>index) this.data.splice(index,1);
  234. }
  235. }
  236. }
  237. </script>
  238. <style lang="less" scoped>
  239. /deep/.u-icon {
  240. justify-content: flex-end;
  241. }
  242. .btn {
  243. position: fixed;
  244. bottom: 0;
  245. left: 0;
  246. z-index: 1;
  247. padding: 16rpx 30rpx 36rpx 30rpx;
  248. width: 100%;
  249. box-sizing: border-box;
  250. background: #fff;
  251. text {
  252. display: block;
  253. background-color: #007A69;
  254. color: #007A69;
  255. color: #fff;
  256. height: 88rpx;
  257. line-height: 88rpx;
  258. border-radius: 44rpx;
  259. text-align: center;
  260. font-size: 32rp;
  261. font-weight: bold;
  262. box-sizing: border-box;
  263. }
  264. }
  265. .page {
  266. background: #F5F8FA;
  267. padding: 20rpx 24rpx 160rpx;
  268. box-sizing: border-box;
  269. .types {
  270. display: flex;
  271. gap: 36rpx;
  272. justify-content: space-between;
  273. .n {
  274. margin-bottom: 20rpx;
  275. color: #fff;
  276. }
  277. .item {
  278. width: 330rpx;
  279. height: 156rpx;
  280. padding: 34rpx 24rpx;
  281. font-size: 36rpx;
  282. font-weight: bold;
  283. box-sizing: border-box;
  284. }
  285. .bg2 {
  286. background: url('https://i.ringzle.com/file/20240316/3fc9f6a78557492e98caa50392411e3a.png') no-repeat center;
  287. background-size: 100%;
  288. }
  289. .bg1 {
  290. background: url('https://i.ringzle.com/file/20240316/8a927d5d4da84728b6bb0896541baccf.png') no-repeat center;
  291. background-size: 100%;
  292. }
  293. }
  294. .orderInfo {
  295. background-color: #fff;
  296. color: #333;
  297. padding: 0 24rpx 36rpx;
  298. margin: 20rpx 0 0;
  299. background: #fff;
  300. border-radius: 16rpx;
  301. .tit {
  302. padding: 32rpx 0 24rpx;
  303. font-size: 32rpx;
  304. }
  305. .time {
  306. font-size: 36rpx;
  307. font-weight: bold;
  308. margin-bottom: 32rpx;
  309. }
  310. .bottom {
  311. display: flex;
  312. align-items: center;
  313. text {
  314. &:first-child {
  315. width: 88rpx;
  316. height: 54rpx;
  317. background-color: #007A69;
  318. color: #fff;
  319. font-size: 34rpx;
  320. font-weight: bold;
  321. margin-right: 10rpx;
  322. text-align: center;
  323. border-radius: 12rpx;
  324. }
  325. &:nth-child(2) {
  326. width: 200rpx;
  327. flex: 1;
  328. }
  329. &:last-child {
  330. font-size: 30rpx;
  331. font-weight: bold;
  332. }
  333. }
  334. }
  335. }
  336. }
  337. .list {
  338. box-sizing: border-box;
  339. padding: 0 24rpx 0;
  340. border-radius: 16rpx;
  341. background-color: #fff;
  342. margin-top: 20rpx;
  343. .tit {
  344. font-size: 36rpx;
  345. font-weight: bold;
  346. color: #111;
  347. padding: 36rpx 0 17rpx;
  348. }
  349. .typeItem {
  350. display: flex;
  351. justify-content: space-between;
  352. flex-wrap: wrap;
  353. gap: 20rpx 0;
  354. padding-bottom: 50rpx;
  355. .txt {
  356. display: inline-block;
  357. width: 316rpx;
  358. height: 80rpx;
  359. background: #fff;
  360. border-radius: 16rpx;
  361. text-align: center;
  362. line-height: 80rpx;
  363. border: 2rpx solid #EFEFEF;
  364. color: #333;
  365. position: relative;
  366. &.on {
  367. color: #007A69;
  368. background: rgba(0, 122, 105, 0.06);
  369. border: 2rpx solid #007A69;
  370. image {
  371. position: absolute;
  372. bottom: 0;
  373. right: 0;
  374. width: 34rpx;
  375. height: 26rpx;
  376. z-index: 11;
  377. }
  378. }
  379. }
  380. }
  381. .item {
  382. display: flex;
  383. justify-content: space-between;
  384. padding: 24rpx 0;
  385. align-items: center;
  386. .type {
  387. width: 110rpx;
  388. height: 48rpx;
  389. text-align: center;
  390. display: inline-block;
  391. line-height: 48rpx;
  392. border-radius: 11rpx;
  393. font-size: 26rpx;
  394. font-weight: bold;
  395. color: #111;
  396. margin-right: 16rpx;
  397. }
  398. .t1 {
  399. background-color: #F0F8F6;
  400. color: #007A69;
  401. }
  402. .t2 {
  403. background-color: #E8EFFD;
  404. color: #326EE0;
  405. }
  406. .personInfo {
  407. flex: 1;
  408. .name {
  409. font-size: 30rpx;
  410. color: #111;
  411. margin-bottom: 16rpx;
  412. }
  413. .code {
  414. color: #666;
  415. font-size: 28rpx;
  416. }
  417. }
  418. }
  419. }
  420. </style>