练习共享

This commit is contained in:
caoqianming 2020-11-17 20:37:14 +08:00
parent fd88a86074
commit 5affde5711
10 changed files with 158 additions and 129 deletions

View File

@ -1,12 +1,16 @@
// pages/miss/miss.js
const api = require("../../utils/request.js");
Page({
/**
* 页面的初始数据
*/
data: {
page: 1,
serverUrl: getApp().globalData.serverUrl,
query:{
a:'listall',
page:1,
rows:10
},
wslist:[]
},
@ -51,9 +55,9 @@ Page({
*/
onPullDownRefresh: function () {
var that = this;
that.getWslist(1);
this.data.query.page = 1;
that.getWslist();
wx.stopPullDownRefresh();
this.data.page = 1;
},
/**
@ -61,9 +65,16 @@ Page({
*/
onReachBottom: function () {
//上拉分页,将页码加1然后调用分页函数
this.data.page = this.data.page + 1;
this.getWslist();
wx.stopPullDownRefresh();
var that = this
if (that.data.total <= that.data.query.page * that.data.query.rows) {
wx.showToast({
title: '没有更多了',
icon: 'none'
})
} else {
that.data.query.page = that.data.query.page + 1
that.getWslist()
}
},
/**
@ -72,49 +83,18 @@ Page({
onShareAppMessage: function () {
},
getWslist: function (page) {
var that = this;
if (page != 1) { page = that.data.page }
wx.showLoading({
title: '加载中',
}),
wx.request({
url: this.data.serverUrl + 'api/miss?a=listall&rows=10&page=' + page,
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
success: res => {
if (res.statusCode === 200) {
if (res.data.rows.length == 0) {
if (page == 1) {
this.setData({
total: 0,
wslist: []
})
}
else {
wx.showModal({
content: "已经到底啦!",
showCancel: false,
confirmText: "确定",
})
}
getWslist: function () {
var that = this
api.request('api/miss', 'GET', that.data.query).then(res => {
if (that.data.query.page == 1) {
that.data.wslist = res.rows
} else {
let list
if (page == 1) {
list = res.data.rows
} else {
list = this.data.wslist.concat(res.data.rows)
that.data.wslist = that.data.wslist.concat(res.rows)
}
this.setData({
total: res.data.total,
wslist: list
that.setData({
wslist: that.data.wslist,
total: res.total
})
})
}
}
wx.hideLoading();
}
});
},
})

View File

@ -13,6 +13,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.data.missid = options.missid
this.getWsdetail(options.missid);
},
@ -41,7 +42,15 @@ Page({
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
// var pages = getCurrentPages()
// var prePage = pages[pages.length-2]
// if(prePage.data.wslist){
// for(var i=0;i<prePage.data.wslist;i++){
// if(prePage.data.wslist[i].missid == this.data.missid){
// }
// }
// }
},
/**

View File

@ -25,7 +25,7 @@ Page({
//上次选中的列表,用于判断是不是取消选中了
this.lastTimeSelect = []
wx.request({
url: getApp().globalData.serverUrl + 'api/questioncat?a=tree',
url: getApp().globalData.serverUrl + 'api/questioncat?a=tree3',
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,

View File

@ -6,7 +6,7 @@
<view>姓名</view>
</view>
<view class="weui-cell__ft">
{{realname}}
{{user__userprofile__realname}}
</view>
</view>
<view class="weui-cell weui-cell_access">
@ -14,7 +14,7 @@
<view>性别</view>
</view>
<view class="weui-cell__ft">
{{gender}}
{{user__userprofile__gender}}
</view>
</view>
<view class="weui-cell weui-cell_access">

View File

@ -26,7 +26,7 @@ Page({
*/
onShow: function () {
var that = this;
that.getsafecertlist()
that.getsafecertlist2()
},
/**
@ -167,4 +167,21 @@ Page({
});
},
getsafecertlist2: function(){
wx.showLoading({ title: '加载中', })
wx.request({
url: getApp().globalData.serverUrl + 'api/safecert?a=listself',
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
success: res => {
this.setData({
total: res.data.total,
safecertlist: res.data.rows
})
wx.hideLoading();
}
});
}
})

View File

@ -26,7 +26,7 @@ Page({
*/
onShow: function () {
var that = this;
that.getSocertlist()
that.getSocertlist2()
},
/**
@ -166,4 +166,22 @@ Page({
});
},
getSocertlist2: function() {
wx.showLoading({ title: '加载中', })
wx.request({
url: getApp().globalData.serverUrl + 'api/socert?a=listself',
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
success: res => {
this.setData({
total: res.data.total,
socertlist: res.data.rows
})
wx.hideLoading();
}
});
}
})

View File

@ -6,7 +6,7 @@
<view>姓名</view>
</view>
<view class="weui-cell__ft">
{{realname}}
{{user__userprofile__realname}}
</view>
</view>
<view class="weui-cell weui-cell_access">
@ -14,7 +14,7 @@
<view>性别</view>
</view>
<view class="weui-cell__ft">
{{gender}}
{{user__userprofile__gender}}
</view>
</view>
<view class="weui-cell weui-cell_access">

View File

@ -10,7 +10,8 @@ Page({
genderarray: ['男','女'],
genderIndex:0,
userprofile__realname:'',
userprofile__cardnum:''
userprofile__cardnum:'',
userprofile__gender:'男'
},
bindrealnameInput: function (e) {
this.data.userprofile__realname = e.detail.value
@ -161,18 +162,22 @@ Page({
if (res.statusCode === 200) {
if (res.data.code == 1) {
wx.hideLoading()
wx.navigateBack()
wx.request({
url: getApp().globalData.serverUrl + 'api/socert?a=addspiderself',
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
method: 'GET',
data: {},
success: res => {
}
});
wx.showToast({
title: '保存成功',
icon:'none'
})
// wx.navigateBack()
// wx.request({
// url: getApp().globalData.serverUrl + 'api/socert?a=addspiderself',
// header: {
// 'content-type': 'application/json', // 默认值
// 'Cookie': getApp().globalData.sessionId,
// },
// method: 'GET',
// data: {},
// success: res => {
// }
// });
}
}
}

View File

@ -17,17 +17,17 @@
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": false,
"useApiHook": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"compileHotReLoad": false,
"useMultiFrameRuntime": false,
"useApiHook": false,
"useIsolateContext": true,
"packNpmManually": false,
"packNpmRelationList": []
},

View File

@ -2,7 +2,7 @@ function request(url, method, data) {
let promise = new Promise((resolve, reject) => {
wx.showNavigationBarLoading();
wx.request({
url: getApp().globalData.host + url,
url: getApp().globalData.serverUrl + url,
method: method,
data: data,
header: {