123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- // 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 () {
- }
- })
-
|