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. <text class="box-grow-0 bd-name">领券</text>
  6. <view class="big-box dir-left-nowrap cross-center" v-for="(item, index) in newCoupons" :key="index">
  7. <view class="box" :class="theme.color">
  8. 满{{item.min_price}}元{{item.type == 1 ? '享' : '减'}}{{item.type == 1 ?item.discount + '折' : item.sub_price}}
  9. <view class="left"></view>
  10. <view class="right"></view>
  11. </view>
  12. </view>
  13. <image class="box-grow-0" src="../../../static/image/icon/arrow-right.png"></image>
  14. </view>
  15. </view>
  16. <u-popup v-model="show" mode="bottom" border-radius="14" @close="show = false">
  17. <view class="model">
  18. <view class="f-top dir-left-nowrap main-between cross-center">
  19. <view class="f-title">可领取优惠券</view>
  20. <view class="f-image" @click="show = false">
  21. <image class="f-img" src="/static/image/icon/icon-close.png" ></image>
  22. </view>
  23. </view>
  24. <scroll-view :scroll-y="true" class="f-scroll">
  25. <view class="f-scroll-content">
  26. <view class="f-item dir-top-nowrap" v-for="(item, index) in coupons" :key="index">
  27. <view class="f-item-top">
  28. <image :src="couponImg[item.is_receive == 0 ? 'coupon_enabled' : 'coupon_disabled']"></image>
  29. <view class="dir-left-nowrap main-between cross-center">
  30. <view class="f-text-content dir-left-nowrap cross-bottom">
  31. <view class="f-big-text-dis" v-if="item.type == 1">
  32. <text>{{item.discount}}</text>
  33. <text>折</text>
  34. </view>
  35. <view class="f-big-text-pri" v-else-if="item.type == 2">
  36. <text>¥</text>
  37. <text>{{item.sub_price}}</text>
  38. </view>
  39. <view class="f-small-text">
  40. <view>优惠券</view>
  41. <view>满{{item.min_price}}元使用</view>
  42. </view>
  43. </view>
  44. <button @click="receive(item.id, index)" :style="{'color': item.is_receive == 0 ? '#caa76e' : '#b4b4b4'}">{{item.is_receive == 0 ? '立即领取' : '已领取'}}</button>
  45. </view>
  46. </view>
  47. <view class="f-item-bottom dir-top-nowrap">
  48. <text v-if="item.expire_type == `1`">领取后{{item.expire_day}}天过期</text>
  49. <text v-if="item.expire_type == `2`">有效日期:{{item.begin_time}} - {{item.end_time}}</text>
  50. <text class="t-omit" v-if="item.appoint_type == `3`">适用范围:全场通用</text>
  51. <text class="t-omit" v-else-if="item.appoint_type == `4`">适用范围:仅限当面付活动使用</text>
  52. <text class="t-omit" v-else-if="item.appoint_type == `5`">适用范围:仅限礼品卡使用</text>
  53. <text class="t-omit" v-else-if="item.appoint_type == `2`">
  54. <text>适用商品:</text>
  55. <block v-for="(goods,index) in item.goods" :key="goods.id">
  56. <text>{{index !== 0 ? '、' : ''}}{{goods.name}}</text>
  57. </block>
  58. </text>
  59. <text class="t-omit" v-else-if="item.appoint_type == `1`">
  60. 适用分类:
  61. <block v-for="(cat,index) in item.cat" :key="cat.id">
  62. {{index !== 0 ? '、' : ''}}{{cat.name}}
  63. </block>
  64. </text>
  65. </view>
  66. </view>
  67. </view>
  68. </scroll-view>
  69. </view>
  70. </u-popup>
  71. </view>
  72. </template>
  73. <script>
  74. import uPopup from '../../basic-component/u-popup/u-popup.vue';
  75. import appExclusiveCoupon from '../../page-component/app-exclusive-coupon/app-exclusive-coupon.vue';
  76. import {mapState} from "vuex";
  77. import user from '../../../core/user.js';
  78. export default {
  79. name: 'bd-coupon',
  80. props: {
  81. coupons: Array,
  82. theme: Object,
  83. guarantee_title: {
  84. type: String
  85. },
  86. },
  87. data() {
  88. return {
  89. show: false,
  90. newCoupons: []
  91. }
  92. },
  93. methods: {
  94. async receive(id, index) {
  95. uni.showLoading({
  96. mask: true,
  97. title: '领取中'
  98. });
  99. const e = await this.$request({
  100. url: this.$api.coupon.receive,
  101. data: {
  102. coupon_id: id
  103. }
  104. });
  105. uni.hideLoading();
  106. if (e.code === 1) {
  107. uni.showModal({
  108. title: '提示',
  109. content: e.msg,
  110. showCancel: false,
  111. });
  112. } else {
  113. if (e.data.rest == 0) {
  114. this.$emit('change', index);
  115. }
  116. uni.showToast({
  117. icon: 'none',
  118. title: '领取成功',
  119. duration: 1000,
  120. });
  121. }
  122. },
  123. setShow() {
  124. if (user.isLogin()) {
  125. this.show = true;
  126. } else {
  127. this.$user.getInfo();
  128. }
  129. }
  130. },
  131. computed: {
  132. ...mapState({
  133. couponImg: state => state.mallConfig.__wxapp_img.coupon,
  134. })
  135. },
  136. components: {
  137. uPopup,
  138. appExclusiveCoupon
  139. },
  140. watch: {
  141. coupons: {
  142. handler(data) {
  143. this.newCoupons = data.slice(0, 3);
  144. },
  145. deep: true,
  146. immediate: true
  147. }
  148. }
  149. }
  150. </script>
  151. <style scoped lang="scss">
  152. .content {
  153. padding: 10upx 0 10upx 30upx;
  154. }
  155. .marketing {
  156. width: 702upx;
  157. border-radius: 15upx;
  158. padding: 20upx;
  159. background-color: #ffffff;
  160. height: 88upx;
  161. line-height: 48upx;
  162. margin: 24upx 24upx 0 24upx;
  163. .block {
  164. position: relative;
  165. image {
  166. width: 12upx;
  167. height: 22upx;
  168. position: absolute;
  169. right: 0;
  170. }
  171. .bd-name {
  172. margin-right: 26upx;
  173. font-size: #{26upx};
  174. color: #999999;
  175. }
  176. }
  177. }
  178. .big-box {
  179. overflow: hidden;
  180. margin-right: 10upx;
  181. }
  182. .box {
  183. border: 1upx solid;
  184. border-radius: 4upx;
  185. position: relative;
  186. display: inline-block;
  187. box-sizing: content-box;
  188. padding: 0 12upx;
  189. font-size: 20upx;
  190. height: 30upx;
  191. line-height: 32upx;
  192. .left,.right {
  193. width: 10upx;
  194. height: 10upx;
  195. border-radius: 50%;
  196. position: absolute;
  197. z-index: 1;
  198. top: 50%;
  199. border: 1upx solid;
  200. background-color: #ffffff;
  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>