index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="scanCoupons">
  3. <capsule :showBorder="true" bgColor="#FFFFFF">
  4. <template v-slot:top>
  5. <view class="shop-top">
  6. <view class="back-icon" @click="backClick">
  7. <tui-icon name="arrowleft" :size="42" color="#000000"></tui-icon>
  8. </view>
  9. <view class="shop-name">{{ shopInfo.shopName }}</view>
  10. </view>
  11. </template>
  12. </capsule>
  13. <view class="seat"></view>
  14. <view class="ipt">
  15. <view class="ipt-box">
  16. <template v-if="iptValue == ''">
  17. <view class="ipt-empty">请输入劵码</view>
  18. </template>
  19. <template v-else>
  20. <view class="ipt-code">{{ iptValue }}</view>
  21. </template>
  22. </view>
  23. </view>
  24. <view class="footer">
  25. <keyboard
  26. :iptValue="iptValue"
  27. @single="singleWord"
  28. @deleteOne="deleteOne"
  29. @deleteAll="this.iptValue = ''"
  30. @setVerifica="setVerifica"
  31. >
  32. </keyboard>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import { getCoupons } from "@/config/index";
  38. export default {
  39. created() {
  40. // 获取本地存储的店铺数据
  41. this.shopInfo = uni.getStorageSync("shopInfo");
  42. },
  43. data() {
  44. return {
  45. shopInfo: {},
  46. iptValue: "",
  47. };
  48. },
  49. methods: {
  50. backClick() {
  51. uni.navigateBack({
  52. delta: 1,
  53. fail: () => {
  54. uni.switchTab({
  55. url: "/pages/tabbar/index/index",
  56. });
  57. },
  58. });
  59. },
  60. // 修改单个验劵码
  61. singleWord(val) {
  62. this.iptValue = `${this.iptValue}${val}`;
  63. },
  64. // 验劵
  65. async setVerifica() {
  66. if (this.iptValue == "") {
  67. this.$showToast("请输入劵码");
  68. return;
  69. }
  70. let {data,code} = await getCoupons({ writeCode: this.iptValue });
  71. if(code == "核销码错误"){
  72. this.$showToast("核销码错误")
  73. return
  74. }
  75. // 传递值过去
  76. uni.navigateTo({
  77. url: `/pages_module/orderVerifica/index?orderId=${data.orderId}&code=${data.writeCode}`,
  78. });
  79. console.log(res);
  80. },
  81. // 删除单个字符
  82. deleteOne() {
  83. this.iptValue = this.iptValue.slice(0, this.iptValue.length - 1);
  84. },
  85. },
  86. };
  87. </script>
  88. <style lang="scss" scoped>
  89. .scanCoupons {
  90. width: 100%;
  91. height: 100vh;
  92. background-color: rgb(241, 241, 241);
  93. .shop-top {
  94. width: 100%;
  95. height: 100%;
  96. position: relative;
  97. z-index: 999;
  98. @include flex(center);
  99. .back-icon {
  100. position: absolute;
  101. left: 0;
  102. top: 50%;
  103. transform: translateY(-50%);
  104. }
  105. .shop-name {
  106. color: #000000;
  107. }
  108. }
  109. .seat {
  110. width: 100%;
  111. height: 30rpx;
  112. background-color: #ffffff;
  113. }
  114. .ipt {
  115. margin-top: 50rpx;
  116. width: 100%;
  117. .ipt-box {
  118. width: 686rpx;
  119. height: 108rpx;
  120. background-color: #ffffff;
  121. margin: 0 auto;
  122. box-sizing: border-box;
  123. padding: 32rpx 0 32rpx 38rpx;
  124. border-radius: 16rpx;
  125. .ipt-empty {
  126. color: #999999;
  127. font-size: 36rpx;
  128. position: relative;
  129. &::after {
  130. content: "";
  131. width: 6rpx;
  132. height: 80%;
  133. background-color: #ef530e;
  134. position: absolute;
  135. left: -14rpx;
  136. top: 60%;
  137. transform: translateY(-60%);
  138. }
  139. }
  140. .ipt-code {
  141. width: 100%;
  142. overflow-x: scroll;
  143. color: #333333;
  144. font-size: 36rpx;
  145. }
  146. }
  147. }
  148. .footer {
  149. position: fixed;
  150. left: 0;
  151. bottom: 0;
  152. width: 100%;
  153. /* 底部安全区域 */
  154. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  155. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  156. }
  157. }
  158. </style>