ATFAdWindow.vue 7.5 KB

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