question.js
9.8 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
$(document).ready(function() {
var url = window.location.search;
// console.log(url);
if (url.indexOf('?') != -1) {
newId = url.substr(4)
// console.log(newId);
//获取左边实习内容list
var url = "/recommend/recommendTwoList"; // 接口
var header = {
"Content-Type": "application/x-www-form-urlencoded",
"token": localStorage.getItem('token'),
}
var params = {
id: newId
}
// 调用公共ajax
ajax(url, "POST", header, params, function(res) {
console.log(res);
for (let i in res.data) {
// console.log(res.data);
let title = `<div>
<div id="title-head">${res.data[i].headline}</div>
</div>
<div id="content-l">
</div>`
$("#title-content").append(title)
}
for (let i in res.data) {
$.each(res.data[i].recommendThrees, function(index, val) {
// console.log(val.subhead);
let title1 = `<p id="content-list" style='display:flex'><input type="radio" class="input-radio" name='input-radio'>${val.subhead}</input></p>`
$("#content-l").append(title1)
})
}
}, function(res) {
console.log(res);
})
// $.ajax({
// type: 'GET',
// url: 'http://192.168.1.241:9004/recommend/recommendTwoList',
// headers: {
// "Content-Type": "application/x-www-form-urlencoded",
// "token": localStorage.getItem('token'),
// },
// data: {
// id: newId
// },
// success: function(res) {
// // console.log(res);
// for (let i in res.data) {
// // console.log(res.data);
// let title = `<div>
// <div id="title-head">${res.data[i].headline}</div>
// </div>
// <div id="content-l">
// </div>`
// $("#title-content").append(title)
// }
// for (let i in res.data) {
// $.each(res.data[i].recommendThrees, function(index, val) {
// // console.log(val.subhead);
// let title1 = `<p id="content-list" style='display:flex'><input type="radio" class="input-radio" name='input-radio'>${val.subhead}</input></p>`
// $("#content-l").append(title1)
// })
// }
// }
// })
//获得问题
var url1 = "/recommend/recommendFiveList"; // 接口
// 调用公共ajax
ajax(url1, "GET", header, params, function(res) {
console.log(res);
for (let i in res.data) {
let title = `
<div class='all-list'>
<!-- 左边 -->
<div class='list-left'>
<div class='yuan-num'>
<!-- 圆 -->
<div class='left-yuan'></div>
<!-- 数字 -->
<div class='left-num'>${res.data[i].id<10 ? '0'+res.data[i].id : res.data[i].id}</div>
</div>
<!-- 线 -->
<div class='left-xian' style="height:100px;"> </div>
</div>
<!-- 题目 -->
<div class="list-right" id="dati-list">
<div class="questList" data-index="${i}" data-id='${res.data[i].id}'><div id="timu" >${res.data[i].topic}</div>
<div style="display: flex;place-items: center; color: #5a5a5a;" id="ans1">
<input type="radio" class="input-radio" value="${res.data[i].issue1}" name="beishu" />${res.data[i].issue1}</div>
<div style="display: flex;place-items: center; color: #5a5a5a;" id="ans2">
<input type="radio" class="input-radio" value="${res.data[i].issue2}" name="beishu" />${res.data[i].issue2}</div>
<div style="display: flex;place-items: center; color: #5a5a5a;" id="ans3">
<input type="radio" class="input-radio" value="${res.data[i].issue3}" name="beishu" />${res.data[i].issue3}</div>
<div style="display: flex;place-items: center; color: #5a5a5a;" id="ans4">
<input type="radio" class="input-radio" value="${res.data[i].issue4}" name="beishu" />${res.data[i].issue4}</div>
</div>
</div>
</div>`
$('#recommend-List').append(title);
}
}, function(res) {
console.log(res);
})
// $.ajax({
// type: 'GET',
// url: 'http://192.168.1.241:9004/recommend/recommendFiveList',
// headers: {
// "Content-Type": "application/x-www-form-urlencoded",
// "token": localStorage.getItem('token'),
// },
// data: {
// id: newId
// },
// success: function(res) {
// console.log(res);
// for (let i in res.data) {
// let title = `
// <div class='all-list'>
// <!-- 左边 -->
// <div class='list-left'>
// <div class='yuan-num'>
// <!-- 圆 -->
// <div class='left-yuan'></div>
// <!-- 数字 -->
// <div class='left-num'>${res.data[i].id<10 ? '0'+res.data[i].id : res.data[i].id}</div>
// </div>
// <!-- 线 -->
// <div class='left-xian' style="height:100px;"> </div>
// </div>
// <!-- 题目 -->
// <div class="list-right" id="dati-list">
// <div class="questList" data-index="${i}" data-id='${res.data[i].id}'><div id="timu" >${res.data[i].topic}</div>
// <div style="display: flex;place-items: center; color: #5a5a5a;" id="ans1">
// <input type="radio" class="input-radio" value="${res.data[i].issue1}" name="beishu" />${res.data[i].issue1}</div>
// <div style="display: flex;place-items: center; color: #5a5a5a;" id="ans2">
// <input type="radio" class="input-radio" value="${res.data[i].issue2}" name="beishu" />${res.data[i].issue2}</div>
// <div style="display: flex;place-items: center; color: #5a5a5a;" id="ans3">
// <input type="radio" class="input-radio" value="${res.data[i].issue3}" name="beishu" />${res.data[i].issue3}</div>
// <div style="display: flex;place-items: center; color: #5a5a5a;" id="ans4">
// <input type="radio" class="input-radio" value="${res.data[i].issue4}" name="beishu" />${res.data[i].issue4}</div>
// </div>
// </div>
// </div>`
// $('#recommend-List').append(title);
// }
// }
// })
}
})
$('#recommend-List').on('click', '.input-radio', function(e) {
console.log($(this).parents('.questList')[0].dataset.index)
console.log($(this).parents('.questList')[0].dataset.id)
console.log($(this).parents('.questList'));
console.log($(this).val())
})
//获取用户VIP信息判断是否是VIP
function setPersonal() {
var url = "/login/userInfo"; // 接口
var header = {
"Content-Type": "application/json",
"token": localStorage.getItem('token'),
}
// 调用公共ajax
ajax(url, "GET", header, function(res) {
console.log(res);
if (res.data.status1 == 1) {
window.location.href = 'personalCenter.html'
} else {
window.location.href = 'personalCenter2.html'
}
}, function(res) {
console.log(res);
})
// $.ajax({
// type: 'GET',
// url: 'http://192.168.1.241:9004/login/userInfo',
// headers: {
// "Content-Type": "application/json",
// "token": localStorage.getItem('token'),
// },
// success: function(res) {
// console.log(res);
// if (res.data.status1 == 1) {
// window.location.href = 'personalCenter.html'
// } else {
// window.location.href = 'personalCenter2.html'
// }
// }
// })
}
function setInputInformation() {
window.location.href = 'inputInformation.html?id=' + newId
}
function setAnswers() {
window.location.href = 'answers.html?id=' + newId
}