personalCenter.js
8.6 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
var screenType = ''
$(document).ready(function() {
//获取屏幕宽度
var screenWidth = $(window).width()
console.log(screenWidth);
//设置支付类型 1:网页支付 2:H5支付
if (screenWidth < 768) {
screenType = 2
} else {
screenType = 1
}
console.log(screenType);
//获取个人信息(传一个token)
var url = "/login/userInfo"; // 接口
var header = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
// 调用公共ajax
ajax(url, "GET", header, function(res) {
console.log(res);
}, function(res) {
console.log(res);
// if (res.data.wname == null) {
// let title = `<div onClick='binding'>绑定</div>`
// $("#WXunbind").html(title)
// } else {
// let title = `<div onClick='binding'>解绑</div>`
// $("#WXunbind").html(title)
// }
if (res.data.wname == null) {
$("#WXunbind").html("绑定")
} else {
$("#WXunbind").html("解绑")
}
if (res.data.phoneNumber == null) {
$("#Punbind").html("绑定")
} else {
$("#Punbind").html("解绑")
}
//缺一个img
//input用val,a用html
let a = res.data.surname + res.data.userName
console.log(a);
$("#fullName").html(a)
$('#phone').val(res.data.phone)
$('#surname').val(res.data.surname)
$('#userName').val(res.data.userName)
$('#specialty').val(res.data.specialty)
$('#school').val(res.data.school)
$('#emailAddress').val(res.data.emailAddress)
$('#WXname').html(res.data.wname)
$('#Pnumber').html(res.data.phoneNumber)
let title = ` <img src="${res.data.img}" style='width:100%'>`
$("#head-img").html(title)
})
//修改个人信息
$(".btnSave button").click(function() {
//姓
var inputSurname = $("#surname").val();
console.log(inputSurname);
//名
var inputUserName = $("#userName").val();
console.log(inputUserName);
//专业(null)
var inputSpecialty = $("#specialty").val();
console.log(inputSpecialty);
//学校
var inputSchool = $("#school").val();
console.log(inputSchool);
//手机号
var inputPhone = $("#phone").val();
console.log(inputPhone);
//邮箱
var inputEmailAddress = $("#emailAddress").val();
console.log(inputEmailAddress);
var url1 = "/login/updateSysUser";
var header1 = {
"Content-Type": "application/json",
}
var params = JSON.stringify({
emailAddress: inputEmailAddress,
id: localStorage.getItem("userId"),
img: null,
phone: inputPhone,
specialty: inputSpecialty,
school: inputSchool,
surname: inputSurname,
userName: inputUserName
})
// 调用公共ajax
ajax(url1, "PUT", header1, params, function(res) {
console.log(res);
alert('保存成功!')
location.reload();
}, function(res) {
console.log(res);
})
})
//删除微信(传token)
$("#WXunbind").click(function() {
var url2 = "/login/deleteWeXin"; // 接口
// 调用公共ajax
ajax(url2, "DELETE", header, function(res) {
console.log(res);
}, function(res) {
console.log(res);
alert("解绑成功!")
location.reload();
})
})
//删除手机号(传token)
$("#Punbind").click(function() {
var url3 = "/login/deletePhone"; // 接口
// 调用公共ajax
ajax(url3, "DELETE", header, function(res) {
console.log(res);
}, function(res) {
console.log(res);
alert("解绑成功!")
location.reload();
})
})
//
var header1 = {
"Content-Type": "application/x-www-form-urlencoded",
}
ajax("/login/memberList", "GET", header1, function(res) {
console.log(res);
}, function(res) {
console.log(res);
var color = ['#66CA94', '#ff8000', '#6F1C0B'];
var quarter = ['单月', '半年', '年度']
var chooseTime = [1, 6, 12]
for (var i in res.data) {
console.log(res.data[i].memberType);
let title = `
<div onclick="clickVIPone(${res.data[i].id},'${res.data[i].memberType}',${chooseTime[i]},${res.data[i].memberMoney})" class="personal-vip-basic" id='personal_vip_${res.data[i].id}'>
<div class="personal-vip-info" style='background-color:${color[i]}'>
<p>${res.data[i].memberType}</p>
<a>${res.data[i].memberName}</a>
</div>
<div style="background: #fff;">
<div style="text-align: center;padding: 5%;">
<a style="color: ${color[i]};">
<span style="font-size: 2em;">${res.data[i].memberMoney}</span> /${quarter[i]}
</a>
</div>
<div class="personal-ol">${res.data[i].introduce}</div>
</div>
</div>`
$("#meau_nav").append(title)
}
$('.personal-vip-basic').click(function() {
// var index = $(this).index();
$(this).addClass('active-click').siblings().removeClass('active-click');
})
})
});
// $('#meau_nav>div').click(function() {
// // var index = $(this).index();
// $(this).addClass('active-click').siblings().removeClass('active-click');
// })
var actualFee = ''
var memberMonth = ''
var memberName = ''
var paymentType = ''
function clickVIPone(id, type, time, money) {
console.log(id);
console.log(type);
console.log(time);
console.log(money);
actualFee = money
memberMonth = time
memberName = type
}
// function clickVIPtwo() {
// actualFee = 399
// memberMonth = 6
// memberName = '标准会员'
// }
// function clickVIPthree() {
// actualFee = 699
// memberMonth = 12
// memberName = '超级会员'
// }
//获得支付方式选值
function checkRadio() {
paymentType = $("input[name='zhifu']:checked").val()
}
//立即支付
function payment() {
console.log(paymentType);
console.log(actualFee);
console.log(memberMonth);
console.log(memberName);
console.log(screenType);
var header = {
"Content-Type": "application/json",
"token": localStorage.getItem('token'),
}
var header1 = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
var params = JSON.stringify({
actualFee: actualFee,
memberMonth: memberMonth,
memberName: memberName,
paymentType: paymentType
})
// 支付下单获取订单号
ajax("/orderLog/orderAdd", "POST", header, params, function(res) {
console.log(res);
console.log(res);
console.log(res.data);
$(".hide_box").fadeToggle();
$(".shang_box").fadeToggle();
var params1 = {
id: res.data,
type: screenType
}
//微信支付
ajax("/pay/createNative", "GET", header1, params1, function(res) {
console.log(res);
let title = `<img src="${res.data.codeUrl}" alt="扫码支付" title="扫一扫" >`
$(".shang_payimg").html(title)
}, function(res) {})
}, function(res) {})
}
//获取用户VIP信息判断是否是VIP
function ifVIP() {
var url5 = "/login/userInfo"; // 接口
var header = {
"Content-Type": "application/json",
"token": localStorage.getItem('token'),
}
// 调用公共ajax
ajax(url5, "GET", header, function(res) {
console.log(res);
}, function(res) {
console.log(res);
if (res.data.status1 == 1) {
window.location.href = 'personalCenter.html'
} else {
window.location.href = 'aboutUs.html'
}
})
}