Commit eee933be authored by ziyu's avatar ziyu

feat: 优化代码暂存

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