index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 :iptValue='iptValue' @single="singleWord" @deleteOne="deleteOne" @deleteAll="this.iptValue = ''">
  26. </keyboard>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. created() {
  33. // 获取本地存储的店铺数据
  34. this.shopInfo = uni.getStorageSync('shopInfo')
  35. },
  36. data() {
  37. return {
  38. shopInfo: {},
  39. iptValue: '',
  40. }
  41. },
  42. methods: {
  43. backClick() {
  44. uni.navigateBack()
  45. },
  46. // 修改单个验劵码
  47. singleWord(val) {
  48. this.iptValue = `${this.iptValue}${val}`
  49. },
  50. // 删除单个字符
  51. deleteOne() {
  52. this.iptValue = this.iptValue.slice(0, this.iptValue.length - 1)
  53. },
  54. },
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. .scanCoupons {
  59. width: 100%;
  60. height: 100vh;
  61. background-color: rgb(241, 241, 241);
  62. .shop-top {
  63. width: 100%;
  64. height: 100%;
  65. position: relative;
  66. z-index: 999;
  67. @include flex(center);
  68. .back-icon {
  69. position: absolute;
  70. left: 0;
  71. top: 50%;
  72. transform: translateY(-50%);
  73. }
  74. .shop-name {
  75. color: #000000;
  76. }
  77. }
  78. .seat {
  79. width: 100%;
  80. height: 30rpx;
  81. background-color: #FFFFFF;
  82. }
  83. .ipt {
  84. margin-top: 50rpx;
  85. width: 100%;
  86. .ipt-box {
  87. width: 686rpx;
  88. height: 108rpx;
  89. background-color: #FFFFFF;
  90. margin: 0 auto;
  91. box-sizing: border-box;
  92. padding: 32rpx 0 32rpx 38rpx;
  93. border-radius: 16rpx;
  94. .ipt-empty {
  95. color: #999999;
  96. font-size: 36rpx;
  97. position: relative;
  98. &::after {
  99. content: '';
  100. width: 6rpx;
  101. height: 80%;
  102. background-color: #EF530E;
  103. position: absolute;
  104. left: -14rpx;
  105. top: 60%;
  106. transform: translateY(-60%);
  107. }
  108. }
  109. .ipt-code {
  110. width: 100%;
  111. overflow-x: scroll;
  112. color: #333333;
  113. font-size: 36rpx;
  114. }
  115. }
  116. }
  117. .footer {
  118. position: fixed;
  119. left: 0;
  120. bottom: 0;
  121. width: 100%;
  122. /* 底部安全区域 */
  123. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  124. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  125. }
  126. }
  127. </style>