|
@@ -1,4 +1,5 @@
|
|
|
// index.js
|
|
|
+const db=wx.cloud.database();
|
|
|
Page({
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
@@ -26,7 +27,51 @@ Page({
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
+ input_name:function(e){
|
|
|
+ this.setData({user_name:e.detail.value})
|
|
|
+ },
|
|
|
+ input_pwds:function(e){
|
|
|
+
|
|
|
+ this.setData({user_pwds:e.detail.value})
|
|
|
+ },
|
|
|
+ login:function(){
|
|
|
+ console.log("登录获取的参数:"+this.data.user_name+","+this.data.user_pwds);
|
|
|
+ var that=this;
|
|
|
+ wx.request({
|
|
|
+ url: 'http://localhost:8084/login',
|
|
|
+ method:'POST',
|
|
|
+ header:{'content-type':'application/x-www-form-urlencoded'},
|
|
|
+ data:{
|
|
|
+ 'user_name':that.data.user_name,
|
|
|
+ 'user_pwds':that.data.user_pwds
|
|
|
+ },
|
|
|
+ success:function(res){
|
|
|
+ var resData=res.data;
|
|
|
+ console.log(":"+resData);
|
|
|
+ if(resData==true){
|
|
|
+ wx.showToast({
|
|
|
+ title: '登录成功',
|
|
|
+ icon:'success',
|
|
|
+ duration:15000,
|
|
|
+ success:function(){
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../insert/insert',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ wx.showToast({
|
|
|
+ title: '登陆失败',
|
|
|
+ icon:'none',
|
|
|
+ duration:2000,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
toggleLogin: function(){
|
|
|
+
|
|
|
this.setData({
|
|
|
flag: !this.data.flag
|
|
|
})
|
|
@@ -34,7 +79,72 @@ Page({
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad: function (options) {
|
|
|
+ onLoad: function (options) {
|
|
|
+ // 增
|
|
|
+ // db.collection('product').add({
|
|
|
+ // data:{
|
|
|
+ // name:'小刘',
|
|
|
+ // age:20,
|
|
|
+ // gender:'男'
|
|
|
+ // },
|
|
|
+ // success(res){
|
|
|
+ // console.log('添加数据成功',res)
|
|
|
+ // },
|
|
|
+ // fail(res){
|
|
|
+ // console.log('添加数据失败',res)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+
|
|
|
+
|
|
|
+ // 删
|
|
|
+ // db.collection('product').doc('6d85a2b962a6a5ac0a4953f76ba21682').remove({
|
|
|
+ // success(res){
|
|
|
+ // console.log("数据删除成功",res)
|
|
|
+ // },
|
|
|
+ // fail(res){
|
|
|
+ // console.log("数据删除失败",res)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+
|
|
|
+
|
|
|
+ // 改
|
|
|
+ // db.collection('product').doc('058dfefe62a6a83308856bcf1ec46e96').update({
|
|
|
+ // data:{
|
|
|
+ // name:'CreatorRay',
|
|
|
+ // QQ:505417246
|
|
|
+ // },
|
|
|
+ // success(res){
|
|
|
+ // console.log("数据修改成功")
|
|
|
+ // },
|
|
|
+ // fail(res){
|
|
|
+ // console.log("数据修改失败")
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+
|
|
|
+
|
|
|
+ // 查 get
|
|
|
+ // db.collection('product').get({
|
|
|
+ // success(res){
|
|
|
+ // console.log("查询成功",res)
|
|
|
+ // },
|
|
|
+ // fail(res){
|
|
|
+ // console.log("查询失败",res)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+
|
|
|
+
|
|
|
+ // 查 where
|
|
|
+ // db.collection('product').where({
|
|
|
+ // name:'CreatorRay'
|
|
|
+ // }).get({
|
|
|
+ // success(res){
|
|
|
+ // console.log('name 为 Creator 的数据成功查到',res)
|
|
|
+ // },
|
|
|
+ // fail(res){
|
|
|
+ // console.log('查询失败',res)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|