2022-09-08 18:22:18 +08:00
|
|
|
|
let urlPrefix = getUrlPrefix()
|
|
|
|
|
let browser = checkVersion()
|
|
|
|
|
let queryObj = getQueryString()
|
|
|
|
|
|
|
|
|
|
if (EnvCheck() === 'test') new VConsole
|
|
|
|
|
|
|
|
|
|
// 封装layer消息提醒框
|
|
|
|
|
let layerIndex
|
2022-10-11 15:38:44 +08:00
|
|
|
|
const showLoading = (content = '加載中...') => {
|
2022-09-08 18:22:18 +08:00
|
|
|
|
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'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取门票包信息
|
|
|
|
|
let ticketObj = {}
|
|
|
|
|
let ticketStatus
|
|
|
|
|
let options, callLib;
|
|
|
|
|
const getTicketDetail = () => {
|
|
|
|
|
showLoading()
|
|
|
|
|
networkRequest({
|
|
|
|
|
type: 'GET',
|
|
|
|
|
url: urlPrefix + '/gameManage/channel/ticket/getDetail',
|
|
|
|
|
data: {
|
|
|
|
|
packageId : queryObj.pid
|
|
|
|
|
// packageId: 2
|
|
|
|
|
},
|
|
|
|
|
success(res) {
|
|
|
|
|
hideLoading(layerIndex)
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
ticketStatus = res.data.status
|
|
|
|
|
ticketObj = res.data
|
|
|
|
|
|
|
|
|
|
if(browser.android){
|
|
|
|
|
options = {
|
|
|
|
|
scheme: {
|
2023-08-03 14:11:46 +08:00
|
|
|
|
protocol: 'pikoapp',
|
2022-09-08 18:22:18 +08:00
|
|
|
|
host: 'linkedme'
|
|
|
|
|
},
|
|
|
|
|
intent: {
|
2023-08-03 14:11:46 +08:00
|
|
|
|
package: 'com.mango.piko',
|
|
|
|
|
scheme: 'pikoapp',
|
2022-09-08 18:22:18 +08:00
|
|
|
|
},
|
|
|
|
|
universal: {
|
|
|
|
|
host: 'api.zhongjialx.com',
|
|
|
|
|
pathKey: ''
|
|
|
|
|
},
|
|
|
|
|
// appstore: 'http://doudouyue.com/8axv',
|
|
|
|
|
appstore: 'https://apps.apple.com/cn/app/id1513122909',
|
|
|
|
|
fallback: res.data.packageUrl,
|
|
|
|
|
timeout: 3000,
|
|
|
|
|
}
|
|
|
|
|
callLib = new CallApp(options)
|
|
|
|
|
}
|
|
|
|
|
showView()
|
|
|
|
|
} else {
|
|
|
|
|
toastMsg(res.message)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
error(err) {
|
|
|
|
|
hideLoading(layerIndex)
|
2022-10-11 15:38:44 +08:00
|
|
|
|
toastMsg('網絡錯誤')
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 根据status渲染不同视图
|
|
|
|
|
const showView = () => {
|
|
|
|
|
// ticketStatus = 1
|
|
|
|
|
if (ticketStatus === 2) {
|
|
|
|
|
$('.fail-wrap .tip2').html(`已超过领取时间,下次要抓紧哦~`)
|
|
|
|
|
$('.fail-wrap').show()
|
|
|
|
|
} else if (ticketStatus === 3) {
|
|
|
|
|
window.location.href = './invalid.html'
|
|
|
|
|
} else if (ticketStatus === 1) {
|
|
|
|
|
if (!ticketObj.stock) {
|
|
|
|
|
$('.fail-wrap .tip2').html(`很抱歉,已领完,下次手速要快哦!`)
|
|
|
|
|
$('.fail-wrap').show()
|
|
|
|
|
} else {
|
|
|
|
|
$('.index-wrap').show()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
renderView()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const renderView = () => {
|
|
|
|
|
$('.desc').html(ticketObj.showText)
|
|
|
|
|
|
|
|
|
|
$('.ticket-info img, .fail-wrap img').attr('src', ticketObj.ticketPic)
|
|
|
|
|
$('.ticket-name').html(ticketObj.ticketName)
|
|
|
|
|
$('.ticket-left-num span, .current-left span').html(ticketObj.stock)
|
|
|
|
|
$('.limitNum').html(ticketObj.limitNum)
|
|
|
|
|
let month = dateFormat(ticketObj.endTime, 'MM')
|
|
|
|
|
let day = dateFormat(ticketObj.endTime, 'dd')
|
|
|
|
|
let hour = dateFormat(ticketObj.endTime, 'hh:mm')
|
|
|
|
|
$('.month').html(month)
|
|
|
|
|
$('.day').html(day)
|
|
|
|
|
$('.hour').html(hour)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取手机验证码
|
|
|
|
|
const getCode = (mobile) => {
|
|
|
|
|
showLoading()
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
2023-08-03 14:11:46 +08:00
|
|
|
|
url: urlPrefix + '/sms/getCode?app=piko',
|
2022-09-08 18:22:18 +08:00
|
|
|
|
data: {
|
|
|
|
|
mobile,
|
|
|
|
|
type: 1
|
|
|
|
|
},
|
|
|
|
|
success(res) {
|
|
|
|
|
hideLoading(layerIndex)
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
toastMsg(res.message)
|
|
|
|
|
timer()
|
|
|
|
|
} else {
|
|
|
|
|
toastMsg(res.message)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
error() {
|
|
|
|
|
hideLoading(layerIndex)
|
2022-10-11 15:38:44 +08:00
|
|
|
|
toastMsg('網絡錯誤')
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证码倒计时
|
|
|
|
|
let time
|
|
|
|
|
let num = 60
|
|
|
|
|
let canGetCode = true
|
|
|
|
|
const timer = () => {
|
|
|
|
|
canGetCode = false
|
|
|
|
|
$('.verify-btn').html(`重新获取(${num}s)`)
|
|
|
|
|
clearInterval(time)
|
|
|
|
|
time = setInterval(() => {
|
|
|
|
|
if (num--) {
|
|
|
|
|
$('.verify-btn').html(`重新获取(${num}s)`)
|
|
|
|
|
} else {
|
|
|
|
|
$('.verify-btn').html(`获取验证码`)
|
|
|
|
|
clearInterval(time)
|
|
|
|
|
canGetCode = true
|
|
|
|
|
}
|
|
|
|
|
}, 1000)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 用户领取门票
|
|
|
|
|
let drawParams = {}
|
|
|
|
|
const drawTicket = (params) => {
|
|
|
|
|
showLoading();
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: 'POST',
|
|
|
|
|
url: urlPrefix + `/gameManage/channel/ticket/receiveTicket`,
|
|
|
|
|
data: {
|
|
|
|
|
packageId : queryObj.pid,
|
|
|
|
|
// packageId: 2,
|
|
|
|
|
phone: params.phone,
|
|
|
|
|
smsCode: params.smsCode,
|
|
|
|
|
},
|
|
|
|
|
success(res) {
|
|
|
|
|
hideLoading(layerIndex)
|
|
|
|
|
// res.code = 230003
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
$('.desc').html(ticketObj.showText)
|
|
|
|
|
$('.success-wrap img').attr('src', ticketObj.ticketPic)
|
|
|
|
|
$('.success-wrap .ticket-name').html(ticketObj.ticketName + '*' + ticketObj.limitNum)
|
|
|
|
|
$('.index-wrap').hide()
|
|
|
|
|
$('.success-wrap').show()
|
|
|
|
|
} else if (res.code === 230003) {
|
2023-08-03 14:11:46 +08:00
|
|
|
|
$('.shade-content .title').html('该手机号未注册pikoApp<br>无法领取门票')
|
|
|
|
|
$('.shade-content .content-tip').html('请先前往pikoApp完成注册再来领取哦~')
|
2022-09-08 18:22:18 +08:00
|
|
|
|
$('.shade-content .content-btn').html('去APP内注册>>')
|
|
|
|
|
$('.shade-mask').show()
|
|
|
|
|
} else if (res.code === 230004) {
|
|
|
|
|
$('.shade-content .title').html('领取失败<br>该手机号已经领取过该门票')
|
|
|
|
|
$('.shade-content .content-tip').html('请优先使用已领取的门票哦~')
|
|
|
|
|
$('.shade-content .content-btn').html('去参赛>>')
|
|
|
|
|
$('.shade-mask').show()
|
|
|
|
|
} else if (res.code === 230006) {
|
|
|
|
|
window.location.href = './invalid.html'
|
|
|
|
|
} else if (res.code === 230007) {
|
|
|
|
|
$('.index-wrap').hide()
|
|
|
|
|
$('.fail-wrap .tip2').html(`已超过领取时间,下次要抓紧哦~`)
|
|
|
|
|
$('.fail-wrap').show()
|
|
|
|
|
} else if (res.code === 230008) {
|
|
|
|
|
$('.index-wrap').hide()
|
|
|
|
|
$('.fail-wrap .tip2').html(`很抱歉,已领完,下次手速要快哦!`)
|
|
|
|
|
$('.fail-wrap .current-left span').html(0)
|
|
|
|
|
$('.fail-wrap').show()
|
|
|
|
|
} else if (res.code === 230009) {
|
|
|
|
|
$('.shade-content .title').html('领取失败<br>该用户已经领取过门票')
|
|
|
|
|
$('.shade-content .content-tip').html('请优先使用已领取的门票哦~')
|
|
|
|
|
$('.shade-content .content-btn').html('去参赛>>')
|
|
|
|
|
$('.shade-mask').show()
|
|
|
|
|
} else {
|
|
|
|
|
toastMsg(res.message)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
error() {
|
|
|
|
|
hideLoading(layerIndex)
|
2022-10-11 15:38:44 +08:00
|
|
|
|
toastMsg('網絡錯誤')
|
2022-09-08 18:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(function () {
|
|
|
|
|
getInfoFromClient()
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
getTicketDetail()
|
|
|
|
|
}, 50)
|
|
|
|
|
|
|
|
|
|
let phoneReg = /^1[3-9][0-9]{9}$/;
|
|
|
|
|
$('.verify-btn').on('click', () => {
|
|
|
|
|
if (!phoneReg.test($('.mobile-number').val())) {
|
|
|
|
|
return toastMsg('请输入正确的手机号码~')
|
|
|
|
|
}
|
|
|
|
|
if (canGetCode) {
|
|
|
|
|
getCode($('.mobile-number').val())
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
$('.draw-btn').on('click', () => {
|
|
|
|
|
drawParams.phone = $('.mobile-number').val();
|
|
|
|
|
drawParams.smsCode = $('.verify-ipt').val();
|
|
|
|
|
|
|
|
|
|
if (!phoneReg.test($('.mobile-number').val())) {
|
|
|
|
|
return toastMsg('请输入正确的手机号码~')
|
|
|
|
|
}
|
|
|
|
|
if (!$('.verify-ipt').val()) {
|
|
|
|
|
return toastMsg('请输入验证码~')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
drawTicket(drawParams)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 关闭弹窗
|
|
|
|
|
$('.shade-mask').on('click', function () {
|
|
|
|
|
$(this).hide()
|
|
|
|
|
})
|
|
|
|
|
$('.shade-content').on('click', function (e) {
|
|
|
|
|
e.stopPropagation()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 安卓系统键盘会撑起底部固定定位元素
|
|
|
|
|
$('.mobile-number, .verify-ipt').focus(() => {
|
|
|
|
|
$('.bottom').hide()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
$('.mobile-number, .verify-ipt').blur(() => {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if ($(document.activeElement).attr("id") === 'body') {
|
|
|
|
|
$('.bottom').fadeIn(400)
|
|
|
|
|
}
|
|
|
|
|
}, 50)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let ua = navigator.userAgent.toLowerCase();
|
|
|
|
|
// 按钮点击
|
|
|
|
|
if(browser.android){
|
|
|
|
|
if (browser.weixin || ua.match(/\sQQ/i) == " qq") {
|
|
|
|
|
return $('.tips-tit').fadeIn(30);
|
|
|
|
|
}
|
|
|
|
|
$('.download, .content-btn, .success-btn').on('click', function () {
|
|
|
|
|
callLib.open({
|
|
|
|
|
path: "", //必填,可传空字符串
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ios使用深度链接
|
|
|
|
|
if(browser.ios){
|
|
|
|
|
let linkedKey = 'af4f58541a86d5f6c4193349f675419a'
|
|
|
|
|
let linkedObj = {
|
|
|
|
|
type: EnvCheck(),
|
|
|
|
|
}
|
|
|
|
|
if(queryObj.enterprise){
|
|
|
|
|
linkedKey = 'af4f58541a86d5f6c4193349f675419a'
|
|
|
|
|
}
|
|
|
|
|
linkedme.init(linkedKey, { type: EnvCheck() }, null)
|
|
|
|
|
linkedme.link(linkedObj, function(err, response){
|
|
|
|
|
if(err){
|
|
|
|
|
// 生成深度链接失败,返回错误对象err
|
|
|
|
|
console.log('err:', err);
|
|
|
|
|
}else{
|
|
|
|
|
$('.download, .content-btn, .success-btn').on('click', function(){
|
|
|
|
|
linkedme.trigger_deeplink(response.url);
|
|
|
|
|
})
|
|
|
|
|
$('.download, .content-btn, .success-btn').attr('href', response.url)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}, false)
|
|
|
|
|
}
|
|
|
|
|
})
|