coupon-popup.vue 13 KB

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