练习共享

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 // pages/miss/miss.js
const api = require("../../utils/request.js");
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
page: 1, query:{
serverUrl: getApp().globalData.serverUrl, a:'listall',
page:1,
rows:10
},
wslist:[] wslist:[]
}, },
@ -51,9 +55,9 @@ Page({
*/ */
onPullDownRefresh: function () { onPullDownRefresh: function () {
var that = this; var that = this;
that.getWslist(1); this.data.query.page = 1;
that.getWslist();
wx.stopPullDownRefresh(); wx.stopPullDownRefresh();
this.data.page = 1;
}, },
/** /**
@ -61,9 +65,16 @@ Page({
*/ */
onReachBottom: function () { onReachBottom: function () {
//上拉分页,将页码加1然后调用分页函数 //上拉分页,将页码加1然后调用分页函数
this.data.page = this.data.page + 1; var that = this
this.getWslist(); if (that.data.total <= that.data.query.page * that.data.query.rows) {
wx.stopPullDownRefresh(); wx.showToast({
title: '没有更多了',
icon: 'none'
})
} else {
that.data.query.page = that.data.query.page + 1
that.getWslist()
}
}, },
/** /**
@ -72,49 +83,18 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
}, },
getWslist: function (page) { getWslist: function () {
var that = this; var that = this
if (page != 1) { page = that.data.page } api.request('api/miss', 'GET', that.data.query).then(res => {
wx.showLoading({ if (that.data.query.page == 1) {
title: '加载中', that.data.wslist = res.rows
}),
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: "确定",
})
}
} else { } else {
let list that.data.wslist = that.data.wslist.concat(res.rows)
if (page == 1) {
list = res.data.rows
} else {
list = this.data.wslist.concat(res.data.rows)
} }
this.setData({ that.setData({
total: res.data.total, wslist: that.data.wslist,
wslist: list total: res.total
})
}) })
}
}
wx.hideLoading();
}
});
}, },
}) })

View File

@ -13,6 +13,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.data.missid = options.missid
this.getWsdetail(options.missid); this.getWsdetail(options.missid);
}, },
@ -41,7 +42,15 @@ Page({
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload: function () { 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 = [] this.lastTimeSelect = []
wx.request({ wx.request({
url: getApp().globalData.serverUrl + 'api/questioncat?a=tree', url: getApp().globalData.serverUrl + 'api/questioncat?a=tree3',
header: { header: {
'content-type': 'application/json', // 默认值 'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId, 'Cookie': getApp().globalData.sessionId,

View File

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

View File

@ -26,7 +26,7 @@ Page({
*/ */
onShow: function () { onShow: function () {
var that = this; 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 () { onShow: function () {
var that = this; 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>
</view> </view>
<view class="weui-cell__ft"> <view class="weui-cell__ft">
{{realname}} {{user__userprofile__realname}}
</view> </view>
</view> </view>
<view class="weui-cell weui-cell_access"> <view class="weui-cell weui-cell_access">
@ -14,7 +14,7 @@
<view>性别</view> <view>性别</view>
</view> </view>
<view class="weui-cell__ft"> <view class="weui-cell__ft">
{{gender}} {{user__userprofile__gender}}
</view> </view>
</view> </view>
<view class="weui-cell weui-cell_access"> <view class="weui-cell weui-cell_access">

View File

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

View File

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

View File

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