code.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view class="sub">
  3. </view>
  4. </template>
  5. <script>
  6. import {
  7. getReservatvav
  8. } from "@/api/mine/order.js"
  9. export default {
  10. data() {
  11. return {};
  12. },
  13. onLoad() {
  14. this.scanAction()
  15. },
  16. onShow() {},
  17. onHide() {},
  18. methods: {
  19. //扫码功能
  20. scanAction() {
  21. var that = this;
  22. uni.scanCode({
  23. onlyFromCamera: true,
  24. autoZoom:false,
  25. scanType: ['qrCode'],
  26. success: function(red) {
  27. let result = red.result;
  28. if (typeof result == 'string') {
  29. try {
  30. var obj = result;
  31. if (typeof obj == 'string' && obj) {
  32. } else {
  33. uni.showToast({
  34. title: '扫码查询失败,请检查二维码是否正确',
  35. icon: "none"
  36. })
  37. uni.navigateBack({
  38. delta: 1
  39. })
  40. return;
  41. }
  42. } catch (e) {
  43. uni.navigateBack({
  44. delta: 1
  45. })
  46. uni.showToast({
  47. title: '扫码查询失败,请检查二维码是否正确',
  48. icon: "none"
  49. })
  50. return
  51. }
  52. }
  53. var id = red.result
  54. var params = {
  55. "reservatId": id,
  56. }
  57. getReservatvav(params).then(res => {
  58. if (res.code == 200) {
  59. // 刷新页面
  60. if(res.msg=='核销失败'){
  61. that.$tab.redirectTo('/pages/order/stafffail')
  62. }else{
  63. uni.$emit('refreshdatalist')
  64. that.$tab.redirectTo('/pages/order/staffcode?id='+id)
  65. }
  66. } else {
  67. uni.navigateBack({
  68. delta: 1
  69. })
  70. uni.showToast({
  71. title: res.msg,
  72. duration: 1000,
  73. icon: 'none'
  74. });
  75. }
  76. }).catch(re=>{
  77. if(re=='500'){
  78. uni.navigateBack({
  79. delta: 1
  80. })
  81. }
  82. })
  83. },
  84. fail: function(e) {
  85. console.log(e)
  86. if (e && e.errMsg && e.errMsg.indexOf('scanCode:fail cancel') != -1) {
  87. return;
  88. }
  89. uni.showToast({
  90. title: '扫码失败',
  91. icon: "none"
  92. })
  93. }
  94. });
  95. },
  96. }
  97. }
  98. </script>
  99. <style lang="scss">
  100. .sub {
  101. box-sizing: border-box;
  102. width: 100%;
  103. min-height: 100vh;
  104. }
  105. .jhyyes {
  106. display: flex;
  107. justify-content: center;
  108. margin-top: 200upx;
  109. }
  110. .img {
  111. width: 258upx;
  112. height: 251upx;
  113. // margin: auto;
  114. // margin-left: 50%;
  115. // transform: translateX(-50%);
  116. }
  117. .naver {
  118. width: 416rpx;
  119. height: 84rpx;
  120. width: 208px;
  121. height: 42px;
  122. background: linear-gradient(90deg, #A00517, #E93030);
  123. border-radius: 21px;
  124. display: flex;
  125. align-items: center;
  126. justify-content: center;
  127. font-size: 30rpx;
  128. color: #ffffff;
  129. margin: 150rpx auto 0;
  130. }
  131. </style>