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 { 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 { toastMsg(res.message) } hideLoading(layerIndex) }, error (err) { hideLoading(layerIndex) toastMsg('網絡錯誤,請退出重進') } }) } // 返回按钮 $('.back').click(function () { window.history.go(-1) })