小程序端工程代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
4.7 KiB

  1. <template>
  2. <view class="OrderCancellation">
  3. <view class="header">
  4. <image mode="aspectFit" :src="`${$VUE_APP_RESOURCES_URL}/images/writeOffBg.jpg`" @click="openQRCode" />
  5. </view>
  6. <view class="whiteBg">
  7. <view class="input">
  8. <input type="number" placeholder="0" v-model="verify_code" />
  9. </view>
  10. <view class="bnt" @click="storeCancellation">立即核销</view>
  11. <view class="bnt" v-if="$deviceType !== 'weixin'" @click="openQRCode">扫码核销</view>
  12. </view>
  13. <!-- #ifndef H5 -->
  14. <!-- <view class="scan" v-if="iswechat">
  15. <image :src="`${$VUE_APP_RESOURCES_URL}/images/scan.gif`" @click="openQRCode" />
  16. </view> -->
  17. <!-- #endif -->
  18. <WriteOff :iShidden="iShidden" :orderInfo="orderInfo" @cancel="cancel" @confirm="confirm"></WriteOff>
  19. </view>
  20. </template>
  21. <script>
  22. import WriteOff from '@/components/WriteOff'
  23. import { isWeixin } from '@/utils'
  24. // import { wechatEvevt } from "@/libs/wechat";
  25. import { orderVerific } from '@/api/order'
  26. const NAME = 'OrderCancellation'
  27. export default {
  28. name: NAME,
  29. components: {
  30. WriteOff,
  31. },
  32. props: {},
  33. data: function() {
  34. return {
  35. iShidden: true,
  36. orderInfo: {},
  37. verify_code: '',
  38. }
  39. },
  40. mounted: function() {},
  41. methods: {
  42. cancel: function(res) {
  43. this.iShidden = res
  44. },
  45. confirm: function() {
  46. orderVerific(this.verify_code, 1)
  47. .then(res => {
  48. this.iShidden = true
  49. this.verify_code = ''
  50. uni.showToast({
  51. title: res.msg,
  52. icon: 'none',
  53. duration: 2000,
  54. })
  55. })
  56. .catch(err => {
  57. uni.showToast({
  58. title: err.msg || err.response.data.msg || err.response.data.message,
  59. icon: 'none',
  60. duration: 2000,
  61. })
  62. })
  63. },
  64. storeCancellation: function() {
  65. let ref = /[0-9]{12}/
  66. if (!this.verify_code) {
  67. uni.showToast({
  68. title: '请输入核销码',
  69. icon: 'none',
  70. duration: 2000,
  71. })
  72. return
  73. }
  74. if (!ref.test(this.verify_code)) {
  75. uni.showToast({
  76. title: '请输入正确的核销码',
  77. icon: 'none',
  78. duration: 2000,
  79. })
  80. return
  81. }
  82. uni.showLoading({
  83. title: '查询中',
  84. })
  85. orderVerific(this.verify_code, 0)
  86. .then(res => {
  87. uni.hideLoading()
  88. this.orderInfo = res.data
  89. this.iShidden = false
  90. uni.showToast({
  91. title: res.msg,
  92. icon: 'success',
  93. duration: 2000,
  94. })
  95. })
  96. .catch(error => {
  97. uni.hideLoading()
  98. uni.showToast({
  99. title: error.msg || error.response.data.msg || error.response.data.message,
  100. icon: 'none',
  101. duration: 2000,
  102. })
  103. })
  104. },
  105. openQRCode: function() {
  106. let that = this
  107. // 这里需要调用扫码功能
  108. uni.scanCode({
  109. success: res => {
  110. var result = res.result
  111. if (result) {
  112. that.verify_code = res.result
  113. that.storeCancellation()
  114. } else {
  115. uni.showToast({
  116. title: '没有扫描到什么!',
  117. icon: 'none',
  118. duration: 2000,
  119. })
  120. }
  121. },
  122. })
  123. },
  124. },
  125. }
  126. </script>
  127. <style scoped lang="less">
  128. .OrderCancellation .header {
  129. width: 100%;
  130. height: 3 * 100rpx;
  131. background-size: 100% 100%;
  132. image {
  133. width: 100%;
  134. height: 3 * 100rpx;
  135. }
  136. }
  137. .OrderCancellation .whiteBg {
  138. width: 6.9 * 100rpx;
  139. background-color: #fff;
  140. margin: -0.93 * 100rpx auto 0 auto;
  141. padding-top: 0.8 * 100rpx;
  142. padding-bottom: 30rpx;
  143. z-index: 20;
  144. position: relative;
  145. border-radius: 0.06 * 100rpx 0.06 * 100rpx 0 0;
  146. }
  147. .OrderCancellation .whiteBg .input {
  148. width: 5.8 * 100rpx;
  149. margin: 0 auto;
  150. border-bottom: 0.01 * 100rpx solid #eee;
  151. }
  152. .OrderCancellation .whiteBg .input input {
  153. padding-bottom: 0.25 * 100rpx;
  154. font-size: 0.6 * 100rpx;
  155. height: auto;
  156. color: #282828;
  157. width: 100%;
  158. text-align: center;
  159. }
  160. .OrderCancellation .whiteBg .bnt {
  161. font-size: 0.32 * 100rpx;
  162. color: #fff;
  163. width: 5.8 * 100rpx;
  164. height: 0.86 * 100rpx;
  165. border-radius: 0.43 * 100rpx;
  166. background-image: linear-gradient(to right, #eb3729 0%, #eb3729 100%);
  167. background-image: -webkit-linear-gradient(to right, #eb3729 0%, #eb3729 100%);
  168. background-image: -moz-linear-gradient(to right, #eb3729 0%, #eb3729 100%);
  169. text-align: center;
  170. line-height: 0.86 * 100rpx;
  171. margin: 0.55 * 100rpx auto 0 auto;
  172. }
  173. .OrderCancellation .scan {
  174. width: 3 * 100rpx;
  175. height: 3 * 100rpx;
  176. margin: 1.1 * 100rpx auto 0 auto;
  177. }
  178. .OrderCancellation .scan image {
  179. width: 100%;
  180. height: 100%;
  181. display: block;
  182. }
  183. </style>