Commit 32b474b8 authored by 郝聪敏's avatar 郝聪敏

Merge branch 'feature/animation' into 'master'

修改奖品列表接口;优化notify延迟问题;奖品图片添加loading;

See merge request !48
parents 73fc42ce 0ead2cc8
...@@ -26,8 +26,9 @@ module.exports = { ...@@ -26,8 +26,9 @@ module.exports = {
signIn(params) { signIn(params) {
return http.post('/api/user/signin', params, { 'content-type': 'application/json' }); return http.post('/api/user/signin', params, { 'content-type': 'application/json' });
}, },
getPrizeList(params) { getPrizeList(id) {
return http.post('/api/prize/list', params, { 'content-type': 'application/json' }); const params = !id ? undefined : { prizeId: id };
return http.post('/api/prize/list', params);
}, },
getRaffles() { getRaffles() {
return http.post('/api/user/join/list'); return http.post('/api/user/join/list');
......
...@@ -38,16 +38,20 @@ const request = async (url, options) => { ...@@ -38,16 +38,20 @@ const request = async (url, options) => {
method: options.method, method: options.method,
header: options.header header: options.header
}).then(res => { }).then(res => {
let msg = res.data.msg || '服务器异常'; let errMsg = null;
if (res.statusCode === 200) { if (res.statusCode === 200) {
if (res.data.code === 2000) { if (res.data.code === 2000) {
return res.data.data; return res.data.data;
} }
Notify({ message: '服务器异常,请稍后重试', safeAreaInsetTop }); Notify({ message: '服务器异常,请稍后重试', safeAreaInsetTop });
throw new Error(msg + ',请求url:' + url + '请求返回:' + res.data); errMsg = `httpurl: ${url}, method: ${options.method}, params: ${JSON.stringify(options.data)}, status: ${res.statusCode}, data: ${JSON.stringify(res.data)}`;
if (env === 'test') console.error(errMsg);
throw new Error(errMsg);
} }
Notify({ message: '服务器异常,请稍后重试', safeAreaInsetTop }); Notify({ message: '服务器异常,请稍后重试', safeAreaInsetTop });
throw new Error(msg + ',请求url:' + url + '请求返回:' + res.data); errMsg = `httpurl: ${url}, method: ${options.method}, params: ${JSON.stringify(options.data)}, status: ${res.statusCode}, data: ${JSON.stringify(res.data)}`;
if (env === 'test') console.error(errMsg);
throw new Error(errMsg);
}); });
}; };
......
<template> <template>
<div class="loading-container"> <div class="loading-container">
<image class="loading-image" :src="snapshot" mode="widthFix"></image> <image v-if="snapshot" class="loading-image" :src="snapshot" mode="widthFix" bindload="imageLoad"></image>
<!-- <van-loading size="24px" vertical></van-loading> --> <div v-if="!snapshot || snapshot && !imageLoaded" class="loading-animation">
<van-loading size="24px"></van-loading>
</div>
</div> </div>
</template> </template>
<script> <script>
...@@ -13,19 +15,36 @@ ...@@ -13,19 +15,36 @@
type: String, type: String,
default: '' default: ''
} }
},
data: {
imageLoaded: false
},
methods: {
imageLoad() {
this.imageLoaded = true;
}
} }
}); });
</script> </script>
<style lang="less"> <style lang="less">
.loading-container { .loading-container {
position: absolute; position: absolute;
top: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
background:rgba(0,0,0,0.7);
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
z-index: 1; z-index: 1;
.loading-animation{
position: absolute;
width: 100%;
height: 100%;
background:rgba(0,0,0);
display: flex;
justify-content: center;
align-items: center;
}
.loading-image { .loading-image {
position: absolute; position: absolute;
width: 100%; width: 100%;
......
...@@ -96,7 +96,9 @@ ...@@ -96,7 +96,9 @@
<video-loading v-if="item.time === 0" :snapshot="item.videoSnapUrl"/> <video-loading v-if="item.time === 0" :snapshot="item.videoSnapUrl"/>
<video-pause :pause="pause"></video-pause> <video-pause :pause="pause"></video-pause>
</video> </video>
<image v-if="item.showType && item.showType.value === 1" class="images" :src="item.photoUrl" mode="widthFix"></image> <image v-if="item.showType && item.showType.value === 1" lazy-load class="images" :src="item.photoUrl" mode="widthFix" bindload="imageLoad(item.id)">
<image-loading v-if="item.time === 0"/>
</image>
<view class="rightcont" v-show="item.id > 0"> <view class="rightcont" v-show="item.id > 0">
<view class="info">奖品库存: {{item.stock}}/{{item.totalStock}}</view> <view class="info">奖品库存: {{item.stock}}/{{item.totalStock}}</view>
<view class="info">中奖概率: {{item.probability}}</view> <view class="info">中奖概率: {{item.probability}}</view>
...@@ -155,6 +157,7 @@ ...@@ -155,6 +157,7 @@
this.updateAwardsInfo(this.current); this.updateAwardsInfo(this.current);
}, },
async getProgress(id) { async getProgress(id) {
if (id <= 0) return;
let detail = await getAwardsDetail({ prizeId: id }); let detail = await getAwardsDetail({ prizeId: id });
detail = detail || {}; detail = detail || {};
if (detail.join > detail.quantity) detail.join = detail.quantity; if (detail.join > detail.quantity) detail.join = detail.quantity;
...@@ -177,7 +180,9 @@ ...@@ -177,7 +180,9 @@
return item; return item;
}); });
this.compute(this.userAccount); this.compute(this.userAccount);
this.playCurrent(0); setTimeout(() => {
this.playCurrent(0);
}, 300);
}, },
async bindanimationfinish(e) { async bindanimationfinish(e) {
const current = e.$wx.detail.current; const current = e.$wx.detail.current;
...@@ -212,8 +217,6 @@ ...@@ -212,8 +217,6 @@
}, },
playCurrent(current) { playCurrent(current) {
if (!this.curQueue || this.curQueue.length <= 1) return; if (!this.curQueue || this.curQueue.length <= 1) return;
// 更新抽奖页面参数
this.updateAwardsInfo(current);
// 播放当前视频 // 播放当前视频
this._videoContexts.forEach((ctx, index) => { this._videoContexts.forEach((ctx, index) => {
if (index !== current) { if (index !== current) {
...@@ -222,6 +225,8 @@ ...@@ -222,6 +225,8 @@
ctx && ctx.play(); ctx && ctx.play();
} }
}); });
// 更新抽奖页面参数
this.updateAwardsInfo(current);
// 更新奖品进度 // 更新奖品进度
this.getProgress(this.curQueue[current].id); this.getProgress(this.curQueue[current].id);
}, },
...@@ -243,6 +248,14 @@ ...@@ -243,6 +248,14 @@
this.pause = !this.pause; this.pause = !this.pause;
} }
}); });
},
imageLoad(id) {
this.curQueue.forEach(item => {
if (item.id === id) {
item.time = 1;
}
});
this.curQueue = [...this.curQueue];
} }
} }
}); });
...@@ -252,6 +265,7 @@ ...@@ -252,6 +265,7 @@
usingComponents: { usingComponents: {
'video-pause': '~@/components/custom/videoPause', 'video-pause': '~@/components/custom/videoPause',
'video-loading': '~@/components/custom/loading', 'video-loading': '~@/components/custom/loading',
'image-loading': '~@/components/custom/loading',
"van-image": "~@/components/vant/image/index" "van-image": "~@/components/vant/image/index"
} }
} }
......
...@@ -5,7 +5,9 @@ const getClassNames = (name) => ({ ...@@ -5,7 +5,9 @@ const getClassNames = (name) => ({
leave: `van-${name}-leave van-${name}-leave-active leave-class leave-active-class`, leave: `van-${name}-leave van-${name}-leave-active leave-class leave-active-class`,
'leave-to': `van-${name}-leave-to van-${name}-leave-active leave-to-class leave-active-class`, 'leave-to': `van-${name}-leave-to van-${name}-leave-active leave-to-class leave-active-class`,
}); });
const nextTick = () => new Promise((resolve) => setTimeout(resolve, 1000 / 30)); // const nextTick = () => new Promise((resolve) => setTimeout(resolve, 1000 / 30));
// 解决动画延迟问题
const nextTick = () => new Promise((resolve) => resolve());
export const transition = function (showDefaultValue) { export const transition = function (showDefaultValue) {
return Behavior({ return Behavior({
properties: { properties: {
......
...@@ -295,7 +295,7 @@ ...@@ -295,7 +295,7 @@
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}`, path: `/pages/index?openid=${openid}&prizeId=${this.$wepy.awardsInfo.id}`,
imageUrl: decodeURIComponent(this.$wepy.awardsInfo.photoUrl), imageUrl: decodeURIComponent(this.$wepy.awardsInfo.photoUrl),
success: function(res) { success: function(res) {
let shareId = res.shareTickets[0]; let shareId = res.shareTickets[0];
...@@ -416,12 +416,13 @@ ...@@ -416,12 +416,13 @@
// 获取活动信息 // 获取活动信息
this.showActivity(); this.showActivity();
// 获取奖品列表 // 获取奖品列表
this.videoList = await getPrizeList(); this.videoList = await getPrizeList(options.prizeId);
}, },
async onShow() { async onShow() {
let join = wx.getStorageSync('userJoin'); let join = wx.getStorageSync('userJoin');
if (join === 1) { if (join === 1) {
wx.removeStorageSync('userJoin'); wx.removeStorageSync('userJoin');
this.getMainInfo();
this.showActivity(); this.showActivity();
} }
} }
......
...@@ -331,7 +331,7 @@ ...@@ -331,7 +331,7 @@
title: title[code], title: title[code],
message: message[code] message: message[code]
}).then(() => { }).then(() => {
wx.reLaunch({url: '/pages/index'}); wx.navigateBack({url: '/pages/index'});
}); });
}).catch(() => { }).catch(() => {
this.btnfont = '立即参与'; this.btnfont = '立即参与';
......
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