check.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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}}</view>
  33. <view class="code">
  34. 身份证 {{i.touristCode}}
  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="btn">
  42. <text @click="hexiao">开始发船</text>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. var that;
  48. export default {
  49. data() {
  50. return {
  51. date: new Date().Format('yyyy-MM-dd'),
  52. show: false,
  53. data: [],
  54. merchantId: uni.getStorageSync('merchantId'),
  55. playTime: '',
  56. boatNo: '',
  57. type: '',
  58. orderInfo: {},
  59. keyName: ''
  60. }
  61. },
  62. onLoad(opt) {
  63. that = this;
  64. this.playTime = opt.playTime || '';
  65. this.boatNo = opt.boatNo || '';
  66. this.getOrderInfo();
  67. //获取上次核销缓存
  68. },
  69. methods: {
  70. back() {
  71. this.keyName = this.orderInfo.playDate + this.orderInfo.playTime + this.boatNo;
  72. uni.setStorageSync(this.keyName, JSON.stringify(this.data));
  73. //decodeURIComponent
  74. },
  75. getOrderInfo() {
  76. this.$api.post('/scenic/order/queryStartOrderInfo', {
  77. merchantId: this.merchantId,
  78. boatNo: this.boatNo
  79. }).then(res => {
  80. console.log(res.data)
  81. if (res.data.code == 0) {
  82. console.log(res)
  83. this.orderInfo = res.data.data;
  84. this.keyName = this.orderInfo.playDate + this.orderInfo.playTime + this.boatNo;
  85. console.log(uni.getStorageSync(this.keyName))
  86. this.data = JSON.parse(uni.getStorageSync(this.keyName)) || [];
  87. console.log(this.data)
  88. }
  89. })
  90. },
  91. scanCode(type) {
  92. uni.scanCode({
  93. onlyFromCamera: true,
  94. success: (res) => {
  95. console.log('扫码结果:' + res.result);
  96. // 扫码成功后的操作,例如:
  97. that.handleScanResult(res.result, type);
  98. },
  99. fail: (err) => {
  100. console.error('扫码失败:' + err);
  101. }
  102. });
  103. },
  104. // 处理扫码结果的函数,可以根据实际需求进行扩展
  105. handleScanResult(result, type) {
  106. // 例如:导航到某个页面,或者处理其他业务逻辑
  107. let sendData = {};
  108. sendData.playDate = this.orderInfo.playDate;
  109. sendData.playTime = this.orderInfo.playTime;
  110. sendData.playLength = this.orderInfo.playLength || 1;
  111. sendData.merchantId = this.orderInfo.merchantId;
  112. sendData.orderType = this.orderInfo.orderType;
  113. sendData.type = type;
  114. sendData.writeOffCode = result;
  115. console.log(sendData)
  116. this.$api.post('/scenic/order/scanCode', sendData).then(res => {
  117. console.log(res.data)
  118. if (res.data.code == 0) {
  119. console.log(this.data.findIndex(item => {
  120. item.touristCode == res.data.data.touristCode
  121. }))
  122. if (this.data.findIndex((item) => {
  123. return item.touristCode == res.data.data.touristCode
  124. }) > -1) {
  125. this.$showToast('该核验码已扫')
  126. } else {
  127. this.data.push(res.data.data)
  128. }
  129. } else {
  130. this.$showToast(res.data.msg)
  131. }
  132. })
  133. },
  134. check() {
  135. uni.navigateTo({
  136. url: '/pagesHouse/Verification/check'
  137. })
  138. },
  139. hexiao() {
  140. if (this.data.length == 0) {
  141. this.$showToast('请选择核销人')
  142. }
  143. this.$api.post('/scenic/order/sailWriteOff', {
  144. orderType: this.orderInfo.orderType,
  145. touristList: this.data
  146. }).then(res => {
  147. if (res.data.code == 0) {
  148. uni.redirectTo({
  149. url: "/pagesHouse/Verification/success?boatNo=" + this.boatNo + '&price=' +
  150. this.orderInfo.realPrice
  151. })
  152. }
  153. })
  154. uni.removeStorageSync(this.keyName);
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang="less" scoped>
  160. /deep/.u-icon {
  161. justify-content: flex-end;
  162. }
  163. .btn {
  164. position: fixed;
  165. bottom: 0;
  166. left: 0;
  167. z-index: 1;
  168. padding: 16rpx 30rpx 36rpx 30rpx;
  169. width: 100%;
  170. box-sizing: border-box;
  171. background: #fff;
  172. text {
  173. display: block;
  174. background-color: #007A69;
  175. color: #007A69;
  176. color: #fff;
  177. height: 88rpx;
  178. line-height: 88rpx;
  179. border-radius: 44rpx;
  180. text-align: center;
  181. font-size: 32rp;
  182. font-weight: bold;
  183. box-sizing: border-box;
  184. }
  185. }
  186. .page {
  187. background: #F5F8FA;
  188. padding: 20rpx 24rpx 160rpx;
  189. box-sizing: border-box;
  190. .types {
  191. display: flex;
  192. gap: 36rpx;
  193. justify-content: space-between;
  194. .n {
  195. margin-bottom: 20rpx;
  196. color: #fff;
  197. }
  198. .item {
  199. width: 330rpx;
  200. height: 156rpx;
  201. padding: 34rpx 24rpx;
  202. font-size: 36rpx;
  203. font-weight: bold;
  204. box-sizing: border-box;
  205. }
  206. .bg2 {
  207. background: url('https://i.ringzle.com/file/20240316/3fc9f6a78557492e98caa50392411e3a.png') no-repeat center;
  208. background-size: 100%;
  209. }
  210. .bg1 {
  211. background: url('https://i.ringzle.com/file/20240316/8a927d5d4da84728b6bb0896541baccf.png') no-repeat center;
  212. background-size: 100%;
  213. }
  214. }
  215. .orderInfo {
  216. background-color: #fff;
  217. color: #333;
  218. padding: 0 24rpx 36rpx;
  219. margin: 20rpx 0;
  220. background: #fff;
  221. border-radius: 16rpx;
  222. .tit {
  223. padding: 32rpx 0 24rpx;
  224. font-size: 32rpx;
  225. }
  226. .time {
  227. font-size: 36rpx;
  228. font-weight: bold;
  229. margin-bottom: 32rpx;
  230. }
  231. .bottom {
  232. display: flex;
  233. align-items: center;
  234. text {
  235. &:first-child {
  236. width: 88rpx;
  237. height: 54rpx;
  238. background-color: #007A69;
  239. color: #fff;
  240. font-size: 34rpx;
  241. font-weight: bold;
  242. margin-right: 10rpx;
  243. text-align: center;
  244. border-radius: 12rpx;
  245. }
  246. &:nth-child(2) {
  247. width: 200rpx;
  248. flex: 1;
  249. }
  250. &:last-child {
  251. font-size: 30rpx;
  252. font-weight: bold;
  253. }
  254. }
  255. }
  256. }
  257. }
  258. .list {
  259. box-sizing: border-box;
  260. padding: 0 24rpx 0;
  261. border-radius: 16rpx;
  262. background-color: #fff;
  263. .tit {
  264. font-size: 36rpx;
  265. font-weight: bold;
  266. color: #111;
  267. padding: 36rpx 0 17rpx;
  268. }
  269. .item {
  270. display: flex;
  271. justify-content: space-between;
  272. padding: 24rpx 0;
  273. align-items: center;
  274. .type {
  275. width: 110rpx;
  276. height: 48rpx;
  277. text-align: center;
  278. display: inline-block;
  279. line-height: 48rpx;
  280. border-radius: 11rpx;
  281. font-size: 26rpx;
  282. font-weight: bold;
  283. color: #111;
  284. margin-right: 16rpx;
  285. }
  286. .t1 {
  287. background-color: #F0F8F6;
  288. color: #007A69;
  289. }
  290. .t2 {
  291. background-color: #E8EFFD;
  292. color: #326EE0;
  293. }
  294. .personInfo {
  295. flex: 1;
  296. .name {
  297. font-size: 30rpx;
  298. color: #111;
  299. margin-bottom: 16rpx;
  300. }
  301. .code {
  302. color: #666;
  303. font-size: 28rpx;
  304. }
  305. }
  306. }
  307. }
  308. </style>