giftPopup.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view>
  3. <uni-popup ref="popup" type="center" :mask-click="false">
  4. <view class="giftpop y-f">
  5. <image class="close_icon" src="@/static/images/ad/close_icon.png" @click="closePop"></image>
  6. <image class="gift_img_head" src="@/static/images/ad/gift_img_head.png" mode="widthFix"></image>
  7. <view class="giftpop-body y-f">
  8. <view class="new_user_bg">
  9. <image style="width: 308rpx;height: auto;" src="@/static/images/ad/new_user_bg.svg"
  10. mode="widthFix"></image>
  11. </view>
  12. <image class="free_font_img" src="@/static/images/ad/free_font_img.svg" mode="widthFix"></image>
  13. <view class="y-f" :style="{display: haveGift ? 'flex':'none'}">
  14. <image class="gift-img" :src="giftImage" mode="aspectFill"></image>
  15. <text class="gift-name textOne">{{package.packageName}}</text>
  16. </view>
  17. <view class="y-f" :style="{display: !haveGift ? 'flex':'none'}">
  18. <image class="gift-img" src="/static/image/nodata.png" mode="aspectFill"></image>
  19. <text class="gift-name textOne">暂无礼品</text>
  20. </view>
  21. </view>
  22. <view class="giftpop-footer x-c" v-if='showBtn&&package.packageId'>
  23. <image class="buy_btn" src="@/static/images/ad/buy_btn.svg" mode="widthFix" @click="handClick(1)"></image>
  24. <image class="addfans_btn" src="@/static/images/ad/addfans_btn.svg" mode="widthFix" @click="handClick(2)"></image>
  25. </view>
  26. </view>
  27. </uni-popup>
  28. </view>
  29. </template>
  30. <script>
  31. import { popAd } from '@/api/user.js'
  32. import {getConfigByKey} from '@/api/common.js'
  33. import { gotoMiniProgram } from '@/utils/healthButlerPop.js'
  34. export default {
  35. data() {
  36. return {
  37. giftImage: '',
  38. package: {},
  39. showBtn: false,
  40. haveGift: true
  41. }
  42. },
  43. mounted() {
  44. this.getConfigByKey()
  45. },
  46. methods: {
  47. openPop() {
  48. this.$refs.popup.open('center')
  49. popAd().then(res=>{
  50. if(res.code == 200) {
  51. this.showBtn = true
  52. } else {
  53. uni.showToast({
  54. title: res.msg,
  55. icon: 'none'
  56. })
  57. }
  58. })
  59. },
  60. closePop() {
  61. this.$refs.popup.close()
  62. },
  63. getConfigByKey(){
  64. let param = {key:"app.config"};
  65. getConfigByKey(param).then(
  66. res => {
  67. if(res.code==200){
  68. let data=JSON.parse(res.data);
  69. this.giftImage = data.giftImage
  70. this.package = data.fsPackage&&data.fsPackage.length > 0 ? data.fsPackage[0] : {}
  71. this.haveGift = this.package.packageId ? true : false
  72. }else{
  73. uni.showToast({
  74. icon:'none',
  75. title: "请求失败",
  76. });
  77. }
  78. },
  79. rej => {}
  80. )
  81. },
  82. handClick(type) {
  83. if(type == 1) {
  84. uni.navigateTo({
  85. url: '/pages/store/packageDetails?choose=1&packageId='+this.package.packageId || ''
  86. })
  87. } else {
  88. gotoMiniProgram();
  89. }
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .close_icon {
  96. width: 64rpx;
  97. height: 64rpx;
  98. position: absolute;
  99. right: 0;
  100. top: 0;
  101. }
  102. .giftpop {
  103. width: 590rpx;
  104. min-height: 758rpx;
  105. margin-bottom: 100rpx;
  106. position: relative;
  107. .gift_img_head {
  108. width: 312rpx;
  109. height: auto;
  110. }
  111. .new_user_bg {
  112. width: 308rpx;
  113. margin-top: -4rpx;
  114. }
  115. .free_font_img {
  116. width: 520rpx;
  117. height: auto;
  118. margin-top: 16rpx;
  119. }
  120. .gift-img {
  121. width: 470rpx;
  122. height: 320rpx;
  123. margin-top: 24rpx;
  124. background: #FFFFFF;
  125. border-radius: 36rpx 36rpx 36rpx 36rpx;
  126. }
  127. .gift-name {
  128. width: 90%;
  129. margin-top: 26rpx;
  130. text-align: center;
  131. }
  132. &-footer {
  133. margin-top: 48rpx;
  134. }
  135. .buy_btn {
  136. width: 240rpx;
  137. height: auto;
  138. }
  139. .addfans_btn {
  140. width: 318rpx;
  141. height: auto;
  142. margin-left: 32rpx;
  143. }
  144. &-body {
  145. width: 582rpx;
  146. min-height: 632rpx;
  147. margin-top: 4rpx;
  148. padding-bottom: 34rpx;
  149. background: linear-gradient(180deg, #F7E4DE 0%, #FFEDD8 27%, #FFF7ED 100%);
  150. border-radius: 32rpx 32rpx 32rpx 32rpx;
  151. box-sizing: border-box;
  152. position: relative;
  153. font-family: PingFang SC, PingFang SC;
  154. font-weight: 400;
  155. font-size: 28rpx;
  156. color: #FF5C03;
  157. &::after {
  158. content: "";
  159. position: absolute;
  160. width: 590rpx;
  161. height: 640rpx;
  162. background: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
  163. border-radius: 32rpx 32rpx 32rpx 32rpx;
  164. top: -4rpx;
  165. left: -4rpx;
  166. z-index: -1;
  167. }
  168. }
  169. }
  170. </style>