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

430 lines
9.6 KiB

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. console.log(this.triggerCondition,'triggerCondition000000')
  113. const res = uni.getStorageSync('storage_key'),
  114. token = res.token;
  115. setTimeout(() => {
  116. this.buyerUserId = res.buyerUserId
  117. this.isLogin = !!token
  118. console.log(this.buyerUserId,this.isLogin,this.triggerCondition)
  119. NET.request(API.GetAd, {
  120. triggerCondition: this.triggerCondition
  121. }, 'POST').then(res => {
  122. console.log('123131321323', res)
  123. if (res.data) {
  124. this.adInfo = res.data[0]
  125. if (this.adInfo.jumpContent) {
  126. this.jumpContent = JSON.parse(this.adInfo.jumpContent)
  127. }
  128. this.visible = true
  129. if (this.adInfo.jumpType === 3) {
  130. this.getCoupons()
  131. }
  132. }
  133. }).catch(res => {
  134. })
  135. }, 500)
  136. },
  137. // 查询优惠券
  138. getCoupons() {
  139. if (this.isLogin) {
  140. const _items = this.jumpContent.items
  141. if (_items) {
  142. NET.request(API.getCoupons, {
  143. page: 1,
  144. pageSize: 99,
  145. ids: _items
  146. }, 'GET').then(res => {
  147. if (res.data) {
  148. this.couponList = res.data.list
  149. }
  150. }).catch(res => {
  151. })
  152. }
  153. } else {
  154. uni.showToast({
  155. title: '登录之后领取更多优惠',
  156. icon: "none"
  157. })
  158. // uni.navigateTo({
  159. // url: '/pages_category_page2/userModule/login'
  160. // })
  161. }
  162. },
  163. // 关闭弹窗
  164. close() {
  165. this.visible = false
  166. var params = {}
  167. if (this.isLogin) {
  168. params.buyerUserId = this.buyerUserId
  169. } else {
  170. uni.getSystemInfo({
  171. success: function (res) {
  172. params.deviceId = res.deviceId
  173. }
  174. })
  175. }
  176. NET.request(API.adClose, params, 'POST').then(res => {
  177. }).catch(res => {
  178. })
  179. },
  180. goRoll() {
  181. this.visible = false
  182. console.log(this.jumpContent, 'this.jumpContent')
  183. switch (this.adInfo.jumpType) {
  184. case 1:
  185. uni.navigateTo({
  186. url: '/pages_category_page1/goodsModule/goodsDetails?shopId=' + this.jumpContent
  187. .shopId + '&productId=' + this.jumpContent.id + '&skuId=' + this.jumpContent
  188. .skuId
  189. })
  190. break
  191. case 2:
  192. let _id = this.jumpContent.id[this.jumpContent.id.length - 1]
  193. uni.navigateTo({
  194. url: `/pages_category_page1/goodsModule/goodsList?category3Id=${_id}`
  195. })
  196. break
  197. case 4:
  198. uni.navigateToMiniProgram({
  199. appId: this.jumpContent.appId,
  200. path: this.jumpContent.link,
  201. success(res) {
  202. // 打开成功
  203. }
  204. })
  205. case 5:
  206. uni.navigateTo({
  207. path: this.jumpContent.link
  208. })
  209. break
  210. }
  211. },
  212. }
  213. };
  214. </script>
  215. <style scoped
  216. lang="scss">
  217. .mask {
  218. position: fixed;
  219. top: 0;
  220. left: 0;
  221. right: 0;
  222. bottom: 0;
  223. z-index: 55;
  224. background-color: rgba(0, 0, 0, 0.7);
  225. }
  226. .mask-coupon {
  227. z-index: 9999;
  228. /*background: rgba(39, 38, 39, .15);*/
  229. display: flex;
  230. justify-content: center;
  231. align-items: center;
  232. .ad-box-warp {
  233. width: 100%;
  234. position: relative;
  235. }
  236. flex-direction: column;
  237. .ad-boxs {
  238. position: relative;
  239. width: 100%;
  240. text-align: center;
  241. .img {
  242. width: 70%;
  243. }
  244. }
  245. .btn-receive {
  246. width: 446rpx;
  247. height: 84rpx;
  248. background: #EC6F43;
  249. border-radius: 42rpx;
  250. display: block;
  251. text-align: center;
  252. font-size: 28rpx;
  253. line-height: 84rpx;
  254. color: #fff;
  255. position: absolute;
  256. bottom: 32rpx;
  257. left: 50%;
  258. margin-left: -223rpx;
  259. }
  260. .close-btn {
  261. position: absolute;
  262. bottom: -70rpx;
  263. left: 50%;
  264. margin-left: -25rpx;
  265. .btn {
  266. width: 50rpx;
  267. height: 50rpx;
  268. }
  269. }
  270. }
  271. .ad-coupons {
  272. .ad-box-warp {
  273. width: 510rpx;
  274. position: relative;
  275. .ad-boxs {
  276. min-height: 700rpx;
  277. .img {
  278. position: absolute;
  279. top:0;
  280. left:0;
  281. width: 100%;
  282. height: 100%;
  283. }
  284. }
  285. }
  286. .coupon-list {
  287. width: 446rpx;
  288. height: 40%;
  289. overflow: auto;
  290. position: absolute;
  291. top: 40%;
  292. left: 50%;
  293. margin-left: -223rpx;
  294. .scrollBox {
  295. height: 450upx;
  296. }
  297. .item {
  298. width: 100%;
  299. height: 140rpx;
  300. margin-top: 15rpx;
  301. border-radius: 8rpx;
  302. display: flex;
  303. position: relative;
  304. align-items: center;
  305. overflow: hidden;
  306. &:first-child {
  307. margin-top: 0px;
  308. }
  309. .borderBox {
  310. width: 32rpx;
  311. height: 140rpx;
  312. overflow: hidden;
  313. .boxTop {
  314. width: 32rpx;
  315. height: 54rpx;
  316. background: #FFFFFF;
  317. }
  318. .boxCent {
  319. height: 36rpx;
  320. overflow: hidden;
  321. position: relative;
  322. &:after {
  323. content: '';
  324. width: 32rpx;
  325. height: 32rpx;
  326. border-radius: 50%;
  327. display: block;
  328. position: absolute;
  329. top: 50%;
  330. margin-top: -47rpx;
  331. left: -15rpx;
  332. border: 32rpx solid #FFFFFF;
  333. }
  334. }
  335. .boxBottom {
  336. width: 32rpx;
  337. height: 54rpx;
  338. background: #FFFFFF;
  339. }
  340. }
  341. .leftBox {
  342. .boxCent {
  343. &:after {
  344. left: -50rpx;
  345. }
  346. }
  347. }
  348. .rightBox {
  349. }
  350. .centerBox {
  351. display: flex;
  352. align-items: center;
  353. height: 140rpx;
  354. background: #FFFFFF;
  355. flex: 1;
  356. }
  357. .money {
  358. width: 190rpx;
  359. text-align: center;
  360. .num {
  361. font-size: 48rpx;
  362. color: #EC6F43;
  363. display: block;
  364. &.num-minus::before {
  365. content: '¥';
  366. font-size: 36rpx;
  367. }
  368. &.num-discount::after {
  369. content: '折';
  370. font-size: 36rpx;
  371. }
  372. }
  373. .text {
  374. font-size: 24rpx;
  375. color: #999;
  376. }
  377. }
  378. .text {
  379. flex: 1;
  380. padding-right: 16rpx;
  381. width: 0;
  382. text {
  383. font-size: 32rpx;
  384. color: #333;
  385. display: block;
  386. overflow: hidden;
  387. text-overflow: ellipsis;
  388. white-space: nowrap;
  389. }
  390. }
  391. }
  392. }
  393. }
  394. </style>