-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcommon.js
More file actions
73 lines (69 loc) · 1.96 KB
/
common.js
File metadata and controls
73 lines (69 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
async function checkIsVip() {
const userInfoResp = await sendRequest({
url: `api/user/getUserInfo`,
type: `get`
})
if (userInfoResp && userInfoResp.data && userInfoResp.data.isMember) {
$('.user-info-api-img').html('<img src="./images/vip.png" alt="" />')
}
}
function onOpenVipTips() {
layer.confirm(
'仅需1680元VIP即可开启刑冲,奇门遁甲,神煞,紫薇,六爻,大六壬等权限',
{
btn: ['立即开启', '取消']
},
async function (index, layero) {
//按钮【按钮一】的回调
const orderPayResp = await sendRequest({
url: `api/order/pay`,
type: `get`
})
if (orderPayResp) {
layer.confirm(
'是否完成支付?',
{
btn: ['已经支付', '未完成']
},
async function (index, layero) {
window.location.reload()
},
function (index) {
layer.close(index)
}
)
let form = orderPayResp
const div = document.createElement('formdiv')
div.innerHTML = form
document.body.appendChild(div)
for (let index = 0; index < document.forms.length; index++) {
const element = document.forms[index]
if (element.name == 'punchout_form') {
element.setAttribute('target', '_blank')
element.submit()
div.remove()
}
}
}
},
function (index) {
layer.close(index)
}
)
}
// 退出登录
function logout() {
layer.confirm('确定要退出登录吗?', function (index) {
sendRequest({
method: 'GET',
url: '/api/user/userLogout'
}).then(res => {
if (res.code == 200) {
window.localStorage.removeItem('token')
window.localStorage.removeItem('username')
window.location.href = 'login.html'
}
layer.close(index)
})
})
}