checkApp.vue 11 KB

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