check.vue 9.6 KB

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