cm-coupon-list.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="cm-coupon-list">
  3. <view class="mask" v-if="visible"></view>
  4. <view class="main-content">
  5. <uni-transition mode-class="slide-bottom" :show="visible">
  6. <view class="content">
  7. <!-- 关闭弹框按钮 -->
  8. <view class="iconfont icon-iconfontguanbi close" @click="$emit('close')"></view>
  9. <!-- 弹框标题 -->
  10. <view class="title">{{ title }}</view>
  11. <view class="other" v-if="listType !== 'receive'">
  12. <!-- 勾选不使用优惠券 -->
  13. <view class="unset" v-if="listType === 'use'">
  14. <text>不使用优惠券</text> <text class="radio-flag iconfont icon-xuanze"></text>
  15. </view>
  16. <!-- tab切换 -->
  17. <view class="tabs" v-if="listType === 'search'">
  18. <view
  19. class="tab"
  20. :class="{ active: currentTab === index }"
  21. v-for="(tab, index) in tabs"
  22. :key="index"
  23. @click="checkedTab(index)"
  24. >
  25. <text>{{ tab.name }}</text> <text>({{ 1 }})</text>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="list" :class="['scroll-' + listType]">
  30. <!-- 优惠券列表 -->
  31. <cm-coupon :key="i" v-for="i in 6"></cm-coupon>
  32. <!-- 使用优惠券按钮 -->
  33. <view class="btn" @click="confirm" v-if="listType === 'use'">确定</view>
  34. <!-- IPhoneX 以上版本适配 -->
  35. <view :style="{ height: isIphoneX ? '40rpx' : 0 }"></view>
  36. </view>
  37. </view>
  38. </uni-transition>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import CmCoupon from '@/components/cm-module/cm-coupon/cm-coupon.vue'
  44. import { mapGetters } from 'vuex'
  45. export default {
  46. name: 'cm-coupon-list',
  47. components: {
  48. CmCoupon
  49. },
  50. props: {
  51. // 列表标题
  52. title: {
  53. type: String,
  54. default: '优惠券'
  55. },
  56. // 优惠券列表
  57. couponList: {
  58. type: Object,
  59. default: () => {}
  60. },
  61. // 显示弹窗
  62. visible: {
  63. type: Boolean,
  64. default: false
  65. },
  66. // 列表类型 receive 领取 use 使用 search 查看
  67. listType: {
  68. type: String,
  69. default: 'receive'
  70. }
  71. },
  72. data() {
  73. return {
  74. currentTab: 0,
  75. tabs: [
  76. {
  77. name: '已领取优惠券'
  78. },
  79. {
  80. name: '可领取优惠券'
  81. }
  82. ]
  83. }
  84. },
  85. computed: {
  86. ...mapGetters(['isIphoneX'])
  87. },
  88. methods: {
  89. // 确认需要把优惠券对象返回
  90. confirm() {
  91. this.$emit('confirm')
  92. },
  93. checkedTab(index) {
  94. this.currentTab = index
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. $grid: 24rpx;
  101. $title-top: 50rpx;
  102. $title-bottom: 28rpx;
  103. $title-line-height: 50rpx;
  104. $other-line-height: 40rpx;
  105. $tabs-height: 80rpx;
  106. $main-height: 1028rpx;
  107. $base-scroll-height: $main-height - $title-top - $title-bottom - $title-line-height;
  108. .mask {
  109. position: fixed;
  110. bottom: 0;
  111. left: 0;
  112. width: 100%;
  113. height: 100%;
  114. background: rgba(0, 0, 0, 0.5);
  115. z-index: 99998;
  116. }
  117. .cm-coupon-list {
  118. .main-content {
  119. width: 750rpx;
  120. position: fixed;
  121. bottom: 0;
  122. left: 0;
  123. z-index: 99999;
  124. .content {
  125. position: relative;
  126. width: 100%;
  127. height: $main-height;
  128. border-radius: 16rpx 16rpx 0px 0px;
  129. background: #fff;
  130. .close {
  131. position: absolute;
  132. top: 36rpx;
  133. right: 36rpx;
  134. font-size: 34rpx;
  135. color: #b2b2b2;
  136. }
  137. .title {
  138. padding: $title-top 0 $title-bottom;
  139. text-align: center;
  140. font-size: 34rpx;
  141. font-weight: 500;
  142. line-height: $title-line-height;
  143. color: #333333;
  144. }
  145. .other {
  146. padding: 0 $grid $grid;
  147. line-height: $other-line-height;
  148. .unset {
  149. display: flex;
  150. justify-content: space-between;
  151. align-items: center;
  152. padding-right: 30rpx;
  153. font-size: 30rpx;
  154. color: #333333;
  155. .radio-flag {
  156. color: #ff457b;
  157. }
  158. }
  159. .tabs {
  160. height: $tabs-height;
  161. line-height: $tabs-height;
  162. border-bottom: 1px solid #e1e1e1;
  163. display: flex;
  164. justify-content: space-around;
  165. align-items: center;
  166. .tab {
  167. position: relative;
  168. font-size: 30rpx;
  169. color: #333333;
  170. &::after {
  171. content: '';
  172. position: absolute;
  173. width: 100%;
  174. height: 4rpx;
  175. bottom: 0;
  176. left: 0;
  177. background-color: #fff;
  178. }
  179. &.active {
  180. color: #ff457b;
  181. &::after {
  182. background-color: #ff457b;
  183. }
  184. }
  185. }
  186. }
  187. }
  188. .list {
  189. overflow-y: scroll;
  190. // 查看优惠券
  191. &.scroll-search {
  192. height: $base-scroll-height - $tabs-height;
  193. }
  194. // 领取优惠券
  195. &.scroll-receive {
  196. height: $base-scroll-height;
  197. }
  198. // 使用优惠券
  199. &.scroll-use {
  200. height: $base-scroll-height - $other-line-height - $grid;
  201. }
  202. .btn {
  203. width: 600rpx;
  204. height: 90rpx;
  205. margin: $grid auto;
  206. background: linear-gradient(90deg, #fc32b4 0%, #f83c6c 100%);
  207. opacity: 1;
  208. border-radius: 45rpx;
  209. line-height: 90rpx;
  210. text-align: center;
  211. font-size: 30rpx;
  212. color: #ffffff;
  213. }
  214. }
  215. }
  216. }
  217. }
  218. </style>