Commit 837abb20 authored by wildfirecode13's avatar wildfirecode13

1

parent f738c1a5
...@@ -6,5 +6,8 @@ ...@@ -6,5 +6,8 @@
"pages/myprize/myprize", "pages/myprize/myprize",
"pages/pagewo_de_jiang_pin_ye_mian1/pagewo_de_jiang_pin_ye_mian1" "pages/pagewo_de_jiang_pin_ye_mian1/pagewo_de_jiang_pin_ye_mian1"
], ],
"window": {} "window": {
"allowsBounceVertical":"NO"
}
} }
\ No newline at end of file
...@@ -7,7 +7,7 @@ import playBgMusic from '/utils/playBgMusic'; ...@@ -7,7 +7,7 @@ import playBgMusic from '/utils/playBgMusic';
const app = getApp(); const app = getApp();
const { tbcc } = app; const { tbcc } = app;
const { commonToast, getAuthUserInfo, navigateToOutside } = tbcc.tb; const { commonToast, getAuthUserInfo, navigateToOutside } = tbcc.tb;
let musicUrl = null;
Page({ Page({
data: { data: {
resList: resList, resList: resList,
...@@ -35,7 +35,7 @@ Page({ ...@@ -35,7 +35,7 @@ Page({
end: '', end: '',
// 活动结束时间props // 活动结束时间props
endTime:'', endTime: '',
// 会员消耗积分 // 会员消耗积分
vipCredits: '', vipCredits: '',
...@@ -45,16 +45,16 @@ Page({ ...@@ -45,16 +45,16 @@ Page({
totalFloor: '', totalFloor: '',
// 单人最多购买楼层 // 单人最多购买楼层
eachBuyMostFloor: '', eachBuyMostFloor: '',
userTotalFloor:'', userTotalFloor: '',
countDown: '', countDown: '',
ruleModalVisible: false, ruleModalVisible: false,
myPrizeBtnVisible: false, myPrizeBtnVisible: false,
ruleData: '', ruleData: '',
screentop:'', screentop: '',
maskVisible:false, maskVisible: false,
musicSwitch:true musicSwitch: true
}, },
...@@ -69,21 +69,21 @@ Page({ ...@@ -69,21 +69,21 @@ Page({
this.getOrderList(); this.getOrderList();
// this.screenAdapt(); // this.screenAdapt();
}, },
onReady(){ onReady() {
this.onmusicSwitch(); this.onmusicSwitch();
}, },
onmusicSwitch(){ onmusicSwitch() {
let {musicSwitch} = this.data; let { musicSwitch } = this.data;
this.addMusic(musicSwitch); this.addMusic(musicSwitch);
this.setData({ this.setData({
musicSwitch:!musicSwitch musicSwitch: !musicSwitch
}) })
console.log('music点击后',musicSwitch); console.log('music点击后', musicSwitch);
}, },
...@@ -103,13 +103,13 @@ Page({ ...@@ -103,13 +103,13 @@ Page({
showRuleModal() { showRuleModal() {
this.setData({ this.setData({
ruleModalVisible: true, ruleModalVisible: true,
maskVisible:true maskVisible: true
}) })
}, },
ruleModalClose() { ruleModalClose() {
this.setData({ this.setData({
ruleModalVisible: false, ruleModalVisible: false,
maskVisible:false maskVisible: false
}) })
}, },
...@@ -119,7 +119,7 @@ Page({ ...@@ -119,7 +119,7 @@ Page({
// 更新购买记录 // 更新购买记录
// 总楼层数更新 // 总楼层数更新
this.setData({ this.setData({
maskVisible:false maskVisible: false
}) })
this.getUserCredits(); this.getUserCredits();
this.getOrderList(); this.getOrderList();
...@@ -153,21 +153,21 @@ Page({ ...@@ -153,21 +153,21 @@ Page({
console.log('click', this.data) console.log('click', this.data)
this.setData({ this.setData({
orderModalVisible: true, orderModalVisible: true,
maskVisible:true maskVisible: true
}) })
}, },
// 关闭弹窗 // 关闭弹窗
orderModalClose() { orderModalClose() {
this.setData({ this.setData({
orderModalVisible: false, orderModalVisible: false,
maskVisible:false maskVisible: false
}) })
}, },
// 购买楼层 // 购买楼层
async buyFloors() { async buyFloors() {
// 购买楼层数 // 购买楼层数
let { canBuyFloor, end, userTotalFloor,eachBuyMostFloor } = this.data; let { canBuyFloor, end, userTotalFloor, eachBuyMostFloor } = this.data;
let { data: { isVip, grade, gradeName, gradeCredits } } = await API.getVipInfo() || {}; let { data: { isVip, grade, gradeName, gradeCredits } } = await API.getVipInfo() || {};
// 判断会员等级 // 判断会员等级
...@@ -178,7 +178,7 @@ Page({ ...@@ -178,7 +178,7 @@ Page({
grade, grade,
gradeName gradeName
}, },
}) })
// 判断活动时间 // 判断活动时间
let currentTime = new Date().getTime(); let currentTime = new Date().getTime();
...@@ -186,17 +186,17 @@ Page({ ...@@ -186,17 +186,17 @@ Page({
let reduced = eachBuyMostFloor - userTotalFloor; let reduced = eachBuyMostFloor - userTotalFloor;
if (currentTime < end) { if (currentTime < end) {
if(reduced <= 0){ if (reduced <= 0) {
commonToast('已购买的楼层达到最大值'); commonToast('已购买的楼层达到最大值');
}else if(canBuyFloor <= reduced){ } else if (canBuyFloor <= reduced) {
// 可以买 // 可以买
// 显示 // 显示
this.setData({ this.setData({
orderNowModalVisible: true, orderNowModalVisible: true,
maskVisible:true maskVisible: true
}) })
} else{ } else {
commonToast('当前最多可购买'+ reduced +'层'); commonToast('当前最多可购买' + reduced + '层');
} }
} else { } else {
commonToast('无法购买') commonToast('无法购买')
...@@ -306,7 +306,7 @@ Page({ ...@@ -306,7 +306,7 @@ Page({
ruleData, ruleData,
userTotalFloor userTotalFloor
}) })
console.log('zhixingcount'); console.log('zhixingcount');
this.countDowning(end); this.countDowning(end);
} else { } else {
// 错误码 // 错误码
...@@ -319,8 +319,8 @@ Page({ ...@@ -319,8 +319,8 @@ Page({
countDowning(end) { countDowning(end) {
// console.log('执行时间count') // console.log('执行时间count')
if(end.length == 0){ if (end.length == 0) {
this.setData({ this.setData({
endingTime: { endingTime: {
d: '00', d: '00',
...@@ -363,9 +363,9 @@ Page({ ...@@ -363,9 +363,9 @@ Page({
// 每1000ms刷新一次 // 每1000ms刷新一次
if (time > 0) { if (time > 0) {
this.setData({ this.setData({
countDown:true countDown: true
}) })
timer = setTimeout(this.countDowning.bind(this,end), 1000); timer = setTimeout(this.countDowning.bind(this, end), 1000);
} else { } else {
clearTimeout(timer); clearTimeout(timer);
this.setData({ this.setData({
...@@ -409,17 +409,17 @@ Page({ ...@@ -409,17 +409,17 @@ Page({
top: 50 * i + 'rpx', top: 50 * i + 'rpx',
position: 'absolute', position: 'absolute',
color: 'white', color: 'white',
width:260+'rpx', width: 260 + 'rpx',
textAlign:'center' textAlign: 'center'
}, },
orderCredits: { orderCredits: {
left: 370 + 'rpx', left: 370 + 'rpx',
top: 50 * i + 'rpx', top: 50 * i + 'rpx',
position: 'absolute', position: 'absolute',
color: 'white', color: 'white',
width:140+'rpx', width: 140 + 'rpx',
textAlign:'center', textAlign: 'center',
overflow:'hidden' overflow: 'hidden'
} }
} }
data[i].order = orderStyle; data[i].order = orderStyle;
...@@ -454,14 +454,14 @@ Page({ ...@@ -454,14 +454,14 @@ Page({
this.setData({ this.setData({
userCredits: data userCredits: data
}) })
console.log(data,'更新') console.log(data, '更新')
}, },
// 关闭立即购买 // 关闭立即购买
orderNowModalClose() { orderNowModalClose() {
this.setData({ this.setData({
orderNowModalVisible: false, orderNowModalVisible: false,
maskVisible:false maskVisible: false
}) })
}, },
...@@ -500,15 +500,17 @@ Page({ ...@@ -500,15 +500,17 @@ Page({
// console.log(SHARE_CONFIG) // console.log(SHARE_CONFIG)
return SHARE_CONFIG; return SHARE_CONFIG;
}, },
async addMusic(musicSwitch){ async addMusic(musicSwitch) {
const resultSrc = await app.cloud.file.getTempFileURL({ console.log('musicSwitch', musicSwitch,musicUrl)
fileId: 'cloud://C7A066C702682E94326284DF8A2975CC//FILA_building_loop.mp3' if (!musicUrl) {
}); const resultSrc = await app.cloud.file.getTempFileURL({
let musicUrl = null; fileId: 'cloud://C7A066C702682E94326284DF8A2975CC//FILA_building_loop.mp3'
if (resultSrc[0]) musicUrl = resultSrc[0].url; });
if (resultSrc[0]) musicUrl = resultSrc[0].url;
}
// let {musicSwitch} = this.data; // let {musicSwitch} = this.data;
// playBgMusic(true,musicUrl) // playBgMusic(true,musicUrl)
playBgMusic(musicSwitch,musicUrl); playBgMusic(musicSwitch, musicUrl);
console.log('fuck music') // console.log('fuck music')
} }
}); });
\ No newline at end of file
...@@ -27,11 +27,11 @@ const createAudio = opts => { ...@@ -27,11 +27,11 @@ const createAudio = opts => {
}; };
let bgs = { let bgs = {
} }
const playBgMusic = (isOn, src) => {//待测试 export const playBgMusic = (isOn, src) => {//待测试
for (let k in bgs) { for (let k in bgs) {
if (bgs[k].isOn) { if (bgs[k].isOn) {
bgs[k].stop(); bgs[k].pause();
} }
// bgs[k].isOn = false; /// TODO 自己记一个开关,因为淘宝的玩意stop之后虽然听不到,但还是在播放,会触发loop播放和onEnded事件 // bgs[k].isOn = false; /// TODO 自己记一个开关,因为淘宝的玩意stop之后虽然听不到,但还是在播放,会触发loop播放和onEnded事件
} }
...@@ -53,14 +53,15 @@ const playBgMusic = (isOn, src) => {//待测试 ...@@ -53,14 +53,15 @@ const playBgMusic = (isOn, src) => {//待测试
bgs[key].onStop(() => { bgs[key].onStop(() => {
bgs[key].isOn = false; bgs[key].isOn = false;
}); });
bgs[key].onPause(() => {
bgs[key].isOn = false;
});
/// TODO监听结束,因为loop无效 2020.08.12 loop有效,这个操作是为了解决stop之后还会跑音频数据的问题 /// TODO监听结束,因为loop无效 2020.08.12 loop有效,这个操作是为了解决stop之后还会跑音频数据的问题
bgs[key].onEnded(() => { bgs[key].onEnded(() => {
if (bgs[key].isOn) { // 判断自己记录的开关 if (bgs[key].isOn) { // 判断自己记录的开关
bgs[key].play(); bgs[key].play();
console.log('bgs[key].onEnded')
// bgs[key].isOn = true; // bgs[key].isOn = true;
} }
}); });
...@@ -77,9 +78,10 @@ const playBgMusic = (isOn, src) => {//待测试 ...@@ -77,9 +78,10 @@ const playBgMusic = (isOn, src) => {//待测试
} else { } else {
if (bgs[key]) { if (bgs[key]) {
// bgs[key].pause(); /// pause 垃圾,不能用 // bgs[key].pause(); /// pause 垃圾,不能用
bgs[key].stop(); bgs[key].pause();
// bgs[key].isOn = false; /// TODO 自己记一个开关,因为淘宝的玩意stop之后虽然听不到,但还是在播放,会触发loop播放和onEnded事件 // bgs[key].isOn = false; /// TODO 自己记一个开关,因为淘宝的玩意stop之后虽然听不到,但还是在播放,会触发loop播放和onEnded事件
} }
} }
} }
export default playBgMusic export default playBgMusic
\ No newline at end of file
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