Commit e718e4cb authored by ziyu's avatar ziyu

feat: 内测邀请码功能

parent 7d63281b
...@@ -46,5 +46,8 @@ module.exports = { ...@@ -46,5 +46,8 @@ module.exports = {
}, },
getPrize(params) { getPrize(params) {
return http.post('/api/user/prize/receive', params, { 'content-type': 'application/json' }); return http.post('/api/user/prize/receive', params, { 'content-type': 'application/json' });
},
checkInnerCode(params) {
return http.post('/api/user/inviteCode', params);
} }
}; };
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
videoList () { videoList () {
const newVal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; const newVal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
this._videoListChanged(newVal); this._videoListChanged(newVal);
this.compute(this.userAccount); // this.compute(this.userAccount);
}, },
userAccount(newVal) { userAccount(newVal) {
this.compute(newVal); this.compute(newVal);
...@@ -172,6 +172,7 @@ ...@@ -172,6 +172,7 @@
item.time = 0; item.time = 0;
return item; return item;
}); });
this.compute(this.userAccount);
this.playCurrent(0); this.playCurrent(0);
}, },
async bindanimationfinish(e) { async bindanimationfinish(e) {
......
...@@ -615,6 +615,11 @@ ...@@ -615,6 +615,11 @@
this.mainInfo = await getUserInfo(wx.getStorageSync('openId')); this.mainInfo = await getUserInfo(wx.getStorageSync('openId'));
this.sign = this.mainInfo && this.mainInfo.signin; this.sign = this.mainInfo && this.mainInfo.signin;
wx.setStorageSync('hasPhone', this.mainInfo.phone); wx.setStorageSync('hasPhone', this.mainInfo.phone);
if(this.mainInfo&&this.mainInfo.innerActivity) {
wx.setStorageSync('innerActivity', this.mainInfo.innerActivity);
} else {
wx.setStorageSync('innerActivity','')
}
if (this.mainInfo.inviteRecord && this.mainInfo.inviteRecord.length) { if (this.mainInfo.inviteRecord && this.mainInfo.inviteRecord.length) {
this.showShareModal = true; this.showShareModal = true;
} else if (this.mainInfo.joinRecord && this.mainInfo.joinRecord.id) { } else if (this.mainInfo.joinRecord && this.mainInfo.joinRecord.id) {
......
...@@ -123,6 +123,87 @@ ...@@ -123,6 +123,87 @@
font-size: 34rpx; font-size: 34rpx;
color:@whitecolor; color:@whitecolor;
} }
.innerActivity {
width:100%;
height:100%;
background-color: rgba(0,0,0,0.7);
position: fixed;
top:0;left:0;
animation:fadein .3s linear forwards;
&.anima {
animation:fadeout .3s linear forwards;
}
&.hide {
display: none;
}
.inner-content {
width: 70%;
position: absolute;
top:30%;
height:360rpx;
left:15%;
background-color: @whiteback;
box-shadow:0 2rpx 20rpx 0 rgba(144, 144, 144, 0.35);
border-radius:20rpx;
}
.inner-title {
text-align: center;
font-size: 34rpx;
padding-top:50rpx;
}
.inner-input {
background-color: #ddd;
height:70rpx;
width:330rpx;
margin:0 auto;
line-height:70rpx;
font-size: 32rpx;
border-radius:35rpx;
padding:0 30rpx;
margin-top:30rpx;
}
.error-text {
color:@redcolor;
font-size: 22rpx;
width:390rpx;
margin:0 auto;
padding:20rpx 0;
}
.inner-footer {
width:100%;
height:88rpx;
position: absolute;
bottom:0;
left:0;
border-top: 1rpx solid #E6E6E6;
overflow: hidden;
.button {
width:50%;
float: left;
text-align: center;
line-height:88rpx;
}
.cancel {
color:@lightgrey;
font-size: @font-middle;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border-right: 1rpx solid #E6E6E6;
}
.confirm {
color: @maincolor;
font-size: 34rpx;
}
}
}
@-webkit-keyframes fadeout {
from { background: rgba(0, 0, 0, 0.7); opacity: 1;}
to { background: rgba(0, 0, 0, 0); opacity: 0;}
}
@-webkit-keyframes fadein {
from { background: rgba(0, 0, 0, 0); opacity: 0;}
to { background: rgba(0, 0, 0, 0.7); opacity: 1;}
}
</style> </style>
<template> <template>
<view class="raffle-wrapper"> <view class="raffle-wrapper">
...@@ -151,13 +232,26 @@ ...@@ -151,13 +232,26 @@
<button class="joinin" open-type="{{opentype}}" bindtap="joinin" bindgetphonenumber="getPhoneNumber">{{btnfont}}</button> <button class="joinin" open-type="{{opentype}}" bindtap="joinin" bindgetphonenumber="getPhoneNumber">{{btnfont}}</button>
<van-notify id="van-notify" /> <van-notify id="van-notify" />
<van-dialog id="van-dialog"/> <van-dialog id="van-dialog"/>
<view class="innerActivity {{isInnerDone}}">
<view class="inner-content">
<view class="inner-title">请输入邀请码</view>
<view>
<input type="text" class="inner-input" v-model="code">
</view>
<view class="error-text" v-show="isError">邀请码错误,请重新输入</view>
<view class="inner-footer">
<view class="cancel button" bindtap="closeModal">内测结束再抽</view>
<view class="confirm button" bindtap="checkCode">确定</view>
</view>
</view>
</view>
</view> </view>
</template> </template>
<script> <script>
import wepy from '@wepy/core'; import wepy from '@wepy/core';
import Notify from '../components/vant/notify/notify'; import Notify from '../components/vant/notify/notify';
import Dialog from '../components/vant/dialog/dialog'; import Dialog from '../components/vant/dialog/dialog';
import { updateUserPhone, confirmRaffle, register, login, getAwardsDetail } from '../common/api'; import { updateUserPhone, confirmRaffle, register, login, getAwardsDetail, checkInnerCode } from '../common/api';
import store from '../store'; import store from '../store';
wepy.page({ wepy.page({
store, store,
...@@ -171,7 +265,11 @@ ...@@ -171,7 +265,11 @@
chance: '', chance: '',
photoUrl: '', photoUrl: '',
btnfont: '立即参与', btnfont: '立即参与',
hasPhone: false hasPhone: false,
isInnerDone:'hide',
innerActivity:'',
isError:false,
code:'',
}, },
methods: { methods: {
check() { check() {
...@@ -191,7 +289,7 @@ ...@@ -191,7 +289,7 @@
}); });
} }
if (detail.encryptedData) { if (detail.encryptedData) {
this.btnfont = '提交中...'; this.btnfont = '参与中...';
const { code } = await wepy.wx.login(); const { code } = await wepy.wx.login();
await login(code); await login(code);
goprize(); goprize();
...@@ -208,7 +306,7 @@ ...@@ -208,7 +306,7 @@
await register(store.state.userInfo); await register(store.state.userInfo);
wx.setStorageSync('isRegister', true); wx.setStorageSync('isRegister', true);
} }
this.btnfont = '提交中...'; this.btnfont = '参与中...';
confirmRaffle({batchId: this.batchId}).then(data => { confirmRaffle({batchId: this.batchId}).then(data => {
this.btnfont = '立即参与'; this.btnfont = '立即参与';
let code = data.joinCode; let code = data.joinCode;
...@@ -229,7 +327,11 @@ ...@@ -229,7 +327,11 @@
return; return;
} }
if (this.hasPhone) { if (this.hasPhone) {
this.confirmRaff(); if(this.innerActivity && !this.innerActivity.haveCode && !this.innerActivity.vip) {
this.showModal();
}else {
this.confirmRaff();
}
} }
}, },
async getProgress(id) { async getProgress(id) {
...@@ -240,6 +342,27 @@ ...@@ -240,6 +342,27 @@
this.progress = Math.round((detail.join / detail.quantity) * 100) + '%'; this.progress = Math.round((detail.join / detail.quantity) * 100) + '%';
this.progressStyle = 'width:' + this.progress; this.progressStyle = 'width:' + this.progress;
} }
},
closeModal() {
this.isInnerDone = 'anima';
setTimeout(() => {
this.isInnerDone = 'hide';
}, 300);
},
showModal() {
this.isInnerDone = '';
this.isError = false;
this.code = '';
},
checkCode () {
checkInnerCode({code:this.code}).then(data=>{
if(+data.checkCode === 0) {
this.closeModal();
this.confirmRaff();
}else{
this.isError = true;
}
})
} }
}, },
computed: { computed: {
...@@ -251,6 +374,13 @@ ...@@ -251,6 +374,13 @@
} }
} }
}, },
watch: {
code(val) {
if(!val.length&&this.isError) {
this.isError = false;
}
}
},
onLoad (query) { onLoad (query) {
let {prizeId, quantity, name, chance, photoUrl} = query; let {prizeId, quantity, name, chance, photoUrl} = query;
this.getProgress(prizeId); this.getProgress(prizeId);
...@@ -259,6 +389,7 @@ ...@@ -259,6 +389,7 @@
this.name = name; this.name = name;
this.chance = chance; this.chance = chance;
this.photoUrl = photoUrl; this.photoUrl = photoUrl;
this.innerActivity = wx.getStorageSync('innerActivity');
} }
}); });
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment