Commit eee933be authored by ziyu's avatar ziyu

feat: 优化代码暂存

parent ca35f130
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
import wepy from '@wepy/core'; import wepy from '@wepy/core';
import { getProbability } from '../../common/raffleProbability'; import { getProbability } from '../../common/raffleProbability';
import { getAwardsDetail } from '../../common/api.js'; import { getAwardsDetail } from '../../common/api.js';
let _videoContexts = [];
wepy.component({ wepy.component({
props: { props: {
videoList: { videoList: {
...@@ -131,7 +131,6 @@ ...@@ -131,7 +131,6 @@
data: { data: {
pause: false, pause: false,
curQueue: [], curQueue: [],
_videoContexts: [],
current: 0 current: 0
}, },
watch: { watch: {
...@@ -177,7 +176,7 @@ ...@@ -177,7 +176,7 @@
}, },
_videoListChanged (newVal) { _videoListChanged (newVal) {
this.curQueue = newVal.map((item, index) => { this.curQueue = newVal.map((item, index) => {
this._videoContexts.push(item.videoUrl ? wx.createVideoContext(`video_${index}`, this.$wx) : null); _videoContexts.push(item.videoUrl ? wx.createVideoContext(`video_${index}`, this.$wx) : null);
item.time = 0; item.time = 0;
return item; return item;
}); });
...@@ -220,7 +219,7 @@ ...@@ -220,7 +219,7 @@
playCurrent(current) { playCurrent(current) {
if (!this.curQueue || this.curQueue.length <= 1) return; if (!this.curQueue || this.curQueue.length <= 1) return;
// 播放当前视频 // 播放当前视频
this._videoContexts.forEach((ctx, index) => { _videoContexts.forEach((ctx, index) => {
if (index !== current) { if (index !== current) {
ctx && ctx.pause(); ctx && ctx.pause();
} else { } else {
...@@ -240,7 +239,7 @@ ...@@ -240,7 +239,7 @@
}, },
videoTap(e) { videoTap(e) {
const current = e.currentTarget.dataset.index; const current = e.currentTarget.dataset.index;
this._videoContexts.forEach((ctx, index) => { _videoContexts.forEach((ctx, index) => {
if (index === current) { if (index === current) {
this.pause ? ctx.play() : ctx.pause(); this.pause ? ctx.play() : ctx.pause();
} }
......
...@@ -205,6 +205,7 @@ ...@@ -205,6 +205,7 @@
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 { login, register, getMainInfo, addGold, getPrizeList, signIn, getActivityFeed, checkCornCode } from '../common/api.js'; import { login, register, getMainInfo, addGold, getPrizeList, signIn, getActivityFeed, checkCornCode } from '../common/api.js';
let awardsInfo = {};
wepy.page({ wepy.page({
store, store,
data: { data: {
...@@ -216,7 +217,6 @@ ...@@ -216,7 +217,6 @@
inviter: '', inviter: '',
mainInfo: null, mainInfo: null,
showModal: 0, // 1: 展示领取金币弹窗 2: 展示抽奖弹窗 3: 头像菜单弹窗 showModal: 0, // 1: 展示领取金币弹窗 2: 展示抽奖弹窗 3: 头像菜单弹窗
awardsInfo: {},
isReceive: false, // 是否显示领取克币动画 isReceive: false, // 是否显示领取克币动画
cornModal:false, cornModal:false,
cornCode: '', //克币充值码 cornCode: '', //克币充值码
...@@ -314,8 +314,8 @@ ...@@ -314,8 +314,8 @@
const openid = wx.getStorageSync('openId'); const openid = wx.getStorageSync('openId');
return { return {
title: `${(this.$wepy.userInfo && this.$wepy.userInfo.nickName) || '您的好朋友'}邀请您来抽奖啦~`, title: `${(this.$wepy.userInfo && this.$wepy.userInfo.nickName) || '您的好朋友'}邀请您来抽奖啦~`,
path: `/pages/index?openid=${openid}&prizeId=${this.$wepy.awardsInfo.id}`, path: `/pages/index?openid=${openid}&prizeId=${awardsInfo.id}`,
imageUrl: decodeURIComponent(this.$wepy.awardsInfo.photoUrl), imageUrl: decodeURIComponent(awardsInfo.photoUrl),
success: function(res) { success: function(res) {
let shareId = res.shareTickets[0]; let shareId = res.shareTickets[0];
console.log('shareId', shareId); console.log('shareId', shareId);
...@@ -326,7 +326,7 @@ ...@@ -326,7 +326,7 @@
}; };
}, },
getAwards: function() { getAwards: function() {
const { id, photoUrl, name, chance } = this.awardsInfo; const { id, photoUrl, name, chance } = awardsInfo;
if ((!id && id !== 0) || !this.mainInfo || !this.mainInfo.account) { if ((!id && id !== 0) || !this.mainInfo || !this.mainInfo.account) {
Notify({ message: '服务器异常,请稍后重试', safeAreaInsetTop: true }); Notify({ message: '服务器异常,请稍后重试', safeAreaInsetTop: true });
return; return;
...@@ -345,7 +345,7 @@ ...@@ -345,7 +345,7 @@
}); });
}, },
getAwardsInfo: function(v) { getAwardsInfo: function(v) {
this.awardsInfo = v; awardsInfo = v;
}, },
showMenu: function(v) { showMenu: function(v) {
this.showModal = v ? 3 : 0; this.showModal = v ? 3 : 0;
......
...@@ -253,21 +253,19 @@ ...@@ -253,21 +253,19 @@
import Dialog from '../components/vant/dialog/dialog'; import Dialog from '../components/vant/dialog/dialog';
import { updateUserPhone, confirmRaffle, register, login, getAwardsDetail, checkInnerCode } from '../common/api'; import { updateUserPhone, confirmRaffle, register, login, getAwardsDetail, checkInnerCode } from '../common/api';
import store from '../store'; import store from '../store';
let hasPhone = false, innerActivity= '', batchId = null;
wepy.page({ wepy.page({
store, store,
data: { data: {
progress: '0%', progress: '0%',
progressStyle: 'width:0%', progressStyle: 'width:0%',
isCheck: true, isCheck: true,
batchId: null,
quantity: '', quantity: '',
name: '', name: '',
chance: '', chance: '',
photoUrl: '', photoUrl: '',
btnfont: '立即参与', btnfont: '立即参与',
hasPhone: false,
isInnerDone: 'hide', isInnerDone: 'hide',
innerActivity: '',
isError: false, isError: false,
code: '', code: '',
errorText: '', errorText: '',
...@@ -285,7 +283,7 @@ ...@@ -285,7 +283,7 @@
function goprize() { function goprize() {
updateUserPhone(detail).then(() => { updateUserPhone(detail).then(() => {
wx.setStorageSync('hasPhone', true); wx.setStorageSync('hasPhone', true);
that.hasPhone = true; hasPhone = true;
that.joinin(); that.joinin();
}).catch(() => { }).catch(() => {
that.btnfont = '立即参与'; that.btnfont = '立即参与';
...@@ -319,7 +317,7 @@ ...@@ -319,7 +317,7 @@
wx.setStorageSync('isRegister', true); wx.setStorageSync('isRegister', true);
} }
this.btnfont = '参与中...'; this.btnfont = '参与中...';
confirmRaffle({batchId: this.batchId}).then(data => { confirmRaffle({batchId: batchId}).then(data => {
this.btnfont = '立即参与'; this.btnfont = '立即参与';
let code = data.joinCode; let code = data.joinCode;
if (code === undefined) code = 3; if (code === undefined) code = 3;
...@@ -342,9 +340,9 @@ ...@@ -342,9 +340,9 @@
Notify({message: '勾选同意后才可以抽奖!'}); Notify({message: '勾选同意后才可以抽奖!'});
return; return;
} }
if (this.hasPhone) { if (hasPhone) {
// 当有innerActivity并且没有邀请码(没有验证过)并且不是VIP的时候才显示modal // 当有innerActivity并且没有邀请码(没有验证过)并且不是VIP的时候才显示modal
if (this.innerActivity && !this.innerActivity.haveCode && !this.innerActivity.vip) { if (innerActivity && !innerActivity.haveCode && !innerActivity.vip) {
this.showModal(); this.showModal();
} else { } else {
this.confirmRaff(); this.confirmRaff();
...@@ -354,7 +352,7 @@ ...@@ -354,7 +352,7 @@
async getProgress(id) { async getProgress(id) {
let detail = await getAwardsDetail({ prizeId: id }); let detail = await getAwardsDetail({ prizeId: id });
detail = detail || {}; detail = detail || {};
this.batchId = detail.id; batchId = detail.id;
if (detail.quantity) { if (detail.quantity) {
if (detail.join > detail.quantity) detail.join = detail.quantity; if (detail.join > detail.quantity) detail.join = detail.quantity;
const progressFloat = detail.join / detail.quantity; const progressFloat = detail.join / detail.quantity;
...@@ -403,7 +401,7 @@ ...@@ -403,7 +401,7 @@
}, },
computed: { computed: {
opentype() { opentype() {
if (this.isCheck && !this.hasPhone) { if (this.isCheck && !hasPhone) {
return 'getPhoneNumber'; return 'getPhoneNumber';
} else { } else {
return ''; return '';
...@@ -420,12 +418,12 @@ ...@@ -420,12 +418,12 @@
onLoad (query) { onLoad (query) {
let {prizeId, quantity, name, chance, photoUrl} = query; let {prizeId, quantity, name, chance, photoUrl} = query;
this.getProgress(prizeId); this.getProgress(prizeId);
this.hasPhone = wx.getStorageSync('hasPhone');
this.quantity = quantity || ''; this.quantity = quantity || '';
this.name = name; this.name = name;
this.chance = chance; this.chance = chance;
this.photoUrl = decodeURIComponent(photoUrl); this.photoUrl = decodeURIComponent(photoUrl);
this.innerActivity = wx.getStorageSync('innerActivity'); hasPhone = wx.getStorageSync('hasPhone');
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