多租户商城-商户小程序端
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.

427 lines
9.4 KiB

2 years ago
2 years ago
2 years ago
  1. <template>
  2. <view v-if="visible">
  3. <view v-if="adInfo.jumpType === 3 && couponList && couponList.length> 0"
  4. class="mask mask-coupon ad-coupons"
  5. @touchmove.stop.prevent="moveHandle">
  6. <view class="ad-box-warp">
  7. <view class="ad-boxs">
  8. <image class="img"
  9. :src="adInfo.popupImg"
  10. ></image>
  11. <view class="coupon-list">
  12. <scroll-view :scroll-top="0"
  13. class="scrollBox"
  14. scroll-y="true">
  15. <view class="item"
  16. v-for="(item, index) in couponList"
  17. :key="index">
  18. <view class="leftBox borderBox">
  19. <view class="boxTop"></view>
  20. <view class="boxCent"></view>
  21. <view class="boxBottom"></view>
  22. </view>
  23. <view class="centerBox">
  24. <view class="money">
  25. <text class="num"
  26. :class="[item.discountMode ===1?'num-minus':'num-discount']">{{ item.reduceMoney }}
  27. </text>
  28. <text class="text">
  29. {{ item.fullMoney }}元可用
  30. </text>
  31. </view>
  32. <view class="text">
  33. <text>
  34. {{ item.activityName }}
  35. </text>
  36. </view>
  37. </view>
  38. <view class="rightBox borderBox">
  39. <view class="boxTop"></view>
  40. <view class="boxCent"></view>
  41. <view class="boxBottom"></view>
  42. </view>
  43. </view>
  44. </scroll-view>
  45. </view>
  46. <WxSendCoupon v-if="couponList && couponList.length > 0"
  47. :couponList="couponList"
  48. @closeAd="close">
  49. <view class="btn-receive">一键领取</view>
  50. </WxSendCoupon>
  51. </view>
  52. <view class="close-btn">
  53. <image :src="adInfo.closeImg"
  54. class='btn'
  55. mode="widthFix"
  56. @click="close()"></image>
  57. </view>
  58. </view>
  59. </view>
  60. <view v-else-if="adInfo.jumpType !== 3"
  61. class="mask mask-coupon ad-link">
  62. <view class="ad-box-warp">
  63. <view class="ad-boxs"
  64. @click="goRoll()">
  65. <image class="img"
  66. :src="adInfo.popupImg"
  67. mode="widthFix"></image>
  68. </view>
  69. <view class="close-btn">
  70. <image :src="adInfo.closeImg"
  71. class='btn'
  72. mode="widthFix"
  73. @click="close()"></image>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </template>
  79. <script>
  80. import WxSendCoupon from "./wx/wxSendCoupon";
  81. const NET = require('../utils/request')
  82. const API = require('../config/api')
  83. export default {
  84. name: "adWindow",
  85. components: {
  86. WxSendCoupon
  87. },
  88. props: {
  89. triggerCondition: {
  90. type: Number,
  91. default: 1
  92. }
  93. },
  94. data() {
  95. return {
  96. visible: false,
  97. adInfo: {},
  98. jumpContent: {},
  99. couponList: [],
  100. isLogin: false,
  101. buyerUserId: 0,
  102. cParams: {}
  103. };
  104. },
  105. methods: {
  106. // 阻止滑动
  107. moveHandle() {
  108. return
  109. },
  110. // 获取广告信息
  111. getAd() {
  112. const res = uni.getStorageSync('storage_key'),
  113. token = res.token;
  114. setTimeout(() => {
  115. this.buyerUserId = res.buyerUserId
  116. this.isLogin = !!token
  117. NET.request(API.GetAd, {
  118. triggerCondition: this.triggerCondition
  119. }, 'POST').then(res => {
  120. if (res.data) {
  121. this.adInfo = res.data[0]
  122. if (this.adInfo.jumpContent) {
  123. this.jumpContent = JSON.parse(this.adInfo.jumpContent)
  124. }
  125. this.visible = true
  126. if (this.adInfo.jumpType === 3) {
  127. this.getCoupons()
  128. }
  129. }
  130. }).catch(res => {
  131. })
  132. }, 500)
  133. },
  134. // 查询优惠券
  135. getCoupons() {
  136. if (this.isLogin) {
  137. const _items = this.jumpContent.items
  138. if (_items) {
  139. NET.request(API.getCoupons, {
  140. page: 1,
  141. pageSize: 99,
  142. ids: _items
  143. }, 'GET').then(res => {
  144. if (res.data) {
  145. this.couponList = res.data.list
  146. }
  147. }).catch(res => {
  148. })
  149. }
  150. } else {
  151. uni.showToast({
  152. title: '登录之后领取更多优惠',
  153. icon: "none"
  154. })
  155. // uni.navigateTo({
  156. // url: '/pages_category_page2/userModule/login'
  157. // })
  158. }
  159. },
  160. // 关闭弹窗
  161. close() {
  162. this.visible = false
  163. var params = {}
  164. if (this.isLogin) {
  165. params.buyerUserId = this.buyerUserId
  166. } else {
  167. uni.getSystemInfo({
  168. success: function (res) {
  169. params.deviceId = res.deviceId
  170. }
  171. })
  172. }
  173. NET.request(API.adClose, params, 'POST').then(res => {
  174. }).catch(res => {
  175. })
  176. },
  177. goRoll() {
  178. this.visible = false
  179. switch (this.adInfo.jumpType) {
  180. case 1:
  181. uni.navigateTo({
  182. url: '/pages_category_page1/goodsModule/goodsDetails?shopId=' + this.jumpContent
  183. .shopId + '&productId=' + this.jumpContent.id + '&skuId=' + this.jumpContent
  184. .skuId
  185. })
  186. break
  187. case 2:
  188. let _id = this.jumpContent.id[this.jumpContent.id.length - 1]
  189. uni.navigateTo({
  190. url: `/pages_category_page1/goodsModule/goodsList?category3Id=${_id}`
  191. })
  192. break
  193. case 4:
  194. uni.navigateToMiniProgram({
  195. appId: this.jumpContent.appId,
  196. path: this.jumpContent.link,
  197. success(res) {
  198. // 打开成功
  199. }
  200. })
  201. case 5:
  202. uni.navigateTo({
  203. path: this.jumpContent.link
  204. })
  205. break
  206. }
  207. },
  208. }
  209. };
  210. </script>
  211. <style scoped
  212. lang="scss">
  213. .mask {
  214. position: fixed;
  215. top: 0;
  216. left: 0;
  217. right: 0;
  218. bottom: 0;
  219. z-index: 55;
  220. background-color: rgba(0, 0, 0, 0.7);
  221. }
  222. .mask-coupon {
  223. z-index: 9999;
  224. /*background: rgba(39, 38, 39, .15);*/
  225. display: flex;
  226. justify-content: center;
  227. align-items: center;
  228. .ad-box-warp {
  229. width: 100%;
  230. position: relative;
  231. }
  232. flex-direction: column;
  233. .ad-boxs {
  234. position: relative;
  235. width: 100%;
  236. text-align: center;
  237. .img {
  238. width: 70%;
  239. }
  240. }
  241. .btn-receive {
  242. width: 446rpx;
  243. height: 84rpx;
  244. background: #EC6F43;
  245. border-radius: 42rpx;
  246. display: block;
  247. text-align: center;
  248. font-size: 28rpx;
  249. line-height: 84rpx;
  250. color: #fff;
  251. position: absolute;
  252. bottom: 32rpx;
  253. left: 50%;
  254. margin-left: -223rpx;
  255. }
  256. .close-btn {
  257. position: absolute;
  258. bottom: -70rpx;
  259. left: 50%;
  260. margin-left: -25rpx;
  261. .btn {
  262. width: 50rpx;
  263. height: 50rpx;
  264. }
  265. }
  266. }
  267. .ad-coupons {
  268. .ad-box-warp {
  269. width: 510rpx;
  270. position: relative;
  271. .ad-boxs {
  272. min-height: 700rpx;
  273. .img {
  274. position: absolute;
  275. top:0;
  276. left:0;
  277. width: 100%;
  278. height: 100%;
  279. }
  280. }
  281. }
  282. .coupon-list {
  283. width: 446rpx;
  284. height: 40%;
  285. overflow: auto;
  286. position: absolute;
  287. top: 40%;
  288. left: 50%;
  289. margin-left: -223rpx;
  290. .scrollBox {
  291. height: 450upx;
  292. }
  293. .item {
  294. width: 100%;
  295. height: 140rpx;
  296. margin-top: 15rpx;
  297. border-radius: 8rpx;
  298. display: flex;
  299. position: relative;
  300. align-items: center;
  301. overflow: hidden;
  302. &:first-child {
  303. margin-top: 0px;
  304. }
  305. .borderBox {
  306. width: 32rpx;
  307. height: 140rpx;
  308. overflow: hidden;
  309. .boxTop {
  310. width: 32rpx;
  311. height: 54rpx;
  312. background: #FFFFFF;
  313. }
  314. .boxCent {
  315. height: 36rpx;
  316. overflow: hidden;
  317. position: relative;
  318. &:after {
  319. content: '';
  320. width: 32rpx;
  321. height: 32rpx;
  322. border-radius: 50%;
  323. display: block;
  324. position: absolute;
  325. top: 50%;
  326. margin-top: -47rpx;
  327. left: -15rpx;
  328. border: 32rpx solid #FFFFFF;
  329. }
  330. }
  331. .boxBottom {
  332. width: 32rpx;
  333. height: 54rpx;
  334. background: #FFFFFF;
  335. }
  336. }
  337. .leftBox {
  338. .boxCent {
  339. &:after {
  340. left: -50rpx;
  341. }
  342. }
  343. }
  344. .rightBox {
  345. }
  346. .centerBox {
  347. display: flex;
  348. align-items: center;
  349. height: 140rpx;
  350. background: #FFFFFF;
  351. flex: 1;
  352. }
  353. .money {
  354. width: 190rpx;
  355. text-align: center;
  356. .num {
  357. font-size: 48rpx;
  358. color: #EC6F43;
  359. display: block;
  360. &.num-minus::before {
  361. content: '¥';
  362. font-size: 36rpx;
  363. }
  364. &.num-discount::after {
  365. content: '折';
  366. font-size: 36rpx;
  367. }
  368. }
  369. .text {
  370. font-size: 24rpx;
  371. color: #999;
  372. }
  373. }
  374. .text {
  375. flex: 1;
  376. padding-right: 16rpx;
  377. width: 0;
  378. text {
  379. font-size: 32rpx;
  380. color: #333;
  381. display: block;
  382. overflow: hidden;
  383. text-overflow: ellipsis;
  384. white-space: nowrap;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. </style>