六娃密码管理小程序开发经验总结
【摘要】
昨天晚上 利用下班后的三个小时,做了一个密码管理的小程序,使用云开发,搭配云函数
小程序只要两个页面,一个新增,一个列表
昨晚提交的审核,今天早上就通过了,大家可以扫码看看
该项目我已经开源了, 项目地址:https://github.com/PmcFizz/FasterCoder
主要js代...
昨天晚上 利用下班后的三个小时,做了一个密码管理的小程序,使用云开发,搭配云函数
小程序只要两个页面,一个新增,一个列表
昨晚提交的审核,今天早上就通过了,大家可以扫码看看
该项目我已经开源了, 项目地址:https://github.com/PmcFizz/FasterCoder
主要js代码 新增代码
// 输入双向绑定
bindAppNameInput (e) {
this.setData({
appName: e.detail.value
})
},
// 输入双向绑定
bindAccountInput (e) {
this.setData({
account: e.detail.value
})
},
// 输入双向绑定
bindPasswordInput (e) {
this.setData({
password: e.detail.value
})
},
toList () {
wx.redirectTo({
url: '../pwdList/pwdList',
})
},
// 提交数据
formSubmit () {
const db = wx.cloud.database()
let appName = this.data.appName
let account = this.data.account
let password = this.data.password
let openid = getApp().globalData.openid
db.collection('pwdBox')
.add({ data: { appName, account, password, openid}})
.then(res=>{
wx.showToast({
title: '新增成功',
icon: 'success',
duration: 2000
})
wx.redirectTo({
url: '../pwdList/pwdList',
})
})
},
查询列表代码:
onLoad: function (options) {
let self = this
wx.cloud.callFunction({
name: 'login',
data: {},
success: res => {
app.globalData.openid = res.result.openid
const db = wx.cloud.database()
let openid = res.result.openid
db.collection('pwdBox')
.where({ openid }).get({
success(res) {
self.setData({
pwdList: res.data
})
}
})
},
fail: err => {
console.error('[云函数] [login] 调用失败', err)
wx.navigateTo({
url: '../deployFunctions/deployFunctions',
})
}
})
},
一个新增函数, 一个查询函数,
另外,使用云函数获取 用户的openid 作为用户的唯一主键,作为查询条件 获取用户openid 的云函数如下
wx.cloud.callFunction({
name: 'login',
data: {},
success: res => {
app.globalData.openid = res.result.openid
}
})
文章来源: fizzz.blog.csdn.net,作者:拿我格子衫来,版权归原作者所有,如需转载,请联系作者。
原文链接:fizzz.blog.csdn.net/article/details/87867441
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)