Commit 36b4ed06 authored by 郝聪敏's avatar 郝聪敏

优化网络刷新页面;添加签到开奖音效

parent ec09cbdb
......@@ -15,33 +15,33 @@ wepy.app({
// 同时存在 Page hook 和 App hook 时,优先执行 Page hook,返回值再交由 App hook 处
},
globalData: {
statusBarHeight:''
statusBarHeight: ''
},
onLaunch() {
// this.$options.globalData.info = '333';
let that = this;
wx.getSystemInfo({
success: function (res) {
that.$options.globalData.statusBarHeight = res.statusBarHeight
that.$options.globalData.statusBarHeight = res.statusBarHeight;
}
});
wx.checkSession({
success () {
console.log('已登录')
//session_key 未过期,并且在本生命周期一直有效
console.log('已登录');
// session_key 未过期,并且在本生命周期一直有效
},
fail () {
// session_key 已经失效,需要重新执行登录流程
wx.login({
success (res) {
if (res.code) {
//发起网络请求,告诉后端
wx.setStorageSync('wxCode',res.code);
// 发起网络请求,告诉后端
wx.setStorageSync('wxCode', res.code);
} else {
console.log('登录失败!' + res.errMsg)
console.log('登录失败!' + res.errMsg);
}
}
})
});
}
});
wx.setStorageSync('onNetworkStatusChange', true);
......
<template>
<div class="network-container">
<div class="network-container" :class="{'show': show}">
<div class="network-wrapper">
<span class="network-text">网络状况不佳,请刷新重试</span>
<van-button custom-class="network-button" round type="info" @tap="setIsConnected">刷新</van-button>
......@@ -12,9 +12,15 @@
import store from '../../store';
wepy.component({
data: {
show: false
},
store,
methods: {
...mapActions(['setIsConnected'])
},
created() {
this.show = true;
}
});
</script>
......@@ -27,7 +33,7 @@
display: flex;
justify-content: center;
align-items: center;
z-index: 10;
z-index: -1;
.network-wrapper {
display: flex;
justify-content: center;
......@@ -35,19 +41,22 @@
flex-direction: column;
.network-text {
color: #AAA;
font-size: 12px;
font-size: 24rpx;
}
.network-button {
margin-top: 10px;
width: 90px;
font-size: 12px;
height: 28px;
line-height: 28px;
margin-top: 20rpx;
width: 180rpx;
font-size: 24rpx;
height: 56rpx;
line-height: 56rpx;
background: #FF6600;
border-color: #FF6600;
}
}
}
.show {
z-index: 10;
}
</style>
<config>
{
......
......@@ -39,6 +39,16 @@
setTimeout(() => {
this.opened = true;
setTimeout(() => {
const innerAudioContext = wx.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.src = '/static/images/winning.mp3';
innerAudioContext.onPlay(() => {
console.log('开始播放');
});
innerAudioContext.onError((res) => {
console.log(res.errMsg);
console.log(res.errCode);
});
this.showChest = false;
this.blur = true;
this.show = true;
......@@ -52,8 +62,8 @@
created() {
setTimeout(() => {
this.showAnimation = true;
this.click();
},1000);
// this.click();
}, 1000);
}
});
</script>
......
......@@ -115,7 +115,7 @@
},
total: {
type: Number,
value: 0,
value: 0
}
},
data: {
......@@ -129,8 +129,8 @@
_invalidUp: 0,
_invalidDown: 0,
_videoContexts: [],
progress:0,
progressStyle:'',
progress: 0,
progressStyle: '',
loading: false
},
watch: {
......@@ -142,7 +142,7 @@
},
attached() {
this.progress = 47;
this.progressStyle = 'width:'+this.progress+'%';
this.progressStyle = 'width:' + this.progress + '%';
this._videoContexts = [
wx.createVideoContext('video_0', this.$wx),
wx.createVideoContext('video_1', this.$wx),
......@@ -166,7 +166,7 @@
if (diff === 0) return;
this._last = current;
this.playCurrent(current);
// this.$emit('change', { activeId: this.curQueue[current].id });
this.$emit('change', { activeId: this.curQueue[current].id });
this.loading = true;
this.circular = false;
......@@ -217,8 +217,7 @@
// console.log('circular2');
// this.circular = false;
// }
})
});
},
onWaiting (e) {
this.trigger(e, 'wait');
......
......@@ -239,6 +239,8 @@
<script>
let touchDotX = 0, touchDotY = 0;
let timeout = null;
let timeout1 = null;
import store from '../store';
import { mapState, mapActions } from '@wepy/x';
import wepy from '@wepy/core';
......@@ -250,22 +252,23 @@
},
data: {
list:[], //商品list
adlist:[],
current:5, //商品列表初次展示第几个
list: [], // 商品list
adlist: [],
current: 5, // 商品列表初次展示第几个
// userInfo: {},
swiperItem:2,
videoList:[],
swiperItem: 2,
videoList: [],
length: 4,
circular:false, // 商品是否无限循环
topPage:0,
lastPage:0,
currentIndex:5, //商品当前滑动到第几个
authmodal:false,
circular: false, // 商品是否无限循环
topPage: 0,
lastPage: 0,
currentIndex: 5, // 商品当前滑动到第几个
authmodal: false,
sign: false,
showAnimation: false,
userImgStyle:'',
goldNum:2500,
userImgStyle: '',
goldNum: 2500,
awards: false
},
computed: {
......@@ -274,36 +277,36 @@
methods: {
...mapActions([ 'setIsConnected', 'setUserInfo' ]),
moveSwiper(e){
if(e.$wx.detail.source == 'touch') {
moveSwiper(e) {
if (e.$wx.detail.source == 'touch') {
let current = e.$wx.detail.current;
this.currentIndex = current;
}
},
swipermoveDone(e){
if(e.$wx.detail.source == 'touch') {
swipermoveDone(e) {
if (e.$wx.detail.source == 'touch') {
let current = e.$wx.detail.current;
let totalPage = 3;
let nextlist=[
{value:11,text: '白色条纹马克杯,马克吐温同款11', imgsrc:'/static/images/test1.jpg', price:'¥9.89',people:2200,sku:'100004549235'},
{value:12,text: '白色条纹马克杯,马克吐温同款12', imgsrc:'/static/images/test2.png', price:'¥19.20',people:'2200',sku:'100004549235'},
{value:13,text: '白色条纹马克杯,马克吐温同款13', imgsrc:'/static/images/peo1.jpg', price:'¥39.08',people:2200,sku:'100004549235'},
{value:14,text: '白色条纹马克杯,马克吐温同款14', imgsrc:'/static/images/peo2.jpg', price:'¥599.20',people:2200,sku:'100004549235'},
{value:15,text: '白色条纹马克杯,马克吐温同款15', imgsrc:'/static/images/peo3.jpg', price:'¥2399.01',people:2200,sku:'100004549235'},
let nextlist = [
{value: 11, text: '白色条纹马克杯,马克吐温同款11', imgsrc: '/static/images/test1.jpg', price: '¥9.89', people: 2200, sku: '100004549235'},
{value: 12, text: '白色条纹马克杯,马克吐温同款12', imgsrc: '/static/images/test2.png', price: '¥19.20', people: '2200', sku: '100004549235'},
{value: 13, text: '白色条纹马克杯,马克吐温同款13', imgsrc: '/static/images/peo1.jpg', price: '¥39.08', people: 2200, sku: '100004549235'},
{value: 14, text: '白色条纹马克杯,马克吐温同款14', imgsrc: '/static/images/peo2.jpg', price: '¥599.20', people: 2200, sku: '100004549235'},
{value: 15, text: '白色条纹马克杯,马克吐温同款15', imgsrc: '/static/images/peo3.jpg', price: '¥2399.01', people: 2200, sku: '100004549235'}
];
let that = this;
function debounce(func,wait) {
function debounce(func, wait) {
let timeout;
return function () {
if (timeout) clearTimeout(timeout);
let callNow = !timeout;
timeout = setTimeout(func, wait)
timeout = setTimeout(func, wait);
if (callNow) func();
};
}
}
/*if(current <= 2) {
/* if(current <= 2) {
debounce(setTimeout(function(){
that.topPage +=1;
if(that.lastPage+that.topPage >= totalPage) {
......@@ -314,35 +317,35 @@
// that.current = current+1;
// that.currentIndex = current+1;
},1000),500);
}*/
if(current >= this.list.length-3) {
debounce(setTimeout(function(){
that.lastPage +=1;
if(that.lastPage+that.topPage >= totalPage) {
} */
if (current >= this.list.length - 3) {
debounce(setTimeout(function() {
that.lastPage += 1;
if (that.lastPage + that.topPage >= totalPage) {
that.circular = true;
return;
}
that.list = [ ...that.list,...nextlist];
},1000),500)
that.list = [ ...that.list, ...nextlist];
}, 1000), 500);
}
}
},
toViewPage(e) {
let item = e.$wx.currentTarget.dataset.item
let item = e.$wx.currentTarget.dataset.item;
// console.log(sku,12)
//解决长按触发tap事件的bug
// 解决长按触发tap事件的bug
wx.navigateToMiniProgram({
appId: 'wx91d27dbf599dff74',
path: 'pages/item/detail/detail?sku='+item.sku, // 跳转小程序的路径
path: 'pages/item/detail/detail?sku=' + item.sku, // 跳转小程序的路径
// 有效值 develop(开发版),trial(体验版),release(正式版)
envVersion: 'release',
success(res) {
console.log('跳转成功');
}
})
});
/* wx.navigateTo({
url: '/pages/auth'
});*/
}); */
},
touchStart (event) {
touchDotX = event.touches[0].pageX; // 获取触摸时的原点
......@@ -366,7 +369,7 @@
// 手指离开屏幕时记录的坐标
let touchMoveX = event.changedTouches[0].pageX;
let touchMoveY = event.changedTouches[0].pageY;
let current = event.currentTarget.dataset
let current = event.currentTarget.dataset;
// 起始点的坐标(x0,y0)和手指离开时的坐标(x1,y1)之差
let tmX = touchMoveX - touchDotX;
let tmY = touchMoveY - touchDotY;
......@@ -394,7 +397,7 @@
}
},
getUserInfo (e) {
if(e.$wx.detail.userInfo) {
if (e.$wx.detail.userInfo) {
this.setUserInfo(e.$wx.detail.userInfo);
this.authmodal = false;
}
......@@ -402,11 +405,11 @@
changeVideo(e) {
this.setIsConnected();
console.log(this.length, e.activeId);
if (this.length - e.activeId === 1) {
this.videoList = [{id: e.activeId + 2, url: 'https://ip1707952229.mobgslb.tbcache.com/youku/6974c3708c0337150e1743b1c/03000801005EA2A6C8FB4C2003E8807282A547-8207-4F52-9663-969096765248.mp4?sid=158960247500010009412_00_Bac09720260d484f23ac2ccebe5206930&sign=b76f4099e108fc306d3db993d1bec0a8&ctype=50&ali_redirect_domain=vali.cp31.ott.cibntv.net&ali_redirect_ex_ftag=5898cd25832bbff232de6d9fa668e8ddf8bacc5fef3f2e7b&ali_redirect_ex_tmining_ts=1589602477&ali_redirect_ex_tmining_expire=3600&ali_redirect_ex_hot=111'}];
this.length += 1;
console.log('add video');
}
// if (this.length - e.activeId === 1) {
// this.videoList = [{id: e.activeId + 2, url: 'https://ip1707952229.mobgslb.tbcache.com/youku/6974c3708c0337150e1743b1c/03000801005EA2A6C8FB4C2003E8807282A547-8207-4F52-9663-969096765248.mp4?sid=158960247500010009412_00_Bac09720260d484f23ac2ccebe5206930&sign=b76f4099e108fc306d3db993d1bec0a8&ctype=50&ali_redirect_domain=vali.cp31.ott.cibntv.net&ali_redirect_ex_ftag=5898cd25832bbff232de6d9fa668e8ddf8bacc5fef3f2e7b&ali_redirect_ex_tmining_ts=1589602477&ali_redirect_ex_tmining_expire=3600&ali_redirect_ex_hot=111'}];
// this.length += 1;
// console.log('add video');
// }
},
deleteAnimation (current) {
if (current && current.itemid != undefined) {
......@@ -420,12 +423,12 @@
});
this.list = list;
let that = this;
//如果剩下4个就不让他循环了,这时候就一屏显示出来了
if(list.length <= 4) {
// 如果剩下4个就不让他循环了,这时候就一屏显示出来了
if (list.length <= 4) {
this.circular = false;
}
if(current.itemid >= list.length -1) {
this.current = this.currentIndex -1;
if (current.itemid >= list.length - 1) {
this.current = this.currentIndex - 1;
}
setTimeout(function() {
let newlist = that.list.filter((item, index) => index != current.itemid);
......@@ -461,6 +464,16 @@
timeout = null;
timeout1 = null;
} else {
const innerAudioContext = wx.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.src = '/static/images/supermarie.mp3';
innerAudioContext.onPlay(() => {
console.log('开始播放');
});
innerAudioContext.onError((res) => {
console.log(res.errMsg);
console.log(res.errCode);
});
timeout = setTimeout(() => {
that.showAnimation = that.sign;
timeout1 = setTimeout(() => {
......@@ -493,15 +506,15 @@
imageUrl: '',
success: function(res) {
let shareId = res.shareTickets[0];
console.log('shareId', shareId)
console.log('shareId', shareId);
// 转发成功
console.log(res)
console.log(res);
},
fail: function(res) {
// 转发失败
console.log(res)
}
console.log(res);
}
};
},
getAwards: function() {
wx.navigateTo({
......@@ -514,7 +527,7 @@
created () {
let self = this;
let statusHeight = this.$app.$options.globalData.statusBarHeight || '';
statusHeight && (this.userImgStyle = 'top:'+statusHeight+'px')
statusHeight && (this.userImgStyle = 'top:' + statusHeight + 'px');
if (store.state.userInfo) {
this.userInfo = store.state.userInfo;
} else {
......@@ -526,16 +539,16 @@
});
}
this.list = [
{value: 1, text: '白色条纹马克杯,马克吐温同款1', imgsrc:'/static/images/test1.jpg', price:'¥399.00',people:2200,sku:'100004549235'},
{value: 2, text: '白色条纹马克杯,马克吐温同款2', imgsrc:'/static/images/test2.png', price:'¥1399.22',people:2200,sku:'2004203'},
{value: 3, text: '白色条纹马克杯,马克吐温同款3', imgsrc:'/static/images/peo1.jpg', price:'¥199.22',people:2200,sku:'17818909707'},
{value: 4, text: '白色条纹马克杯,马克吐温同款4', imgsrc:'/static/images/peo2.jpg', price:'¥134.12',people:2200,sku:'67704484242'},
{value: 5, text: '白色条纹马克杯,马克吐温同款5', imgsrc:'/static/images/peo3.jpg', price:'¥194.22',people:2200,sku:'100004549235'},
{value: 6, text: '白色条纹马克杯,马克吐温同款6', imgsrc:'/static/images/peo1.jpg', price:'¥292.22',people:2200,sku:'100004549235'},
{value: 7, text: '白色条纹马克杯,马克吐温同款7', imgsrc:'/static/images/test1.jpg', price:'¥1399.92',people:2200,sku:'100004549235'},
{value: 8, text: '白色条纹马克杯,马克吐温同款8', imgsrc:'/static/images/test2.png', price:'¥1399.98',people:2200,sku:'100004549235'},
{value: 9, text: '白色条纹马克杯,马克吐温同款9', imgsrc:'/static/images/peo3.jpg', price:'¥1399.78',people:2200,sku:'100004549235'},
{value: 10, text: '白色条纹马克杯,马克吐温同款10', imgsrc:'/static/images/peo2.jpg', price:'¥1399.67',people:2200,sku:'100004549235'}
{value: 1, text: '白色条纹马克杯,马克吐温同款1', imgsrc: '/static/images/test1.jpg', price: '¥399.00', people: 2200, sku: '100004549235'},
{value: 2, text: '白色条纹马克杯,马克吐温同款2', imgsrc: '/static/images/test2.png', price: '¥1399.22', people: 2200, sku: '2004203'},
{value: 3, text: '白色条纹马克杯,马克吐温同款3', imgsrc: '/static/images/peo1.jpg', price: '¥199.22', people: 2200, sku: '17818909707'},
{value: 4, text: '白色条纹马克杯,马克吐温同款4', imgsrc: '/static/images/peo2.jpg', price: '¥134.12', people: 2200, sku: '67704484242'},
{value: 5, text: '白色条纹马克杯,马克吐温同款5', imgsrc: '/static/images/peo3.jpg', price: '¥194.22', people: 2200, sku: '100004549235'},
{value: 6, text: '白色条纹马克杯,马克吐温同款6', imgsrc: '/static/images/peo1.jpg', price: '¥292.22', people: 2200, sku: '100004549235'},
{value: 7, text: '白色条纹马克杯,马克吐温同款7', imgsrc: '/static/images/test1.jpg', price: '¥1399.92', people: 2200, sku: '100004549235'},
{value: 8, text: '白色条纹马克杯,马克吐温同款8', imgsrc: '/static/images/test2.png', price: '¥1399.98', people: 2200, sku: '100004549235'},
{value: 9, text: '白色条纹马克杯,马克吐温同款9', imgsrc: '/static/images/peo3.jpg', price: '¥1399.78', people: 2200, sku: '100004549235'},
{value: 10, text: '白色条纹马克杯,马克吐温同款10', imgsrc: '/static/images/peo2.jpg', price: '¥1399.67', people: 2200, sku: '100004549235'}
];
let urls = [
// 'https://www.apple.com/105/media/us/iphone-x/2017/01df5b43-28e4-4848-bf20-490c34a926a7/films/feature/iphone-x-feature-tpl-cc-us-20170912_1920x1080h.mp4',
......@@ -567,8 +580,8 @@
{imgsrc: '/static/images/test1.jpg', text: '小8刚刚参与了抽奖'}
];
// console.log(this.$app.$options.globalData.info,111)
//如果已经存在store里就不用再获取用户信息了
if(this.userInfo) return;
// 如果已经存在store里就不用再获取用户信息了
if (this.userInfo) return;
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
......@@ -576,7 +589,7 @@
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
if(res.userInfo) {
if (res.userInfo) {
that.setUserInfo(res.userInfo);
// that.userInfo = res.userInfo;
}
......@@ -584,22 +597,22 @@
// 所以此处加入 callback 以防止这种情况
if (that.userInfoReadyCallback) {
that.userInfoReadyCallback(res => {
that.setUserInfo(res.userInfo||{});
that.setUserInfo(res.userInfo || {});
// that.userInfo = res.userInfo||{};
})
});
}
}
})
}else{
});
} else {
that.authmodal = true;
}
}
});
},
onShow() {
//从其他小程序回来可以在当前生命周期检测到,但是这个方法,自己的小程序页面返回也会进入
console.log('页面show!!')
},
// 从其他小程序回来可以在当前生命周期检测到,但是这个方法,自己的小程序页面返回也会进入
console.log('页面show!!');
}
});
</script>
<config>
......
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