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.
guoxinyu_project/scr/wechat-weapp-mapdemo-master/wechat-weapp-mapdemo-master.../miniprogram/pages/addusers/index.js

88 lines
1.6 KiB

// pages/addusers/index.js
const db = wx.cloud.database()
Page({
/**
* 页面的初始数据
*/
data: {
User_ID:'',
User_College:'',
User_Key:'',
User_Class:'',
User_Grade:''
},
//监听并修改用户名和年龄的输入
inputID:function(e){
this.setData({
User_ID:e.detail.value
})
},
inputCollege:function(e){
this.setData({
User_College:e.detail.value
})
},
inputGrade:function(e){
this.setData({
User_Grade:e.detail.value
})
},
inputClass:function(e){
this.setData({
User_Class:e.detail.value
})
},
inputKey:function(e){
this.setData({
User_Key: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_College:this.data.User_College,
User_Grade:this.data.User_Grade,
User_Class:this.data.User_Class,
User_Key:this.data.User_Key
}
},
success: res => {
wx.showToast({
title: '用户添加成功',
})
console.log("添加成功")
console.log(res)
},
fail:err => {
wx.showToast({
title: '用户添加失败',
})
}
})
},
getback:function(){
wx.navigateBack({
delta:1,
})
}
})