check.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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(item)"
  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. export default {
  64. data() {
  65. return {
  66. typeIndex: null,
  67. types: [],
  68. date: new Date().Format('yyyy-MM-dd'),
  69. show: false,
  70. data: [],
  71. merchantId: uni.getStorageSync('merchantId'),
  72. playTime: '',
  73. boatNo: '',
  74. type: '',
  75. orderInfo: {},
  76. keyName: ''
  77. }
  78. },
  79. onLoad(opt) {
  80. that = this;
  81. this.playTime = opt.playTime || '';
  82. this.boatNo = opt.boatNo || '';
  83. this.getOrderInfo();
  84. this.getTypes();
  85. console.log(tuomin())
  86. //获取上次核销缓存
  87. },
  88. filters: {
  89. handle(val, type) {
  90. return tuomin(decrypt(val), type)
  91. }
  92. },
  93. methods: {
  94. getTypes() {
  95. this.$api.get('/scenic/api/boat/page', {
  96. page: -1
  97. }).then(res => {
  98. if (res.data.code == 0) {
  99. this.types = res.data.data.list;
  100. }
  101. })
  102. },
  103. back() {
  104. this.keyName = this.orderInfo.playDate + this.orderInfo.playTime + this.boatNo;
  105. uni.setStorageSync(this.keyName, JSON.stringify(this.data));
  106. //decodeURIComponent
  107. },
  108. getOrderInfo() {
  109. this.$api.post('/scenic/api/order/queryStartOrderInfo', {
  110. merchantId: this.merchantId,
  111. boatNo: this.boatNo
  112. }).then(res => {
  113. console.log(res.data)
  114. if (res.data.code == 0) {
  115. this.orderInfo = res.data.data;
  116. this.keyName = this.orderInfo.playDate + this.orderInfo.playTime + this.boatNo;
  117. if (uni.getStorageSync(this.keyName)) {
  118. this.data = JSON.parse(uni.getStorageSync(this.keyName)) || [];
  119. }
  120. }
  121. })
  122. },
  123. scanCode(type) {
  124. uni.scanCode({
  125. onlyFromCamera: true,
  126. success: (res) => {
  127. console.log('扫码结果:' + res.result);
  128. // 扫码成功后的操作,例如:
  129. that.handleScanResult(res.result, type);
  130. },
  131. fail: (err) => {
  132. console.error('扫码失败:' + err);
  133. }
  134. });
  135. },
  136. // 处理扫码结果的函数,可以根据实际需求进行扩展
  137. handleScanResult(result, type) {
  138. // 例如:导航到某个页面,或者处理其他业务逻辑
  139. let sendData = {};
  140. sendData.playDate = this.orderInfo.playDate;
  141. sendData.playTime = this.orderInfo.playTime;
  142. sendData.playLength = this.orderInfo.playLength || 1;
  143. sendData.merchantId = this.orderInfo.merchantId;
  144. sendData.orderType = this.orderInfo.orderType;
  145. sendData.type = type;
  146. sendData.writeOffCode = result;
  147. console.log(sendData)
  148. this.$api.post('/scenic/api/order/scanCode', sendData).then(res => {
  149. console.log(res.data)
  150. if (res.data.code == 0) {
  151. if (this.data.findIndex((item) => {
  152. return item.touristCode == res.data.data.touristCode
  153. }) > -1) {
  154. this.$showToast('该核验码已扫')
  155. } else {
  156. // "id": 0,
  157. // "orderCode": "",
  158. // "remark": "",
  159. // "touristCode": "",
  160. // "touristName": ""
  161. res.data.data.touristCode = encrypt(res.data.data.touristCode);
  162. res.data.data.touristName = encrypt(res.data.data.touristName)
  163. let json = {
  164. id: res.data.data.id,
  165. orderCode:res.data.data.orderCode,
  166. remark:res.data.data.remark,
  167. touristCode:res.data.data.touristCode,
  168. touristName: res.data.data.touristName
  169. }
  170. this.data.push(json)
  171. }
  172. } else {
  173. this.$showToast(res.data.msg)
  174. }
  175. })
  176. },
  177. check() {
  178. uni.navigateTo({
  179. url: '/pagesHouse/Verification/check'
  180. })
  181. },
  182. hexiao() {
  183. if (this.data.length == 0) {
  184. return this.$showToast('请选择核销人')
  185. }
  186. if (this.typeIndex == null) {
  187. return this.$showToast('请选择渔船')
  188. }
  189. let boatCode = this.types[this.typeIndex].boatNo;
  190. this.$api.post('/scenic/api/order/sailWriteOff', {
  191. playDate:this.orderInfo.playDate,
  192. playTime:this.orderInfo.playTime,
  193. playLength:this.orderInfo.playLength,
  194. orderType: this.orderInfo.orderType,
  195. touristList: this.data,
  196. boatCode: boatCode
  197. }).then(res => {
  198. if (res.data.code == 0) {
  199. uni.redirectTo({
  200. url: "/pagesHouse/Verification/success?boatNo=" + this.boatNo + '&price=' +
  201. this.orderInfo.realPrice
  202. })
  203. }
  204. })
  205. uni.removeStorageSync(this.keyName);
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang="less" scoped>
  211. /deep/.u-icon {
  212. justify-content: flex-end;
  213. }
  214. .btn {
  215. position: fixed;
  216. bottom: 0;
  217. left: 0;
  218. z-index: 1;
  219. padding: 16rpx 30rpx 36rpx 30rpx;
  220. width: 100%;
  221. box-sizing: border-box;
  222. background: #fff;
  223. text {
  224. display: block;
  225. background-color: #007A69;
  226. color: #007A69;
  227. color: #fff;
  228. height: 88rpx;
  229. line-height: 88rpx;
  230. border-radius: 44rpx;
  231. text-align: center;
  232. font-size: 32rp;
  233. font-weight: bold;
  234. box-sizing: border-box;
  235. }
  236. }
  237. .page {
  238. background: #F5F8FA;
  239. padding: 20rpx 24rpx 160rpx;
  240. box-sizing: border-box;
  241. .types {
  242. display: flex;
  243. gap: 36rpx;
  244. justify-content: space-between;
  245. .n {
  246. margin-bottom: 20rpx;
  247. color: #fff;
  248. }
  249. .item {
  250. width: 330rpx;
  251. height: 156rpx;
  252. padding: 34rpx 24rpx;
  253. font-size: 36rpx;
  254. font-weight: bold;
  255. box-sizing: border-box;
  256. }
  257. .bg2 {
  258. background: url('https://i.ringzle.com/file/20240316/3fc9f6a78557492e98caa50392411e3a.png') no-repeat center;
  259. background-size: 100%;
  260. }
  261. .bg1 {
  262. background: url('https://i.ringzle.com/file/20240316/8a927d5d4da84728b6bb0896541baccf.png') no-repeat center;
  263. background-size: 100%;
  264. }
  265. }
  266. .orderInfo {
  267. background-color: #fff;
  268. color: #333;
  269. padding: 0 24rpx 36rpx;
  270. margin: 20rpx 0 0;
  271. background: #fff;
  272. border-radius: 16rpx;
  273. .tit {
  274. padding: 32rpx 0 24rpx;
  275. font-size: 32rpx;
  276. }
  277. .time {
  278. font-size: 36rpx;
  279. font-weight: bold;
  280. margin-bottom: 32rpx;
  281. }
  282. .bottom {
  283. display: flex;
  284. align-items: center;
  285. text {
  286. &:first-child {
  287. width: 88rpx;
  288. height: 54rpx;
  289. background-color: #007A69;
  290. color: #fff;
  291. font-size: 34rpx;
  292. font-weight: bold;
  293. margin-right: 10rpx;
  294. text-align: center;
  295. border-radius: 12rpx;
  296. }
  297. &:nth-child(2) {
  298. width: 200rpx;
  299. flex: 1;
  300. }
  301. &:last-child {
  302. font-size: 30rpx;
  303. font-weight: bold;
  304. }
  305. }
  306. }
  307. }
  308. }
  309. .list {
  310. box-sizing: border-box;
  311. padding: 0 24rpx 0;
  312. border-radius: 16rpx;
  313. background-color: #fff;
  314. margin-top: 20rpx;
  315. .tit {
  316. font-size: 36rpx;
  317. font-weight: bold;
  318. color: #111;
  319. padding: 36rpx 0 17rpx;
  320. }
  321. .typeItem {
  322. display: flex;
  323. justify-content: space-between;
  324. flex-wrap: wrap;
  325. gap: 20rpx 0;
  326. padding-bottom: 50rpx;
  327. .txt {
  328. display: inline-block;
  329. width: 316rpx;
  330. height: 80rpx;
  331. background: #fff;
  332. border-radius: 16rpx;
  333. text-align: center;
  334. line-height: 80rpx;
  335. border: 2rpx solid #EFEFEF;
  336. color: #333;
  337. position: relative;
  338. &.on {
  339. color: #007A69;
  340. background: rgba(0, 122, 105, 0.06);
  341. border: 2rpx solid #007A69;
  342. image {
  343. position: absolute;
  344. bottom: 0;
  345. right: 0;
  346. width: 34rpx;
  347. height: 26rpx;
  348. z-index: 11;
  349. }
  350. }
  351. }
  352. }
  353. .item {
  354. display: flex;
  355. justify-content: space-between;
  356. padding: 24rpx 0;
  357. align-items: center;
  358. .type {
  359. width: 110rpx;
  360. height: 48rpx;
  361. text-align: center;
  362. display: inline-block;
  363. line-height: 48rpx;
  364. border-radius: 11rpx;
  365. font-size: 26rpx;
  366. font-weight: bold;
  367. color: #111;
  368. margin-right: 16rpx;
  369. }
  370. .t1 {
  371. background-color: #F0F8F6;
  372. color: #007A69;
  373. }
  374. .t2 {
  375. background-color: #E8EFFD;
  376. color: #326EE0;
  377. }
  378. .personInfo {
  379. flex: 1;
  380. .name {
  381. font-size: 30rpx;
  382. color: #111;
  383. margin-bottom: 16rpx;
  384. }
  385. .code {
  386. color: #666;
  387. font-size: 28rpx;
  388. }
  389. }
  390. }
  391. }
  392. </style>