// index.js const db=wx.cloud.database(); Page({ /** * 页面的初始数据 */ data: { qrCode: "../../images/qr.png", flag: "true", imgToggle: "../../images/qrcode.png", list: [ { src: "../../images/rice.png", text: "饭" }, { src: "../../images/noodles.png", text: "面" }, { src: "../../images/congee.png", text: "粥" }, { src: "../../images/drink.png", text: "饮料" } ] }, 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 }) }, /** * 生命周期函数--监听页面加载 */ 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) // } // }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })