Files
peko-h5/view/peko/modules/h5Income/js/index.js
2023-07-12 17:00:50 +08:00

94 lines
2.4 KiB
JavaScript

let urlPrefix = getUrlPrefix()
let browser = checkVersion()
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'
})
}
$(function () {
setTimeout(function () {
getInfoFromClient()
if (browser.app) {
$('.back').hide();
}
setTimeout(function () {
getQueryWithRoomType();
getUser();
}, 100)
})
})
// 鉆石金幣接口
function getQueryWithRoomType () {
showLoading()
networkRequest({
type: 'GET',
url: urlPrefix + '/purse/queryWithRoomType',
success (res) {
if (res.code === 200) {
$('.diamond p').text(res.data.diamonds);
$('.gold p').text(res.data.golds);
} else if (res.code ? res.code == 401 : JSON.parse(res).code == 401) {
window.location.href = './login.html'
} else {
toastMsg(res.message)
}
hideLoading(layerIndex)
},
error (err) {
hideLoading(layerIndex)
toastMsg('網絡錯誤,請退出重進')
}
})
}
// 基本信息接口
function getUser () {
showLoading()
networkRequest({
type: 'GET',
url: urlPrefix + '/user/get',
data: { uid: pubInfo.uid },
success (res) {
if (res.code === 200) {
$('.myInfo img').attr('src', res.data.avatar);
$('.myInfo div p').text(res.data.nick);
$('.myInfo div b').text("ID:" + res.data.erbanNo);
} else if (res.code ? res.code == 401 : JSON.parse(res).code == 401) {
window.location.href = './login.html'
} else {
toastMsg(res.message)
}
hideLoading(layerIndex)
},
error (err) {
hideLoading(layerIndex)
toastMsg('網絡錯誤,請退出重進')
}
})
}
// 返回按鈕
$('.back').click(function () {
window.history.go(-1)
})