index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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} = await getCoupons({ writeCode: this.iptValue });
  71. // 传递值过去
  72. uni.navigateTo({
  73. url: `/pages_module/orderVerifica/index?orderId=${data.orderId}&code=${data.writeCode}`,
  74. });
  75. console.log(res);
  76. },
  77. // 删除单个字符
  78. deleteOne() {
  79. this.iptValue = this.iptValue.slice(0, this.iptValue.length - 1);
  80. },
  81. },
  82. };
  83. </script>
  84. <style lang="scss" scoped>
  85. .scanCoupons {
  86. width: 100%;
  87. height: 100vh;
  88. background-color: rgb(241, 241, 241);
  89. .shop-top {
  90. width: 100%;
  91. height: 100%;
  92. position: relative;
  93. z-index: 999;
  94. @include flex(center);
  95. .back-icon {
  96. position: absolute;
  97. left: 0;
  98. top: 50%;
  99. transform: translateY(-50%);
  100. }
  101. .shop-name {
  102. color: #000000;
  103. }
  104. }
  105. .seat {
  106. width: 100%;
  107. height: 30rpx;
  108. background-color: #ffffff;
  109. }
  110. .ipt {
  111. margin-top: 50rpx;
  112. width: 100%;
  113. .ipt-box {
  114. width: 686rpx;
  115. height: 108rpx;
  116. background-color: #ffffff;
  117. margin: 0 auto;
  118. box-sizing: border-box;
  119. padding: 32rpx 0 32rpx 38rpx;
  120. border-radius: 16rpx;
  121. .ipt-empty {
  122. color: #999999;
  123. font-size: 36rpx;
  124. position: relative;
  125. &::after {
  126. content: "";
  127. width: 6rpx;
  128. height: 80%;
  129. background-color: #ef530e;
  130. position: absolute;
  131. left: -14rpx;
  132. top: 60%;
  133. transform: translateY(-60%);
  134. }
  135. }
  136. .ipt-code {
  137. width: 100%;
  138. overflow-x: scroll;
  139. color: #333333;
  140. font-size: 36rpx;
  141. }
  142. }
  143. }
  144. .footer {
  145. position: fixed;
  146. left: 0;
  147. bottom: 0;
  148. width: 100%;
  149. /* 底部安全区域 */
  150. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  151. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  152. }
  153. }
  154. </style>