123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- <template>
- <view>
- <u-navbar title="免费抽奖" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
- <u-count-down :time="activityTime" format="DD:HH:mm:ss" autoStart millisecond @change="onChange">
- <view style="height: 98rpx;background-color: #fff;margin: 0 30rpx;line-height: 98rpx;overflow: hidden;">
- <view class="data-btn">距离开奖时间:
- <text v-if="timeData.days != 0" >{{timeData.days}} 天</text>
- <text>{{ timeData.hours>10?timeData.hours:'0'+timeData.hours}} :</text>
- <text>{{timeData.minutes>10?timeData.minutes:'0'+timeData.minutes}} :</text>
- <text>{{timeData.seconds>10?timeData.seconds:'0'+timeData.seconds}}</text>
- </view>
- <view style="float: right;"><span style="font-weight: 600;">{{info.fakeNum}}</span>人已参与</view>
- </view>
- </u-count-down>
- <view>
- <view v-for="(item,index) in awardsList" :key="index">
- <view v-if="item.name == '一等奖'">
- <view style="height: 90rpx;">
- <view style="float: left;">
- <text
- style="display: inline-block; background-color: #bbbbbb;width: 200rpx;height: 90rpx;line-height:90rpx;text-align: center;">{{item.name}}</text>
- </view>
- <view style="float: right;line-height: 90rpx;">{{item.quantity}}个名额</view>
- </view>
- <view v-for="(itemTwo,index) in item.prizeList" :key="index">
- <view style="text-align: center;">
- <image :src="itemTwo.picUrl" mode="" style="width: 400rpx;"></image>
- <view>{{itemTwo.title}}</view>
- <view>¥{{itemTwo.value / 100}}</view>
- </view>
- </view>
- <view v-if="item.prizeList.length > 1 " style="text-align: center;">以上奖品随机获得一件</view>
- </view>
- </view>
- <view v-for="(item,index) in awardsList" :key="index">
- <view v-if="item.name != '一等奖'">
- <view style="height: 60rpx;">
- <view style="float: left;">
- <text style="display: inline-block; background-color: #bbbbbb;width: 200rpx;height: 60rpx;line-height:60rpx;text-align: center;">{{item.name}}</text>
- </view>
- <view style="float: right;line-height: 60rpx;">{{item.quantity}}个名额</view>
- </view>
- <view v-for="(itemTwo,index) in item.prizeList" :key="index">
- <view style="overflow: hidden; width: 100%;padding: 10rpx 20rpx;">
- <view style="display: inline-block;">
- <image :src="itemTwo.picUrl" mode="" style="width: 100rpx;height: 100rpx;"></image>
- </view>
- <view style="display: inline-block;width: 60%;margin-left: 20rpx;">
- <view>{{itemTwo.title}}</view>
- <view>¥{{itemTwo.value / 100}}</view>
- </view>
- </view>
- </view>
- <view v-if="item.prizeList.length > 1 " style="text-align: center;">以上奖品随机获得一件</view>
- </view>
- </view>
- </view>
- <view>
- <view style="height: 90rpx;line-height: 90rpx;">
- <text
- style="display: inline-block; background-color: #bbbbbb;width: 200rpx;text-align: center;">图文介绍</text>
- </view>
- <view v-html="description">{{description}} </view>
- </view>
- <view v-if="false"> 关注公众号:获取抽奖码和开奖提醒 > </view>
- <view>
- <view>我的抽奖码</view>
- <view style="text-align: center;margin-top: 20rpx;margin-bottom: 50rpx;">
- <view v-if="info.codeList.length > 0">
- <view v-for="(item,index) in info.codeList">{{item}}</view>
- </view>
- <view v-else>还没有抽奖码</view>
- </view>
- <view style="text-align: center;line-height: 90rpx;border-top: 2rpx solid #555;">抽奖码越多,中奖概率越大</view>
- </view>
- <view style="height: 200rpx;"></view>
- <view class="footer-fixed">
- <view class="flex btn">
- <button type="default" @click="exChange">获取抽奖码</button>
- </view>
- </view>
- <u-popup :show="popupShow" mode="bottom" @close="close" closeable>
- <view
- style="height: 98rpx;width: 100%; border-bottom: 2rpx solid #bbbbbb;text-align: center;line-height: 98rpx;">
- 获取抽奖码</view>
- <view style="padding: 30rpx 20rpx;">
- <view style="color: #101010; line-height: 50rpx;">邀请好友助力,获取抽奖码</view>
- <text style="color: #8c8c8c; font-size: 24rpx;">每邀请一位好友助力成功,即可获得1个抽奖码,没有上限</text>
- </view>
- <view style="padding: 0rpx 20rpx 50rpx ; ">
- <button type="default" style="background-color: #f7682b; color: #fff;" open-type="share">立即邀请好友助力</button>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import env from '../../config/env.js'
- import $http from '@/utils/request.js'
- export default {
- data() {
- return {
- popupShow: false,
- id: '',
- description: '', //富文本
- info: {}, //列表
- timeData: {}, //时间
- awardsList: [], //奖品
- inviteCode: '', //邀请码
- activityTime: 0
- }
- },
- onLoad(opthios) {
- this.id = opthios.id
- this.getDetail()
- },
- onShow() {
- },
- methods: {
- getDetail() {
- uni.showLoading({
- title: '加载中'
- });
- $http.post(`/api/v1/mp/user/marketing/detail/${this.id}`, {}).then(res => {
- uni.hideLoading();
- console.log(res)
- if (res.code == 0) {
- this.info = res.data
- let awardsList = res.data.awardsList
- awardsList.forEach(item => {
- item.prizeList.forEach(itemTwo => {
- itemTwo.picUrl = (env.filePublic + itemTwo.picUrl.split(',')[0] +
- '?imageView2/2/w/750')
- })
- })
- this.awardsList = awardsList
- // 处理富文本
- const description = res.data.description.replaceAll(".jpg\"", ".jpg?imageView2/2/w/750\"")
- .replaceAll(".jpeg\"", ".jpeg?imageView2/2/w/750\"").replaceAll(".png\"",
- ".png?imageView2/2/w/750\"");
- this.description = this.formatRichText(description);
- let timestamp = parseInt(new Date().getTime())
- this.activityTime = this.info.endTime - timestamp
- console.log(this.activityTime);
- }
- }).catch(() => {
- uni.hideLoading();
- })
- },
- onChange(e) {
- this.timeData = e
- },
- exChange() {
- //弹出层打开
- this.popupShow = true
- $http.post('/api/v1/mp/user/marketing/inviteCode', {}).then(res=>{
- if(res.code == 0){
- this.inviteCode = res.data
- console.log(this.inviteCode);
- }
- })
- uni.requestSubscribeMessage({
- tmplIds:['3y_My-yRmqmGd3-f-vAwNaK4LQeehzXBSNDi_5wcnFI','FGcPOV1j9ApESr3VUlWjFr6E1vF4X_h0LLN82T2CLL0','92xxL8XTRPLROyNUtmN04OT0kyq4iwSCH3sz-j6zbZs'],
- success (res) {
- console.log(res);
- }
- })
- },
- close() {
- //弹出层收起
- this.popupShow = false
- },
- /**
- * 处理富文本里的图片宽度自适应
- * 1.去掉img标签里的style、width、height属性
- * 2.img标签添加style属性:max-width:100%;height:auto
- * 3.修改所有style里的width属性为max-width:100%
- * 4.去掉<br/>标签
- * @param html
- * @returns {void|string|*}
- */
- formatRichText(html) { //控制小程序中图片大小
- let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
- match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
- match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
- match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
- return match;
- });
- newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) {
- match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
- 'max-width:100%;');
- return match;
- });
- newContent = newContent.replace(/<br[^>]*\/>/gi, '');
- newContent = newContent.replace(/\<img/gi,
- '<img style="max-width:100%;height:auto;font-size: 0;margin-top: -5px;"');
- return newContent;
- },
- },
- onShareAppMessage(res) {
- return {
- title: '超值宝贝免费抽,参与活动仅需3秒',
- path: `/pages/index/index?marketingId=${ this.info.id }?inviteCode=${ this.inviteCode }`
- }
- },
- }
- </script>
- <style lang="scss" scoped>
- .data-btn {
- float: left;
- text {
- display: inline-block;
- width: 60rpx;
- }
- }
- .footer-fixed {
- position: fixed;
- bottom: var(--window-bottom);
- left: 0;
- right: 0;
- z-index: 11;
- box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
- background: #fff;
- // 设置ios刘海屏底部横线安全区域
- padding-bottom: constant(safe-area-inset-bottom);
- padding-bottom: env(safe-area-inset-bottom);
- .btn {
- padding: 20rpx 0;
- /deep/ button {
- width: 640rpx;
- height: 90rpx;
- line-height: 90rpx;
- font-size: 36rpx;
- color: #fff;
- background-color: $uni-bg-color;
- border: none;
- border-radius: 20rpx;
- }
- }
- // 设置ios刘海屏底部横线安全区域
- padding-bottom: constant(safe-area-inset-bottom);
- padding-bottom: env(safe-area-inset-bottom);
- }
- </style>
|