1
0

app-goods-coupon.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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="box-grow-0 block-name">领券</view>
  6. <view class="big-box dir-left-nowrap cross-center" v-for="(item, index) in newCoupons" :key="index">
  7. <view class="box" :class="sign !== 'gift' ? theme + '-m-text ' + theme : 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" @touchmove.stop.prevent>
  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 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: 'app-goods-coupon',
  80. props: {
  81. coupons: Array,
  82. theme: String,
  83. sign: String
  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. & :empty {
  155. margin: 0;
  156. }
  157. .block {
  158. background-color: #ffffff;
  159. font-size: #{26upx};
  160. color: #999999;
  161. height: 80upx;
  162. position: relative;
  163. padding: 0 #{24rpx} 0 #{24rpx};
  164. image {
  165. width: #{12rpx};
  166. height: #{22rpx};
  167. display: block;
  168. position: absolute;
  169. right: 24upx;
  170. }
  171. .block-name {
  172. margin-right: 30upx;
  173. }
  174. }
  175. }
  176. .model {
  177. height: #{1100upx};
  178. width: 750upx;
  179. .f-top {
  180. height: 105upx;
  181. border-bottom: 1upx solid #e2e2e2;
  182. padding-left:24upx;
  183. background-color: #ffffff;
  184. .f-image {
  185. width: 78upx;
  186. height: 78upx;
  187. padding: 24upx;
  188. .f-img {
  189. width: 30upx;
  190. height: 30upx;
  191. }
  192. }
  193. }
  194. .f-scroll {
  195. height: 995upx;
  196. width: 100%;
  197. background-color: #f7f7f7;
  198. .f-scroll-content {
  199. padding: 0 24upx;
  200. height: 995upx;
  201. width: 100%;
  202. }
  203. .f-item {
  204. width: 702upx;
  205. height: 272upx;
  206. border: 1upx solid #cfcfcf;
  207. margin-top: 17upx;
  208. border-radius: 14upx;
  209. background-color: #ffffff;
  210. }
  211. .f-item:last-child {
  212. margin-bottom: 24upx;
  213. }
  214. .f-item-top {
  215. height: 159upx;
  216. position: relative;
  217. >image {
  218. height: 159upx;
  219. width: 100%;
  220. }
  221. >view {
  222. position: absolute;
  223. top: 0;
  224. width: 702upx;
  225. height: 159upx;
  226. padding: 0 24upx;
  227. color: #ffffff;
  228. }
  229. .dir-left-nowrap>button {
  230. width: 161upx;
  231. height: 56upx;
  232. line-height: 56upx;
  233. padding: 0;
  234. border: none;
  235. margin: 0;
  236. border-radius: 28upx;
  237. background-color: #ffffff;
  238. font-size: 26upx;
  239. text-align: center;
  240. }
  241. .f-text-content {
  242. padding-bottom: 25upx;
  243. }
  244. .f-big-text-dis text{
  245. line-height: 1;
  246. }
  247. .f-big-text-dis text:first-child {
  248. font-size: 56upx;
  249. font-weight: bold;
  250. }
  251. .f-big-text-dis text:last-child {
  252. font-size: 34upx;
  253. margin-left: 14upx;
  254. }
  255. .f-small-text {
  256. font-size: 24upx;
  257. margin-left: 27upx;
  258. }
  259. .f-big-text-pri text {
  260. line-height: 1;
  261. }
  262. .f-big-text-pri text:first-child {
  263. font-size: 27upx;
  264. }
  265. .f-big-text-pri text:last-child {
  266. font-size: 56upx;
  267. font-weight: bold;
  268. }
  269. }
  270. .f-item-bottom {
  271. height: 111upx;
  272. padding: 24upx;
  273. text {
  274. font-size: 22upx;
  275. color: #545454;
  276. }
  277. }
  278. }
  279. }
  280. .big-box {
  281. overflow: hidden;
  282. margin-right: 10upx;
  283. padding-right: 1rpx;
  284. }
  285. .box {
  286. border: 1upx solid;
  287. border-radius: 4upx;
  288. position: relative;
  289. display: inline-block;
  290. padding: 2upx 12upx;
  291. font-size: 20upx;
  292. transform: rotateZ(360deg);
  293. .left,.right {
  294. width: 10upx;
  295. height: 10upx;
  296. border-radius: 50%;
  297. position: absolute;
  298. z-index: 1;
  299. top: 50%;
  300. border: 1upx solid;
  301. background-color: #ffffff;
  302. }
  303. .left {
  304. left: 0;
  305. transform: translate(-51%, -50%);
  306. }
  307. .right {
  308. right: 0;
  309. transform: translate(51%,-50%);
  310. }
  311. }
  312. </style>