You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
3.2 KiB
148 lines
3.2 KiB
// pages/constitutionGrade/constitutionGrade.js
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
res_test_id:0,//测试id
|
|
child:[],//排名
|
|
user_id:0,
|
|
avatar:'',
|
|
nickname:''
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getUserId();
|
|
this.setData({
|
|
res_test_id:options.res_test_id,
|
|
})
|
|
this.getinfo();
|
|
|
|
},
|
|
onShow:function(){
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
addHandle(){
|
|
wx.request({
|
|
url: 'https://mini.nanjingchuangyou.com/api/mini/viewUser',
|
|
method:'POST',
|
|
header: {
|
|
'content-type': 'application/x-www-form-urlencoded',
|
|
},
|
|
data:{
|
|
test_id:this.data.res_test_id,
|
|
user_id:this.data.user_id,
|
|
from:'wx',
|
|
avatar:this.data.avatar,
|
|
nickname:this.data.nickname
|
|
},
|
|
success:(res)=>{
|
|
console.log(res,"0-00")
|
|
// this.setData({
|
|
// list:res.data.data.list,
|
|
// total:res.data.data.total
|
|
// })
|
|
}
|
|
})
|
|
},
|
|
//详情
|
|
getinfo:function(){
|
|
console.log(this.data.user_id)
|
|
var that=this;
|
|
this.setData({ loading: true });
|
|
app.request('/api/mini/getTestById', {
|
|
test_id:this.data.res_test_id,
|
|
user_id:this.data.user_id,
|
|
}, function (data, ret) {
|
|
if(ret.code == 1){
|
|
var detail = ret.data.detail;
|
|
that.setData({
|
|
loading: false,
|
|
child:detail.orichild,
|
|
});
|
|
that.addHandle()
|
|
}
|
|
typeof cb == 'function' && cb(data);
|
|
}, function (data, ret) {
|
|
|
|
that.setData({
|
|
loading: false
|
|
});
|
|
app.error(ret.msg);
|
|
},2);
|
|
},
|
|
|
|
getUserId(){
|
|
var getuser = wx.getStorageSync("userInfo");
|
|
if(getuser){
|
|
this.data.user_id = getuser.id;
|
|
this.setData({
|
|
nickname:getuser.nickname,
|
|
avatar:getuser.avatar
|
|
})
|
|
}else if(app.globalData.userInfo){
|
|
this.data.user_id = app.globalData.userInfo.id;
|
|
this.setData({
|
|
nickname:app.globalData.userInfo.nickname,
|
|
avatar:app.globalData.userInfo.avatar
|
|
})
|
|
}else{
|
|
wx.navigateTo({
|
|
url: '/page/login/login',
|
|
});
|
|
}
|
|
},
|
|
//查看
|
|
seeResult:function(){
|
|
wx.navigateTo({
|
|
url: '/page/identificationTwo/identificationTwo?res_test_id='+this.data.res_test_id,
|
|
});
|
|
},
|
|
//转发
|
|
onShareAppMessage: function() {
|
|
return {
|
|
title: '',
|
|
path: '/page/constitutionGrade/constitutionGrade?res_test_id='+this.data.res_test_id,
|
|
success: function(res) {
|
|
wx.showToast({
|
|
title: '分享成功',
|
|
icon: 'none',
|
|
duration: 1500//持续的时间
|
|
})
|
|
}
|
|
}
|
|
},
|
|
}) |