bd-coupon.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <view class="coupon" v-if="newCoupons.length > 0">
  3. <view class="marketing">
  4. <view class="block dir-left-nowrap cross-center" @click="setShow">
  5. <view class="big-box dir-left-nowrap cross-center" v-for="(item, index) in newCoupons" :key="index">
  6. <view class="box">
  7. <image class="icon-coupon" src="../../../static/image/icon/icon-coupon.png"></image>
  8. 满{{item.min_price}}元{{item.type == 1 ? '享' : '减'}}{{item.type == 1 ?item.discount + '折' : item.sub_price}}
  9. </view>
  10. </view>
  11. <text class="box-grow-0 bd-name">领券 ></text>
  12. </view>
  13. </view>
  14. <u-popup v-model="show" mode="bottom" border-radius="14" @close="show = false">
  15. <view class="model">
  16. <view class="f-top dir-left-nowrap main-between cross-center">
  17. <view class="f-title">可领取优惠券</view>
  18. <view class="f-image" @click="show = false">
  19. <image class="f-img" src="/static/image/icon/icon-close.png" ></image>
  20. </view>
  21. </view>
  22. <scroll-view :scroll-y="true" class="f-scroll">
  23. <view class="f-scroll-content">
  24. <view class="f-item dir-top-nowrap" v-for="(item, index) in coupons" :key="index">
  25. <view class="f-item-top">
  26. <image :src="couponImg[item.is_receive == 0 ? 'coupon_enabled' : 'coupon_disabled']"></image>
  27. <view class="dir-left-nowrap main-between cross-center">
  28. <view class="f-text-content dir-left-nowrap cross-bottom">
  29. <view class="f-big-text-dis" v-if="item.type == 1">
  30. <text>{{item.discount}}</text>
  31. <text>折</text>
  32. </view>
  33. <view class="f-big-text-pri" v-else-if="item.type == 2">
  34. <text>¥</text>
  35. <text>{{item.sub_price}}</text>
  36. </view>
  37. <view class="f-small-text">
  38. <view>优惠券</view>
  39. <view>满{{item.min_price}}元使用</view>
  40. </view>
  41. </view>
  42. <button @click="receive(item.id, index)" :style="{'color': item.is_receive == 0 ? '#caa76e' : '#b4b4b4'}">{{item.is_receive == 0 ? '立即领取' : '已领取'}}</button>
  43. </view>
  44. </view>
  45. <view class="f-item-bottom dir-top-nowrap">
  46. <text v-if="item.expire_type == `1`">领取后{{item.expire_day}}天过期</text>
  47. <text v-if="item.expire_type == `2`">有效日期:{{item.begin_time}} - {{item.end_time}}</text>
  48. <text class="t-omit" v-if="item.appoint_type == `3`">适用范围:全场通用</text>
  49. <text class="t-omit" v-else-if="item.appoint_type == `4`">适用范围:仅限当面付活动使用</text>
  50. <text class="t-omit" v-else-if="item.appoint_type == `5`">适用范围:仅限礼品卡使用</text>
  51. <text class="t-omit" v-else-if="item.appoint_type == `2`">
  52. <text>适用商品:</text>
  53. <block v-for="(goods,index) in item.goods" :key="goods.id">
  54. <text>{{index !== 0 ? '、' : ''}}{{goods.name}}</text>
  55. </block>
  56. </text>
  57. <text class="t-omit" v-else-if="item.appoint_type == `1`">
  58. 适用分类:
  59. <block v-for="(cat,index) in item.cat" :key="cat.id">
  60. {{index !== 0 ? '、' : ''}}{{cat.name}}
  61. </block>
  62. </text>
  63. </view>
  64. </view>
  65. </view>
  66. </scroll-view>
  67. </view>
  68. </u-popup>
  69. </view>
  70. </template>
  71. <script>
  72. import uPopup from '../../basic-component/u-popup/u-popup.vue';
  73. import appExclusiveCoupon from '../../page-component/app-exclusive-coupon/app-exclusive-coupon.vue';
  74. import {mapState} from "vuex";
  75. import user from '../../../core/user.js';
  76. export default {
  77. name: 'bd-coupon',
  78. props: {
  79. coupons: Array,
  80. theme: Object,
  81. guarantee_title: {
  82. type: String
  83. },
  84. },
  85. data() {
  86. return {
  87. show: false,
  88. newCoupons: []
  89. }
  90. },
  91. methods: {
  92. async receive(id, index) {
  93. uni.showLoading({
  94. mask: true,
  95. title: '领取中'
  96. });
  97. const e = await this.$request({
  98. url: this.$api.coupon.receive,
  99. data: {
  100. coupon_id: id
  101. }
  102. });
  103. uni.hideLoading();
  104. if (e.code === 1) {
  105. uni.showModal({
  106. title: '提示',
  107. content: e.msg,
  108. showCancel: false,
  109. });
  110. } else {
  111. if (e.data.rest == 0) {
  112. this.$emit('change', index);
  113. }
  114. uni.showToast({
  115. icon: 'none',
  116. title: '领取成功',
  117. duration: 1000,
  118. });
  119. }
  120. },
  121. setShow() {
  122. if (user.isLogin()) {
  123. this.show = true;
  124. } else {
  125. this.$user.getInfo();
  126. }
  127. }
  128. },
  129. computed: {
  130. ...mapState({
  131. couponImg: state => state.mallConfig.__wxapp_img.coupon,
  132. })
  133. },
  134. components: {
  135. uPopup,
  136. appExclusiveCoupon
  137. },
  138. watch: {
  139. coupons: {
  140. handler(data) {
  141. this.newCoupons = data.slice(0, 3);
  142. },
  143. deep: true,
  144. immediate: true
  145. }
  146. }
  147. }
  148. </script>
  149. <style scoped lang="scss">
  150. .content {
  151. padding: 10upx 0 10upx 30upx;
  152. }
  153. .marketing {
  154. width: 100%;
  155. padding: 20upx;
  156. background-color: #ffffff;
  157. height: 88upx;
  158. line-height: 48upx;
  159. margin-top: 24rpx;
  160. .block {
  161. position: relative;
  162. .bd-name {
  163. margin-right: 26upx;
  164. font-size: #{26upx};
  165. color: #ff3665;
  166. position: absolute;
  167. right: 0;
  168. }
  169. }
  170. }
  171. .big-box {
  172. overflow: hidden;
  173. margin-right: 10upx;
  174. }
  175. .box {
  176. position: relative;
  177. display: inline-block;
  178. box-sizing: content-box;
  179. padding: 0 12upx;
  180. font-size: 20upx;
  181. color: #000000;
  182. display: flex;
  183. align-items: center;
  184. font-size: 25rpx;
  185. .left,.right {
  186. width: 10upx;
  187. height: 10upx;
  188. border-radius: 50%;
  189. position: absolute;
  190. z-index: 1;
  191. top: 50%;
  192. border: 1upx solid;
  193. background-color: #ffffff;
  194. }
  195. .icon-coupon{
  196. position: unset;
  197. width: 46rpx;
  198. height: 46rpx;
  199. right: unset;
  200. margin-right: 5rpx;
  201. }
  202. .left {
  203. left: 0;
  204. transform: translate(-51%, -50%);
  205. }
  206. .right {
  207. right: 0;
  208. transform: translate(51%,-50%);
  209. }
  210. }
  211. .model {
  212. height: #{1100upx};
  213. width: 750upx;
  214. .f-top {
  215. height: 105upx;
  216. border-bottom: 1upx solid #e2e2e2;
  217. padding-left:24upx;
  218. background-color: #ffffff;
  219. .f-image {
  220. width: 78upx;
  221. height: 78upx;
  222. padding: 24upx;
  223. .f-img {
  224. width: 30upx;
  225. height: 30upx;
  226. }
  227. }
  228. }
  229. .f-scroll {
  230. height: 995upx;
  231. width: 100%;
  232. background-color: #f7f7f7;
  233. .f-scroll-content {
  234. padding: 0 24upx;
  235. height: 995upx;
  236. width: 100%;
  237. }
  238. .f-item {
  239. width: 702upx;
  240. height: 272upx;
  241. border: 1upx solid #cfcfcf;
  242. margin-top: 17upx;
  243. border-radius: 14upx;
  244. background-color: #ffffff;
  245. }
  246. .f-item:last-child {
  247. margin-bottom: 24upx;
  248. }
  249. .f-item-top {
  250. height: 159upx;
  251. position: relative;
  252. >image {
  253. height: 159upx;
  254. width: 100%;
  255. }
  256. >view {
  257. position: absolute;
  258. top: 0;
  259. width: 702upx;
  260. height: 159upx;
  261. padding: 0 24upx;
  262. color: #ffffff;
  263. }
  264. .dir-left-nowrap>button {
  265. width: 161upx;
  266. height: 56upx;
  267. line-height: 56upx;
  268. padding: 0;
  269. border: none;
  270. margin: 0;
  271. border-radius: 28upx;
  272. background-color: #ffffff;
  273. font-size: 26upx;
  274. text-align: center;
  275. }
  276. .f-text-content {
  277. padding-bottom: 25upx;
  278. }
  279. .f-big-text-dis text{
  280. line-height: 1;
  281. }
  282. .f-big-text-dis text:first-child {
  283. font-size: 56upx;
  284. font-weight: bold;
  285. }
  286. .f-big-text-dis text:last-child {
  287. font-size: 34upx;
  288. margin-left: 14upx;
  289. }
  290. .f-small-text {
  291. font-size: 24upx;
  292. margin-left: 27upx;
  293. }
  294. .f-big-text-pri text {
  295. line-height: 1;
  296. }
  297. .f-big-text-pri text:first-child {
  298. font-size: 27upx;
  299. }
  300. .f-big-text-pri text:last-child {
  301. font-size: 56upx;
  302. font-weight: bold;
  303. }
  304. }
  305. .f-item-bottom {
  306. height: 111upx;
  307. padding: 24upx;
  308. text {
  309. font-size: 22upx;
  310. color: #545454;
  311. }
  312. }
  313. }
  314. }
  315. </style>