coupon-popup.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <view class="coupon-popup" :class="showActivity && 'show'" >
  3. <view class="mask" @click="closePopup"></view>
  4. <view class="couponShow-box" id="popupInner">
  5. <view class="tabsbox">
  6. <u-tabs
  7. :list="activeTypeList"
  8. bar-width="0"
  9. bar-height="0"
  10. :bold="false"
  11. active-color="#C5AA7B"
  12. inactive-color="#999999"
  13. :is-scroll="false"
  14. :current="activeTypeFlag"
  15. @change="activeTypeActive"
  16. ></u-tabs>
  17. </view>
  18. <view v-show="activeTypeFlag === 0">
  19. <view class="couponShow">
  20. <view class="title-box">
  21. <image class="close-btn" @click="onActivityClose" src="https://ceres.zkthink.com/static/images/close.png"></image>
  22. </view>
  23. <view class="shopCouponBox" :class="markTools.length === 0 && 'flex'">
  24. <view class="list" v-if="markTools.length > 0">
  25. <view class="item"
  26. v-for="(item, index) in markTools"
  27. :key="index"
  28. :class="{received: item.state === 1}"
  29. >
  30. <view class="info-box">
  31. <view class="discoun" v-if="item.couponType == 1"><text style="font-size: 28rpx">¥</text>{{item.reduceMoney}}</view>
  32. <view class="discoun" v-if="item.couponType == 2">{{item.reduceMoney}}折</view>
  33. <view class="info-date">{{getDate(item.startTime)}}-{{getDate(item.endTime)}}</view>
  34. <view class="info-condition mar-top-30">{{item.content}}</view>
  35. <!-- <view class="info-condition" v-if="item.couponType == 2">{{item.reduceMoney}}折优惠</view>-->
  36. <wx-send-coupon @success="success" v-if="item.state === 3" :couponList="[item]">
  37. <view class="use-btn mar-top-10"
  38. v-if="item.state === 3">
  39. 立即领取
  40. </view>
  41. </wx-send-coupon>
  42. <view class="use-btn mar-top-10" v-if="item.state === 0">已领取</view>
  43. <view class="use-btn mar-top-10" v-if="item.state === 1">已使用</view>
  44. </view>
  45. </view>
  46. </view>
  47. <view v-else class="emptyOrder-box flex-items-plus flex-column">
  48. <image class="emptyOrder-img" src="https://ceres.zkthink.com/static/img/bgnull.png"></image>
  49. <label class="font-color-999 fs26 mar-top-30">你还没有优惠券哦~</label>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <view v-show="activeTypeFlag === 1">
  55. <view class="couponShow">
  56. <view class="title-box">
  57. <image class="close-btn" @click="onActivityClose" src="https://ceres.zkthink.com/static/images/close.png"></image>
  58. </view>
  59. <view class="shopCouponBox" :class="shopMarkTools.length === 0 && 'flex'">
  60. <view class="list" v-if="shopMarkTools.length > 0">
  61. <view
  62. class="item"
  63. v-for="(item, index) in shopMarkTools"
  64. :key="index"
  65. :class="{received: item.state === 1}"
  66. >
  67. <view class="info-box">
  68. <view class="discoun" v-if="item.couponType === 1"><text
  69. style="font-size: 28rpx">¥</text>{{item.reduceMoney}}</view>
  70. <view class="discoun" v-if="item.couponType === 2">{{item.reduceMoney}}折</view>
  71. <view class="info-date">{{getDate(item.startTime)}}-{{getDate(item.endTime)}}</view>
  72. <view class="info-condition" v-if="item.couponType === 1">
  73. 满{{item.fullMoney}}元减{{item.reduceMoney}}元</view>
  74. <view class="info-condition" v-if="item.couponType === 2">{{item.reduceMoney}}折优惠
  75. </view>
  76. <view class="use-btn" @click="receiveTap(item,1)" v-if="item.state === 3">立即领取
  77. </view>
  78. <view class="use-btn" v-if="item.state === 0">已领取</view>
  79. </view>
  80. </view>
  81. </view>
  82. <view v-else class="emptyOrder-box flex-items-plus flex-column">
  83. <image class="emptyOrder-img" src="https://ceres.zkthink.com/static/img/bgnull.png"></image>
  84. <label class="font-color-999 fs26 mar-top-30">你还没有优惠券哦~</label>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="receive-success" v-if="isShowSuccess">
  90. <view class="success-box">
  91. <image class="success-img" src="https://ceres.zkthink.com/static/images/success_tu.png"></image>
  92. <view class="text">领取成功</view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. import WxSendCoupon from "@/components/wx/wxSendCoupon";
  100. const NET = require('../../utils/request')
  101. const API = require('../../config/api')
  102. export default {
  103. name: "coupon-popup",
  104. components: {
  105. WxSendCoupon,
  106. },
  107. props: {
  108. markTools: {
  109. type: Array,
  110. default: ()=>[]
  111. },
  112. shopMarkTools: {
  113. type: Array,
  114. default: ()=>[]
  115. },
  116. setTop: {
  117. type: Number,
  118. default: 0,
  119. },
  120. currentActive: {
  121. type: Number,
  122. default: 0
  123. }
  124. },
  125. data () {
  126. return {
  127. showActivity: false,
  128. isShowSuccess: false,
  129. activeTypeFlag: this.currentActive,
  130. activeTypeList: [{
  131. name: '平台活动'
  132. }, {
  133. name: '店铺活动'
  134. }],
  135. }
  136. },
  137. methods:{
  138. activeTypeActive(index) {
  139. this.activeTypeFlag = index
  140. },
  141. //关闭优惠券弹窗
  142. onActivityClose() {
  143. this.showActivity = false
  144. },
  145. // 时间格式化
  146. getDate(time) {
  147. if (!time) return '';
  148. return time.split(' ')[0].split('-').join('.');
  149. },
  150. // 领取优惠券
  151. receiveTap(couponItemInfo, type) {
  152. uni.showLoading({
  153. mask: true,
  154. title: '领取中...',
  155. })
  156. let ReceiveCoupon
  157. if (type === 0) {
  158. ReceiveCoupon = {
  159. couponId: couponItemInfo.couponId,
  160. shopId:this.shopId
  161. }
  162. } else {
  163. ReceiveCoupon = {
  164. shopCouponId: couponItemInfo.shopCouponId,
  165. shopId:this.shopId
  166. }
  167. }
  168. NET.request(API.ReceiveCoupon, ReceiveCoupon, 'POST').then(res => {
  169. uni.hideLoading()
  170. this.isShowSuccess = true
  171. setTimeout(() => {
  172. this.isShowSuccess = false
  173. // this.showActivity = false;
  174. // this.queryProductDetail()
  175. }, 1500);
  176. // setTimeout(() => {
  177. // this.showActivity = false
  178. // }, 3000);
  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("https://ceres.zkthink.com/static/images/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("https://ceres.zkthink.com/static/images/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>