bd-coupon.vue 11 KB

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