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.

198 lines
3.8 KiB

3 years ago
  1. <template>
  2. <uni-popup ref="popup" type="bottom">
  3. <view class="wrap">
  4. <view class="s-header center">
  5. <text class="btn" @click="close">取消</text>
  6. <text>请选择优惠券</text>
  7. <text class="btn" @click="confirm">确定</text>
  8. </view>
  9. <scroll-view class="scroll-view" scroll-y="true">
  10. <view class="coupon-item" v-for="(item,index) in list" :key="index" @click="checkCoupon(item)">
  11. <view class="con">
  12. <view class="left">
  13. <text class="title clamp">{{item.title}}</text>
  14. <text class="time">有效期至 {{ item.end_time | date('Y-m-d H:i') }}</text>
  15. </view>
  16. <view class="right">
  17. <text class="price">{{item.coupon_money}}</text>
  18. <text>{{ item.total_money }}可用</text>
  19. </view>
  20. <view class="circle l"></view>
  21. <view class="circle r"></view>
  22. </view>
  23. <view class="bot row">
  24. <text class="tips">平台所有商品可用</text>
  25. <text v-if="curCoupon._id === item._id" class="mix-icon icon-xuanzhong"></text>
  26. </view>
  27. </view>
  28. </scroll-view>
  29. </view>
  30. </uni-popup>
  31. </template>
  32. <script>
  33. /**
  34. * 优惠券选择弹窗
  35. * @prop {Array} list 用户可用优惠券列表
  36. */
  37. export default {
  38. data() {
  39. return {
  40. curCoupon: {}
  41. }
  42. },
  43. props: {
  44. list: {
  45. type: Array,
  46. default(){
  47. return []
  48. }
  49. }
  50. },
  51. methods: {
  52. //确定选择
  53. confirm(){
  54. this.$emit('confirm', this.curCoupon);
  55. this.close();
  56. },
  57. //选择优惠券
  58. checkCoupon(item){
  59. if(this.curCoupon._id === item._id){
  60. this.curCoupon = {};
  61. }else{
  62. this.curCoupon = item;
  63. }
  64. },
  65. open(type){
  66. this.$refs.popup.open();
  67. },
  68. close(){
  69. this.$refs.popup.close();
  70. }
  71. }
  72. }
  73. </script>
  74. <style scoped lang="scss">
  75. .wrap{
  76. padding-bottom: 10rpx;
  77. border-radius: 16rpx 16rpx 0 0;
  78. background-color: #f7f7f7;
  79. }
  80. .s-header{
  81. justify-content: space-between;
  82. padding: 30rpx 0 14rpx;
  83. font-size: 32rpx;
  84. color: #333;
  85. font-weight: 700;
  86. .btn{
  87. padding: 10rpx 36rpx;
  88. font-size: 28rpx;
  89. color: #666;
  90. font-weight: normal;
  91. &:last-child{
  92. color: $base-color;
  93. }
  94. }
  95. }
  96. .scroll-view{
  97. min-height: 50vh;
  98. max-height: 70vh;
  99. }
  100. .coupon-item{
  101. display: flex;
  102. flex-direction: column;
  103. margin: 20rpx 24rpx;
  104. background: #fff;
  105. .con{
  106. display: flex;
  107. align-items: center;
  108. position: relative;
  109. height: 140rpx;
  110. padding: 0 30rpx;
  111. &:after{
  112. position: absolute;
  113. left: 0;
  114. bottom: 0;
  115. content: '';
  116. width: 100%;
  117. height: 0;
  118. border-bottom: 1px dashed #e5e5e5;
  119. transform: scaleY(50%);
  120. }
  121. }
  122. .left{
  123. display: flex;
  124. flex-direction: column;
  125. justify-content: center;
  126. flex: 1;
  127. overflow: hidden;
  128. height: 100rpx;
  129. }
  130. .title{
  131. font-size: 32rpx;
  132. color: #333;
  133. margin-bottom: 24rpx;
  134. }
  135. .time{
  136. font-size: 24rpx;
  137. color: #999;
  138. }
  139. .right{
  140. display: flex;
  141. flex-direction: column;
  142. justify-content: center;
  143. align-items: center;
  144. margin-left: 30rpx;
  145. font-size: 24rpx;
  146. color: #666;
  147. height: 100rpx;
  148. }
  149. .price{
  150. margin-bottom: 14rpx;
  151. font-size: 50rpx;
  152. color: $base-color;
  153. font-weight: 700;
  154. &:before{
  155. content: '¥';
  156. font-size: 34rpx;
  157. }
  158. }
  159. .bot{
  160. height: 72rpx;
  161. padding: 0 28rpx 0 30rpx;
  162. .tips{
  163. flex: 1;
  164. font-size: 24rpx;
  165. color: #999;
  166. }
  167. .icon-xuanzhong{
  168. font-size: 36rpx;
  169. color: $base-color;
  170. }
  171. }
  172. .circle{
  173. position: absolute;
  174. left: -6rpx;
  175. bottom: -10rpx;
  176. z-index: 10;
  177. width: 20rpx;
  178. height: 20rpx;
  179. background: #f3f3f3;
  180. border-radius: 100px;
  181. &.r{
  182. left: auto;
  183. right: -6rpx;
  184. }
  185. }
  186. }
  187. </style>