国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 熱點 > 微信 > 正文

微信小程序云開發(fā)(數(shù)據(jù)庫)詳解

2024-07-22 01:18:27
字體:
供稿:網(wǎng)友

開發(fā)者可以使用云開發(fā)開發(fā)微信小程序、小游戲,無需搭建服務(wù)器,即可使用云端能力。

云開發(fā)為開發(fā)者提供完整的云端支持,弱化后端和運維概念,無需搭建服務(wù)器,使用平臺提供的 API 進行核心業(yè)務(wù)開發(fā),即可實現(xiàn)快速上線和迭代,同時這一能力,同開發(fā)者已經(jīng)使用的云服務(wù)相互兼容,并不互斥。

目前提供三大基礎(chǔ)能力支持:

1、云函數(shù):在云端運行的代碼,微信私有協(xié)議天然鑒權(quán),開發(fā)者只需編寫自身業(yè)務(wù)邏輯代碼

2、數(shù)據(jù)庫:一個既可在小程序前端操作,也能在云函數(shù)中讀寫的 JSON 數(shù)據(jù)庫

3、存儲:在小程序前端直接上傳/下載云端文件,在云開發(fā)控制臺可視化管理

具體的可以去小程序文檔上查看,下面用一個登錄注冊的案例來演示小程序云開發(fā)數(shù)據(jù)庫的運用

注冊

在創(chuàng)建的時候,要在點下一步的時候,調(diào)數(shù)據(jù)庫來看用戶名有沒有重復(fù)的。在點擊同意的時候來調(diào)用數(shù)據(jù)庫,然后把所有的判斷放到下一步來判斷。所有條件都滿足就將用戶名和密碼放到全局變量中。

var app = getApp();Page({ data: {  userName: '',  userPassword: '',  userPasswordAgain: '',  checkbox: false,  repetition: false }, // 返回主頁面 backHomeTap: function() {  wx.switchTab({   url: '../index/index',  }) }, // 綁定 bindingTap: function () {  wx.redirectTo({   url: '../login/login',  }) }, // 用戶名 userNameInput: function(e) {  this.setData({   userName: e.detail.value  }); }, // 密碼 userPasswordInput: function(e) {  this.setData({   userPassword: e.detail.value  }); }, // 再次輸入密碼 userPasswordAgainInput: function(e) {  this.setData({   userPasswordAgain: e.detail.value  }); }, // 同意 checkboxChange: function() {  if (this.data.checkbox === false) {   this.setData({    checkbox: true   })  } else {   this.setData({    checkbox: false   })  }  var that = this;  var userName = this.data.userName;  // 初始化云  wx.cloud.init({   env: 'wubaib-9543f7',   traceUser: true  });  // 初始化數(shù)據(jù)庫  const db = wx.cloud.database();  const _ = db.command;  db.collection('userInformation').where({   userName: _.eq(userName)  }).get({   success: function (res) {    if (res.data.length === 1) {     that.setData({      repetition: true     })    }   }  }) }, // 下一步,完善個人信息 perfectInforTap: function() {  var userName = this.data.userName;  var userPassword = this.data.userPassword;  var checkbox = this.data.checkbox;  var userPasswordAgain = this.data.userPasswordAgain;  var name = /^[A-Za-z0-9/u4e00-/u9fa5]+$/;  var repetition = this.data.repetition;  if (userName === '') {   wx.showToast({    title: '請輸入用戶名',    icon: 'none',    duration: 2000,    mask: true   })  } else if (!name.test(userName)) {   wx.showToast({    title: '用戶名格式不正確',    icon: 'none',    duration: 2000,    mask: true   })  } else if (repetition === true) {   wx.showToast({    title: '用戶名已存在',    icon: 'none',    duration: 2000,    mask: true   })  } else if (userPassword === '') {   wx.showToast({    title: '請輸入密碼',    icon: 'none',    duration: 2000,    mask: true   })  } else if (userPassword.length < 6) {   wx.showToast({    title: '密碼最少6位',    icon: 'none',    duration: 2000,    mask: true   })  } else if (userPassword !== userPasswordAgain) {   wx.showToast({    title: '兩次密碼輸入不一致',    icon: 'none',    duration: 2000,    mask: true   })  } else if (checkbox === false) {   wx.showToast({    title: '請選中已閱讀',    icon: 'none',    duration: 2000,    mask: true   })  } else {   wx.redirectTo({    url: 'perfectInfor/perfectInfor',   })   // 保存用戶名和密碼   app.appData.account = {    userName: userName,    userPassword: userPassword   }  } }})            
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 克拉玛依市| 蓝田县| 四会市| 全椒县| 塘沽区| 棋牌| 大理市| 曲周县| 桐柏县| 曲周县| 长丰县| 泰安市| 白朗县| 综艺| 沧州市| 台湾省| 鄱阳县| 盐津县| 盈江县| 漳浦县| 潜江市| 德庆县| 女性| 新乡县| 长治县| 当阳市| 泸州市| 平潭县| 南雄市| 新营市| 湾仔区| 新和县| 翁牛特旗| 洪江市| 西林县| 茌平县| 临城县| 鲁山县| 轮台县| 乃东县| 广宁县|