coupon-popup.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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. },
  121. data () {
  122. return {
  123. showActivity: false,
  124. isShowSuccess: false,
  125. activeTypeFlag: 0,
  126. activeTypeList: [{
  127. name: '平台活动'
  128. }, {
  129. name: '店铺活动'
  130. }],
  131. }
  132. },
  133. methods:{
  134. activeTypeActive(index) {
  135. this.activeTypeFlag = index
  136. },
  137. //关闭优惠券弹窗
  138. onActivityClose() {
  139. this.showActivity = false
  140. },
  141. // 时间格式化
  142. getDate(time) {
  143. if (!time) return '';
  144. return time.split(' ')[0].split('-').join('.');
  145. },
  146. // 领取优惠券
  147. receiveTap(couponItemInfo, type) {
  148. uni.showLoading({
  149. mask: true,
  150. title: '领取中...',
  151. })
  152. let ReceiveCoupon
  153. if (type === 0) {
  154. ReceiveCoupon = {
  155. couponId: couponItemInfo.couponId,
  156. shopId:this.shopId
  157. }
  158. } else {
  159. ReceiveCoupon = {
  160. shopCouponId: couponItemInfo.shopCouponId,
  161. shopId:this.shopId
  162. }
  163. }
  164. NET.request(API.ReceiveCoupon, ReceiveCoupon, 'POST').then(res => {
  165. uni.hideLoading()
  166. this.isShowSuccess = true
  167. setTimeout(() => {
  168. this.isShowSuccess = false
  169. // this.showActivity = false;
  170. // this.queryProductDetail()
  171. }, 1500);
  172. // setTimeout(() => {
  173. // this.showActivity = false
  174. // }, 3000);
  175. }).catch(res => {
  176. uni.hideLoading()
  177. uni.showToast({
  178. title: res.msg,
  179. icon: 'none'
  180. })
  181. })
  182. },
  183. success(){
  184. this.isShowSuccess = true
  185. setTimeout(() => {
  186. this.isShowSuccess = false
  187. }, 1500);
  188. },
  189. closePopup(){
  190. this.showActivity = false;
  191. }
  192. }
  193. }
  194. </script>
  195. <style lang="scss" scoped>
  196. .coupon-popup{
  197. display: block;
  198. position: fixed;
  199. top: 0;
  200. left: 0;
  201. right: 0;
  202. bottom: 0;
  203. overflow: hidden;
  204. // background-color: rgba(0, 0, 0, 0.6);
  205. z-index: -1;
  206. opacity: 0;
  207. &.show{
  208. z-index: 1000;
  209. opacity: 1;
  210. .couponShow-box{
  211. /*transform: translate3D(0px, 0px, 0px);*/
  212. bottom: 0;
  213. }
  214. }
  215. .mask{
  216. display: block;
  217. position: fixed;
  218. width: 100%;
  219. height: 100%;
  220. top: 0;
  221. left: 0;
  222. right: 0;
  223. bottom: 0;
  224. overflow: hidden;
  225. background-color: rgba(0, 0, 0, 0.6);
  226. z-index:1001;
  227. }
  228. .couponShow-box{
  229. .couponShow {
  230. height: 1000rpx;
  231. z-index: 333;
  232. }
  233. width: 100%;
  234. height: auto;
  235. /*transform: translate3d(0px, 100%, 0px);*/
  236. transition: all 0.3s ease-in-out 0s;
  237. background-color: #fff;
  238. position: absolute;
  239. left: 0;
  240. right: 0;
  241. bottom: -100%;
  242. z-index: 1002;
  243. .tabsbox{
  244. padding:0 20rpx;
  245. /deep/ .u-tab-item{
  246. height: 100rpx !important;
  247. line-height: 100rpx !important;
  248. }
  249. }
  250. .title-box .close-btn {
  251. width: 50upx;
  252. height: 50upx;
  253. box-sizing: border-box;
  254. position: absolute;
  255. top: 20upx;
  256. right: 20upx;
  257. }
  258. // #ifdef MP-ALIPAY
  259. .title-box .close-btn {
  260. width: 30upx;
  261. height: 30upx;
  262. top: 10upx;
  263. right: 10upx;
  264. }
  265. // #endif
  266. .shopCouponBox {
  267. height: 100%;
  268. overflow: auto;
  269. position: relative;
  270. &.flex{
  271. display: flex;
  272. justify-content: center;
  273. align-items: center;
  274. }
  275. .emptyOrder-box {
  276. position: absolute;
  277. top: 0;
  278. bottom: 0;
  279. right: 0;
  280. left: 0;
  281. margin: auto;
  282. // padding-top: 80upx;
  283. .emptyOrder-img {
  284. width: 225upx;
  285. height: 196upx;
  286. }
  287. }
  288. .list {
  289. display: flex;
  290. flex-wrap: wrap;
  291. }
  292. .item {
  293. width: 50%;
  294. height: 291rpx;
  295. background: url("https://ceres.zkthink.com/static/images/couponsIcon.png") no-repeat center top;
  296. border-radius: 10rpx;
  297. margin-top: 20rpx;
  298. display: flex;
  299. flex-direction: row;
  300. position: relative;
  301. background-size: contain;
  302. padding: 0 50rpx;
  303. margin-bottom: 30rpx;
  304. }
  305. .received {
  306. background: url("https://ceres.zkthink.com/static/images/couponsIcon1.png") no-repeat center top;
  307. background-size: contain;
  308. .discoun {
  309. color: #999999;
  310. padding-top: 35rpx;
  311. }
  312. .use-btn {
  313. height: 48rpx;
  314. border: 2rpx solid #CCCCCC;
  315. line-height: 48rpx;
  316. text-align: center;
  317. font-size: 24rpx;
  318. font-weight: 400;
  319. background-color: #CCCCCC;
  320. color: #FFFFFF;
  321. margin: 50rpx auto 0 auto;
  322. padding: 0 10rpx;
  323. }
  324. }
  325. /*.item:last-child {*/
  326. /*margin-bottom: 100rpx;*/
  327. /*}*/
  328. .discoun {
  329. display: flex;
  330. flex-direction: row;
  331. align-items: baseline;
  332. font-size: 40rpx;
  333. color: #C5AA7B;
  334. margin: 0 auto;
  335. padding-top: 40rpx;
  336. }
  337. .discoun text {
  338. display: inline-block;
  339. }
  340. .info-box {
  341. width: 100%;
  342. display: flex;
  343. flex-direction: column;
  344. align-items: center;
  345. }
  346. .info-condition {
  347. font-size: 20rpx;
  348. font-weight: 400;
  349. color: #999999;
  350. margin:0 auto;
  351. }
  352. .info-date {
  353. font-size: 20rpx;
  354. font-family: PingFang SC;
  355. font-weight: 400;
  356. color: #999999;
  357. margin: 10rpx auto;
  358. line-height: 20rpx;
  359. }
  360. .use-btn {
  361. height: 48rpx;
  362. border: 2rpx solid #C5AA7B;
  363. line-height: 48rpx;
  364. text-align: center;
  365. font-size: 24rpx;
  366. font-weight: 400;
  367. background-color: #C5AA7B;
  368. color: #FFFFFF;
  369. margin: 50rpx auto 0 auto;
  370. padding: 0 10rpx;
  371. }
  372. }
  373. }
  374. }
  375. .receive-success {
  376. width: 100%;
  377. position: fixed;
  378. top: 0;
  379. bottom: 0;
  380. left: 0;
  381. display: flex;
  382. flex-direction: column;
  383. align-items: center;
  384. justify-content: center;
  385. z-index: 8888;
  386. .success-box {
  387. width: 380upx;
  388. height: 280upx;
  389. background: rgba(0, 0, 0, 0.5);
  390. border-radius: 10upx;
  391. display: flex;
  392. flex-direction: column;
  393. align-items: center;
  394. justify-content: center;
  395. .success-img {
  396. width: 200upx;
  397. height: 130upx;
  398. }
  399. .text {
  400. font-size: 28upx;
  401. margin-top: 50upx;
  402. font-weight: 400;
  403. color: rgba(255, 255, 255, 1);
  404. }
  405. }
  406. }
  407. </style>