2022-09-08 18:22:18 +08:00
|
|
|
|
|
|
|
let urlPrefix = getUrlPrefix();
|
|
|
|
var browser = checkVersion();
|
|
|
|
// 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 btnStatus = []
|
|
|
|
// 获取用户铭牌状态
|
|
|
|
const getUserNameplateInfo = () => {
|
|
|
|
showLoading()
|
|
|
|
networkRequest({
|
|
|
|
type: 'GET',
|
|
|
|
url: urlPrefix + '/user/couple/userCpLevelMp',
|
|
|
|
data: {
|
|
|
|
uid: pubInfo.uid
|
|
|
|
},
|
|
|
|
success(res){
|
|
|
|
hideLoading(layerIndex);
|
|
|
|
if(res.code === 200){
|
|
|
|
btnStatus = res.data.mpDtoList
|
|
|
|
renderBtnStatus()
|
|
|
|
}else{
|
|
|
|
toastMsg(res.message)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error(){
|
|
|
|
hideLoading(layerIndex);
|
2022-10-11 15:38:44 +08:00
|
|
|
toastMsg('網絡錯誤')
|
2022-09-08 18:22:18 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 渲染按钮状态
|
|
|
|
const renderBtnStatus = () => {
|
|
|
|
let str = ''
|
|
|
|
btnStatus.map((item, index) => {
|
|
|
|
str += `
|
|
|
|
<div class="nameplate_item">
|
|
|
|
<p class="nameplate_pic"><img src="${item.iconPic}" alt=""></p>
|
|
|
|
<p class="btn ${item.isHave ? '' : 'active'}" data-mpid=${item.mpId}></p>
|
|
|
|
</div>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
$('.nameplate_cp_wrap').html(str)
|
|
|
|
|
|
|
|
// 点击立刻申请
|
|
|
|
let index, mpId
|
|
|
|
$('.nameplate_cp_wrap').on('click', '.nameplate_item', function(){
|
|
|
|
index = $(this).index()
|
|
|
|
})
|
|
|
|
|
|
|
|
$('.btn').click(function() {
|
|
|
|
if($(this).hasClass('active')){
|
|
|
|
mpId = $(this).data('mpid')
|
|
|
|
$('.popup').show()
|
|
|
|
$('body').css('overflow', 'hidden')
|
|
|
|
$('input').focus()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
$('.confirm_btn').click(() => {
|
|
|
|
if($('input').val().length != 4) {
|
|
|
|
return toastMsg('请添加4个字的铭牌文字')
|
|
|
|
}
|
|
|
|
sendApply(mpId, $('input').val(), index)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 发送申请
|
|
|
|
const sendApply = (mpId, mpTxt, index) => {
|
|
|
|
showLoading()
|
|
|
|
networkRequest({
|
|
|
|
type: 'POST',
|
|
|
|
url: urlPrefix + '/user/couple/cpMpApply',
|
|
|
|
data: {
|
|
|
|
mpId,
|
|
|
|
mpTxt
|
|
|
|
},
|
|
|
|
success(res){
|
|
|
|
hideLoading(layerIndex);
|
|
|
|
if(res.code === 200){
|
|
|
|
toastMsg('申请成功')
|
|
|
|
$('.content input').val('')
|
|
|
|
$('.popup').hide()
|
|
|
|
$('body').css('overflow', 'auto')
|
|
|
|
$('.nameplate_cp_wrap .nameplate_item').eq(index).find('.btn').removeClass('active')
|
|
|
|
}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( () => {
|
|
|
|
getUserNameplateInfo()
|
|
|
|
}, 50)
|
|
|
|
|
|
|
|
$('.popup').click(() => {
|
|
|
|
$('.content input').val('')
|
|
|
|
$('.popup').hide()
|
|
|
|
$('body').css('overflow', 'auto')
|
|
|
|
})
|
|
|
|
$('.content').click(function(e){
|
|
|
|
e.stopPropagation()
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 点击申请记录按钮
|
|
|
|
$('.record').on('click', function(){
|
|
|
|
window.location.href = './record.html'
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|