|
|
|
@ -1 +1,801 @@
|
|
|
|
|
dyw
|
|
|
|
|
index.js
|
|
|
|
|
// 云函数入口文件
|
|
|
|
|
const cloud = require('wx-server-sdk')
|
|
|
|
|
|
|
|
|
|
cloud.init()
|
|
|
|
|
|
|
|
|
|
// 云函数入口函数
|
|
|
|
|
exports.main = async (event, context) => {
|
|
|
|
|
const wxContext = cloud.getWXContext()
|
|
|
|
|
|
|
|
|
|
//写有关于数据库操作的地方
|
|
|
|
|
//获取数据库的连接对象
|
|
|
|
|
const db = cloud.database();
|
|
|
|
|
|
|
|
|
|
//在一个云函数里面有4种数据库操作。所以要先判断是什么操作:增删改查
|
|
|
|
|
|
|
|
|
|
//增
|
|
|
|
|
if(event.option=='add'){
|
|
|
|
|
return await db.collection('users').add({
|
|
|
|
|
//花括号里面是你要添加的对象
|
|
|
|
|
data:event.addData
|
|
|
|
|
//可添加多条或一条
|
|
|
|
|
//event:包含传过来的所有数据的一个对象
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//删
|
|
|
|
|
else if(event.option=="deleteuser"){
|
|
|
|
|
return await db.collection('users').where({
|
|
|
|
|
//将要删除的值赋给name
|
|
|
|
|
User_ID:event.delUser_ID
|
|
|
|
|
}).remove();
|
|
|
|
|
}
|
|
|
|
|
else if(event.option=="deleteusers"){
|
|
|
|
|
return await db.collection('users').where({
|
|
|
|
|
//将要删除的值赋给name
|
|
|
|
|
User_College:event.delUser_College,
|
|
|
|
|
User_Grade:event.delUser_Grade,
|
|
|
|
|
User_Class:event.delUser_Class
|
|
|
|
|
}).remove();
|
|
|
|
|
}
|
|
|
|
|
//查
|
|
|
|
|
else if(event.option=="getcomments1"){
|
|
|
|
|
return await db.collection('users').where({
|
|
|
|
|
User_ID:event.getUser_ID
|
|
|
|
|
}).get({
|
|
|
|
|
success:function(res){
|
|
|
|
|
return res
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if(event.option=="getCollege"){
|
|
|
|
|
return await db.collection('users').where({
|
|
|
|
|
User_College:event.getUser_College,
|
|
|
|
|
User_Grade:event.getUser_Grade,
|
|
|
|
|
User_Class:event.getUser_Class
|
|
|
|
|
}).get({
|
|
|
|
|
success:function(res){
|
|
|
|
|
return res
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else if(event.option=="getcomments2"){
|
|
|
|
|
return await db.collection('users').where({
|
|
|
|
|
}).get({
|
|
|
|
|
success:function(res){
|
|
|
|
|
return res
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if(event.option=="update"){
|
|
|
|
|
return await db.collection('users').where({
|
|
|
|
|
User_ID:event.updateUser_ID
|
|
|
|
|
}).update({
|
|
|
|
|
data:{
|
|
|
|
|
User_College:event.updateUser_College
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pages js
|
|
|
|
|
// pages/index/index.js
|
|
|
|
|
//连接数据库
|
|
|
|
|
const db = wx.cloud.database()
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
User_ID:'',
|
|
|
|
|
User_comments:'',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//监听并修改用户名和年龄的输入
|
|
|
|
|
inputID:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
User_ID:e.detail.value
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
inputcomments:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
User_comments:e.detail.value
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//使用云函数
|
|
|
|
|
//插入数据(增)
|
|
|
|
|
add:function(e){
|
|
|
|
|
//要添加的数据是一个对象
|
|
|
|
|
// var user={
|
|
|
|
|
// username:this.data.username,
|
|
|
|
|
// age:this.data.age
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
console.log(e);
|
|
|
|
|
wx.cloud.callFunction({
|
|
|
|
|
name: 'useroption',
|
|
|
|
|
data: {
|
|
|
|
|
option: 'add',
|
|
|
|
|
addData:{
|
|
|
|
|
User_ID:this.data.User_ID,
|
|
|
|
|
User_comments:this.data.User_comments
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
success: res => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户添加成功',
|
|
|
|
|
})
|
|
|
|
|
console.log("添加成功")
|
|
|
|
|
console.log(res)
|
|
|
|
|
},
|
|
|
|
|
fail:err => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户添加失败',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getback:function(){
|
|
|
|
|
wx.navigateBack({
|
|
|
|
|
delta:1,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// pages/addusers/index.js
|
|
|
|
|
const db = wx.cloud.database()
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
User_ID:'',
|
|
|
|
|
User_comments:'',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//监听并修改用户名和年龄的输入
|
|
|
|
|
inputID:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
User_ID:e.detail.value
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
inputcomments:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
User_comments:e.detail.value
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
//使用云函数
|
|
|
|
|
//插入数据(增)
|
|
|
|
|
add:function(e){
|
|
|
|
|
//要添加的数据是一个对象
|
|
|
|
|
// var user={
|
|
|
|
|
// username:this.data.username,
|
|
|
|
|
// age:this.data.age
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
console.log(e);
|
|
|
|
|
wx.cloud.callFunction({
|
|
|
|
|
name: 'useroption',
|
|
|
|
|
data: {
|
|
|
|
|
option: 'add',
|
|
|
|
|
addData:{
|
|
|
|
|
User_ID:this.data.User_ID,
|
|
|
|
|
User_comments:this.data.User_comments,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
success: res => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户添加成功',
|
|
|
|
|
})
|
|
|
|
|
console.log("添加成功")
|
|
|
|
|
console.log(res)
|
|
|
|
|
},
|
|
|
|
|
fail:err => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户添加失败',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getback:function(){
|
|
|
|
|
wx.navigateBack({
|
|
|
|
|
delta:1,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// pages/adduserssuccess/index.js
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad(options) {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
*/
|
|
|
|
|
onReady() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
*/
|
|
|
|
|
onShow() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
*/
|
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
*/
|
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
*/
|
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
*/
|
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户点击右上角分享
|
|
|
|
|
*/
|
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// pages/delete/index.js
|
|
|
|
|
const db = wx.cloud.database()
|
|
|
|
|
Page({
|
|
|
|
|
removeuser:function(){
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/deleteuser/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
removeusers:function(){
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/deleteusers/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
// pages/deleteuser/index.js
|
|
|
|
|
Page({
|
|
|
|
|
inputdelID:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
delUser_ID:e.detail.value
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
removeDataFn:function(){
|
|
|
|
|
wx.cloud.callFunction({
|
|
|
|
|
name: 'useroption',
|
|
|
|
|
data: {
|
|
|
|
|
option: 'deleteuser',
|
|
|
|
|
//要删除的数据
|
|
|
|
|
delUser_ID:this.data.delUser_ID
|
|
|
|
|
},
|
|
|
|
|
success: res => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户删除成功',
|
|
|
|
|
})
|
|
|
|
|
console.log(res)
|
|
|
|
|
},
|
|
|
|
|
fail: err => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户删除失败',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getback:function(){
|
|
|
|
|
wx.navigateBack({
|
|
|
|
|
delta:2,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// pages/deleteusers/index.js
|
|
|
|
|
Page({
|
|
|
|
|
inputdelCollege:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
delUser_College:e.detail.value,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
inputdelGrade:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
delUser_Grade:e.detail.value,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
inputdelClass:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
delUser_Class:e.detail.value,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
removeDataFn:function(){
|
|
|
|
|
wx.cloud.callFunction({
|
|
|
|
|
name: 'useroption',
|
|
|
|
|
data: {
|
|
|
|
|
option: 'deleteusers',
|
|
|
|
|
//要删除的数据
|
|
|
|
|
delUser_College:this.data.delUser_College,
|
|
|
|
|
delUser_Grade:this.data.delUser_Grade,
|
|
|
|
|
delUser_Class:this.data.delUser_Class
|
|
|
|
|
},
|
|
|
|
|
success: res => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户删除成功',
|
|
|
|
|
})
|
|
|
|
|
console.log(res)
|
|
|
|
|
},
|
|
|
|
|
fail: err => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户删除失败',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getback:function(){
|
|
|
|
|
wx.navigateBack({
|
|
|
|
|
delta:2,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// pages/deleteuserssuccess/index.js
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad(options) {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
*/
|
|
|
|
|
onReady() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
*/
|
|
|
|
|
onShow() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
*/
|
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
*/
|
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
*/
|
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
*/
|
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户点击右上角分享
|
|
|
|
|
*/
|
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// pages/index/index.js
|
|
|
|
|
//连接数据库
|
|
|
|
|
const db = wx.cloud.database()
|
|
|
|
|
Page({
|
|
|
|
|
data:{
|
|
|
|
|
imgUrl: "cloud://cloud1-0g194k9vcb31e843.636c-cloud1-0g194k9vcb31e843-1314274913/psc.jpg"
|
|
|
|
|
},
|
|
|
|
|
add:function(e){
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/adduser/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//删除数据(删)
|
|
|
|
|
removeDataFn:function(){
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/delete/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询数据(查)
|
|
|
|
|
searchDataNameFn:function(){
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/selectusers/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//修改数据(改)
|
|
|
|
|
updateDataFn(){
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/updateusers/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
// pages/selectusers/index.js
|
|
|
|
|
const db = wx.cloud.database()
|
|
|
|
|
Page({
|
|
|
|
|
//查询数据(查)
|
|
|
|
|
searchID:function(){
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/selectusers(ID)/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
searchCollege:function(){
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/selectusers(college)/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
search:function(){
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/selectuserss/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
// pages/selectusers(college)/index.js
|
|
|
|
|
Page({
|
|
|
|
|
inputgetcomments:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
getUser_comments:e.detail.value
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
searchDataNameFn:function(){
|
|
|
|
|
wx.cloud.callFunction({
|
|
|
|
|
name: 'useroption',
|
|
|
|
|
data: {
|
|
|
|
|
option: 'getcomments1',
|
|
|
|
|
getUser_comments:this.data.getUser_comments,
|
|
|
|
|
},
|
|
|
|
|
success: res => {
|
|
|
|
|
this.setData({
|
|
|
|
|
array: res.result.data
|
|
|
|
|
})
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户查询成功',
|
|
|
|
|
})
|
|
|
|
|
console.log(res.result.data)
|
|
|
|
|
},
|
|
|
|
|
fail: err => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户查询失败',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getback:function(){
|
|
|
|
|
wx.navigateBack({
|
|
|
|
|
delta:2,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// pages/selectusers/index.js
|
|
|
|
|
Page({
|
|
|
|
|
inputgetID:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
getUser_ID:e.detail.value
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
searchDataNameFn:function(){
|
|
|
|
|
wx.cloud.callFunction({
|
|
|
|
|
name: 'useroption',
|
|
|
|
|
data: {
|
|
|
|
|
option: 'getcomments1',
|
|
|
|
|
getUser_ID:this.data.getUser_ID
|
|
|
|
|
},
|
|
|
|
|
success: res => {
|
|
|
|
|
this.setData({
|
|
|
|
|
array: res.result.data
|
|
|
|
|
})
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户查询成功',
|
|
|
|
|
})
|
|
|
|
|
console.log(res.result.data)
|
|
|
|
|
},
|
|
|
|
|
fail: err => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户查询失败',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getback:function(){
|
|
|
|
|
wx.navigateBack({
|
|
|
|
|
delta:2,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// pages/selectuserss/index.js
|
|
|
|
|
Page({
|
|
|
|
|
searchDataNameFn:function(){
|
|
|
|
|
wx.cloud.callFunction({
|
|
|
|
|
name: 'useroption',
|
|
|
|
|
data: {
|
|
|
|
|
option: 'getcomments2',
|
|
|
|
|
},
|
|
|
|
|
success: res => {
|
|
|
|
|
this.setData({
|
|
|
|
|
array: res.result.data
|
|
|
|
|
})
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户查询成功',
|
|
|
|
|
})
|
|
|
|
|
console.log(res.result.data)
|
|
|
|
|
},
|
|
|
|
|
fail: err => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户查询失败',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getback:function(){
|
|
|
|
|
wx.navigateBack({
|
|
|
|
|
delta:2,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// pages/selectuserssuccess/index.js
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad(options) {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
*/
|
|
|
|
|
onReady() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
*/
|
|
|
|
|
onShow() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
*/
|
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
*/
|
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
*/
|
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
*/
|
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户点击右上角分享
|
|
|
|
|
*/
|
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// pages/updateusers/index.js
|
|
|
|
|
Page({
|
|
|
|
|
//修改数据(改)
|
|
|
|
|
inputupdateID:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
updateUser_ID:e.detail.value
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
inputupdateCollege:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
updateUser_College:e.detail.value
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
inputupdateKey:function(e){
|
|
|
|
|
this.setData({
|
|
|
|
|
updateUser_Key:e.detail.value
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
updateDataFn(){
|
|
|
|
|
wx.cloud.callFunction({
|
|
|
|
|
name: 'useroption',
|
|
|
|
|
data: {
|
|
|
|
|
option: 'update',
|
|
|
|
|
updateUser_ID:this.data.updateUser_ID,
|
|
|
|
|
updateUser_College:this.data.updateUser_College,
|
|
|
|
|
updateUser_Key:this.data.updateUser_Key
|
|
|
|
|
},
|
|
|
|
|
success: res => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户修改成功',
|
|
|
|
|
})
|
|
|
|
|
console.log(res)
|
|
|
|
|
},
|
|
|
|
|
fail:err => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '用户修改失败',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getback:function(){
|
|
|
|
|
wx.navigateBack({
|
|
|
|
|
delta:1,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// pages/updateuserssuccess/index.js
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad(options) {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
*/
|
|
|
|
|
onReady() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
*/
|
|
|
|
|
onShow() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
*/
|
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
*/
|
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
*/
|
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
*/
|
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户点击右上角分享
|
|
|
|
|
*/
|
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// app.js
|
|
|
|
|
App({
|
|
|
|
|
onLaunch: function () {
|
|
|
|
|
if (!wx.cloud) {
|
|
|
|
|
console.error('请使用 2.2.3 或以上的基础库以使用云能力');
|
|
|
|
|
} else {
|
|
|
|
|
wx.cloud.init({
|
|
|
|
|
// env 参数说明:
|
|
|
|
|
// env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源
|
|
|
|
|
// 此处请填入环境 ID, 环境 ID 可打开云控制台查看
|
|
|
|
|
// 如不填则使用默认环境(第一个创建的环境)
|
|
|
|
|
// env: 'my-env-id',
|
|
|
|
|
env:'cloud1-0g194k9vcb31e843',
|
|
|
|
|
traceUser: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.globalData = {};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|