2024-03-18 11:13:22 +08:00
|
|
|
|
let urlPrefix = getUrlPrefix()
|
|
|
|
|
let browser = checkVersion()
|
|
|
|
|
var urlDate = getQueryString()
|
|
|
|
|
let env = EnvCheck();
|
|
|
|
|
if (env == 'test') {
|
|
|
|
|
new VConsole();
|
|
|
|
|
}
|
|
|
|
|
// 封裝layer消息提醒框
|
|
|
|
|
let layerIndex
|
|
|
|
|
const showLoading = (content = '加載中...') => {
|
|
|
|
|
layer.open({
|
|
|
|
|
type: 2,
|
|
|
|
|
shadeClose: false,
|
|
|
|
|
content,
|
|
|
|
|
success (e) {
|
|
|
|
|
layerIndex = $(e).attr('index')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const hideLoading = (index) => {
|
|
|
|
|
layer.close(index)
|
|
|
|
|
}
|
|
|
|
|
const toastMsg = (content = '操作完成', time = 2) => {
|
|
|
|
|
layer.open({
|
|
|
|
|
content,
|
|
|
|
|
time,
|
|
|
|
|
skin: 'msg'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
var inviteCode = "";
|
|
|
|
|
// 初始化函數
|
|
|
|
|
$(function () {
|
|
|
|
|
inviteCode = urlDate.inviteCode;
|
2024-03-18 16:05:30 +08:00
|
|
|
|
$('.box .codeBg .num').text(inviteCode);
|
2024-03-18 11:13:22 +08:00
|
|
|
|
getInfoFromClient()
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
var mySwiper = new Swiper('.swiper', {
|
|
|
|
|
// direction: "vertical",
|
|
|
|
|
loop: true,
|
|
|
|
|
autoplay: {
|
|
|
|
|
delay: 3500,
|
|
|
|
|
disableOnInteraction: false
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
/*
|
|
|
|
|
* MobLink 支持数组=>MobLink([...]) 和对象=>MobLink({...}) 两种初始化形式
|
|
|
|
|
* 页面上有多个元素需要跳转时使用数组方式,仅单个元素需要跳转时可以使用对象的方式进行初始化
|
|
|
|
|
* el: 表示网页上Element的id值,该字段为空或者不写,则表示MobLink **默认浮层** 上的打开按钮(注意:该字段支持selector方式: 1.'.class' 2.'#id1' 3.['#id1','#id2'])
|
|
|
|
|
* path: 对应App里需要恢复页面的路径
|
|
|
|
|
* default: 指定分享页默认场景参数(最多只能指定一项作为默认场景参数)
|
|
|
|
|
* params: 网页需要带给客户端的参数
|
|
|
|
|
*/
|
|
|
|
|
// 页面上有多个元素需要跳转时要使用数组方式进行初始化
|
|
|
|
|
if (browser.android) {
|
|
|
|
|
MobLink([{
|
|
|
|
|
el: '#downloads',
|
|
|
|
|
path: '',
|
|
|
|
|
params: { mobLinkType: 1, inviteCode, }
|
|
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
$.copy({
|
|
|
|
|
text: "复制成功", //分享提示文案
|
|
|
|
|
copyUrl: inviteCode, //自定义复制
|
|
|
|
|
tipTime: 1000, //分享提示消失时间
|
|
|
|
|
copyId: "#copy" //复制按钮id
|
|
|
|
|
});
|
|
|
|
|
}, 100)
|
|
|
|
|
})
|
|
|
|
|
// 獲取接口
|
|
|
|
|
function get () {
|
|
|
|
|
showLoading()
|
|
|
|
|
networkRequest({
|
|
|
|
|
type: 'get',
|
|
|
|
|
url: urlPrefix + '',
|
|
|
|
|
success (res) {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
toastMsg(res.message)
|
|
|
|
|
}
|
|
|
|
|
hideLoading(layerIndex)
|
|
|
|
|
},
|
|
|
|
|
error (err) {
|
|
|
|
|
hideLoading(layerIndex)
|
|
|
|
|
toastMsg('網路錯誤,請退出重進')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
$('.box .xz').click(function () {
|
|
|
|
|
if (browser.ios) {
|
2024-03-20 11:16:26 +08:00
|
|
|
|
// window.location.href = `pikoApp://register?inviteCode=${inviteCode}&type=8`
|
|
|
|
|
isAppInstalled(`pikoApp://register?inviteCode=${inviteCode}&type=8`);
|
2024-03-18 11:13:22 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
2024-03-20 11:16:26 +08:00
|
|
|
|
function isAppInstalled(scheme) {
|
|
|
|
|
try {
|
|
|
|
|
// 尝试打开应用
|
|
|
|
|
window.location.href = scheme;
|
|
|
|
|
// 如果应用打开,则在500毫秒后捕获超时错误
|
2024-03-20 14:09:26 +08:00
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// window.location.href = 'https://apps.apple.com/app/id6446155565';
|
|
|
|
|
// }, 500);
|
2024-03-20 11:16:26 +08:00
|
|
|
|
|
|
|
|
|
// 应用可能打开,也可能没有打开,所以这里不返回结果
|
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
// 如果发生错误,说明应用没有安装
|
|
|
|
|
console.log('App not installed');
|
|
|
|
|
// 重定向到fallback URL
|
|
|
|
|
window.location.href = 'https://apps.apple.com/app/id6446155565';
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-18 11:13:22 +08:00
|
|
|
|
$('.box .codeBg .copy').click(function () {
|
|
|
|
|
$.copy({
|
|
|
|
|
text: "复制成功", //分享提示文案
|
|
|
|
|
copyUrl: inviteCode, //自定义复制
|
|
|
|
|
tipTime: 1000, //分享提示消失时间
|
|
|
|
|
copyId: "#copy" //复制按钮id
|
|
|
|
|
});
|
|
|
|
|
})
|