92 lines
2.7 KiB
JavaScript
92 lines
2.7 KiB
JavaScript
|
|
let urlPrefix = getUrlPrefix();
|
|
var browser = checkVersion();
|
|
if (EnvCheck() === '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 () {
|
|
getInfoFromClient()
|
|
setTimeout(() => {
|
|
getVipNameplateList();
|
|
}, 50)
|
|
})
|
|
// 获取名牌列表
|
|
function getVipNameplateList () {
|
|
networkRequest({
|
|
type: 'GET',
|
|
url: urlPrefix + '/vip/getVipNameplateList',
|
|
success (res) {
|
|
if (res.code == 200) {
|
|
res.data.forEach((res, index) => {
|
|
$(`.list .li${index + 1} img`).attr('src', res.icon);
|
|
$(`.list .li${index + 1} .but${index + 1}`).attr('isCouldApply', res.isCouldApply);
|
|
$(`.list .li${index + 1} .but${index + 1}`).attr('nameplateId', res.nameplateId);
|
|
if (res.isCouldApply) {
|
|
$(`.list .li${index + 1} .but${index + 1}`).addClass('but_active');
|
|
} else {
|
|
$(`.list .li${index + 1} .but${index + 1}`).removeClass('but_active');
|
|
}
|
|
});
|
|
}
|
|
},
|
|
error (err) {
|
|
toastMsg('網絡錯誤,請退出重進')
|
|
}
|
|
})
|
|
}
|
|
// 申请按钮
|
|
$('.list li .but').click(function () {
|
|
var loca = $(this).attr('iscouldapply');
|
|
var val = $(this).siblings('.input_box').find('input').val();
|
|
var data = {
|
|
nameplateId: $(this).attr('nameplateId'),
|
|
text: val
|
|
}
|
|
console.log(data);
|
|
if (val == '') {
|
|
toastMsg('请输入铭牌文案');
|
|
} else {
|
|
if (loca == 'true') {
|
|
showLoading();
|
|
networkRequest({
|
|
type: 'POST',
|
|
url: urlPrefix + '/vip/vipMpApply',
|
|
data: data,
|
|
success (res) {
|
|
if (res.code == 200) {
|
|
hideLoading(layerIndex);
|
|
$('.list li .input_box input').val('');
|
|
getVipNameplateList();
|
|
} else {
|
|
toastMsg(res.message)
|
|
}
|
|
},
|
|
error (err) {
|
|
toastMsg('網絡錯誤,請退出重進')
|
|
}
|
|
})
|
|
} else {
|
|
console.log('暂不可申请');
|
|
}
|
|
}
|
|
}) |