Commit 50ce6883 authored by wildfirecode13's avatar wildfirecode13

1

parent 39db8b73
{ {
"pages": [ "pages": [
"pages/pageshou_ye/pageshou_ye", "pages/index/index",
"pages/pagehuo_dong_ye/pagehuo_dong_ye", "pages/index2/index2"
"pages/pagejie_shu_ye/pagejie_shu_ye",
"pages/myprize/myprize",
"pages/pagewo_de_jiang_pin_ye_mian1/pagewo_de_jiang_pin_ye_mian1"
], ],
"window": { "window": {
"allowsBounceVertical":"NO" "allowsBounceVertical":"NO"
......
...@@ -8,3 +8,23 @@ ...@@ -8,3 +8,23 @@
opacity: 1; opacity: 1;
position: absolute; position: absolute;
} }
.index-page .music {
z-index: 90;
width: 56rpx;
height: 56rpx;
opacity: 1;
left: 524rpx;
top: 262rpx;
position: absolute;
}
.index-page .jiang_pinicon {
z-index: 90;
width: 136rpx;
height: 48rpx;
opacity: 1;
left: 613rpx;
top: 340rpx;
position: absolute;
}
\ No newline at end of file
<view class="index-page"> <view class="index-page">
<image class="bg" src={{resList['66f2b76f-7265-4cb2-9b4d-7e8207ab1d74'].url}} /> <image class="bg" src={{resList['66f2b76f-7265-4cb2-9b4d-7e8207ab1d74'].url}} />
<image class="music" a:if="{{musicSwitch}}" onTap="onmusicSwitch" src={{resList['0c115480-d22e-4902-a745-e55eadf7bf91'].url}} />
<image class="music" a:if="{{!musicSwitch}}" onTap="onmusicSwitch" src={{resList['ddd2f68b-0059-4eb1-8667-4b7471b11ddd'].url}} />
<image onTap="onPrizeBtnClick" class="jiang_pinicon" src={{resList['b7517eae-3bc2-4456-935a-e6e3e1fe995e'].url}} />
</view> </view>
\ No newline at end of file
const app = getApp(); const app = getApp();
const { tbcc } = app; const { tbcc } = app;
const { SHARE_CONFIG, REDIRECT_URL } = tbcc.constants;
import resList from '../../resconfig/resList'; import resList from '../../resconfig/resList';
import API from '../../api'; import playBgMusic from '/utils/playBgMusic';
const { commonToast, getAuthUserInfo, navigateToOutside } = tbcc.tb;
let musicUrl = '';
// let musicUrl = '/resource/bg.mp3';
// let musicUrl = 'http://download.taobaocdn.com/freedom/90053/media/Animal.mp3';
// let musicUrl = 'https://yun.duiba.com.cn/aurora/assets/2e357ad0d82662627ddcdbf99e117ce36e786248.mp3';
Page({ Page({
data: { data: {
title: '', musicSwitch: true
content: '',
rule: '',
commonModalData: {
content: '',
btnText: ''
},
commonModalConfirm: null,
commonModalVisible: false,
ruleModalVisible: false
}, },
onLoad(query) { onLoad(query) {
this.setData({ this.setData({
resList: resList resList: resList
}); });
// 页面加载 console.log('onLoad')
this.getAuth();
console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
},
async init() {
const [activity, vipInfo] = await Promise.all([
API.getActivityBaseInfoById(),
API.getVipInfo(),
]);
// vipInfo.isVip=true;
if (vipInfo.isVip && activity.data.isUserJoin) {
my.redirectTo({ url: '/pages/pagehuo_dong_ye/pagehuo_dong_ye' });
} else {
my.redirectTo({ url: '/pages/pageshou_ye/pageshou_ye' });
}
},
async onReady() {
// 页面加载完成
//取图片链接
const result1 = await getApp().cloud.file.getTempFileURL({ fileId: 'cloud://2291129AC27E68610B8DFDA7F139E34A//D2B4599F-878D-402A-8101-5465AE571FB9.png' });
if (result1[0]) SHARE_CONFIG.imageUrl = result1[0].url
},
onShow() {
// 页面显示
}, },
onHide() { onHide() {
// 页面隐藏 console.log('onHide');
}, },
onUnload() { onShow() {
// 页面被关闭 console.log('onShow');
},
onTitleClick() {
// 标题被点击
},
onPullDownRefresh() {
// 页面被下拉
},
onReachBottom() {
// 页面被拉到底部
},
/**
* 获取用户授权信息
*/
async getAuth() {
const userInfo = await getAuthUserInfo().catch(err => {
console.log('未授权成功', err);
});
if (userInfo) {
console.log('授权成功,userInfo=>', userInfo);
const { nickName, avatar } = userInfo;
app.nickName = nickName;
app.avatar = avatar;
this.login();
}
}, },
/**
* 获取主接口
*/
async getIndex() {
const { success, data } = await API.getIndex().catch(res => {
commonToast(res && res.message);
}) || {};
if (success && data) { async onReady() {
const { title, content, rule } = data; console.log('onReady');
this.setData({ title, content, rule }); this.onmusicSwitch();
}
}, },
/**
* 登录接口
*/
async login() {
const { nickName, avatar } = app;
const { success } = await API.login({ userNick: nickName, avatar }).catch(res => {
console.log('登录失败..')
commonToast(res && res.message);
}) || {};
if (success) { onmusicSwitch() {
console.log('登录成功,正在初始化') let { musicSwitch } = this.data;
this.init(); this.addMusic(musicSwitch);
}
},
/**
* 显示规则弹层
*/
showRuleModal() {
this.setData({
ruleModalVisible: true
});
},
/**
* 通用弹出确认按钮回调
*/
confirmCommonModal() {
const { commonModalConfirm } = this.data;
commonModalConfirm && commonModalConfirm();
},
/**
* 执行开始
*/
doStart() {
this.showCommonModal({
content: '活动还未开始\n请稍后',
btnText: '我知道了',
commonModalVisible: true,
confirmCallback: () => {
this.closeCommonModal();
}
});
},
/**
* 显示通用弹层
* @param {object} options content: 通用弹层内容 btnText:按钮文案 confirmCallback: 按钮确认回调
*/
showCommonModal({ content, btnText, confirmCallback }) {
this.setData({ this.setData({
commonModalConfirm: confirmCallback || null, musicSwitch: !musicSwitch
commonModalVisible: true, })
commonModalData: { content, btnText } console.log('music点击后', musicSwitch);
});
},
/**
* 跳转到天猫页面
*/
goTmallPage() {
navigateToOutside(REDIRECT_URL['tmall']);
},
/**
* 关闭通用弹层
*/
closeCommonModal() {
this.setData({
commonModalVisible: false
});
}, },
/**
* 关闭活动规则弹层 async addMusic(musicSwitch) {
*/ console.log('musicSwitch', musicSwitch, musicUrl)
closeRuleModal() { if (!musicUrl) {
this.setData({ const resultSrc = await app.cloud.file.getTempFileURL({
ruleModalVisible: false fileId: 'cloud://C7A066C702682E94326284DF8A2975CC//FILA_building_loop.mp3'
}); });
if (resultSrc[0]) musicUrl = resultSrc[0].url;
}
playBgMusic(musicSwitch, musicUrl);
}, },
onShareAppMessage() {
// 返回自定义分享信息
// export const SHARE_CONFIG = { onPrizeBtnClick() {
// title: '分享测试标题', my.navigateTo({
// desc: '分享测试描述', url: '/pages/index2/index2'
// imageUrl: '', // 分享图片URL });
// path: 'pages/index/index'
// };
// my.alert({content:JSON.stringify(SHARE_CONFIG)})
// console.log(SHARE_CONFIG)
return SHARE_CONFIG;
}, },
}); });
/* required by usingComponents */
\ No newline at end of file
<view class="index-page">
<image class="bg" src={{resList['66f2b76f-7265-4cb2-9b4d-7e8207ab1d74'].url}} />
</view>
\ No newline at end of file
const app = getApp();
const { tbcc } = app;
import resList from '../../resconfig/resList';
import playBgMusic from '/utils/playBgMusic';
Page({
data: {
},
onLoad(query) {
this.setData({
resList: resList
});
console.log('onLoad')
},
async onReady() {
console.log('onReady');
},
});
{
"usingComponents": {
}
}
\ No newline at end of file
File added
...@@ -46,7 +46,12 @@ export const playBgMusic = (isOn, src) => {//待测试 ...@@ -46,7 +46,12 @@ export const playBgMusic = (isOn, src) => {//待测试
}); });
bgs[key].onError((res) => {
console.log('onError',res)
});
bgs[key].onPlay(() => { bgs[key].onPlay(() => {
console.log('播放开始')
bgs[key].isOn = true; bgs[key].isOn = true;
}); });
...@@ -60,6 +65,7 @@ export const playBgMusic = (isOn, src) => {//待测试 ...@@ -60,6 +65,7 @@ export const playBgMusic = (isOn, src) => {//待测试
/// TODO监听结束,因为loop无效 2020.08.12 loop有效,这个操作是为了解决stop之后还会跑音频数据的问题 /// TODO监听结束,因为loop无效 2020.08.12 loop有效,这个操作是为了解决stop之后还会跑音频数据的问题
bgs[key].onEnded(() => { bgs[key].onEnded(() => {
console.log('播放结束')
if (bgs[key].isOn) { // 判断自己记录的开关 if (bgs[key].isOn) { // 判断自己记录的开关
bgs[key].play(); bgs[key].play();
// bgs[key].isOn = true; // bgs[key].isOn = true;
......
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