coupon-popup.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <template>
  2. <view class="coupon-popup" :class="showActivity && 'show'">
  3. <global-loading />
  4. <view class="mask" @click="closePopup"></view>
  5. <view id="popupInner" class="couponShow-box">
  6. <view class="tabsbox">
  7. <u-tabs
  8. :list="activeTypeList" bar-width="0" bar-height="0" :bold="false"
  9. active-color="#C5AA7B"
  10. inactive-color="#999999" :is-scroll="false" :current="activeTypeFlag" @change="activeTypeActive"
  11. ></u-tabs>
  12. </view>
  13. <view v-show="activeTypeFlag === 0">
  14. <view class="couponShow">
  15. <view class="title-box">
  16. <image class="close-btn" src="../../static/images/origin/close.png" @click="onActivityClose">
  17. </image>
  18. </view>
  19. <view class="shopCouponBox" :class="markTools.length === 0 && 'flex'">
  20. <view v-if="markTools.length > 0" class="list">
  21. <view v-for="(item, index) in markTools" :key="index" class="item" :class="{ received: item.state === 1 }">
  22. <view class="info-box">
  23. <view v-if="item.couponType == 1" class="discoun">
  24. <text style="font-size: 28rpx">¥</text>{{
  25. item.reduceMoney }}
  26. </view>
  27. <view v-if="item.couponType == 2" class="discoun">{{ item.reduceMoney }}折</view>
  28. <view class="info-date">{{ getDate(item.startTime) }}-{{ getDate(item.endTime) }}</view>
  29. <view class="info-condition mar-top-30">{{ item.content }}</view>
  30. <!-- <view class="info-condition" v-if="item.couponType == 2">{{item.reduceMoney}}折优惠</view> -->
  31. <WxSendCoupon v-if="item.state === 3" :coupon-list="[ item ]" @success="success">
  32. <view v-if="item.state === 3" class="use-btn mar-top-10">
  33. 立即领取
  34. </view>
  35. </WxSendCoupon>
  36. <view v-if="item.state === 0" class="use-btn mar-top-10">已领取</view>
  37. <view v-if="item.state === 1" class="use-btn mar-top-10">已使用</view>
  38. </view>
  39. </view>
  40. </view>
  41. <view v-else class="emptyOrder-box flex-items-plus flex-column">
  42. <image class="emptyOrder-img" src="../../static/images/origin/bgnull.png"></image>
  43. <label class="font-color-999 fs26 mar-top-30">你还没有优惠券哦~</label>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view v-show="activeTypeFlag === 1">
  49. <view class="couponShow">
  50. <view class="title-box">
  51. <image class="close-btn" src="../../static/images/origin/close.png" @click="onActivityClose">
  52. </image>
  53. </view>
  54. <view class="shopCouponBox" :class="shopMarkTools.length === 0 && 'flex'">
  55. <view v-if="shopMarkTools.length > 0" class="list">
  56. <view
  57. v-for="(item, index) in shopMarkTools" :key="index" class="item"
  58. :class="{ received: item.state === 1 }"
  59. >
  60. <view class="info-box">
  61. <view v-if="item.couponType === 1" class="discoun">
  62. <text style="font-size: 28rpx">
  63. </text>{{ item.reduceMoney }}
  64. </view>
  65. <view v-if="item.couponType === 2" class="discoun">{{ item.reduceMoney }}折</view>
  66. <view class="info-date">{{ getDate(item.startTime) }}-{{ getDate(item.endTime) }}</view>
  67. <view v-if="item.couponType === 1" class="info-condition">
  68. 满{{ item.fullMoney }}元减{{ item.reduceMoney }}元
  69. </view>
  70. <view v-if="item.couponType === 2" class="info-condition">
  71. {{ item.reduceMoney }}折优惠
  72. </view>
  73. <view v-if="item.state === 3" class="use-btn" @click="receiveTap(item, 1)">
  74. 立即领取
  75. </view>
  76. <view v-if="item.state === 0" class="use-btn">已领取</view>
  77. </view>
  78. </view>
  79. </view>
  80. <view v-else class="emptyOrder-box flex-items-plus flex-column">
  81. <image class="emptyOrder-img" src="../../static/images/origin/bgnull.png"></image>
  82. <label class="font-color-999 fs26 mar-top-30">你还没有优惠券哦~</label>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <view v-if="isShowSuccess" class="receive-success">
  88. <view class="success-box">
  89. <image class="success-img" src="../../static/images/origin/success_tu.png"></image>
  90. <view class="text">领取成功</view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </template>
  96. <script>
  97. import WxSendCoupon from '@/components/wx/wxSendCoupon'
  98. const NET = require('../../utils/request')
  99. const API = require('../../config/api')
  100. export default {
  101. name: 'CouponPopup',
  102. components: {
  103. WxSendCoupon
  104. },
  105. props: {
  106. markTools: {
  107. type: Array,
  108. default: () => []
  109. },
  110. shopMarkTools: {
  111. type: Array,
  112. default: () => []
  113. },
  114. setTop: {
  115. type: Number,
  116. default: 0
  117. },
  118. currentActive: {
  119. type: Number,
  120. default: 0
  121. }
  122. },
  123. data() {
  124. return {
  125. showActivity: false,
  126. isShowSuccess: false,
  127. activeTypeFlag: this.currentActive,
  128. activeTypeList: [{
  129. name: '平台活动'
  130. }, {
  131. name: '店铺活动'
  132. }]
  133. }
  134. },
  135. methods: {
  136. activeTypeActive(index) {
  137. this.activeTypeFlag = index
  138. },
  139. // 关闭优惠券弹窗
  140. onActivityClose() {
  141. this.showActivity = false
  142. },
  143. // 时间格式化
  144. getDate(time) {
  145. if (!time) return ''
  146. return time.split(' ')[0].split('-').join('.')
  147. },
  148. // 领取优惠券
  149. receiveTap(couponItemInfo, type) {
  150. // uni.showLoading({
  151. // mask: true,
  152. // title: '领取中...',
  153. // })
  154. this.$showLoading('领取中...')
  155. let ReceiveCoupon
  156. if (type === 0) {
  157. ReceiveCoupon = {
  158. couponId: couponItemInfo.couponId,
  159. shopId: this.shopId
  160. }
  161. } else {
  162. ReceiveCoupon = {
  163. shopCouponId: couponItemInfo.shopCouponId,
  164. shopId: this.shopId
  165. }
  166. }
  167. NET.request(API.ReceiveCoupon, ReceiveCoupon, 'POST').then((res) => {
  168. // uni.hideLoading()
  169. this.isShowSuccess = true
  170. setTimeout(() => {
  171. this.isShowSuccess = false
  172. // this.showActivity = false;
  173. // this.queryProductDetail()
  174. }, 1500)
  175. // setTimeout(() => {
  176. // this.showActivity = false
  177. // }, 3000);
  178. })
  179. .catch((res) => {
  180. // uni.hideLoading()
  181. uni.showToast({
  182. title: res.msg,
  183. icon: 'none'
  184. })
  185. })
  186. },
  187. success() {
  188. this.isShowSuccess = true
  189. setTimeout(() => {
  190. this.isShowSuccess = false
  191. }, 1500)
  192. },
  193. closePopup() {
  194. this.showActivity = false
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss" scoped>
  200. .coupon-popup {
  201. display: block;
  202. position: fixed;
  203. top: 0;
  204. left: 0;
  205. right: 0;
  206. bottom: 0;
  207. overflow: hidden;
  208. // background-color: rgba(0, 0, 0, 0.6);
  209. z-index: -1;
  210. opacity: 0;
  211. &.show {
  212. z-index: 1000;
  213. opacity: 1;
  214. .couponShow-box {
  215. /*transform: translate3D(0px, 0px, 0px);*/
  216. bottom: 0;
  217. }
  218. }
  219. .mask {
  220. display: block;
  221. position: fixed;
  222. width: 100%;
  223. height: 100%;
  224. top: 0;
  225. left: 0;
  226. right: 0;
  227. bottom: 0;
  228. overflow: hidden;
  229. background-color: rgba(0, 0, 0, 0.6);
  230. z-index: 1001;
  231. }
  232. .couponShow-box {
  233. .couponShow {
  234. height: 1000rpx;
  235. z-index: 333;
  236. }
  237. width: 100%;
  238. height: auto;
  239. /*transform: translate3d(0px, 100%, 0px);*/
  240. transition: all 0.3s ease-in-out 0s;
  241. background-color: #fff;
  242. position: absolute;
  243. left: 0;
  244. right: 0;
  245. bottom: -100%;
  246. z-index: 1002;
  247. .tabsbox {
  248. padding: 0 20rpx;
  249. /deep/ .u-tab-item {
  250. height: 100rpx !important;
  251. line-height: 100rpx !important;
  252. }
  253. }
  254. .title-box .close-btn {
  255. width: 50upx;
  256. height: 50upx;
  257. box-sizing: border-box;
  258. position: absolute;
  259. top: 20upx;
  260. right: 20upx;
  261. }
  262. // #ifdef MP-ALIPAY
  263. .title-box .close-btn {
  264. width: 30upx;
  265. height: 30upx;
  266. top: 10upx;
  267. right: 10upx;
  268. }
  269. // #endif
  270. .shopCouponBox {
  271. height: 100%;
  272. overflow: auto;
  273. position: relative;
  274. &.flex {
  275. display: flex;
  276. justify-content: center;
  277. align-items: center;
  278. }
  279. .emptyOrder-box {
  280. position: absolute;
  281. top: 0;
  282. bottom: 0;
  283. right: 0;
  284. left: 0;
  285. margin: auto;
  286. // padding-top: 80upx;
  287. .emptyOrder-img {
  288. width: 225upx;
  289. height: 196upx;
  290. }
  291. }
  292. .list {
  293. display: flex;
  294. flex-wrap: wrap;
  295. }
  296. .item {
  297. width: 50%;
  298. height: 291rpx;
  299. background: url("../../static/images/origin/couponsIcon.png") no-repeat center top;
  300. border-radius: 10rpx;
  301. margin-top: 20rpx;
  302. display: flex;
  303. flex-direction: row;
  304. position: relative;
  305. background-size: contain;
  306. padding: 0 50rpx;
  307. margin-bottom: 30rpx;
  308. }
  309. .received {
  310. background: url("../../static/images/origin/couponsIcon1.png") no-repeat center top;
  311. background-size: contain;
  312. .discoun {
  313. color: #999999;
  314. padding-top: 35rpx;
  315. }
  316. .use-btn {
  317. height: 48rpx;
  318. border: 2rpx solid #CCCCCC;
  319. line-height: 48rpx;
  320. text-align: center;
  321. font-size: 24rpx;
  322. font-weight: 400;
  323. background-color: #CCCCCC;
  324. color: #FFFFFF;
  325. margin: 50rpx auto 0 auto;
  326. padding: 0 10rpx;
  327. }
  328. }
  329. /*.item:last-child {*/
  330. /*margin-bottom: 100rpx;*/
  331. /*}*/
  332. .discoun {
  333. display: flex;
  334. flex-direction: row;
  335. align-items: baseline;
  336. font-size: 40rpx;
  337. color: #C5AA7B;
  338. margin: 0 auto;
  339. padding-top: 40rpx;
  340. }
  341. .discoun text {
  342. display: inline-block;
  343. }
  344. .info-box {
  345. width: 100%;
  346. display: flex;
  347. flex-direction: column;
  348. align-items: center;
  349. }
  350. .info-condition {
  351. font-size: 20rpx;
  352. font-weight: 400;
  353. color: #999999;
  354. margin: 0 auto;
  355. }
  356. .info-date {
  357. font-size: 20rpx;
  358. font-family: PingFang SC;
  359. font-weight: 400;
  360. color: #999999;
  361. margin: 10rpx auto;
  362. line-height: 20rpx;
  363. }
  364. .use-btn {
  365. height: 48rpx;
  366. border: 2rpx solid #C5AA7B;
  367. line-height: 48rpx;
  368. text-align: center;
  369. font-size: 24rpx;
  370. font-weight: 400;
  371. background-color: #C5AA7B;
  372. color: #FFFFFF;
  373. margin: 50rpx auto 0 auto;
  374. padding: 0 10rpx;
  375. }
  376. }
  377. }
  378. }
  379. .receive-success {
  380. width: 100%;
  381. position: fixed;
  382. top: 0;
  383. bottom: 0;
  384. left: 0;
  385. display: flex;
  386. flex-direction: column;
  387. align-items: center;
  388. justify-content: center;
  389. z-index: 8888;
  390. .success-box {
  391. width: 380upx;
  392. height: 280upx;
  393. background: rgba(0, 0, 0, 0.5);
  394. border-radius: 10upx;
  395. display: flex;
  396. flex-direction: column;
  397. align-items: center;
  398. justify-content: center;
  399. .success-img {
  400. width: 200upx;
  401. height: 130upx;
  402. }
  403. .text {
  404. font-size: 28upx;
  405. margin-top: 50upx;
  406. font-weight: 400;
  407. color: rgba(255, 255, 255, 1);
  408. }
  409. }
  410. }
  411. </style>