CouponPopup.vue 9.5 KB

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