多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

419 lines
14 KiB

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