cm-coupon-list.vue 7.5 KB

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