checkApp.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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. 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. 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. this.$api.post('/scenic/api/order/sailWriteOff', {
  215. playDate:this.orderInfo.playDate,
  216. playTime:this.orderInfo.playTime,
  217. playLength:this.orderInfo.playLength,
  218. orderType: this.orderInfo.orderType,
  219. touristList: this.data,
  220. boatCode: boatCode
  221. }).then(res => {
  222. if (res.data.code == 0) {
  223. uni.redirectTo({
  224. url: "/pagesHouse/Verification/success?boatNo=" + this.boatNo + '&price=' +
  225. this.orderInfo.realPrice
  226. })
  227. }
  228. })
  229. uni.removeStorageSync(this.keyName);
  230. },
  231. jian(index){
  232. if(this.data.length>index) this.data.splice(index,1);
  233. }
  234. }
  235. }
  236. </script>
  237. <style lang="less" scoped>
  238. /deep/.u-icon {
  239. justify-content: flex-end;
  240. }
  241. .btn {
  242. position: fixed;
  243. bottom: 0;
  244. left: 0;
  245. z-index: 1;
  246. padding: 16rpx 30rpx 36rpx 30rpx;
  247. width: 100%;
  248. box-sizing: border-box;
  249. background: #fff;
  250. text {
  251. display: block;
  252. background-color: #007A69;
  253. color: #007A69;
  254. color: #fff;
  255. height: 88rpx;
  256. line-height: 88rpx;
  257. border-radius: 44rpx;
  258. text-align: center;
  259. font-size: 32rp;
  260. font-weight: bold;
  261. box-sizing: border-box;
  262. }
  263. }
  264. .page {
  265. background: #F5F8FA;
  266. padding: 20rpx 24rpx 160rpx;
  267. box-sizing: border-box;
  268. .types {
  269. display: flex;
  270. gap: 36rpx;
  271. justify-content: space-between;
  272. .n {
  273. margin-bottom: 20rpx;
  274. color: #fff;
  275. }
  276. .item {
  277. width: 330rpx;
  278. height: 156rpx;
  279. padding: 34rpx 24rpx;
  280. font-size: 36rpx;
  281. font-weight: bold;
  282. box-sizing: border-box;
  283. }
  284. .bg2 {
  285. background: url('https://i.ringzle.com/file/20240316/3fc9f6a78557492e98caa50392411e3a.png') no-repeat center;
  286. background-size: 100%;
  287. }
  288. .bg1 {
  289. background: url('https://i.ringzle.com/file/20240316/8a927d5d4da84728b6bb0896541baccf.png') no-repeat center;
  290. background-size: 100%;
  291. }
  292. }
  293. .orderInfo {
  294. background-color: #fff;
  295. color: #333;
  296. padding: 0 24rpx 36rpx;
  297. margin: 20rpx 0 0;
  298. background: #fff;
  299. border-radius: 16rpx;
  300. .tit {
  301. padding: 32rpx 0 24rpx;
  302. font-size: 32rpx;
  303. }
  304. .time {
  305. font-size: 36rpx;
  306. font-weight: bold;
  307. margin-bottom: 32rpx;
  308. }
  309. .bottom {
  310. display: flex;
  311. align-items: center;
  312. text {
  313. &:first-child {
  314. width: 88rpx;
  315. height: 54rpx;
  316. background-color: #007A69;
  317. color: #fff;
  318. font-size: 34rpx;
  319. font-weight: bold;
  320. margin-right: 10rpx;
  321. text-align: center;
  322. border-radius: 12rpx;
  323. }
  324. &:nth-child(2) {
  325. width: 200rpx;
  326. flex: 1;
  327. }
  328. &:last-child {
  329. font-size: 30rpx;
  330. font-weight: bold;
  331. }
  332. }
  333. }
  334. }
  335. }
  336. .list {
  337. box-sizing: border-box;
  338. padding: 0 24rpx 0;
  339. border-radius: 16rpx;
  340. background-color: #fff;
  341. margin-top: 20rpx;
  342. .tit {
  343. font-size: 36rpx;
  344. font-weight: bold;
  345. color: #111;
  346. padding: 36rpx 0 17rpx;
  347. }
  348. .typeItem {
  349. display: flex;
  350. justify-content: space-between;
  351. flex-wrap: wrap;
  352. gap: 20rpx 0;
  353. padding-bottom: 50rpx;
  354. .txt {
  355. display: inline-block;
  356. width: 316rpx;
  357. height: 80rpx;
  358. background: #fff;
  359. border-radius: 16rpx;
  360. text-align: center;
  361. line-height: 80rpx;
  362. border: 2rpx solid #EFEFEF;
  363. color: #333;
  364. position: relative;
  365. &.on {
  366. color: #007A69;
  367. background: rgba(0, 122, 105, 0.06);
  368. border: 2rpx solid #007A69;
  369. image {
  370. position: absolute;
  371. bottom: 0;
  372. right: 0;
  373. width: 34rpx;
  374. height: 26rpx;
  375. z-index: 11;
  376. }
  377. }
  378. }
  379. }
  380. .item {
  381. display: flex;
  382. justify-content: space-between;
  383. padding: 24rpx 0;
  384. align-items: center;
  385. .type {
  386. width: 110rpx;
  387. height: 48rpx;
  388. text-align: center;
  389. display: inline-block;
  390. line-height: 48rpx;
  391. border-radius: 11rpx;
  392. font-size: 26rpx;
  393. font-weight: bold;
  394. color: #111;
  395. margin-right: 16rpx;
  396. }
  397. .t1 {
  398. background-color: #F0F8F6;
  399. color: #007A69;
  400. }
  401. .t2 {
  402. background-color: #E8EFFD;
  403. color: #326EE0;
  404. }
  405. .personInfo {
  406. flex: 1;
  407. .name {
  408. font-size: 30rpx;
  409. color: #111;
  410. margin-bottom: 16rpx;
  411. }
  412. .code {
  413. color: #666;
  414. font-size: 28rpx;
  415. }
  416. }
  417. }
  418. }
  419. </style>