Commit 26afd946 authored by zhijie.xue's avatar zhijie.xue

修复webp ios加载异常

parent e9e43939
...@@ -40,7 +40,8 @@ wepy.app({ ...@@ -40,7 +40,8 @@ wepy.app({
let that = this; let that = this;
wx.getSystemInfo({ wx.getSystemInfo({
success: function (res) { success: function (res) {
that.$options.globalData.statusBarHeight = res.statusBarHeight; const {statusBarHeight} = res;
that.$options.globalData.statusBarHeight = statusBarHeight;
} }
}); });
wx.setStorageSync('onNetworkStatusChange', true); wx.setStorageSync('onNetworkStatusChange', true);
...@@ -49,8 +50,12 @@ wepy.app({ ...@@ -49,8 +50,12 @@ wepy.app({
}); });
}, },
onError(e) { onError(e) {
console.log('onError', e); console.log('app onError', e);
},
onUnhandledRejection(reason, promise) {
console.log('onUnhandledRejection', reason);
} }
}); });
</script> </script>
<config> <config>
......
function isLuckiiResource(url) { function isLuckiiResource(url) {
return url && (url.indexOf('luckiistatic.q-gp.com') !== -1) return url && (url.indexOf('luckiistatic.q-gp.com') !== -1)
} }
function lottery(url) { function lottery(url) {
if (isLuckiiResource(url)) { if (isLuckiiResource(url)) {
return url + '?imageMogr2/auto-orient/thumbnail/500x/gravity/Center/crop/x600/format/webp/blur/1x0/quality/75'; url += '?imageMogr2/auto-orient/thumbnail/500x/gravity/Center/crop/x600/format/webp/blur/1x0/quality/75';
} }
return url; return url;
} }
function prize(url) { function prize(url) {
if (isLuckiiResource(url)) { if (isLuckiiResource(url)) {
return url + '?imageMogr2/format/webp/blur/1x0/quality/75'; url += '?imageMogr2/format/webp/blur/1x0/quality/75';
} }
return url; return url;
} }
......
...@@ -28,7 +28,7 @@ function checkUpdateVersion() { ...@@ -28,7 +28,7 @@ function checkUpdateVersion() {
if (!updateManager) return; if (!updateManager) return;
// 检测版本更新 // 检测版本更新
updateManager.onCheckForUpdate(function(res) { updateManager.onCheckForUpdate(function(res) {
console.log(res, '版本更新'); // console.log(res, '版本更新');
// 请求完新版本信息的回调 // 请求完新版本信息的回调
if (res.hasUpdate) { if (res.hasUpdate) {
// 监听小程序有版本更新事件 // 监听小程序有版本更新事件
......
...@@ -51,7 +51,7 @@ function isLuckiiResource(url) { ...@@ -51,7 +51,7 @@ function isLuckiiResource(url) {
export function compressShareImage(url) { export function compressShareImage(url) {
if (isLuckiiResource(url)) { if (isLuckiiResource(url)) {
return url + '?imageMogr2/auto-orient/thumbnail/500x800!/gravity/Center/crop/x500/format/webp/blur/1x0/quality/75'; url += '?imageMogr2/auto-orient/thumbnail/500x800!/gravity/Center/crop/x500/blur/1x0/quality/75';
} }
return url; return url;
} }
......
...@@ -71,11 +71,11 @@ ...@@ -71,11 +71,11 @@
innerAudioContext.autoplay = true; innerAudioContext.autoplay = true;
innerAudioContext.src = '/static/audio/winning.mp3'; innerAudioContext.src = '/static/audio/winning.mp3';
innerAudioContext.onPlay(() => { innerAudioContext.onPlay(() => {
console.log('开始播放'); // console.log('开始播放');
}); });
innerAudioContext.onError((res) => { innerAudioContext.onError((res) => {
console.log(res.errMsg); console.error(res.errMsg);
console.log(res.errCode); console.error(res.errCode);
}); });
this.showChest = false; this.showChest = false;
this.blur = true; this.blur = true;
......
...@@ -176,7 +176,6 @@ ...@@ -176,7 +176,6 @@
this.$emit('sign-in', true); this.$emit('sign-in', true);
}, },
getUserInfo: function(params) { getUserInfo: function(params) {
console.log(222, this.authmodal);
if (this.authmodal) { if (this.authmodal) {
this.$emit('getUserInfo', params, true); this.$emit('getUserInfo', params, true);
} else { } else {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
methods: { methods: {
onShareAppMessage: function(res) { onShareAppMessage: function(res) {
if (res.from === 'button') { if (res.from === 'button') {
console.log('onShareAppMessage1', res.target); // console.log('onShareAppMessage1', res.target);
} }
} }
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<van-loading type="spinner" size="40" v-if="videoLoading" custom-class="video-loading"/> <van-loading type="spinner" size="40" v-if="videoLoading" custom-class="video-loading"/>
<!--<video-loading v-if="videoLoading" :snapshot="item.videoSnapUrl"/>--> <!--<video-loading v-if="videoLoading" :snapshot="item.videoSnapUrl"/>-->
</video> </video>
<van-image wx:if="{{item.showType && item.showType.value ==1}}" use-loading-slot src="{{ic.prize(item.photoUrl || item.videoSnapUrl)}}" class="images" radius="10rpx" fit="contain" width="100%" height="100%"> <van-image webp="{{true}}" wx:if="{{item.showType && item.showType.value ==1}}" use-loading-slot src="{{ic.prize(item.photoUrl || item.videoSnapUrl)}}" class="images" radius="10rpx" fit="contain" width="100%" height="100%">
<van-loading slot="loading" type="spinner" size="20" vertical/> <van-loading slot="loading" type="spinner" size="20" vertical/>
</van-image> </van-image>
<view class="rightcont" v-show="item.id > 0"> <view class="rightcont" v-show="item.id > 0">
......
...@@ -50,6 +50,10 @@ VantComponent({ ...@@ -50,6 +50,10 @@ VantComponent({
type: Boolean, type: Boolean,
value: true, value: true,
}, },
webp: {
type: Boolean,
value: false,
}
}, },
data: { data: {
error: false, error: false,
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
show-menu-by-longpress="{{ showMenuByLongpress }}" show-menu-by-longpress="{{ showMenuByLongpress }}"
bind:load="onLoad" bind:load="onLoad"
bind:error="onError" bind:error="onError"
webp="{{ webp }}"
/> />
<view <view
......
...@@ -307,7 +307,7 @@ ...@@ -307,7 +307,7 @@
}); });
await wepy.wx.openSetting(); await wepy.wx.openSetting();
} catch (e) { } catch (e) {
console.log(e || e.message); console.error(e || e.message);
} }
return; return;
} }
...@@ -319,7 +319,6 @@ ...@@ -319,7 +319,6 @@
wx.requestSubscribeMessage({ wx.requestSubscribeMessage({
tmplIds, tmplIds,
success (res) { success (res) {
console.log('requestSubscribeMessage success', res);
if (res.errMsg === 'requestSubscribeMessage:ok') { if (res.errMsg === 'requestSubscribeMessage:ok') {
// 兼容写法,有时响应中的模板id不是3个 // 兼容写法,有时响应中的模板id不是3个
const rs = tmplIds.every(v => res[v] === undefined || res[v] === 'accept'); const rs = tmplIds.every(v => res[v] === undefined || res[v] === 'accept');
...@@ -331,8 +330,8 @@ ...@@ -331,8 +330,8 @@
innerAudioContext.src = '/static/audio/supermarie.mp3'; innerAudioContext.src = '/static/audio/supermarie.mp3';
innerAudioContext.onPlay(() => {}); innerAudioContext.onPlay(() => {});
innerAudioContext.onError((res) => { innerAudioContext.onError((res) => {
console.log(res.errMsg); console.error(res.errMsg);
console.log(res.errCode); console.error(res.errCode);
}); });
const { coins } = await signIn(); const { coins } = await signIn();
wepy.wx.hideLoading(); wepy.wx.hideLoading();
...@@ -347,7 +346,7 @@ ...@@ -347,7 +346,7 @@
} }
}, },
fail (res) { fail (res) {
console.log('requestSubscribeMessage fail', res); console.error('requestSubscribeMessage fail', res);
wepy.wx.hideLoading(); wepy.wx.hideLoading();
} }
}); });
...@@ -398,26 +397,28 @@ ...@@ -398,26 +397,28 @@
}, 1000); }, 1000);
}, },
getMainInfo: async function() { getMainInfo: async function() {
this.mainInfo = await getMainInfo(); const info = await getMainInfo();
this.sign = this.mainInfo && this.mainInfo.signin; if (!info) return;
wx.setStorageSync('hasPhone', this.mainInfo.phone); this.mainInfo = info;
this.sign = info && info.signin;
wx.setStorageSync('hasPhone', info.phone);
const activityId = wx.getStorageSync('activityId'); const activityId = wx.getStorageSync('activityId');
if (this.mainInfo && this.mainInfo.innerActivity) { if (info && info.innerActivity) {
wx.setStorageSync('innerActivity', this.mainInfo.innerActivity); wx.setStorageSync('innerActivity', info.innerActivity);
} else { } else {
wx.setStorageSync('innerActivity', ''); wx.setStorageSync('innerActivity', '');
} }
// 弹窗有多个,展示顺序 活动弹窗->邀请好友->购买获得克币->开奖宝箱 // 弹窗有多个,展示顺序 活动弹窗->邀请好友->购买获得克币->开奖宝箱
if (this.mainInfo.activity && this.mainInfo.activity.id && this.mainInfo.activity.id !== +activityId) { if (info.activity && info.activity.id && info.activity.id !== +activityId) {
// 活动弹窗 // 活动弹窗
this.avtivityModal = true; this.avtivityModal = true;
} else if (this.mainInfo.inviteRecord && this.mainInfo.inviteRecord.length) { } else if (info.inviteRecord && info.inviteRecord.length) {
// 邀请好友 // 邀请好友
this.showModal = 1; this.showModal = 1;
} else if (this.mainInfo.buyRecord && this.mainInfo.buyRecord.length) { } else if (info.buyRecord && info.buyRecord.length) {
// 购买获得金币 // 购买获得金币
this.showModal = 4; this.showModal = 4;
} else if (this.mainInfo.joinRecord && this.mainInfo.joinRecord.id) { } else if (info.joinRecord && info.joinRecord.id) {
// 开奖宝箱 // 开奖宝箱
this.showModal = 2; this.showModal = 2;
} }
...@@ -441,19 +442,27 @@ ...@@ -441,19 +442,27 @@
}, },
getOpenId() { getOpenId() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let reLogin = false;
wx.checkSession({ wx.checkSession({
success() { success() {
if (!wx.getStorageSync('openId')) {
reLogin = true;
}
resolve(); resolve();
}, },
async fail() { async fail() {
const { code } = await wepy.wx.login(); reLogin = true;
let loginInfo = await login(code);
loginInfo = loginInfo || {};
wx.setStorageSync('openId', loginInfo.openid);
wx.setStorageSync('isRegister', loginInfo.register);
resolve();
}, },
complete() {} async complete() {
if (reLogin) {
const { code } = await wepy.wx.login();
let loginInfo = await login(code);
loginInfo = loginInfo || {};
wx.setStorageSync('openId', loginInfo.openid);
wx.setStorageSync('isRegister', loginInfo.register);
}
resolve();
}
}); });
}); });
}, },
......
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
<view class="raffle-wrapper"> <view class="raffle-wrapper">
<view class="raffle-content"> <view class="raffle-content">
<van-image use-loading-slot src="{{ic.lottery(photoUrl)}}" class="img" width="610rpx" height="610rpx" radius="10rpx" fit="widthFix"> <van-image webp="{{true}}" use-loading-slot src="{{ic.lottery(photoUrl)}}" class="img" width="610rpx" height="610rpx" radius="10rpx" fit="widthFix">
<van-loading slot="loading" type="spinner" size="20" vertical /> <van-loading slot="loading" type="spinner" size="20" vertical />
</van-image> </van-image>
<view class="goodsinfo"> <view class="goodsinfo">
......
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