Add
14
.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
# Windows
|
||||
[Dd]esktop.ini
|
||||
Thumbs.db
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
|
||||
# Node.js
|
||||
node_modules/
|
22
cloudfunctionTemplate/passwd.json
Normal file
@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"name": "decoder",
|
||||
"value": {
|
||||
"method": "decoder",
|
||||
"argv": {
|
||||
"handle": "b0bf0e91d3ae59711d9569998d4d334b3d551121ede824233d3c8888dd89c3d5",
|
||||
"openid": "oLYkK4-QKvlCBxZFw8qF4suJplv0"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "deleter",
|
||||
"value": {
|
||||
"method": "deleter",
|
||||
"argv": {
|
||||
"openid": "oLYkK4y0t2DjbMijYDURhyqPCQSU",
|
||||
"handle": "19ee001b09e1a39a3c37f72f01528dab2ede602880572b460229e8db85b167c5"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
37
cloudfunctions/changePwd/index.js
Normal file
@ -0,0 +1,37 @@
|
||||
// 云函数入口文件
|
||||
const cloud = require('wx-server-sdk')
|
||||
var crypto = require('crypto')
|
||||
|
||||
cloud.init({
|
||||
traceUser: true,
|
||||
env: "ipasswd-7h7iu"
|
||||
})
|
||||
|
||||
const db = cloud.database()
|
||||
|
||||
// 云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
const wxContext = cloud.getWXContext()
|
||||
let passwd_key = crypto.createHash('sha256').update(event.passwd).digest('hex')
|
||||
return new Promise((resolve, reject) => {
|
||||
db.collection('users').where({
|
||||
openid : wxContext.OPENID
|
||||
}).update({
|
||||
data:{
|
||||
passwd : passwd_key
|
||||
},
|
||||
success:function(){
|
||||
resolve({
|
||||
status : "ok",
|
||||
openid : wxContext.OPENID
|
||||
})
|
||||
},
|
||||
fail: function () {
|
||||
resolve({
|
||||
status: "fail",
|
||||
openid: wxContext.OPENID
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
15
cloudfunctions/changePwd/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "changePwd",
|
||||
"version": "1.0.0",
|
||||
"description": "修改用户六位独立密码",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wx-server-sdk": "latest",
|
||||
"crypto": "latest"
|
||||
}
|
||||
}
|
45
cloudfunctions/check/index.js
Normal file
@ -0,0 +1,45 @@
|
||||
// 云函数入口文件
|
||||
const cloud = require('wx-server-sdk')
|
||||
var crypto = require('crypto')
|
||||
|
||||
cloud.init({
|
||||
traceUser: true,
|
||||
env: "ipasswd-7h7iu"
|
||||
})
|
||||
|
||||
const db = cloud.database()
|
||||
|
||||
|
||||
// 云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
const wxContext = cloud.getWXContext()
|
||||
return new Promise((resolve, reject) => {
|
||||
db.collection('users').where({
|
||||
openid: wxContext.OPENID
|
||||
}).get().then(res=>{
|
||||
if(res.data.length > 0){
|
||||
resolve({
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
userInfo : {
|
||||
avatarUrl:res.data[0].avatarUrl,
|
||||
city: res.data[0].city,
|
||||
date : res.data[0].date,
|
||||
nickName : res.data[0].nickName,
|
||||
language : res.data[0].language,
|
||||
gender : res.data[0].gender,
|
||||
},
|
||||
status: "UserFound"
|
||||
})
|
||||
}
|
||||
else{
|
||||
resolve({
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
userInfo: {},
|
||||
status:"UserNotFound"
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
15
cloudfunctions/check/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "check",
|
||||
"version": "1.0.0",
|
||||
"description": "检查用户是否存在",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Saturneric",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wx-server-sdk": "latest",
|
||||
"crypto": "latest"
|
||||
}
|
||||
}
|
45
cloudfunctions/checkPwd/index.js
Normal file
@ -0,0 +1,45 @@
|
||||
// 云函数入口文件
|
||||
const cloud = require('wx-server-sdk')
|
||||
var crypto = require('crypto')
|
||||
|
||||
cloud.init({
|
||||
traceUser: true,
|
||||
env: "ipasswd-7h7iu"
|
||||
})
|
||||
|
||||
const db = cloud.database()
|
||||
|
||||
// 云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
const wxContext = cloud.getWXContext()
|
||||
return new Promise((resolve, reject) => {
|
||||
db.collection('users').where({
|
||||
openid: wxContext.OPENID
|
||||
}).get().then(res => {
|
||||
if (res.data.length > 0) {
|
||||
var passwd_key = crypto.createHash('sha256').update(event.passwd).digest('hex')
|
||||
if(passwd_key == res.data[0].passwd)
|
||||
resolve({
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
status: "success"
|
||||
})
|
||||
else
|
||||
resolve({
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
status: "failed"
|
||||
})
|
||||
}
|
||||
else {
|
||||
resolve({
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
status: "failed"
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
}
|
15
cloudfunctions/checkPwd/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "checkPwd",
|
||||
"version": "1.0.0",
|
||||
"description": "检查六位密码是否与数据库中的一致",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Saturneric",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wx-server-sdk": "latest",
|
||||
"crypto": "latest"
|
||||
}
|
||||
}
|
37
cloudfunctions/createUser/index.js
Normal file
@ -0,0 +1,37 @@
|
||||
// 云函数入口文件
|
||||
const cloud = require('wx-server-sdk')
|
||||
var crypto = require('crypto')
|
||||
|
||||
cloud.init({
|
||||
traceUser: true,
|
||||
env: "ipasswd-7h7iu"
|
||||
})
|
||||
|
||||
const db = cloud.database()
|
||||
|
||||
// 云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
const wxContext = cloud.getWXContext()
|
||||
var passwd_key = crypto.createHash('sha256').update(event.passwd).digest('hex')
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
db.collection("users").add({
|
||||
data : {
|
||||
avatarUrl: event.avatarUrl,
|
||||
city: event.city,
|
||||
gender: event.gender,
|
||||
language: event.language,
|
||||
nickName: event.nickName,
|
||||
openid: wxContext.OPENID,
|
||||
passwd: passwd_key,
|
||||
date: event.date
|
||||
}
|
||||
}).then(res=>{
|
||||
resolve({
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
status: "ok"
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
14
cloudfunctions/createUser/package.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "createUser",
|
||||
"version": "1.0.0",
|
||||
"description": "创建新用户",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wx-server-sdk": "latest"
|
||||
}
|
||||
}
|
22
cloudfunctions/getHash/index.js
Normal file
@ -0,0 +1,22 @@
|
||||
// 云函数入口文件
|
||||
const cloud = require('wx-server-sdk')
|
||||
var crypto = require('crypto')
|
||||
|
||||
cloud.init({
|
||||
traceUser: true,
|
||||
env: "ipasswd-7h7iu"
|
||||
})
|
||||
|
||||
const db = cloud.database()
|
||||
// 云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
const wxContext = cloud.getWXContext()
|
||||
var hash_value = crypto.createHash('sha256').update(event.text).digest('hex')
|
||||
return {
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
unionid: wxContext.UNIONID,
|
||||
hash : hash_value
|
||||
}
|
||||
}
|
15
cloudfunctions/getHash/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "getHash",
|
||||
"version": "1.0.0",
|
||||
"description": "得到字符串的哈希值",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Saturneric",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wx-server-sdk": "latest",
|
||||
"crypto": "latest"
|
||||
}
|
||||
}
|
5
cloudfunctions/login/config.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"permissions": {
|
||||
"openapi": []
|
||||
}
|
||||
}
|
31
cloudfunctions/login/index.js
Normal file
@ -0,0 +1,31 @@
|
||||
// 云函数模板
|
||||
// 部署:在 cloud-functions/login 文件夹右击选择 “上传并部署”
|
||||
|
||||
const cloud = require('wx-server-sdk')
|
||||
|
||||
// 初始化 cloud
|
||||
cloud.init()
|
||||
|
||||
/**
|
||||
* 这个示例将经自动鉴权过的小程序用户 openid 返回给小程序端
|
||||
*
|
||||
* event 参数包含小程序端调用传入的 data
|
||||
*
|
||||
*/
|
||||
exports.main = (event, context) => {
|
||||
console.log(event)
|
||||
console.log(context)
|
||||
|
||||
// 可执行其他自定义逻辑
|
||||
// console.log 的内容可以在云开发云函数调用日志查看
|
||||
|
||||
// 获取 WX Context (微信调用上下文),包括 OPENID、APPID、及 UNIONID(需满足 UNIONID 获取条件)
|
||||
const wxContext = cloud.getWXContext()
|
||||
|
||||
return {
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
unionid: wxContext.UNIONID,
|
||||
}
|
||||
}
|
14
cloudfunctions/login/package.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "login",
|
||||
"version": "1.0.0",
|
||||
"description": "得到用户的openid",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wx-server-sdk": "latest"
|
||||
}
|
||||
}
|
499
cloudfunctions/passwd/index.js
Normal file
@ -0,0 +1,499 @@
|
||||
// 云函数入口文件
|
||||
const cloud = require('wx-server-sdk')
|
||||
var crypto = require('crypto');
|
||||
var CryptoJS = require('crypto-js')
|
||||
|
||||
cloud.init({
|
||||
traceUser: true,
|
||||
env: "ipasswd-7h7iu"
|
||||
})
|
||||
|
||||
const db = cloud.database()
|
||||
|
||||
function encoder(argv) {
|
||||
var keys = new Array(4);
|
||||
for (let i = 0; i < 4; i++) {
|
||||
keys[i] = new Array(10);
|
||||
}
|
||||
keys[0] = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "#"]
|
||||
keys[1] = ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "#"]
|
||||
keys[2] = ["a", "s", "d", "f", "g", "h", "j", "k", "l", "#", "#"]
|
||||
keys[3] = ["z", "x", "c", "v", "b", "n", "m", "#", "#", "#", "#"]
|
||||
|
||||
var rtn = {
|
||||
data: "",
|
||||
arrgs: []
|
||||
}
|
||||
|
||||
var pos = new Array(randomer(rtn.arrgs,3), randomer(rtn.arrgs,10))
|
||||
var vec = new Array(0, 0), nvec = new Array(0, 0)
|
||||
var getUpper = false, isUpperPoss = 0.2, allGetUpper = false
|
||||
var getSpecial = false, isSpecialPoss = 0.1, allGetSpecial = false
|
||||
for (let i = 0; i < argv.length; i++) {
|
||||
nvec[0] = randomer(rtn.arrgs,50)
|
||||
nvec[1] = randomer(rtn.arrgs,50)
|
||||
vec[0] = nvec[0] * 0.08
|
||||
vec[1] = nvec[1] * 0.24
|
||||
if (possibility(rtn.arrgs, 0.5)) {
|
||||
vec[0] *= -1
|
||||
}
|
||||
if (possibility(rtn.arrgs, 0.5)) {
|
||||
vec[1] *= -1
|
||||
}
|
||||
pos = new Array(pos[0] + vec[0], pos[1] + vec[1])
|
||||
if (pos[0] > 3.4 || pos[0] < 0) {
|
||||
pos[0] = randomer(rtn.arrgs,3)
|
||||
}
|
||||
if (pos[1] > 10.4 || pos[1] < 0) {
|
||||
pos[1] = randomer(rtn.arrgs,10)
|
||||
}
|
||||
var tstr = keys[Math.round(pos[0])][Math.round(pos[1])]
|
||||
if(tstr == "#"){
|
||||
i -= 1;
|
||||
continue;
|
||||
}
|
||||
if (argv.hasUpper == true){
|
||||
if (possibility(rtn.arrgs, isUpperPoss)){
|
||||
tstr = tstr.toUpperCase()
|
||||
getUpper = true
|
||||
allGetUpper = true
|
||||
}
|
||||
|
||||
if ((i+2) == argv.length && allGetUpper == false) {
|
||||
tstr = 'Z';
|
||||
}
|
||||
|
||||
if(getUpper == false){
|
||||
isUpperPoss *= 1.5
|
||||
}
|
||||
else{
|
||||
getUpper = false
|
||||
isUpperPoss *= 0.2
|
||||
if(isUpperPoss < 0.1) isUpperPoss = 0.2
|
||||
}
|
||||
}
|
||||
|
||||
if (argv.hasSpecial == true) {
|
||||
|
||||
if (possibility(rtn.arrgs, isSpecialPoss)) {
|
||||
var selectedSpecial = argv.specialChar;
|
||||
var srand = randomer(rtn.arrgs, selectedSpecial.length)
|
||||
tstr = selectedSpecial[srand]
|
||||
getSpecial = true
|
||||
allGetSpecial = true
|
||||
}
|
||||
|
||||
if ((i+1) == argv.length && allGetSpecial == false) {
|
||||
var selectedSpecial = argv.specialChar;
|
||||
var srand = randomer(rtn.arrgs, selectedSpecial.length)
|
||||
tstr = selectedSpecial[srand]
|
||||
}
|
||||
|
||||
if (getSpecial == false) {
|
||||
isSpecialPoss *= 1.5
|
||||
}
|
||||
else {
|
||||
getSpecial = false
|
||||
isSpecialPoss *= 0.1
|
||||
if (isSpecialPoss < 0.05) isSpecialPoss = 0.1
|
||||
}
|
||||
}
|
||||
|
||||
rtn.data += tstr
|
||||
|
||||
}
|
||||
return rtn
|
||||
}
|
||||
|
||||
|
||||
function decoder(argv, rands) {
|
||||
var ridx = 0
|
||||
var keys = new Array(4);
|
||||
for (let i = 0; i < 4; i++) {
|
||||
keys[i] = new Array(10);
|
||||
}
|
||||
keys[0] = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "#"]
|
||||
keys[1] = ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "#"]
|
||||
keys[2] = ["a", "s", "d", "f", "g", "h", "j", "k", "l", "#", "#"]
|
||||
keys[3] = ["z", "x", "c", "v", "b", "n", "m", "#", "#", "#", "#"]
|
||||
|
||||
var rtn = {
|
||||
data: "",
|
||||
arrgs: []
|
||||
}
|
||||
|
||||
var pos = new Array(derandomer(rands[ridx++], 3), derandomer(rands[ridx++], 10))
|
||||
var vec = new Array(0, 0), nvec = new Array(0, 0)
|
||||
var getUpper = false, isUpperPoss = 0.2, allGetUpper = false
|
||||
var getSpecial = false, isSpecialPoss = 0.1, allGetSpecial = false
|
||||
for (let i = 0; i < argv.length; i++) {
|
||||
nvec[0] = derandomer(rands[ridx++], 50)
|
||||
nvec[1] = derandomer(rands[ridx++], 50)
|
||||
vec[0] = nvec[0] * 0.08
|
||||
vec[1] = nvec[1] * 0.24
|
||||
if (depossibility(rands[ridx++], 0.5)) {
|
||||
vec[0] *= -1
|
||||
}
|
||||
if (depossibility(rands[ridx++], 0.5)) {
|
||||
vec[1] *= -1
|
||||
}
|
||||
pos = new Array(pos[0] + vec[0], pos[1] + vec[1])
|
||||
if (pos[0] > 3.4 || pos[0] < 0) {
|
||||
pos[0] = derandomer(rands[ridx++], 3)
|
||||
}
|
||||
if (pos[1] > 10.4 || pos[1] < 0) {
|
||||
pos[1] = derandomer(rands[ridx++], 10)
|
||||
}
|
||||
var tstr = keys[Math.round(pos[0])][Math.round(pos[1])]
|
||||
if (tstr == "#") {
|
||||
i -= 1;
|
||||
continue;
|
||||
}
|
||||
if (argv.hasUpper == true) {
|
||||
if (depossibility(rands[ridx++], isUpperPoss)) {
|
||||
tstr = tstr.toUpperCase()
|
||||
getUpper = true
|
||||
allGetUpper = true
|
||||
}
|
||||
|
||||
if ((i+2) == argv.length && allGetUpper == false) {
|
||||
tstr = 'Z';
|
||||
}
|
||||
|
||||
if (getUpper == false) {
|
||||
isUpperPoss *= 1.5
|
||||
}
|
||||
else {
|
||||
getUpper = false
|
||||
isUpperPoss *= 0.2
|
||||
if (isUpperPoss < 0.1) isUpperPoss = 0.2
|
||||
}
|
||||
}
|
||||
|
||||
if (argv.hasSpecial == true) {
|
||||
|
||||
if (depossibility(rands[ridx++], isSpecialPoss)) {
|
||||
var selectedSpecial = argv.specialChar;
|
||||
var srand = derandomer(rands[ridx++], selectedSpecial.length)
|
||||
tstr = selectedSpecial[srand]
|
||||
getSpecial = true
|
||||
allGetSpecial = true
|
||||
}
|
||||
|
||||
if ((i+1) == argv.length && allGetSpecial == false) {
|
||||
var selectedSpecial = argv.specialChar;
|
||||
var srand = derandomer(rands[ridx++], selectedSpecial.length)
|
||||
tstr = selectedSpecial[srand]
|
||||
}
|
||||
|
||||
if (getSpecial == false) {
|
||||
isSpecialPoss *= 1.5
|
||||
}
|
||||
else {
|
||||
getSpecial = false
|
||||
isSpecialPoss *= 0.1
|
||||
if (isSpecialPoss < 0.05) isSpecialPoss = 0.1
|
||||
}
|
||||
}
|
||||
|
||||
rtn.data += tstr
|
||||
|
||||
}
|
||||
return rtn
|
||||
}
|
||||
|
||||
|
||||
function possibility(args, possb){
|
||||
var tmp = Math.random()
|
||||
args.push(tmp)
|
||||
if (possb > tmp){
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
function depossibility(arg, possb) {
|
||||
var tmp = arg
|
||||
if (possb > tmp) {
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
function randomer(args, range) {
|
||||
var tmp = Math.random()
|
||||
args.push(tmp)
|
||||
return Math.floor(tmp * range);
|
||||
}
|
||||
|
||||
function derandomer(arg, range) {
|
||||
var tmp = arg
|
||||
return Math.floor(tmp * range);
|
||||
}
|
||||
|
||||
function aes_encrypt(data, openid, iv){
|
||||
var blocks = parseInt(data.length / 16)
|
||||
if (data.length % 16 != 0) blocks += 1;
|
||||
buffdata = new Buffer(16 * blocks)
|
||||
console.log("Blocks",blocks)
|
||||
buffdata.write(data)
|
||||
data = buffdata
|
||||
console.log("Buffdata",buffdata)
|
||||
|
||||
var algorithm = 'aes-256-ecb'
|
||||
var key = crypto.createHash('sha256').update(openid).digest('hex')
|
||||
key = key.substr(0, 32)
|
||||
key = key.toString('hex')
|
||||
console.log("Data", data, "Key", key)
|
||||
var clearEncoding = 'ascii'
|
||||
var cipherEncoding = 'base64'
|
||||
iv = iv || ""
|
||||
var cipher = crypto.createCipher(algorithm, key, iv)
|
||||
cipher.setAutoPadding(true);
|
||||
var cipherChunks = []
|
||||
cipherChunks.push(cipher.update(data, clearEncoding, cipherEncoding));
|
||||
cipherChunks.push(cipher.final(cipherEncoding));
|
||||
return cipherChunks.join('')
|
||||
}
|
||||
|
||||
function aes_decode(ciphertext, openid, iv){
|
||||
var algorithm = 'aes-256-ecb'
|
||||
var key = crypto.createHash('sha256').update(openid).digest('hex')
|
||||
key = key.substr(0, 32)
|
||||
key = key.toString('hex')
|
||||
console.log("Key", key)
|
||||
var clearEncoding = 'ascii'
|
||||
var cipherEncoding = 'base64'
|
||||
iv = iv || "";
|
||||
var decipher = crypto.createDecipheriv(algorithm, key, iv)
|
||||
decipher.setAutoPadding(false);
|
||||
console.log("crypted:" + ciphertext)
|
||||
var cipherChunks = [];
|
||||
cipherChunks.push(decipher.update(ciphertext, cipherEncoding, clearEncoding));
|
||||
cipherChunks.push(decipher.final(clearEncoding));
|
||||
var decrypted = cipherChunks.join('')
|
||||
return decrypted;
|
||||
}
|
||||
|
||||
// 云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
const wxContext = cloud.getWXContext()
|
||||
console.log("[云函数] 调用 " + event.method)
|
||||
if (event.method == "encoder") {
|
||||
var rtn = encoder(event.argv)
|
||||
|
||||
var code = String(wxContext.openid)
|
||||
for (var i = 0; i < rtn.arrgs.length; i++) {
|
||||
code += String(rtn.arrgs[i])
|
||||
}
|
||||
var handle_hash = crypto.createHash('sha256').update(code).digest('hex');
|
||||
return new Promise((resolve, reject) => {
|
||||
db.collection('passwd').add({
|
||||
data: {
|
||||
openid: wxContext.OPENID,
|
||||
args: rtn.arrgs,
|
||||
handle_hash: handle_hash,
|
||||
argv: event.argv
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.errMsg == "collection.add:ok") {
|
||||
resolve({
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
passwd: rtn.data,
|
||||
handle: handle_hash,
|
||||
status: "ok"
|
||||
})
|
||||
}
|
||||
else {
|
||||
resolve({
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
status: "fail"
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
else if (event.method == "saver") {
|
||||
var handle = event.argv.handle
|
||||
var openid = event.argv.openid
|
||||
var tag = event.argv.tag
|
||||
return new Promise((resolve, reject) => {
|
||||
db.collection("passwd").where({
|
||||
handle_hash: handle,
|
||||
openid: openid
|
||||
}).limit(1).get().then(res => {
|
||||
console.log(res)
|
||||
if (res.data.length > 0) {
|
||||
var tag_hash = crypto.createHash('sha256').update(tag).digest('hex')
|
||||
db.collection('passwd_saved').add({
|
||||
data: {
|
||||
openid: wxContext.OPENID,
|
||||
args: res.data[0].args,
|
||||
handle_hash: handle,
|
||||
tag_hash: tag_hash,
|
||||
argv : res.data[0].argv,
|
||||
custom: false
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.errMsg == "collection.add:ok") {
|
||||
resolve({
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
handle: handle_hash,
|
||||
status: "ok"
|
||||
})
|
||||
}
|
||||
else {
|
||||
resolve({
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
status: "fail"
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
else if (event.method == "customer") {
|
||||
var handle_hash = event.argv.handle
|
||||
var openid = event.argv.openid
|
||||
var tag = event.argv.tag
|
||||
var passwd = event.argv.passwd
|
||||
return new Promise((resolve, reject) => {
|
||||
db.collection("passwd").where({
|
||||
handle_hash: handle_hash,
|
||||
openid: openid
|
||||
}).limit(1).get().then(res => {
|
||||
if (res.data.length > 0) {
|
||||
|
||||
var tag_hash = crypto.createHash('sha256').update(tag).digest('hex')
|
||||
|
||||
var key = crypto.createHash('sha256').update(openid).digest('hex')
|
||||
key = key.substr(0, 32)
|
||||
key = key.toString('hex')
|
||||
|
||||
var encrypt = CryptoJS.AES.encrypt(passwd, CryptoJS.enc.Utf8.parse(key), {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
});
|
||||
|
||||
db.collection("passwd_saved").add({
|
||||
data: {
|
||||
openid: wxContext.OPENID,
|
||||
ciphertext: encrypt.toString(),
|
||||
handle_hash: handle_hash,
|
||||
tag_hash: tag_hash,
|
||||
custom: true
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.errMsg == "collection.add:ok") {
|
||||
resolve({
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
handle: handle_hash,
|
||||
status: "ok"
|
||||
})
|
||||
}
|
||||
else {
|
||||
resolve({
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
status: "fail"
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
else if (event.method == "decoder") {
|
||||
var handle_hash = event.argv.handle
|
||||
var openid = event.argv.openid
|
||||
return new Promise((resolve, reject) => {
|
||||
db.collection("passwd_saved").where({
|
||||
handle_hash: handle_hash,
|
||||
openid: openid
|
||||
}).limit(1).get().then(res => {
|
||||
console.log(res)
|
||||
if (res.data.length > 0) {
|
||||
if(res.data[0].custom){
|
||||
var key = crypto.createHash('sha256').update(openid).digest('hex')
|
||||
key = key.substr(0, 32)
|
||||
key = key.toString('hex')
|
||||
|
||||
var decrypt = CryptoJS.AES.decrypt(res.data[0].ciphertext, CryptoJS.enc.Utf8.parse(key), {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
});
|
||||
resolve({
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
passwd: decrypt.toString(CryptoJS.enc.Utf8),
|
||||
status : "ok",
|
||||
handle : handle_hash
|
||||
})
|
||||
}
|
||||
else{
|
||||
var args = res.data[0].args
|
||||
var argv = res.data[0].argv
|
||||
var rtn = decoder(argv,args)
|
||||
resolve({
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
passwd: rtn.data,
|
||||
status: "ok",
|
||||
handle: handle_hash
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
else if (event.method == "deleter"){
|
||||
var handle_hash = event.argv.handle
|
||||
var openid = event.argv.openid
|
||||
return new Promise((resolve, reject) => {
|
||||
if (wxContext.OPENID != openid){
|
||||
resolve({
|
||||
status: "failed",
|
||||
openid : openid
|
||||
})
|
||||
}
|
||||
var handle = handle_hash
|
||||
var openid = openid
|
||||
db.collection("passwd-saved").where({
|
||||
handle: handle,
|
||||
openid: wxContext.OPENID
|
||||
}).get().then(res=>{
|
||||
console.log(res)
|
||||
if(res.data.length > 0){
|
||||
db.collection("passwd-saved").doc(res.data[0]._id).remove().then(res => {
|
||||
})
|
||||
resolve({
|
||||
status: "ok",
|
||||
openid: openid
|
||||
})
|
||||
}
|
||||
else{
|
||||
resolve({
|
||||
status: "failed",
|
||||
openid: openid
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
502
cloudfunctions/passwd/package-lock.json
generated
Normal file
@ -0,0 +1,502 @@
|
||||
{
|
||||
"name": "passwd",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@cloudbase/database": {
|
||||
"version": "0.0.9",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/@cloudbase%2fdatabase/-/database-0.0.9.tgz",
|
||||
"integrity": "sha512-OTlP0HtSxb8xIeaUN5GKq9gHJLHMEwIfqmOD53vFHMsO4IfOjPOVpNfULmCjtS4j2bhMIzFNnzBNjXjzPJLYDA=="
|
||||
},
|
||||
"@protobufjs/aspromise": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/@protobufjs%2faspromise/-/aspromise-1.1.2.tgz",
|
||||
"integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78="
|
||||
},
|
||||
"@protobufjs/base64": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/@protobufjs%2fbase64/-/base64-1.1.2.tgz",
|
||||
"integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg=="
|
||||
},
|
||||
"@protobufjs/codegen": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/@protobufjs%2fcodegen/-/codegen-2.0.4.tgz",
|
||||
"integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg=="
|
||||
},
|
||||
"@protobufjs/eventemitter": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/@protobufjs%2feventemitter/-/eventemitter-1.1.0.tgz",
|
||||
"integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A="
|
||||
},
|
||||
"@protobufjs/fetch": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/@protobufjs%2ffetch/-/fetch-1.1.0.tgz",
|
||||
"integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=",
|
||||
"requires": {
|
||||
"@protobufjs/aspromise": "^1.1.1",
|
||||
"@protobufjs/inquire": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"@protobufjs/float": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/@protobufjs%2ffloat/-/float-1.0.2.tgz",
|
||||
"integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E="
|
||||
},
|
||||
"@protobufjs/inquire": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/@protobufjs%2finquire/-/inquire-1.1.0.tgz",
|
||||
"integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik="
|
||||
},
|
||||
"@protobufjs/path": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/@protobufjs%2fpath/-/path-1.1.2.tgz",
|
||||
"integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0="
|
||||
},
|
||||
"@protobufjs/pool": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/@protobufjs%2fpool/-/pool-1.1.0.tgz",
|
||||
"integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q="
|
||||
},
|
||||
"@protobufjs/utf8": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/@protobufjs%2futf8/-/utf8-1.1.0.tgz",
|
||||
"integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA="
|
||||
},
|
||||
"@types/long": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/@types%2flong/-/long-4.0.0.tgz",
|
||||
"integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "10.14.7",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/@types%2fnode/-/node-10.14.7.tgz",
|
||||
"integrity": "sha512-on4MmIDgHXiuJDELPk1NFaKVUxxCFr37tm8E9yN6rAiF5Pzp/9bBfBHkoexqRiY+hk/Z04EJU9kKEb59YqJ82A=="
|
||||
},
|
||||
"ajv": {
|
||||
"version": "6.10.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/ajv/-/ajv-6.10.0.tgz",
|
||||
"integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==",
|
||||
"requires": {
|
||||
"fast-deep-equal": "^2.0.1",
|
||||
"fast-json-stable-stringify": "^2.0.0",
|
||||
"json-schema-traverse": "^0.4.1",
|
||||
"uri-js": "^4.2.2"
|
||||
}
|
||||
},
|
||||
"asn1": {
|
||||
"version": "0.2.4",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/asn1/-/asn1-0.2.4.tgz",
|
||||
"integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==",
|
||||
"requires": {
|
||||
"safer-buffer": "~2.1.0"
|
||||
}
|
||||
},
|
||||
"assert-plus": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/assert-plus/-/assert-plus-1.0.0.tgz",
|
||||
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
|
||||
},
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
||||
},
|
||||
"aws-sign2": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/aws-sign2/-/aws-sign2-0.7.0.tgz",
|
||||
"integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg="
|
||||
},
|
||||
"aws4": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/aws4/-/aws4-1.8.0.tgz",
|
||||
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ=="
|
||||
},
|
||||
"bcrypt-pbkdf": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
|
||||
"integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
|
||||
"requires": {
|
||||
"tweetnacl": "^0.14.3"
|
||||
}
|
||||
},
|
||||
"caseless": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/caseless/-/caseless-0.12.0.tgz",
|
||||
"integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"requires": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
||||
},
|
||||
"crypto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
|
||||
"integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig=="
|
||||
},
|
||||
"crypto-js": {
|
||||
"version": "3.1.9-1",
|
||||
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.1.9-1.tgz",
|
||||
"integrity": "sha1-/aGedh/Ad+Af+/3G6f38WeiAbNg="
|
||||
},
|
||||
"dashdash": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/dashdash/-/dashdash-1.14.1.tgz",
|
||||
"integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
|
||||
"requires": {
|
||||
"assert-plus": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
|
||||
},
|
||||
"ecc-jsbn": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
|
||||
"integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=",
|
||||
"requires": {
|
||||
"jsbn": "~0.1.0",
|
||||
"safer-buffer": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"extend": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/extend/-/extend-3.0.2.tgz",
|
||||
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
|
||||
},
|
||||
"extsprintf": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/extsprintf/-/extsprintf-1.3.0.tgz",
|
||||
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU="
|
||||
},
|
||||
"fast-deep-equal": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
|
||||
"integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk="
|
||||
},
|
||||
"fast-json-stable-stringify": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
|
||||
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I="
|
||||
},
|
||||
"forever-agent": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/forever-agent/-/forever-agent-0.6.1.tgz",
|
||||
"integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE="
|
||||
},
|
||||
"form-data": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/form-data/-/form-data-2.3.3.tgz",
|
||||
"integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
|
||||
"requires": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.6",
|
||||
"mime-types": "^2.1.12"
|
||||
}
|
||||
},
|
||||
"function-bind": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/function-bind/-/function-bind-1.1.1.tgz",
|
||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
|
||||
},
|
||||
"getpass": {
|
||||
"version": "0.1.7",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/getpass/-/getpass-0.1.7.tgz",
|
||||
"integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
|
||||
"requires": {
|
||||
"assert-plus": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"har-schema": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/har-schema/-/har-schema-2.0.0.tgz",
|
||||
"integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI="
|
||||
},
|
||||
"har-validator": {
|
||||
"version": "5.1.3",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/har-validator/-/har-validator-5.1.3.tgz",
|
||||
"integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==",
|
||||
"requires": {
|
||||
"ajv": "^6.5.5",
|
||||
"har-schema": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"has": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/has/-/has-1.0.3.tgz",
|
||||
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
|
||||
"requires": {
|
||||
"function-bind": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"http-signature": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/http-signature/-/http-signature-1.2.0.tgz",
|
||||
"integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
|
||||
"requires": {
|
||||
"assert-plus": "^1.0.0",
|
||||
"jsprim": "^1.2.2",
|
||||
"sshpk": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"is-regex": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/is-regex/-/is-regex-1.0.4.tgz",
|
||||
"integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=",
|
||||
"requires": {
|
||||
"has": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"is-typedarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/is-typedarray/-/is-typedarray-1.0.0.tgz",
|
||||
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo="
|
||||
},
|
||||
"isstream": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/isstream/-/isstream-0.1.2.tgz",
|
||||
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
|
||||
},
|
||||
"jsbn": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/jsbn/-/jsbn-0.1.1.tgz",
|
||||
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM="
|
||||
},
|
||||
"json-schema": {
|
||||
"version": "0.2.3",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/json-schema/-/json-schema-0.2.3.tgz",
|
||||
"integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM="
|
||||
},
|
||||
"json-schema-traverse": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
|
||||
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
|
||||
},
|
||||
"json-stringify-safe": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
|
||||
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
|
||||
},
|
||||
"jsprim": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/jsprim/-/jsprim-1.4.1.tgz",
|
||||
"integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
|
||||
"requires": {
|
||||
"assert-plus": "1.0.0",
|
||||
"extsprintf": "1.3.0",
|
||||
"json-schema": "0.2.3",
|
||||
"verror": "1.10.0"
|
||||
}
|
||||
},
|
||||
"lodash.merge": {
|
||||
"version": "4.6.1",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/lodash.merge/-/lodash.merge-4.6.1.tgz",
|
||||
"integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ=="
|
||||
},
|
||||
"long": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/long/-/long-4.0.0.tgz",
|
||||
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.40.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/mime-db/-/mime-db-1.40.0.tgz",
|
||||
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA=="
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.24",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/mime-types/-/mime-types-2.1.24.tgz",
|
||||
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==",
|
||||
"requires": {
|
||||
"mime-db": "1.40.0"
|
||||
}
|
||||
},
|
||||
"oauth-sign": {
|
||||
"version": "0.9.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/oauth-sign/-/oauth-sign-0.9.0.tgz",
|
||||
"integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ=="
|
||||
},
|
||||
"performance-now": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/performance-now/-/performance-now-2.1.0.tgz",
|
||||
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
|
||||
},
|
||||
"protobufjs": {
|
||||
"version": "6.8.8",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/protobufjs/-/protobufjs-6.8.8.tgz",
|
||||
"integrity": "sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw==",
|
||||
"requires": {
|
||||
"@protobufjs/aspromise": "^1.1.2",
|
||||
"@protobufjs/base64": "^1.1.2",
|
||||
"@protobufjs/codegen": "^2.0.4",
|
||||
"@protobufjs/eventemitter": "^1.1.0",
|
||||
"@protobufjs/fetch": "^1.1.0",
|
||||
"@protobufjs/float": "^1.0.2",
|
||||
"@protobufjs/inquire": "^1.1.0",
|
||||
"@protobufjs/path": "^1.1.2",
|
||||
"@protobufjs/pool": "^1.1.0",
|
||||
"@protobufjs/utf8": "^1.1.0",
|
||||
"@types/long": "^4.0.0",
|
||||
"@types/node": "^10.1.0",
|
||||
"long": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"psl": {
|
||||
"version": "1.1.31",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/psl/-/psl-1.1.31.tgz",
|
||||
"integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw=="
|
||||
},
|
||||
"punycode": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/punycode/-/punycode-2.1.1.tgz",
|
||||
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.5.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/qs/-/qs-6.5.2.tgz",
|
||||
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
|
||||
},
|
||||
"request": {
|
||||
"version": "2.88.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/request/-/request-2.88.0.tgz",
|
||||
"integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==",
|
||||
"requires": {
|
||||
"aws-sign2": "~0.7.0",
|
||||
"aws4": "^1.8.0",
|
||||
"caseless": "~0.12.0",
|
||||
"combined-stream": "~1.0.6",
|
||||
"extend": "~3.0.2",
|
||||
"forever-agent": "~0.6.1",
|
||||
"form-data": "~2.3.2",
|
||||
"har-validator": "~5.1.0",
|
||||
"http-signature": "~1.2.0",
|
||||
"is-typedarray": "~1.0.0",
|
||||
"isstream": "~0.1.2",
|
||||
"json-stringify-safe": "~5.0.1",
|
||||
"mime-types": "~2.1.19",
|
||||
"oauth-sign": "~0.9.0",
|
||||
"performance-now": "^2.1.0",
|
||||
"qs": "~6.5.2",
|
||||
"safe-buffer": "^5.1.2",
|
||||
"tough-cookie": "~2.4.3",
|
||||
"tunnel-agent": "^0.6.0",
|
||||
"uuid": "^3.3.2"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"sshpk": {
|
||||
"version": "1.16.1",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/sshpk/-/sshpk-1.16.1.tgz",
|
||||
"integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==",
|
||||
"requires": {
|
||||
"asn1": "~0.2.3",
|
||||
"assert-plus": "^1.0.0",
|
||||
"bcrypt-pbkdf": "^1.0.0",
|
||||
"dashdash": "^1.12.0",
|
||||
"ecc-jsbn": "~0.1.1",
|
||||
"getpass": "^0.1.1",
|
||||
"jsbn": "~0.1.0",
|
||||
"safer-buffer": "^2.0.2",
|
||||
"tweetnacl": "~0.14.0"
|
||||
}
|
||||
},
|
||||
"tcb-admin-node": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/tcb-admin-node/-/tcb-admin-node-1.6.0.tgz",
|
||||
"integrity": "sha512-GvM5uIB02BeOX9B8XVic3xojOQp0VMa4l7LIonRmsHhjzsiRAb573t37k1a6hl92r5kv4x+NkQEEpP8znXpNPw==",
|
||||
"requires": {
|
||||
"@cloudbase/database": "^0.0.9",
|
||||
"is-regex": "^1.0.4",
|
||||
"lodash.merge": "^4.6.1",
|
||||
"request": "^2.87.0"
|
||||
}
|
||||
},
|
||||
"tough-cookie": {
|
||||
"version": "2.4.3",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/tough-cookie/-/tough-cookie-2.4.3.tgz",
|
||||
"integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==",
|
||||
"requires": {
|
||||
"psl": "^1.1.24",
|
||||
"punycode": "^1.4.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"punycode": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/punycode/-/punycode-1.4.1.tgz",
|
||||
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
|
||||
}
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "1.9.3",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/tslib/-/tslib-1.9.3.tgz",
|
||||
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
|
||||
},
|
||||
"tunnel-agent": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
||||
"integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
|
||||
"requires": {
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"tweetnacl": {
|
||||
"version": "0.14.5",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/tweetnacl/-/tweetnacl-0.14.5.tgz",
|
||||
"integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q="
|
||||
},
|
||||
"uri-js": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/uri-js/-/uri-js-4.2.2.tgz",
|
||||
"integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
|
||||
"requires": {
|
||||
"punycode": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/uuid/-/uuid-3.3.2.tgz",
|
||||
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
|
||||
},
|
||||
"verror": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/verror/-/verror-1.10.0.tgz",
|
||||
"integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
|
||||
"requires": {
|
||||
"assert-plus": "^1.0.0",
|
||||
"core-util-is": "1.0.2",
|
||||
"extsprintf": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"wx-server-sdk": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "http://mirrors.tencentyun.com/npm/wx-server-sdk/-/wx-server-sdk-0.5.1.tgz",
|
||||
"integrity": "sha512-W4rL1mh0pM6dQiZ7OP0YT7t1eoF9Yhs3wKLOZChv5TgOz+esSyR95WeEzsGu0NHpw8C/jVlwfz4YqO9oh87DQQ==",
|
||||
"requires": {
|
||||
"protobufjs": "6.8.8",
|
||||
"tcb-admin-node": "1.6.0",
|
||||
"tslib": "^1.9.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
cloudfunctions/passwd/package.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "passwd",
|
||||
"version": "1.0.0",
|
||||
"description": "为用户计算并储存密码,维护密码数据库",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Saturneric",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wx-server-sdk": "latest",
|
||||
"crypto": "latest",
|
||||
"crypto-js": "latest"
|
||||
}
|
||||
}
|
22
miniprogram/app.js
Normal file
@ -0,0 +1,22 @@
|
||||
//app.js
|
||||
App({
|
||||
onLaunch: function () {
|
||||
|
||||
if (!wx.cloud) {
|
||||
console.error('请使用 2.2.3 或以上的基础库以使用云能力')
|
||||
} else {
|
||||
wx.cloud.init({
|
||||
traceUser: true,
|
||||
env: "ipasswd-7h7iu"
|
||||
})
|
||||
}
|
||||
|
||||
this.globalData = {
|
||||
hasCheckPwd : false,
|
||||
hasRegister : null,
|
||||
openid : null,
|
||||
refresh : false,
|
||||
refreshCheck: false
|
||||
}
|
||||
}
|
||||
})
|
50
miniprogram/app.json
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index",
|
||||
"pages/chooseLib/chooseLib",
|
||||
"pages/openapi/openapi",
|
||||
"pages/openapi/serverapi/serverapi",
|
||||
"pages/openapi/callback/callback",
|
||||
"pages/openapi/cloudid/cloudid",
|
||||
"pages/logs/logs",
|
||||
"pages/create/create",
|
||||
"pages/checkPwd/checkPwd",
|
||||
"pages/show/show",
|
||||
"pages/showPwd/showPwd",
|
||||
"pages/showEdit/showEdit"
|
||||
],
|
||||
"window": {
|
||||
"backgroundColor": "#F6F6F6",
|
||||
"backgroundTextStyle": "light",
|
||||
"navigationBarBackgroundColor": "#3f72af",
|
||||
"navigationBarTitleText": "密码便签",
|
||||
"navigationBarTextStyle": "white"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#fff",
|
||||
"selectedColor": "#45deff",
|
||||
"borderStyle": "white",
|
||||
"backgroundColor": "#3f72af",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/index/index",
|
||||
"text": "资料卡",
|
||||
"iconPath": "images/1-1.png",
|
||||
"selectedIconPath": "images/1-2.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/create/create",
|
||||
"text": "密码便签",
|
||||
"iconPath": "images/2-1.png",
|
||||
"selectedIconPath": "images/2-2.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/logs/logs",
|
||||
"text": "便签集",
|
||||
"iconPath": "images/3-1.png",
|
||||
"selectedIconPath": "images/3-2.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sitemapLocation": "sitemap.json"
|
||||
}
|
178
miniprogram/app.wxss
Normal file
@ -0,0 +1,178 @@
|
||||
/**app.wxss**/
|
||||
@import './css/animate.wxss';
|
||||
|
||||
@font-face {
|
||||
font-family: 'iconfont'; /* project id 518032 */
|
||||
src: url('//at.alicdn.com/t/font_518032_t2q88z3jok8iwwmi.eot');
|
||||
src: url('//at.alicdn.com/t/font_518032_t2q88z3jok8iwwmi.eot?#iefix') format('embedded-opentype'),
|
||||
url('//at.alicdn.com/t/font_518032_t2q88z3jok8iwwmi.woff') format('woff'),
|
||||
url('//at.alicdn.com/t/font_518032_t2q88z3jok8iwwmi.ttf') format('truetype'),
|
||||
url('//at.alicdn.com/t/font_518032_t2q88z3jok8iwwmi.svg#iconfont') format('svg');
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
font-family:"iconfont" !important;
|
||||
font-size:60rpx;
|
||||
font-style:normal;
|
||||
-webkit-font-smoothing: antialiase;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-shanchu:before{content: '\e629';}
|
||||
.icon-sousuo:before{content: '\e62f';}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
button {
|
||||
background: initial;
|
||||
}
|
||||
|
||||
button:focus{
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
button::after{
|
||||
border: none;
|
||||
}
|
||||
|
||||
|
||||
page {
|
||||
background: #f6f6f6;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.userinfo, .uploader, .tunnel {
|
||||
margin-top: 40rpx;
|
||||
height: 140rpx;
|
||||
width: 100%;
|
||||
background: #fff;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
transition: all 300ms ease;
|
||||
}
|
||||
|
||||
.userinfo-avatar {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
margin: 20rpx;
|
||||
border-radius: 50%;
|
||||
background-size: cover;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.userinfo-avatar:after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.userinfo-nickname {
|
||||
font-size: 32rpx;
|
||||
color: #007aff;
|
||||
background-color: white;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.userinfo-nickname::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.uploader, .tunnel {
|
||||
height: auto;
|
||||
padding: 0 0 0 40rpx;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.uploader-text, .tunnel-text {
|
||||
width: 100%;
|
||||
line-height: 52px;
|
||||
font-size: 34rpx;
|
||||
color: #007aff;
|
||||
}
|
||||
|
||||
.uploader-container {
|
||||
width: 100%;
|
||||
height: 400rpx;
|
||||
padding: 20rpx 20rpx 20rpx 0;
|
||||
display: flex;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.uploader-image {
|
||||
width: 100%;
|
||||
height: 360rpx;
|
||||
}
|
||||
|
||||
.tunnel {
|
||||
padding: 0 0 0 40rpx;
|
||||
}
|
||||
|
||||
.tunnel-text {
|
||||
position: relative;
|
||||
color: #222;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-content: center;
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.tunnel-text:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.tunnel-switch {
|
||||
position: absolute;
|
||||
right: 20rpx;
|
||||
top: -2rpx;
|
||||
}
|
||||
|
||||
.disable {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.service {
|
||||
position: fixed;
|
||||
right: 40rpx;
|
||||
bottom: 40rpx;
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(#007aff, #0063ce);
|
||||
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
|
||||
display: flex;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
transition: all 300ms ease;
|
||||
}
|
||||
|
||||
.service-button {
|
||||
position: absolute;
|
||||
top: 40rpx;
|
||||
}
|
||||
|
||||
.service:active {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.request-text {
|
||||
padding: 20rpx 0;
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
word-break: break-all;
|
||||
}
|
1823
miniprogram/css/animate.wxss
Normal file
BIN
miniprogram/images/001-2.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
miniprogram/images/001.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
miniprogram/images/002-2.png
Normal file
After Width: | Height: | Size: 739 B |
BIN
miniprogram/images/002.png
Normal file
After Width: | Height: | Size: 717 B |
BIN
miniprogram/images/1-1.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
miniprogram/images/1-2.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
miniprogram/images/2-1.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
miniprogram/images/2-2.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
miniprogram/images/3-1.png
Normal file
After Width: | Height: | Size: 620 B |
BIN
miniprogram/images/3-2.png
Normal file
After Width: | Height: | Size: 714 B |
BIN
miniprogram/images/code-cloud-callback-config.png
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
miniprogram/images/code-db-inc-dec.png
Normal file
After Width: | Height: | Size: 206 KiB |
BIN
miniprogram/images/code-db-onAdd.png
Normal file
After Width: | Height: | Size: 108 KiB |
BIN
miniprogram/images/code-db-onQuery.png
Normal file
After Width: | Height: | Size: 143 KiB |
BIN
miniprogram/images/code-db-onRemove.png
Normal file
After Width: | Height: | Size: 139 KiB |
BIN
miniprogram/images/code-func-sum.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
miniprogram/images/console-entrance.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
miniprogram/images/create-collection.png
Normal file
After Width: | Height: | Size: 36 KiB |
143
miniprogram/pages/checkPwd/checkPwd.js
Normal file
@ -0,0 +1,143 @@
|
||||
// miniprogram/pages/checkPwd/checkPwd.js
|
||||
const db = wx.cloud.database()
|
||||
const app = getApp()
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
hasUserInfo : false,
|
||||
confirmUserInfo : false,
|
||||
userInfo : null,
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
getPwdInfo: function(e){
|
||||
console.log(e)
|
||||
if(e.detail.value.passwd.length < 6){
|
||||
wx.showToast({
|
||||
title: '独立密码长度要为6位',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
else{
|
||||
const that = this;
|
||||
wx.showModal({
|
||||
title: '确认你刚刚输入的密码',
|
||||
content: "“"+e.detail.value.passwd+'”,对吗?',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
var nowdate = Date.parse(new Date())
|
||||
console.log("[云函数]调用createUser")
|
||||
wx.cloud.callFunction({
|
||||
name: 'createUser',
|
||||
data: {
|
||||
avatarUrl: that.data.userInfo.avatarUrl,
|
||||
city: that.data.userInfo.city,
|
||||
gender: that.data.userInfo.gender,
|
||||
language: that.data.userInfo.language,
|
||||
nickName: that.data.userInfo.nickName,
|
||||
openid: app.globalData.openid,
|
||||
passwd: String(e.detail.value.passwd),
|
||||
date: nowdate
|
||||
},
|
||||
success: res => {
|
||||
wx.showToast({
|
||||
title: '注册成功',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
app.globalData.hasRegister = true
|
||||
app.globalData.refresh = true
|
||||
setTimeout(function () { wx.navigateBack() }, 1500)
|
||||
},
|
||||
fail :err =>{
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
else if (res.cancel) {
|
||||
wx.showToast({
|
||||
title: '我愿意等你',
|
||||
icon: 'none',
|
||||
duration: 800
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
confirmUserInfo: function (e) {
|
||||
this.setData({
|
||||
confirmUserInfo: true,
|
||||
})
|
||||
},
|
||||
|
||||
userInfoHandler: function (e) {
|
||||
if(e.detail.errMsg == "getUserInfo:ok"){
|
||||
this.setData({
|
||||
hasUserInfo : true,
|
||||
userInfo : e.detail.userInfo
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
3
miniprogram/pages/checkPwd/checkPwd.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
25
miniprogram/pages/checkPwd/checkPwd.wxml
Normal file
@ -0,0 +1,25 @@
|
||||
<view>
|
||||
<view class='data'>
|
||||
<view wx:if='{{hasUserInfo == true && confirmUserInfo == true}}' class="animated fadeIn">
|
||||
<form bindsubmit='getPwdInfo' >
|
||||
<text>请填写并牢记你的六位独立密码</text>
|
||||
<input type='number' password='true' class="passwd" name="passwd" focus='true' maxlength='6'></input>
|
||||
<button form-type="submit" class="set-button">好了,我记住了</button>
|
||||
</form>
|
||||
</view>
|
||||
<view wx:elif='{{hasUserInfo == false && confirmUserInfo == false}}' class='register-view animated fadeIn'>
|
||||
<button class="register-button" bindgetuserinfo='userInfoHandler' open-type='getUserInfo'>一键注册</button>
|
||||
<text class="info-text-one">“你将获得将你的密码与笔记结合的强大能力,</text>
|
||||
<text class="info-text">定制的密码生成算法将确保您的账号安全无虞。”</text>
|
||||
<text class="info-text-end">您的关键信息始终在云端加密储存,安全、稳妥。</text>
|
||||
</view>
|
||||
<view wx:elif='{{hasUserInfo == true && confirmUserInfo == false}}' class='show-view'>
|
||||
<open-data class = "avatar animated rubberBand" type="userAvatarUrl"></open-data>
|
||||
<open-data type="userNickName"></open-data>
|
||||
<button class="confirm-button animated fadeInRight" bindtap='confirmUserInfo'>下一步</button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
98
miniprogram/pages/checkPwd/checkPwd.wxss
Normal file
@ -0,0 +1,98 @@
|
||||
/* miniprogram/pages/checkPwd/checkPwd.wxss */
|
||||
.passwd{
|
||||
background-color: #dbe2ef;
|
||||
border-style: solid;
|
||||
border-width: 5rpx;
|
||||
border-color: #85C1E9;
|
||||
width: 400rpx;
|
||||
height: 80rpx;
|
||||
margin-left: 150rpx;
|
||||
margin-right: 150rpx;
|
||||
margin-top: 80rpx;
|
||||
text-align: center;
|
||||
font-size: 60rpx;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
|
||||
.info-text{
|
||||
font-size: 30rpx;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.info-text-one{
|
||||
font-size: 30rpx;
|
||||
margin-top: 50rpx;
|
||||
}
|
||||
|
||||
.info-text-end{
|
||||
font-size: 30rpx;
|
||||
margin-top: 90rpx;
|
||||
}
|
||||
|
||||
.data{
|
||||
background-color: white;
|
||||
margin-top: 80rpx;
|
||||
margin-left: 20rpx;
|
||||
margin-right: 20rpx;
|
||||
border-radius: 20rpx;
|
||||
height: 480rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.set-button{
|
||||
background-color:#3f72af;
|
||||
color:white;
|
||||
margin-left: 50rpx;
|
||||
margin-right: 50rpx;
|
||||
margin-top: 130rpx;
|
||||
}
|
||||
|
||||
.register-view{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
border-color: #3f72af;
|
||||
height: 480rpx;
|
||||
}
|
||||
|
||||
.register-button{
|
||||
background-color:#3f72af;
|
||||
color:white;
|
||||
width: 400rpx;
|
||||
}
|
||||
|
||||
.data text{
|
||||
color: #112d4e;
|
||||
}
|
||||
|
||||
.avatar{
|
||||
margin-top: 50rpx;
|
||||
height: 200rpx;
|
||||
width: 200rpx;
|
||||
border-radius:50%;
|
||||
display: flex;
|
||||
overflow:hidden;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.show-view{
|
||||
height: 480rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
border-color: #3f72af;
|
||||
}
|
||||
|
||||
.confirm-button{
|
||||
margin-top: 65rpx;
|
||||
background-color:#3f72af;
|
||||
color:white;
|
||||
width: 400rpx;
|
||||
margin-left: 165rpx;
|
||||
}
|
66
miniprogram/pages/chooseLib/chooseLib.js
Normal file
@ -0,0 +1,66 @@
|
||||
// pages/chooseLib/chooseLib.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
4
miniprogram/pages/chooseLib/chooseLib.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "选择基础库",
|
||||
"usingComponents": {}
|
||||
}
|
14
miniprogram/pages/chooseLib/chooseLib.wxml
Normal file
@ -0,0 +1,14 @@
|
||||
<!--pages/chooseLib/chooseLib.wxml-->
|
||||
<view class="container">
|
||||
|
||||
<view class="list">
|
||||
<view class="list-item">
|
||||
<text class="black">初始化失败</text>
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<text class="request-text">请使用 2.2.3 或以上的基础库以使用云能力</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
7
miniprogram/pages/chooseLib/chooseLib.wxss
Normal file
@ -0,0 +1,7 @@
|
||||
/* pages/chooseLib/chooseLib.wxss */
|
||||
|
||||
@import "../../style/guide.wxss";
|
||||
|
||||
.black {
|
||||
color: black;
|
||||
}
|
332
miniprogram/pages/create/create.js
Normal file
@ -0,0 +1,332 @@
|
||||
//index.js
|
||||
//获取应用实例
|
||||
const app = getApp()
|
||||
const db=wx.cloud.database()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
id:"",
|
||||
user:"",
|
||||
scode:"",
|
||||
handle:"",
|
||||
usershow:"",
|
||||
tagclass: "pass-ipt-plus",
|
||||
ifusershow : false,
|
||||
passwdclass : "pass-ipt",
|
||||
isscode:false, //是否为系统生成密码
|
||||
scode_0:"" , //复制
|
||||
argv:{
|
||||
length: 8,
|
||||
hasUpper: true,
|
||||
hasSpecial: false,
|
||||
specialChar: ["@", "#", "!"]
|
||||
},
|
||||
len_array: ['短密码(6位)', '中等长度密码(8位)', '长密码(12位)','超长密码(16位)'],
|
||||
len_objectArray: [
|
||||
{
|
||||
id: 0,
|
||||
name: '短密码(6位)'
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: '中等长度密码(8位)'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '长密码(12位)'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '超长密码(16位)'
|
||||
},
|
||||
],
|
||||
len_index : 1,
|
||||
upper_array: ['可以有大写字母', '没有大写字母'],
|
||||
upper_objectArray: [
|
||||
{
|
||||
id: 0,
|
||||
name: '可以有大写字母'
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: '没有大写字母'
|
||||
},
|
||||
],
|
||||
upper_index: 0,
|
||||
special_array: ['可以有特殊字符', '没有特殊字符'],
|
||||
special_objectArray: [
|
||||
{
|
||||
id: 0,
|
||||
name: '可以有特殊字符'
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: '没有特殊字符'
|
||||
},
|
||||
],
|
||||
special_index: 1,
|
||||
if_generate : false,
|
||||
id_tag : ""
|
||||
},
|
||||
|
||||
onShow: function(){
|
||||
if(this.data.user.length > 12){
|
||||
let user = this.data.user
|
||||
user = user.substr(0,12)
|
||||
user += "..."
|
||||
this.setData({
|
||||
usershow: user,
|
||||
})
|
||||
}
|
||||
else{
|
||||
this.setData({
|
||||
usershow: this.data.user
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
goShow: function(){
|
||||
wx.navigateTo({
|
||||
url: '../show/show?textdata='+this.data.user,
|
||||
})
|
||||
},
|
||||
|
||||
buttonShow: function(){
|
||||
|
||||
},
|
||||
|
||||
bindLenPickerChange: function (e) {
|
||||
var targv = this.data.argv
|
||||
if (e.detail.value == 0) targv.length = 6
|
||||
else if (e.detail.value == 1) targv.length = 8
|
||||
else if (e.detail.value == 2) targv.length = 12
|
||||
else if (e.detail.value == 3) targv.length = 16
|
||||
this.setData({
|
||||
argv: targv,
|
||||
len_index: e.detail.value
|
||||
})
|
||||
},
|
||||
bindUpperPickerChange: function (e) {
|
||||
var targv = this.data.argv
|
||||
if (e.detail.value == 0) targv.hasUpper = true
|
||||
else targv.hasUpper = false
|
||||
this.setData({
|
||||
argv : targv,
|
||||
upper_index: e.detail.value
|
||||
})
|
||||
},
|
||||
bindSpecialPickerChange: function (e) {
|
||||
var targv = this.data.argv
|
||||
if (e.detail.value == 0) targv.hasSpecial = true
|
||||
else targv.hasSpecial = false
|
||||
this.setData({
|
||||
argv: targv,
|
||||
special_index: e.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
scan : function(){
|
||||
const that = this
|
||||
wx.scanCode({
|
||||
success: (res) => {
|
||||
this.data.user = res.result
|
||||
if (this.data.user.length > 18) {
|
||||
let user = this.data.user
|
||||
user = user.substr(0, 16)
|
||||
user += "..."
|
||||
this.setData({
|
||||
usershow: user,
|
||||
})
|
||||
}
|
||||
else {
|
||||
this.setData({
|
||||
usershow: this.data.user
|
||||
})
|
||||
}
|
||||
wx.showToast({
|
||||
title: '成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
},
|
||||
fail: (res) => {
|
||||
wx.showToast({
|
||||
title: '失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
},
|
||||
complete: (res) => {
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
confirm:function(e){
|
||||
if (app.globalData.hasCheckPwd == true && app.globalData.hasRegister == true) {
|
||||
|
||||
if (e.detail.value.wxml_id.length == 0){
|
||||
this.setData({id_tag : "请填写密码标签"})
|
||||
let that = this
|
||||
setTimeout(function (){that.setData({
|
||||
tagclass: "pass-ipt-plus animated bounceIn",
|
||||
id_tag: ""
|
||||
})},2000)
|
||||
return;
|
||||
}
|
||||
else{
|
||||
this.setData({
|
||||
id_tag: ""
|
||||
})
|
||||
}
|
||||
this.setData({
|
||||
id: e.detail.value.wxml_id,
|
||||
user: this.data.user,
|
||||
scode: e.detail.value.wxml_scode
|
||||
})
|
||||
if (this.data.scode_0 != this.data.scode)
|
||||
this.setData({
|
||||
isscode: false
|
||||
})
|
||||
|
||||
//上传上传上传上传上传上传上传上传上传上传上传
|
||||
var ifhave=false
|
||||
let that=this
|
||||
db.collection('gaoziqi_test02').limit(1).where({
|
||||
_openid: app.globalData.openid,
|
||||
id:this.data.id
|
||||
})
|
||||
.get().then(res => {
|
||||
if(res.data.length>0){
|
||||
ifhave=true
|
||||
wx.showToast({
|
||||
title: '标题和已有标题重复,请重新输入',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
|
||||
}
|
||||
else {
|
||||
db.collection('gaoziqi_test02').add({
|
||||
data: {
|
||||
id: this.data.id,
|
||||
handle: this.data.handle,
|
||||
user: this.data.user,
|
||||
argv: this.data.argv,
|
||||
isscode: this.data.isscode
|
||||
},
|
||||
})
|
||||
}
|
||||
if(ifhave==false){
|
||||
if (this.data.isscode == false) {
|
||||
wx.cloud.callFunction({
|
||||
name: "passwd",
|
||||
data: {
|
||||
method: "customer",
|
||||
argv: {
|
||||
handle: this.data.handle,
|
||||
openid: app.globalData.openid,
|
||||
tag: this.data.id,
|
||||
passwd:this.data.scode
|
||||
}
|
||||
|
||||
},
|
||||
complete: res => {
|
||||
console.log(res)
|
||||
if (res.result.status == "ok") {
|
||||
console.log("[云函数][passwd]customer方法执行密码参数绑定成功")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
else {
|
||||
wx.cloud.callFunction({
|
||||
name: "passwd",
|
||||
data: {
|
||||
method: "saver",
|
||||
argv: {
|
||||
handle: this.data.handle,
|
||||
openid: app.globalData.openid,
|
||||
tag: this.data.id
|
||||
}
|
||||
},
|
||||
complete: res => {
|
||||
if (res.result.status == "ok") {
|
||||
console.log("[云函数][passwd]saver方法执行密码参数绑定成功")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
this.setData({
|
||||
id : "",
|
||||
user : "",
|
||||
scode : "",
|
||||
usershow : "",
|
||||
if_generate: false
|
||||
})
|
||||
wx.showToast({
|
||||
title: '密码添加成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
else {
|
||||
wx.showToast({
|
||||
title: '认证六位独立密码',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
give_scode: function () {
|
||||
if (app.globalData.hasCheckPwd == true && app.globalData.hasRegister == true){
|
||||
wx.showToast({
|
||||
title: '努力生成密码',
|
||||
icon: 'loading',
|
||||
duration: 1000
|
||||
})
|
||||
if (this.data.passwdclass == "pass-ipt animated bounceIn") {
|
||||
this.setData({
|
||||
passwdclass: "pass-ipt",
|
||||
scode: "",
|
||||
scode_0: ""
|
||||
})
|
||||
}
|
||||
wx.cloud.callFunction({
|
||||
name: 'passwd',
|
||||
data: {
|
||||
method : "encoder",
|
||||
argv: this.data.argv
|
||||
},
|
||||
complete:res=>{
|
||||
console.log("[云函数][passwd]encoder方法调用成功")
|
||||
this.setData({
|
||||
scode: res.result.passwd,
|
||||
scode_0: res.result.passwd,
|
||||
handle: res.result.handle,
|
||||
isscode: true,
|
||||
if_generate : true
|
||||
})
|
||||
this.setData({
|
||||
passwdclass: "pass-ipt animated bounceIn",
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
else{
|
||||
wx.showToast({
|
||||
title: '未认证六位密码',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
}
|
||||
},
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
||||
|
3
miniprogram/pages/create/create.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
49
miniprogram/pages/create/create.wxml
Normal file
@ -0,0 +1,49 @@
|
||||
<view class="all-container animated fadeIn">
|
||||
<form bindsubmit='confirm'>
|
||||
<view class="container">
|
||||
<input class='{{tagclass}}' name="wxml_id" placeholder="密码标签" maxlength = "14" value='{{id}}' />
|
||||
<label class="info-label animated shake" wx:if='{{id_tag != ""}}'>{{id_tag}}</label>
|
||||
</view>
|
||||
<view class="container">
|
||||
<input class='pass-ipt' name="wxml_user" placeholder="关联信息(非必须)" value='{{usershow}}' bindtap='goShow'/>
|
||||
<button class='generate-btn' bindtap='scan'>扫码</button>
|
||||
</view>
|
||||
<view class="container">
|
||||
<input class='{{passwdclass}}'name="wxml_scode" placeholder="密码" maxlength = "20" value='{{scode}}'/>
|
||||
<button class='generate-btn' bindtap='give_scode'>生成密码</button>
|
||||
</view>
|
||||
<view class="d-container">
|
||||
<view class="section-title">选择密码长度</view>
|
||||
<picker bindchange="bindLenPickerChange" value="{{len_index}}" range="{{len_array}}">
|
||||
<view class="picker">
|
||||
<text>{{len_array[len_index]}}</text>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<view class="d-container">
|
||||
<view class="section-title">是否含有大小写</view>
|
||||
<picker bindchange="bindUpperPickerChange" value="{{upper_index}}" range="{{upper_array}}">
|
||||
<view class="picker">
|
||||
<text>{{upper_array[upper_index]}}</text>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<view class="d-container">
|
||||
<view class="section-title">是否含有特殊字符</view>
|
||||
<picker bindchange="bindSpecialPickerChange" value="{{special_index}}" range="{{special_array}}">
|
||||
<view class="picker">
|
||||
<text>{{special_array[special_index]}}</text>
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view wx:if='{{if_generate}}' class = "tip-show ">
|
||||
<button class='confirm-btn animated bounceIn' form-type='submit'>添加到记事本</button>
|
||||
<text>您也可以生成密码后自定义您的密码</text>
|
||||
</view>
|
||||
<view wx:else class="tip-show">
|
||||
<text>您的密码会在云端加密储存以确保安全</text>
|
||||
</view>
|
||||
</form>
|
||||
</view>
|
133
miniprogram/pages/create/create.wxss
Normal file
@ -0,0 +1,133 @@
|
||||
/* miniprogram/pages/create/create.wxss */
|
||||
.container{
|
||||
margin-top: 15rpx;
|
||||
display: flex;
|
||||
/*row 横向 column 列表 */
|
||||
flex-direction: row;
|
||||
background-color: #f9f7f7;
|
||||
border-radius: 15rpx;
|
||||
margin-left:15rpx;
|
||||
margin-right:15rpx;
|
||||
}
|
||||
|
||||
.d-container{
|
||||
display: flex;
|
||||
/*row 横向 column 列表 */
|
||||
flex-direction: column;
|
||||
background-color: white;
|
||||
border-radius: 15rpx;
|
||||
border-style: solid;
|
||||
border-width: 4rpx;
|
||||
border-color: #85C1E9;
|
||||
margin-bottom: 20rpx;
|
||||
margin-left: 15rpx;
|
||||
margin-right: 15rpx;
|
||||
margin-top: 15rpx;
|
||||
}
|
||||
|
||||
.section-title{
|
||||
border-style: solid;
|
||||
border-color: #85C1E9;
|
||||
border-width: 1rpx;
|
||||
border-top: 0rpx;
|
||||
border-left: 0rpx;
|
||||
border-right: 0rpx;
|
||||
background-color: #3f72af;
|
||||
font-size: 30rpx;
|
||||
color: #fcf9ec;
|
||||
}
|
||||
|
||||
.picker{
|
||||
height: 80rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
font-size: 35rpx;
|
||||
background-color: #dbe2ef;
|
||||
color: #454d66;
|
||||
}
|
||||
.picker-text{
|
||||
margin-top: 15rpx;
|
||||
}
|
||||
|
||||
.pass-ipt{
|
||||
border-style: solid;
|
||||
border-width: 4rpx;
|
||||
height: 110rpx;
|
||||
width: 450rpx;
|
||||
border-radius: 15rpx;
|
||||
margin-bottom: 15rpx;
|
||||
border-color: #3f72af;
|
||||
font-size: 40rpx;
|
||||
text-align: center;
|
||||
background-color: #dbe2ef;
|
||||
}
|
||||
|
||||
.pass-ipt-plus{
|
||||
border-style: solid;
|
||||
border-width: 4rpx;
|
||||
height: 110rpx;
|
||||
width: 700rpx;
|
||||
border-radius: 15rpx;
|
||||
margin-bottom: 15rpx;
|
||||
border-color: #3f72af;
|
||||
font-size: 40rpx;
|
||||
text-align: center;
|
||||
background-color: #dbe2ef;
|
||||
}
|
||||
|
||||
.blank-view{
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.generate-btn{
|
||||
position: relative;
|
||||
top:0rpx;
|
||||
height: 110rpx;
|
||||
border-style: solid;
|
||||
border-width: 4rpx;
|
||||
width: 200rpx;
|
||||
border-color: #85C1E9;
|
||||
border-radius: 15rpx;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
padding: 0rpx;
|
||||
font-size: 40rpx;
|
||||
background-color: #3f72af;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.all-container{
|
||||
margin-left: 25rpx;
|
||||
margin-right: 25rpx;
|
||||
margin-top: 25rpx;
|
||||
border-radius: 15rpx;
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
border-color: #85C1E9;
|
||||
/*background-color: #f9f7f7;*/
|
||||
background-color: #f9f7f7;
|
||||
font-family: Arial, "Microsoft YaHei";
|
||||
}
|
||||
|
||||
.confirm-btn{
|
||||
background-color: #112d4e;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.info-label{
|
||||
text-align: center;
|
||||
font-size: 30rpx;
|
||||
color: red;
|
||||
}
|
||||
|
||||
.next-btn{
|
||||
background-color: #112d4e;
|
||||
color: #f9f7f7;
|
||||
}
|
||||
|
||||
.tip-show{
|
||||
text-align: center;
|
||||
font-size: 30rpx;
|
||||
color: grey;
|
||||
}
|
304
miniprogram/pages/index/index.js
Normal file
@ -0,0 +1,304 @@
|
||||
//index.js
|
||||
const app = getApp()
|
||||
const db = wx.cloud.database()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
avatarUrl: './user-unlogin.png',
|
||||
userInfo: {},
|
||||
logged: false,
|
||||
takeSession: false,
|
||||
requestResult: '',
|
||||
test: "Hello",
|
||||
passwd_num : 0,
|
||||
ifGetUser : null,
|
||||
ifCheckPwd: false,
|
||||
ifgetdays: false,
|
||||
days : 0,
|
||||
ifchangecode: false,
|
||||
ifchangecode1: false,
|
||||
button1: true,
|
||||
},
|
||||
|
||||
goChange: function(e){
|
||||
this.setData({
|
||||
ifchangecode: true
|
||||
})
|
||||
},
|
||||
|
||||
cancelChange: function(){
|
||||
this.setData({
|
||||
ifchangecode: false,
|
||||
ifchangecode1: false,
|
||||
button1: true,
|
||||
})
|
||||
},
|
||||
|
||||
changecode: function (e) {
|
||||
if(app.globalData.hasCheckPwd&&app.globalData.hasRegister){
|
||||
var old = null
|
||||
|
||||
let that = this
|
||||
db.collection("users").where({
|
||||
openid: app.globalData.openid
|
||||
}).limit(1).get().then(res => {
|
||||
if (res.data.length > 0) {
|
||||
let that=this
|
||||
wx.showToast({
|
||||
title: '正在验证密码',
|
||||
icon: 'loading',
|
||||
duration: 600
|
||||
})
|
||||
wx.cloud.callFunction({
|
||||
name: 'checkPwd',
|
||||
data: {
|
||||
passwd: e.detail.value.wxml_oldcode
|
||||
},
|
||||
complete:res=>{
|
||||
if (res.result.status == "success" && e.detail.value.wxml_oldcode.length) {
|
||||
this.setData({
|
||||
ifchangecode1: true,
|
||||
ifchangecode: false,
|
||||
button1: false,
|
||||
})
|
||||
wx.showToast({
|
||||
title: '请输入您的新密码',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
|
||||
}
|
||||
else if (e.detail.value.wxml_oldcode.length){
|
||||
wx.showToast({
|
||||
title: '密码错误',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
})
|
||||
}
|
||||
else {
|
||||
wx.showToast({
|
||||
title: '请注册',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
else{
|
||||
wx.showToast({
|
||||
title: '请登录',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
|
||||
})
|
||||
}
|
||||
},
|
||||
changecode1: function (e) {
|
||||
if (e.detail.value.wxml_newcode == e.detail.value.wxml_newcode1 && e.detail.value.wxml_newcode.length > 5 && this.data.ifchangecode1 == true) {
|
||||
wx.showToast({
|
||||
title: '成功更改密码',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
let that = this
|
||||
wx.cloud.callFunction({
|
||||
name: 'changePwd',
|
||||
data: {
|
||||
passwd: e.detail.value.wxml_newcode
|
||||
},
|
||||
})
|
||||
this.setData({
|
||||
ifchangecode1: false,
|
||||
ifchangecode: false,
|
||||
button1: true,
|
||||
})
|
||||
|
||||
}
|
||||
else if (e.detail.value.wxml_newcode != e.detail.value.wxml_newcode1) {
|
||||
wx.showToast({
|
||||
title: '两次输入需相同!',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
|
||||
}
|
||||
else if (e.detail.value.wxml_newcode.length <= 5) {
|
||||
wx.showToast({
|
||||
title: '密码需要六位',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
|
||||
}
|
||||
else {
|
||||
wx.showToast({
|
||||
title: '未知错误',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
}
|
||||
},
|
||||
goRegister: function(){
|
||||
if (app.globalData.hasRegister == false) {
|
||||
wx.navigateTo({
|
||||
url: '../checkPwd/checkPwd',
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
goCheck:function(){
|
||||
if(app.globalData.hasCheckPwd == false){
|
||||
wx.navigateTo({
|
||||
url: '../loginPwd/loginPwd',
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onLoad: function() {
|
||||
if (!wx.cloud) {
|
||||
wx.redirectTo({
|
||||
url: '../chooseLib/chooseLib',
|
||||
})
|
||||
}
|
||||
this.onGetOpenid()
|
||||
|
||||
},
|
||||
|
||||
onShow: function() {
|
||||
if(app.globalData.refresh == true){
|
||||
this.onGetOpenid()
|
||||
app.globalData.refresh == false
|
||||
if(app.globalData.hasCheckPwd){
|
||||
this.setData({
|
||||
ifCheckPwd : true
|
||||
})
|
||||
}
|
||||
}
|
||||
if (app.globalData.refreshCheck == true) {
|
||||
if (app.globalData.hasCheckPwd) {
|
||||
this.setData({
|
||||
ifCheckPwd: true
|
||||
})
|
||||
}
|
||||
app.globalData.refreshCheck = false
|
||||
}
|
||||
if (app.globalData.hasRegister == true){
|
||||
db.collection("gaoziqi_test02").where({
|
||||
_openid: app.globalData.openid
|
||||
}).get().then(res => {
|
||||
var that = this
|
||||
db.collection('gaoziqi_test02').where({
|
||||
_openid: app.globalData.openid
|
||||
}).count({success: function(res){
|
||||
that.setData({
|
||||
passwd_num: res.total
|
||||
})
|
||||
}})
|
||||
|
||||
})
|
||||
var cdate = app.globalData.userInfo.date
|
||||
var ndate = Date.parse(new Date())
|
||||
var fdate = new Date(ndate - cdate)
|
||||
this.setData({
|
||||
days: fdate.getDate(),
|
||||
ifgetdays : true
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onGetUserInfo: function(e) {
|
||||
if (!this.logged && e.detail.userInfo) {
|
||||
this.setData({
|
||||
logged: true,
|
||||
avatarUrl: e.detail.userInfo.avatarUrl,
|
||||
userInfo: e.detail.userInfo
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onGetOpenid: function() {
|
||||
// 调用云函数
|
||||
wx.cloud.callFunction({
|
||||
name: 'login',
|
||||
data: {},
|
||||
success: res => {
|
||||
console.log('[云函数][login]获得用户的openid成功:', res.result.openid)
|
||||
app.globalData.openid = res.result.openid
|
||||
let that = this;
|
||||
wx.cloud.callFunction({
|
||||
name: 'check',
|
||||
data: {},
|
||||
success : res=>{
|
||||
console.log('[云函数] [check] 获取用户数据云函数调用成功')
|
||||
if (res.result.status == "UserNotFound") {
|
||||
console.log("[状态]未获得用户注册数据")
|
||||
app.globalData.hasRegister = false
|
||||
this.setData({
|
||||
ifGetUser: false
|
||||
})
|
||||
}
|
||||
else {
|
||||
console.log("[应用状态]成功获取用户注册数据")
|
||||
app.globalData.userInfo = res.result.userInfo
|
||||
app.globalData.hasRegister = true
|
||||
|
||||
that.setData({
|
||||
ifGetUser: true
|
||||
})
|
||||
if(app.globalData.hasRegister)
|
||||
db.collection('gaoziqi_test02').where({
|
||||
_openid: app.globalData.openid
|
||||
}).count({
|
||||
success: function (res) {
|
||||
that.setData({
|
||||
passwd_num: res.total
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
if (app.globalData.hasRegister == false) {
|
||||
wx.navigateTo({
|
||||
url: '../checkPwd/checkPwd',
|
||||
})
|
||||
}
|
||||
else {
|
||||
if (app.globalData.hasCheckPwd == false) {
|
||||
wx.navigateTo({
|
||||
url: '../loginPwd/loginPwd',
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
fail : err=>{
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
console.error('[云函数][login]调用失败', err)
|
||||
wx.navigateTo({
|
||||
url: '../deployFunctions/deployFunctions',
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
clickMe : function (){
|
||||
db.collection("users").where({
|
||||
name: "time"
|
||||
}).limit(1).get({
|
||||
success : function(res){
|
||||
console.log(res.data)
|
||||
},
|
||||
fail : function(err){
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
})
|
3
miniprogram/pages/index/index.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
58
miniprogram/pages/index/index.wxml
Normal file
@ -0,0 +1,58 @@
|
||||
<!--index.wxml-->
|
||||
<view class="container">
|
||||
|
||||
<view class='show-view' wx:if='{{ifGetUser == true}}'>
|
||||
<open-data class = "avatar animated rubberBand" type="userAvatarUrl"></open-data>
|
||||
<open-data class='show-name' type="userNickName"></open-data>
|
||||
</view>
|
||||
<view class='show-register animated fadeIn' wx:elif='{{ifGetUser == false}}'>
|
||||
<button class='register-button ' bindtap='goRegister'>注册</button>
|
||||
</view>
|
||||
<view class='show-register animated fadeIn' wx:else>
|
||||
<view class='loading animated flash'>
|
||||
<text>正在加载数据...</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uploader animated fadeInRight" wx:if="{{ifgetdays == true}}">
|
||||
<view class="uploader-text">
|
||||
<text>已使用密码便签</text>
|
||||
</view>
|
||||
<text class="pwd_num">{{days}}天</text>
|
||||
</view>
|
||||
|
||||
<!-- 上传图片 -->
|
||||
<view class="uploader animated fadeInRight" wx:if="{{ifCheckPwd == true && ifchangecode1 == false && ifchangecode == false}}">
|
||||
<view class="uploader-text">
|
||||
<text>已储存密码便签数量</text>
|
||||
</view>
|
||||
<text class="pwd_num">{{passwd_num}}条标签</text>
|
||||
</view>
|
||||
<view wx:if="{{ifCheckPwd == false && ifGetUser}}">
|
||||
<button class='check-button animated fadeIn delay-3s' bindtap='goCheck'>请认证六位独立密码</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<text>\n</text>
|
||||
|
||||
<button wx:if='{{button1 && ifGetUser && ifCheckPwd && ifchangecode==false}}' class='cd' bindtap="goChange">修改六位独立密码</button>
|
||||
<button wx:if='{{ ifGetUser && ifCheckPwd && ifchangecode}}' class='cd-1' bindtap='cancelChange' class="button-cancel">取消</button>
|
||||
<form bindsubmit='changecode' class = 'animated fadeInRight' wx:if='{{ifGetUser && ifCheckPwd}}'>
|
||||
<view class='container-change animated bounce' wx:if='{{ifchangecode}}'>
|
||||
<input class='cd' type='number' password='true' name='wxml_oldcode'maxlength='6'placeholder="请输入原始密码" focus='true'></input>
|
||||
<button class='cd-1' form-type='submit'>确定</button>
|
||||
</view>
|
||||
</form>
|
||||
<view wx:if='{{ifchangecode1}}' class="change-form-all">
|
||||
<form bindsubmit='changecode1'>
|
||||
<view wx:if='{{ifchangecode1}}' class="change-form animated bounce">
|
||||
<input class='cd' type='number' password='true' name='wxml_newcode'maxlength='6'placeholder="请输入新密码" focus='true'></input>
|
||||
<input class='cd' type='number' password='true' name='wxml_newcode1'maxlength='6'placeholder="请确认新密码"></input>
|
||||
</view>
|
||||
<view wx:if='{{ifchangecode1}}' class="change-form-button animated bounce">
|
||||
<button class='cd-1'form-type='submit' class="change-form-button-yes">确定</button>
|
||||
<button class='cd-1' bindtap='cancelChange' class="change-form-button-no">取消</button>
|
||||
</view>
|
||||
</form>
|
||||
</view>
|
||||
|
299
miniprogram/pages/index/index.wxss
Normal file
@ -0,0 +1,299 @@
|
||||
/**index.wxss**/
|
||||
|
||||
page {
|
||||
background: #f6f6f6;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.container-change{
|
||||
margin-top: 15rpx;
|
||||
display: flex;
|
||||
/*row 横向 column 列表 */
|
||||
flex-direction: row;
|
||||
background-color: #f9f7f7;
|
||||
border-radius: 15rpx;
|
||||
margin-left:15rpx;
|
||||
margin-right:15rpx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.avatar{
|
||||
margin-top: 50rpx;
|
||||
height: 200rpx;
|
||||
width: 200rpx;
|
||||
border-radius:50%;
|
||||
display: flex;
|
||||
overflow:hidden;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.show-view{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
background-color: white;
|
||||
margin-top: 10rpx;
|
||||
width: 720rpx;
|
||||
border-radius: 20rpx;
|
||||
height: 400rpx;
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
border-color: #3f72af;
|
||||
}
|
||||
|
||||
.show-register{
|
||||
align-items: center;
|
||||
background-color: white;
|
||||
margin-top: 10rpx;
|
||||
width: 720rpx;
|
||||
border-radius: 20rpx;
|
||||
height: 400rpx;
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
border-color: #3f72af;
|
||||
}
|
||||
|
||||
.register-button{
|
||||
margin-left: 165rpx;
|
||||
margin-top: 150rpx;
|
||||
background-color:#3f72af;
|
||||
color:white;
|
||||
width: 400rpx;
|
||||
}
|
||||
|
||||
.check-button{
|
||||
margin-top: 150rpx;
|
||||
background-color:#3f72af;
|
||||
color:white;
|
||||
width: 450rpx;
|
||||
}
|
||||
|
||||
.loading{
|
||||
margin-left: 150rpx;
|
||||
margin-right: 150rpx;
|
||||
margin-top: 160rpx;
|
||||
text-align: center;
|
||||
color: #112d4e;
|
||||
font-size: 35rpx;
|
||||
}
|
||||
|
||||
.show-name{
|
||||
font-size: 40rpx;
|
||||
}
|
||||
.cd{
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
height: 110rpx;
|
||||
width: 450rpx;
|
||||
border-radius: 15rpx;
|
||||
margin-bottom: 15rpx;
|
||||
border-color: #3f72af;
|
||||
font-size: 40rpx;
|
||||
text-align: center;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.cd-1{
|
||||
position: relative;
|
||||
top:0rpx;
|
||||
height: 110rpx;
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
width: 200rpx;
|
||||
border-color: rgb(255, 255, 255);
|
||||
border-radius: 15rpx;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
padding: 0rpx;
|
||||
font-size: 40rpx;
|
||||
background-color: #3f72af;
|
||||
color: white;
|
||||
}
|
||||
.userinfo, .uploader, .tunnel, {
|
||||
margin-top: 40rpx;
|
||||
height: 140rpx;
|
||||
width: 100%;
|
||||
background: #fff;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
transition: all 300ms ease;
|
||||
}
|
||||
|
||||
.userinfo-avatar {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
margin: 20rpx;
|
||||
border-radius: 50%;
|
||||
background-size: cover;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.userinfo-avatar:after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.userinfo-nickname {
|
||||
font-size: 32rpx;
|
||||
color: purple;
|
||||
background-color: white;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.userinfo-nickname::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.uploader, .tunnel {
|
||||
display: flex;
|
||||
height: 200rpx;
|
||||
flex-direction: column;
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
border-color: #3f72af;
|
||||
}
|
||||
|
||||
.pwd_num {
|
||||
text-align: center;
|
||||
font-size: 35rpx;
|
||||
}
|
||||
|
||||
.uploader-text, .tunnel-text {
|
||||
width: 100%;
|
||||
line-height: 52px;
|
||||
font-size: 34rpx;
|
||||
color: #007aff;
|
||||
}
|
||||
|
||||
.uploader-container {
|
||||
width: 100%;
|
||||
height: 400rpx;
|
||||
padding: 20rpx 20rpx 20rpx 0;
|
||||
display: flex;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.uploader-image {
|
||||
width: 100%;
|
||||
height: 360rpx;
|
||||
}
|
||||
|
||||
.tunnel {
|
||||
padding: 0 0 0 40rpx;
|
||||
}
|
||||
|
||||
.tunnel-text {
|
||||
position: relative;
|
||||
color: #222;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-content: center;
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.tunnel-text:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.tunnel-switch {
|
||||
position: absolute;
|
||||
right: 20rpx;
|
||||
top: -2rpx;
|
||||
}
|
||||
|
||||
.disable {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.service {
|
||||
position: fixed;
|
||||
right: 40rpx;
|
||||
bottom: 40rpx;
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(#007aff, #0063ce);
|
||||
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
|
||||
display: flex;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
transition: all 300ms ease;
|
||||
}
|
||||
|
||||
.service-button {
|
||||
position: absolute;
|
||||
top: 40rpx;
|
||||
}
|
||||
|
||||
.service:active {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.request-text {
|
||||
padding: 20rpx 0;
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.custom-css {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.change-form{
|
||||
margin-top: 50rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.change-form-button{
|
||||
display: flex;
|
||||
flex-direction: rows;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.change-form-button-yes{
|
||||
width: 300rpx;
|
||||
background-color:#3f72af;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.change-form-button-no{
|
||||
width: 200rpx;
|
||||
background-color:#3f72af;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.change-form-all{
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
border-color: #3f72af;
|
||||
height: 450rpx;
|
||||
}
|
||||
|
||||
.button-cancel{
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
height: 110rpx;
|
||||
width: 450rpx;
|
||||
border-radius: 15rpx;
|
||||
margin-bottom: 15rpx;
|
||||
border-color: #3f72af;
|
||||
font-size: 40rpx;
|
||||
text-align: center;
|
||||
background-color: #ffffff;
|
||||
}
|
BIN
miniprogram/pages/index/user-unlogin.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
118
miniprogram/pages/loginPwd/loginPwd.js
Normal file
@ -0,0 +1,118 @@
|
||||
// miniprogram/pages/loginPwd/loginPwd.js
|
||||
const app = getApp()
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
mover: "data animated bounce",
|
||||
pwd : ""
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
onShow:function(options){
|
||||
|
||||
},
|
||||
|
||||
getPwdInfo: function(e) {
|
||||
let that = this
|
||||
wx.cloud.callFunction({
|
||||
name: 'checkPwd',
|
||||
data: {
|
||||
passwd: e.detail.value.passwd
|
||||
},
|
||||
success: res => {
|
||||
if(res.result.status == "success"){
|
||||
console.log("[云函数][checkPwd]执行密码哈希验证方式成功")
|
||||
wx.showToast({
|
||||
title: '验证成功',
|
||||
icon: 'success',
|
||||
duration: 800
|
||||
})
|
||||
app.globalData.hasCheckPwd = true
|
||||
app.globalData.refreshCheck = true
|
||||
setTimeout(function () { wx.navigateBack() }, 800)
|
||||
}
|
||||
else {
|
||||
console.log("[云函数][checkPwd]执行密码哈希验证方式失败")
|
||||
if (that.data.mover == "data animated shake"){
|
||||
that.setData({
|
||||
mover: "",
|
||||
})
|
||||
that.setData({
|
||||
mover: "data animated shake",
|
||||
pwd: ""
|
||||
})
|
||||
}
|
||||
else{
|
||||
that.setData({
|
||||
mover: "data animated shake",
|
||||
pwd: ""
|
||||
})
|
||||
}
|
||||
|
||||
app.globalData.hasCheckPwd = false
|
||||
}
|
||||
},
|
||||
fail: err => {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
3
miniprogram/pages/loginPwd/loginPwd.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
10
miniprogram/pages/loginPwd/loginPwd.wxml
Normal file
@ -0,0 +1,10 @@
|
||||
<view class='{{mover}}'>
|
||||
<view>
|
||||
<form bindsubmit='getPwdInfo' >
|
||||
<view class="data-text"></view>
|
||||
<text class="data-text">验证六位独立密码</text>
|
||||
<input type='number' password='true' class="passwd" name="passwd" focus='true' maxlength='6' value="{{pwd}}"></input>
|
||||
<button form-type="submit" class="set-button">确定</button>
|
||||
</form>
|
||||
</view>
|
||||
</view>
|
43
miniprogram/pages/loginPwd/loginPwd.wxss
Normal file
@ -0,0 +1,43 @@
|
||||
/* miniprogram/pages/loginPwd/loginPwd.wxss */
|
||||
/* miniprogram/pages/checkPwd/checkPwd.wxss */
|
||||
.passwd{
|
||||
background-color: #dbe2ef;
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
border-color: #85C1E9;
|
||||
width: 400rpx;
|
||||
height: 80rpx;
|
||||
margin-left: 150rpx;
|
||||
margin-right: 150rpx;
|
||||
margin-top: 80rpx;
|
||||
text-align: center;
|
||||
font-size: 60rpx;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
|
||||
.data{
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
border-color: #3f72af;
|
||||
background-color: white;
|
||||
margin-top: 80rpx;
|
||||
margin-left: 20rpx;
|
||||
margin-right: 20rpx;
|
||||
border-radius: 20rpx;
|
||||
height: 480rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.set-button{
|
||||
background-color:#3f72af;
|
||||
color:white;
|
||||
margin-left: 50rpx;
|
||||
margin-right: 50rpx;
|
||||
margin-top: 110rpx;
|
||||
}
|
||||
|
||||
.data-text{
|
||||
height: 30rpx;
|
||||
color: #112d4e;
|
||||
background-color: white;
|
||||
}
|
178
miniprogram/pages/logs/logs.js
Normal file
@ -0,0 +1,178 @@
|
||||
//index.js
|
||||
//获取应用实例
|
||||
const app = getApp()
|
||||
const db = wx.cloud.database()
|
||||
//assciated with <scroll-view> in wxml;
|
||||
var arryHeight = 0;
|
||||
Page({
|
||||
data: {
|
||||
flag: '',
|
||||
focusKey: true,
|
||||
viewlist: [],
|
||||
showViewList:[],
|
||||
inputValue: '',
|
||||
bindlist: [],
|
||||
hideScroll: true,
|
||||
check1:false,
|
||||
check2:false
|
||||
|
||||
},
|
||||
|
||||
login: function () {
|
||||
this.setData({ check1: app.globalData.hasCheckPwd,
|
||||
check2: app.globalData.hasRegister
|
||||
})
|
||||
if(this.data.check1&&this.data.check2){
|
||||
wx.showToast({
|
||||
title: '验证成功',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
|
||||
}
|
||||
else {
|
||||
wx.showToast({
|
||||
title: '请验证六位密码',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
|
||||
}
|
||||
},
|
||||
onShow:function(){
|
||||
this.setData({ check1: app.globalData.hasCheckPwd, check2: app.globalData.hasRegister })
|
||||
var that = this
|
||||
var keyId = app.globalData.openid
|
||||
var list = []
|
||||
db.collection('gaoziqi_test02').where({
|
||||
_openid: keyId
|
||||
}).get().then(res => {
|
||||
list.push(res.data)
|
||||
this.setData({
|
||||
viewlist: list[0]
|
||||
})
|
||||
var tshowViewList = []
|
||||
for (let i = 0; i < this.data.viewlist.length; i++) {
|
||||
let show_user = this.data.viewlist[i].user.substr(0, 12)
|
||||
if (this.data.viewlist[i].user.length > 15) {
|
||||
show_user += "..."
|
||||
}
|
||||
tshowViewList.push({
|
||||
id : "[ "+this.data.viewlist[i].id+" ]",
|
||||
user : show_user
|
||||
})
|
||||
}
|
||||
this.setData({
|
||||
showViewList: tshowViewList
|
||||
})
|
||||
})
|
||||
|
||||
},
|
||||
onLoad: function(options) {
|
||||
|
||||
var that = this;
|
||||
var keyId = app.globalData.openid;
|
||||
var list = [];
|
||||
|
||||
db.collection('gaoziqi_test02').where({
|
||||
_openid: keyId
|
||||
}).get().then(res => {
|
||||
list.push(res.data)
|
||||
this.setData({
|
||||
viewlist: list[0]
|
||||
})
|
||||
})
|
||||
},
|
||||
clickEvent: function (e) {
|
||||
var ind = parseInt(e.target.id)
|
||||
wx.navigateTo({
|
||||
url: '../showPwd/showPwd?hash='+this.data.viewlist[ind].handle+"&&openid="+this.data.viewlist[ind]._openid+"&&user="+this.data.viewlist[ind].user+"&&id="+this.data.viewlist[ind].id+"&&_id="+this.data.viewlist[ind]._id+"&&handle="+this.data.viewlist[ind].handle,
|
||||
success: function (res) { },
|
||||
fail: function (res) { },
|
||||
complete: function (res) { },
|
||||
})
|
||||
},
|
||||
//失焦
|
||||
searchBlur: function (e) {
|
||||
this.setData({
|
||||
focusKey: false
|
||||
})
|
||||
},
|
||||
//聚焦
|
||||
searchFocus: function (e) {
|
||||
},
|
||||
//输入联想,模糊搜索
|
||||
inputsearch: function (event) {
|
||||
var prefix = event.detail.value
|
||||
var newSource=[]
|
||||
if (prefix != "") {
|
||||
this.data.viewlist.forEach(function (e) {
|
||||
if (e.id.indexOf(prefix) != -1) {
|
||||
newSource.push(e.id)
|
||||
}
|
||||
})
|
||||
}
|
||||
//匹配结果存在,将其返回,否则返回空数组
|
||||
if (newSource.length != 0) {
|
||||
this.setData({
|
||||
//匹配结果存在,显示自动联想词下拉列表
|
||||
hideScroll: false,
|
||||
bindlist: newSource,
|
||||
arrayHeight: newSource.length * 71
|
||||
})
|
||||
}
|
||||
else {
|
||||
this.setData({
|
||||
//匹配无结果,不显示下拉列表
|
||||
hideScroll: true,
|
||||
bindlist: []
|
||||
})
|
||||
}
|
||||
},
|
||||
itemtap: function(e){
|
||||
var item=e.currentTarget.id
|
||||
for (let i=0;i<this.data.viewlist.length;i++){
|
||||
if(this.data.viewlist[i].id == item){
|
||||
item = this.data.viewlist[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
hideScroll: true,
|
||||
}),
|
||||
console.log("CS", item.handle)
|
||||
wx.navigateTo({
|
||||
url: '../showPwd/showPwd?hash=' + item.handle + "&&openid=" + item._openid + "&&user=" + item.user + "&&id=" + item.id,
|
||||
success: function (res) { },
|
||||
fail: function (res) { },
|
||||
complete: function (res) { },
|
||||
})
|
||||
},
|
||||
gosearch: function (event) {
|
||||
if (event.detail.value) {
|
||||
this.setData({
|
||||
flag: event.detail.value,
|
||||
focusKey: true
|
||||
});
|
||||
const db = wx.cloud.database();
|
||||
db.collection('passwd_saved').where({
|
||||
id: event.detail.value
|
||||
}).get().then(res => {
|
||||
})
|
||||
}
|
||||
else {
|
||||
focusKey: false
|
||||
}
|
||||
},
|
||||
searchButton: function (event) {
|
||||
if (this.data.flag) {
|
||||
}
|
||||
else {
|
||||
wx.showToast({
|
||||
title: '请输入索引',
|
||||
icon: none,
|
||||
duration: 1500
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
3
miniprogram/pages/logs/logs.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
37
miniprogram/pages/logs/logs.wxml
Normal file
@ -0,0 +1,37 @@
|
||||
<view wx:if='{{check1&&check2}}'>
|
||||
<view class = 'margin'>
|
||||
<view class = 'searchview'>
|
||||
<view class ='overall' >
|
||||
<view class = "icon-group">
|
||||
<icon class = "iconfont icon-sousuo"></icon>
|
||||
</view>
|
||||
<input class ='search-input' type ='text' placeholder ='输入密码标签' value ='{{flag}}' confirm-type ='search' bindblur = "searchBlur" bindconfirm ='gosearch' bindinput ='inputsearch' bindfocus="{{focusKey}}"></input>
|
||||
</view>
|
||||
<scroll-view scroll-y="true" class="scrollview" hidden="{{hideScroll}}" style="{{arrayHeight>340?'height:340rpx':''}}">
|
||||
<view wx:for="{{bindlist}}" class="itemview">
|
||||
<view id="{{item}}" bindtap="itemtap" ><text>{{item}}</text></view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class = 'interval'></view>
|
||||
<block wx:for="{{showViewList}}" wx:key="index">
|
||||
<view class='showView1 animated bounceInLeft' wx:if = "{{index % 2 == 0}}">
|
||||
<view class ='textView1' bindtap='clickEvent' id="{{index}}">
|
||||
<text class="brief-title" id="{{index}}">{{item.id}}</text>
|
||||
<text class="brief" id="{{index}}">{{item.user}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class = 'showView2 animated bounceInRight' wx:if = "{{index % 2 == 1}}">
|
||||
<view class ='textView2' id="{{index}}">
|
||||
<text bindtap='clickEvent' id="{{index}}">{{item.id}}</text>
|
||||
<text id="{{index}}">{{item.user}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<view wx:if='{{!(check1&&check2)}}' >
|
||||
<view class='log'>请先验证六位密码</view>
|
||||
<button class='log' bindtap='login'>点击这里刷新</button>
|
||||
</view>
|
158
miniprogram/pages/logs/logs.wxss
Normal file
@ -0,0 +1,158 @@
|
||||
/* miniprogram/pages/logs/logs.wxss */
|
||||
|
||||
.margin{
|
||||
border-width: 1rpx;
|
||||
border-style: solid;
|
||||
border-color: #3f72af;
|
||||
border-radius: 15rpx;
|
||||
width: 749rpx;
|
||||
background-color: #85C1E9;
|
||||
margin-top: 15rpx;
|
||||
}
|
||||
.searchview{
|
||||
padding-right: 750rpx;
|
||||
background-color: #85C1E9;
|
||||
border-right: 0;
|
||||
align-content: middle;
|
||||
border-radius: 10rpx;
|
||||
padding-left: 70rpx;
|
||||
height: 70rpx;
|
||||
width: 730rpx;
|
||||
}
|
||||
.overall{
|
||||
display: flex;
|
||||
/*row 横向 column 列表 */
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
}
|
||||
.search-input{
|
||||
border-radius: 15rpx;
|
||||
padding-right: 0rpx;
|
||||
box-sizing: border-box;
|
||||
background-color: #85C1E9;
|
||||
color:#f9f7f7;
|
||||
width: 100%;
|
||||
left: 0;
|
||||
}
|
||||
.searchicon{
|
||||
position: absolute;
|
||||
width: 70rpx;
|
||||
height: 70rpx;
|
||||
background-size: 31rpx auto;
|
||||
left: 5rpx;
|
||||
top: 10rpx;
|
||||
}
|
||||
.overall {
|
||||
height: 83rpx;
|
||||
padding-right: 20rpx;
|
||||
margin-top: 10rpx;
|
||||
width: 300rpx;
|
||||
left: 20rpx;
|
||||
}
|
||||
.iconView{
|
||||
top:10rpx;
|
||||
width: 20px;
|
||||
height: 25px;
|
||||
/*border-top: 2px solid #999;
|
||||
border-right: 2px solid #999;
|
||||
/*transform: rotate(45deg);*/
|
||||
right:0%;
|
||||
}
|
||||
.interval{
|
||||
height: 25rpx;
|
||||
border-style: solid;
|
||||
border-width: 2rpx;
|
||||
border-right: 0;
|
||||
border-color: #3f72af;
|
||||
border-top: 0;
|
||||
border-left: 0;
|
||||
}
|
||||
.textView1{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color:#85C1E9;
|
||||
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
height: 110rpx;
|
||||
width: 720rpx;
|
||||
|
||||
}
|
||||
.textView2{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 110rpx;
|
||||
background-color:#dad9ff;
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
width: 720rpx;
|
||||
|
||||
}
|
||||
.showView1{
|
||||
display: flex;
|
||||
width: 750rpx;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background: #3f72af;
|
||||
height: 100rpx;
|
||||
border-style:normal;
|
||||
border-width: 10rpx;
|
||||
border-right: 0;
|
||||
border-color: #3f72af;
|
||||
}
|
||||
.showView2{
|
||||
display: flex;
|
||||
width: 750rpx;
|
||||
justify-content: center;
|
||||
height: 100rpx;
|
||||
align-items: center;
|
||||
background: #3f72af;
|
||||
border-style:normal;
|
||||
border-width: 10rpx;
|
||||
border-right: 0;
|
||||
border-color: #3f72af;
|
||||
}
|
||||
|
||||
.brief{
|
||||
color:white;
|
||||
}
|
||||
|
||||
.brief-title{
|
||||
color: white;
|
||||
}
|
||||
|
||||
.log{
|
||||
text-align: center;
|
||||
margin-top: 50rpx;
|
||||
|
||||
}
|
||||
|
||||
.scrollview{
|
||||
position: absolute;
|
||||
background-color: rgb(156, 204, 236);
|
||||
z-index: 999;
|
||||
opacity:0.9;
|
||||
text-align: center;
|
||||
border-style: solid;
|
||||
border-color: white;
|
||||
border-width: 1rpx;
|
||||
color:white;
|
||||
left: 0%;
|
||||
}
|
||||
|
||||
.itemview{
|
||||
border-color: white;
|
||||
border-width: 1rpx;
|
||||
color:white;
|
||||
margin-bottom: 2rpx;
|
||||
font-size: 50rpx;
|
||||
}
|
||||
|
||||
.iconfont{
|
||||
position: fixed;
|
||||
left: 6.8rpx;
|
||||
}
|
BIN
miniprogram/pages/logs/search.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
15
miniprogram/pages/openapi/callback/callback.js
Normal file
@ -0,0 +1,15 @@
|
||||
// miniprogram/pages/openapi/callback/callback.js
|
||||
Page({
|
||||
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
onCustomerServiceButtonClick(e) {
|
||||
console.log(e)
|
||||
},
|
||||
})
|
3
miniprogram/pages/openapi/callback/callback.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
21
miniprogram/pages/openapi/callback/callback.wxml
Normal file
@ -0,0 +1,21 @@
|
||||
<view class="container">
|
||||
<view class="list">
|
||||
<button open-type="contact" bindcontact="onCustomerServiceButtonClick">
|
||||
进入客服消息
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view class="guide">
|
||||
<text class="headline">测试须知</text>
|
||||
<text class="p">1. 需在项目根目录创建消息推送配置文件 temp-cloud-callback-config.json</text>
|
||||
<text class="p">2. 填写消息推送配置</text>
|
||||
<text class="p">3. 右键配置文件选择上传配置</text>
|
||||
<text class="p">4. 确认接收消息的云函数已上传</text>
|
||||
<text class="p">5. 在手机上测试</text>
|
||||
</view>
|
||||
|
||||
<view class="guide">
|
||||
<text class="headline">示例客服消息配置</text>
|
||||
<image class="code-image" src="../../../images/code-cloud-callback-config.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
</view>
|
3
miniprogram/pages/openapi/callback/callback.wxss
Normal file
@ -0,0 +1,3 @@
|
||||
/* miniprogram/pages/openapi/callback/callback.wxss */
|
||||
|
||||
@import "../../../style/guide.wxss";
|
60
miniprogram/pages/openapi/cloudid/cloudid.js
Normal file
@ -0,0 +1,60 @@
|
||||
// miniprogram/pages/openapi/cloudid/cloudid.js
|
||||
Page({
|
||||
|
||||
data: {
|
||||
weRunResult: '',
|
||||
userInfoResult: '',
|
||||
},
|
||||
|
||||
onGetWeRunData() {
|
||||
wx.getWeRunData({
|
||||
success: res => {
|
||||
wx.cloud.callFunction({
|
||||
name: 'echo',
|
||||
data: {
|
||||
// info 字段在云函数 event 对象中会被自动替换为相应的敏感数据
|
||||
info: wx.cloud.CloudID(res.cloudID),
|
||||
},
|
||||
}).then(res => {
|
||||
console.log('[onGetWeRunData] 收到 echo 回包:', res)
|
||||
|
||||
this.setData({
|
||||
weRunResult: JSON.stringify(res.result),
|
||||
})
|
||||
|
||||
wx.showToast({
|
||||
title: '敏感数据获取成功',
|
||||
})
|
||||
}).catch(err => {
|
||||
console.log('[onGetWeRunData] 失败:', err)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
onGetUserInfo(e) {
|
||||
console.log(e)
|
||||
wx.cloud.callFunction({
|
||||
name: 'openapi',
|
||||
data: {
|
||||
action: 'getOpenData',
|
||||
openData: {
|
||||
list: [
|
||||
e.detail.cloudID,
|
||||
]
|
||||
}
|
||||
}
|
||||
}).then(res => {
|
||||
console.log('[onGetUserInfo] 调用成功:', res)
|
||||
|
||||
this.setData({
|
||||
userInfoResult: JSON.stringify(res.result),
|
||||
})
|
||||
|
||||
wx.showToast({
|
||||
title: '敏感数据获取成功',
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
3
miniprogram/pages/openapi/cloudid/cloudid.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
41
miniprogram/pages/openapi/cloudid/cloudid.wxml
Normal file
@ -0,0 +1,41 @@
|
||||
<!--index.wxml-->
|
||||
<view class="container">
|
||||
|
||||
<view class="guide">
|
||||
<text class="headline">开放数据调用</text>
|
||||
<text class="p">通过 cloudID 获取敏感开放数据有以下两种方式</text>
|
||||
<text class="p">1. 小程序端 callFunction 自动获取</text>
|
||||
<text class="p">2. 通过 wx-server-sdk 获取</text>
|
||||
<text class="p">以下分别先后展示这两种获取方式</text>
|
||||
</view>
|
||||
|
||||
<view class="uploader">
|
||||
<button class="uploader-text" bindtap="onGetWeRunData">getWeRunData 敏感数据获取</button>
|
||||
</view>
|
||||
|
||||
<view class="guide">
|
||||
<text class="headline">测试须知</text>
|
||||
<text class="p">1. 公共库版本需大于 2.7.0</text>
|
||||
<text class="p">2. 请确保 echo 函数已上传</text>
|
||||
</view>
|
||||
|
||||
<view class="guide" style="word-break: break-all">
|
||||
{{weRunResult}}
|
||||
</view>
|
||||
|
||||
|
||||
<view class="uploader">
|
||||
<button class="uploader-text" open-type="getUserInfo" bindgetuserinfo="onGetUserInfo">getUserInfo 敏感数据获取</button>
|
||||
</view>
|
||||
|
||||
<view class="guide">
|
||||
<text class="headline">测试须知</text>
|
||||
<text class="p">1. 公共库版本需大于 2.7.0</text>
|
||||
<text class="p">2. 请确保 openapi 函数已上传</text>
|
||||
</view>
|
||||
|
||||
<view class="guide" style="word-break: break-all">
|
||||
{{userInfoResult}}
|
||||
</view>
|
||||
|
||||
</view>
|
1
miniprogram/pages/openapi/cloudid/cloudid.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import "../../../style/guide.wxss";
|
109
miniprogram/pages/openapi/openapi.js
Normal file
@ -0,0 +1,109 @@
|
||||
Page({
|
||||
|
||||
data: {
|
||||
templateMessageResult: '',
|
||||
wxacodeSrc: '',
|
||||
wxacodeResult: '',
|
||||
showClearWXACodeCache: false,
|
||||
},
|
||||
|
||||
submitTemplateMessageForm(e) {
|
||||
this.setData({
|
||||
templateMessageResult: '',
|
||||
})
|
||||
|
||||
wx.cloud.callFunction({
|
||||
name: 'openapi',
|
||||
data: {
|
||||
action: 'sendTemplateMessage',
|
||||
formId: e.detail.formId,
|
||||
},
|
||||
success: res => {
|
||||
console.warn('[云函数] [openapi] templateMessage.send 调用成功:', res)
|
||||
wx.showModal({
|
||||
title: '发送成功',
|
||||
content: '请返回微信主界面查看',
|
||||
showCancel: false,
|
||||
})
|
||||
wx.showToast({
|
||||
title: '发送成功,请返回微信主界面查看',
|
||||
})
|
||||
this.setData({
|
||||
templateMessageResult: JSON.stringify(res.result)
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '调用失败',
|
||||
})
|
||||
console.error('[云函数] [openapi] templateMessage.send 调用失败:', err)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onGetWXACode() {
|
||||
|
||||
this.setData({
|
||||
wxacodeSrc: '',
|
||||
wxacodeResult: '',
|
||||
showClearWXACodeCache: false,
|
||||
})
|
||||
|
||||
// 此处为演示,将使用 localStorage 缓存,正常开发中文件 ID 应存在数据库中
|
||||
const fileID = wx.getStorageSync('wxacodeCloudID')
|
||||
|
||||
if (fileID) {
|
||||
// 有云文件 ID 缓存,直接使用该 ID
|
||||
// 如需清除缓存,选择菜单栏中的 “工具 -> 清除缓存 -> 清除数据缓存”,或在 Storage 面板中删掉相应的 key
|
||||
this.setData({
|
||||
wxacodeSrc: fileID,
|
||||
wxacodeResult: `从本地缓存中取得了小程序码的云文件 ID`,
|
||||
showClearWXACodeCache: true,
|
||||
})
|
||||
console.log(`从本地缓存中取得了小程序码的云文件 ID:${fileID}`)
|
||||
} else {
|
||||
wx.cloud.callFunction({
|
||||
name: 'openapi',
|
||||
data: {
|
||||
action: 'getWXACode',
|
||||
},
|
||||
success: res => {
|
||||
console.warn('[云函数] [openapi] wxacode.get 调用成功:', res)
|
||||
wx.showToast({
|
||||
title: '调用成功',
|
||||
})
|
||||
this.setData({
|
||||
wxacodeSrc: res.result,
|
||||
wxacodeResult: `云函数获取二维码成功`,
|
||||
showClearWXACodeCache: true,
|
||||
})
|
||||
wx.setStorageSync('wxacodeCloudID', res.result)
|
||||
},
|
||||
fail: err => {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '调用失败',
|
||||
})
|
||||
console.error('[云函数] [openapi] wxacode.get 调用失败:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
clearWXACodeCache() {
|
||||
wx.removeStorageSync('wxacodeCloudID')
|
||||
|
||||
this.setData({
|
||||
wxacodeSrc: '',
|
||||
wxacodeResult: '',
|
||||
showClearWXACodeCache: false,
|
||||
})
|
||||
|
||||
wx.showToast({
|
||||
title: '清除成功',
|
||||
})
|
||||
},
|
||||
|
||||
})
|
||||
|
3
miniprogram/pages/openapi/openapi.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
22
miniprogram/pages/openapi/openapi.wxml
Normal file
@ -0,0 +1,22 @@
|
||||
<!--index.wxml-->
|
||||
<view class="container">
|
||||
|
||||
<view class="uploader">
|
||||
<navigator url="./serverapi/serverapi" open-type="navigate" class="uploader-text">
|
||||
<text>服务端调用</text>
|
||||
</navigator>
|
||||
</view>
|
||||
|
||||
<view class="uploader">
|
||||
<navigator url="./cloudid/cloudid" open-type="navigate" class="uploader-text">
|
||||
<text>开放数据调用</text>
|
||||
</navigator>
|
||||
</view>
|
||||
|
||||
<view class="uploader">
|
||||
<navigator url="./callback/callback" open-type="navigate" class="uploader-text">
|
||||
<text>消息推送</text>
|
||||
</navigator>
|
||||
</view>
|
||||
|
||||
</view>
|
7
miniprogram/pages/openapi/openapi.wxss
Normal file
@ -0,0 +1,7 @@
|
||||
/* miniprogram/pages/openapi/openapi.wxss */
|
||||
|
||||
@import "../../style/guide.wxss";
|
||||
|
||||
.black {
|
||||
color: black;
|
||||
}
|
109
miniprogram/pages/openapi/serverapi/serverapi.js
Normal file
@ -0,0 +1,109 @@
|
||||
Page({
|
||||
|
||||
data: {
|
||||
templateMessageResult: '',
|
||||
wxacodeSrc: '',
|
||||
wxacodeResult: '',
|
||||
showClearWXACodeCache: false,
|
||||
},
|
||||
|
||||
submitTemplateMessageForm(e) {
|
||||
this.setData({
|
||||
templateMessageResult: '',
|
||||
})
|
||||
|
||||
wx.cloud.callFunction({
|
||||
name: 'openapi',
|
||||
data: {
|
||||
action: 'sendTemplateMessage',
|
||||
formId: e.detail.formId,
|
||||
},
|
||||
success: res => {
|
||||
console.warn('[云函数] [openapi] templateMessage.send 调用成功:', res)
|
||||
wx.showModal({
|
||||
title: '发送成功',
|
||||
content: '请返回微信主界面查看',
|
||||
showCancel: false,
|
||||
})
|
||||
wx.showToast({
|
||||
title: '发送成功,请返回微信主界面查看',
|
||||
})
|
||||
this.setData({
|
||||
templateMessageResult: JSON.stringify(res.result)
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '调用失败',
|
||||
})
|
||||
console.error('[云函数] [openapi] templateMessage.send 调用失败:', err)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onGetWXACode() {
|
||||
|
||||
this.setData({
|
||||
wxacodeSrc: '',
|
||||
wxacodeResult: '',
|
||||
showClearWXACodeCache: false,
|
||||
})
|
||||
|
||||
// 此处为演示,将使用 localStorage 缓存,正常开发中文件 ID 应存在数据库中
|
||||
const fileID = wx.getStorageSync('wxacodeCloudID')
|
||||
|
||||
if (fileID) {
|
||||
// 有云文件 ID 缓存,直接使用该 ID
|
||||
// 如需清除缓存,选择菜单栏中的 “工具 -> 清除缓存 -> 清除数据缓存”,或在 Storage 面板中删掉相应的 key
|
||||
this.setData({
|
||||
wxacodeSrc: fileID,
|
||||
wxacodeResult: `从本地缓存中取得了小程序码的云文件 ID`,
|
||||
showClearWXACodeCache: true,
|
||||
})
|
||||
console.log(`从本地缓存中取得了小程序码的云文件 ID:${fileID}`)
|
||||
} else {
|
||||
wx.cloud.callFunction({
|
||||
name: 'openapi',
|
||||
data: {
|
||||
action: 'getWXACode',
|
||||
},
|
||||
success: res => {
|
||||
console.warn('[云函数] [openapi] wxacode.get 调用成功:', res)
|
||||
wx.showToast({
|
||||
title: '调用成功',
|
||||
})
|
||||
this.setData({
|
||||
wxacodeSrc: res.result,
|
||||
wxacodeResult: `云函数获取二维码成功`,
|
||||
showClearWXACodeCache: true,
|
||||
})
|
||||
wx.setStorageSync('wxacodeCloudID', res.result)
|
||||
},
|
||||
fail: err => {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '调用失败',
|
||||
})
|
||||
console.error('[云函数] [openapi] wxacode.get 调用失败:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
clearWXACodeCache() {
|
||||
wx.removeStorageSync('wxacodeCloudID')
|
||||
|
||||
this.setData({
|
||||
wxacodeSrc: '',
|
||||
wxacodeResult: '',
|
||||
showClearWXACodeCache: false,
|
||||
})
|
||||
|
||||
wx.showToast({
|
||||
title: '清除成功',
|
||||
})
|
||||
},
|
||||
|
||||
})
|
||||
|
3
miniprogram/pages/openapi/serverapi/serverapi.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
41
miniprogram/pages/openapi/serverapi/serverapi.wxml
Normal file
@ -0,0 +1,41 @@
|
||||
<view class="container">
|
||||
|
||||
|
||||
<form class="list" bindsubmit="submitTemplateMessageForm" report-submit>
|
||||
<button class="list-item" form-type="submit">
|
||||
<text>发送模板消息</text>
|
||||
</button>
|
||||
<view class="list-item" wx:if="{{templateMessageResult}}">
|
||||
<text class="request-text">调用结果:{{templateMessageResult}}</text>
|
||||
</view>
|
||||
</form>
|
||||
|
||||
<view class="guide">
|
||||
<text class="headline">测试须知</text>
|
||||
<text class="p">1. 需在手机上预览测试,工具中无效</text>
|
||||
<text class="p">2. 需上传 cloudfunctions 目录下的 openapi 云函数</text>
|
||||
<text class="p">3. 调用成功后返回到微信主界面查看收到的模板消息</text>
|
||||
</view>
|
||||
|
||||
<view class="list">
|
||||
<view class="list-item" bindtap="onGetWXACode">
|
||||
<text>获取小程序码</text>
|
||||
</view>
|
||||
<view class="list-item" wx:if="{{wxacodeResult}}">
|
||||
<text class="request-text">{{wxacodeResult}}</text>
|
||||
<text class="request-text" wx:if="{{showClearWXACodeCache}}" bindtap="clearWXACodeCache">清除缓存</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="guide">
|
||||
<text class="headline">测试须知</text>
|
||||
<text class="p">1. 需上传 cloudfunctions 目录下的 openapi 云函数</text>
|
||||
<text class="p">2. 云函数中获取图片后会上传至存储空间并返回至小程序使用和缓存</text>
|
||||
<text class="p">3. 云存储需设置为公有读</text>
|
||||
</view>
|
||||
|
||||
<view class="guide">
|
||||
<image src="{{wxacodeSrc}}" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
</view>
|
7
miniprogram/pages/openapi/serverapi/serverapi.wxss
Normal file
@ -0,0 +1,7 @@
|
||||
/* miniprogram/pages/openapi/openapi.wxss */
|
||||
|
||||
@import "../../../style/guide.wxss";
|
||||
|
||||
.black {
|
||||
color: black;
|
||||
}
|
19
miniprogram/pages/show/show.js
Normal file
@ -0,0 +1,19 @@
|
||||
var app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
user : ""
|
||||
},
|
||||
onLoad: function(option){
|
||||
this.setData({
|
||||
user: option.textdata,
|
||||
})
|
||||
},
|
||||
inputSaver: function(e){
|
||||
let pages = getCurrentPages();
|
||||
let prevPage = pages[pages.length - 2];
|
||||
prevPage.setData({
|
||||
user : e.detail.value
|
||||
})
|
||||
}
|
||||
|
||||
})
|
3
miniprogram/pages/show/show.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
4
miniprogram/pages/show/show.wxml
Normal file
@ -0,0 +1,4 @@
|
||||
<!--show.wxml-->
|
||||
<view class="container">
|
||||
<textarea class = "edit animated fadeIn" bindinput='inputSaver' value = "{{user}}"></textarea>
|
||||
</view>
|
34
miniprogram/pages/show/show.wxss
Normal file
@ -0,0 +1,34 @@
|
||||
/* miniprogram/pages/show/show.wxss */
|
||||
|
||||
.container{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
background-color: white;
|
||||
margin-top: 10rpx;
|
||||
margin-left: 15rpx;
|
||||
width: 720rpx;
|
||||
border-radius: 20rpx;
|
||||
height: 450rpx;
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
border-color: #3f72af;
|
||||
}
|
||||
|
||||
.edit{
|
||||
border-color: #3f72af;
|
||||
font-size: 40rpx;
|
||||
background-color: #dbe2ef;
|
||||
border-radius: 20rpx;
|
||||
margin-top: 15rpx;
|
||||
margin-left: 10rpx;
|
||||
width: 700rpx;
|
||||
height: 420rpx;
|
||||
}
|
||||
|
||||
.saved-btn{
|
||||
background-color:#3f72af;
|
||||
color:white;
|
||||
width: 400rpx;
|
||||
|
||||
}
|
106
miniprogram/pages/showEdit/showEdit.js
Normal file
@ -0,0 +1,106 @@
|
||||
// miniprogram/pages/showEdit/showEdit.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
content:'',
|
||||
count: 0,
|
||||
tmaxlength : 140
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
if (options.count == 1){
|
||||
this.setData({
|
||||
tmaxlength: 14
|
||||
})
|
||||
}
|
||||
this.setData({
|
||||
content: options.content,
|
||||
count: options.count
|
||||
})
|
||||
},
|
||||
inputSaver: function (e) {
|
||||
let pages = getCurrentPages();
|
||||
console.log("aaaaa", pages.length)
|
||||
let prevPage = pages[pages.length - 2];
|
||||
if(this.data.count == 1)
|
||||
prevPage.setData({
|
||||
id: e.detail.value,
|
||||
changeId: true,
|
||||
if_changed: true,
|
||||
|
||||
})
|
||||
else if(this.data.count == 2)
|
||||
prevPage.setData({
|
||||
user: e.detail.value,
|
||||
changeUser: true,
|
||||
if_changed: true,
|
||||
})
|
||||
else if(this.data.count == 3)
|
||||
prevPage.setData({
|
||||
changPPPWD: e.detail.value,
|
||||
passwd: e.detail.value,
|
||||
changePwd: true
|
||||
})
|
||||
},
|
||||
confirmFunc: function(){
|
||||
let pages = getCurrentPages()
|
||||
let prevPage = pages[pages.length - 2]
|
||||
wx.navigateBack({
|
||||
success: res=>{
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
3
miniprogram/pages/showEdit/showEdit.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
7
miniprogram/pages/showEdit/showEdit.wxml
Normal file
@ -0,0 +1,7 @@
|
||||
<!--miniprogram/pages/showEdit/showEdit.wxml-->
|
||||
<view class="container">
|
||||
<textarea class = "edit animated fadeIn" maxlength = "{{tmaxlength}}" bindinput='inputSaver' focus='true' value = "{{content}}" id = '{{count}}'></textarea>
|
||||
</view>
|
||||
<button class = "confirmView" bindtap='confirmFunc'>
|
||||
确定
|
||||
</button>
|
33
miniprogram/pages/showEdit/showEdit.wxss
Normal file
@ -0,0 +1,33 @@
|
||||
/* miniprogram/pages/showEdit/showEdit.wxss */
|
||||
.edit{
|
||||
border-color: #3f72af;
|
||||
font-size: 40rpx;
|
||||
background-color: #dbe2ef;
|
||||
border-radius: 20rpx;
|
||||
margin-top: 15rpx;
|
||||
margin-left: 10rpx;
|
||||
width: 700rpx;
|
||||
height: 420rpx;
|
||||
border-width: 1rpx;
|
||||
border-style: solid;
|
||||
}
|
||||
.icon-group{
|
||||
width:100%;
|
||||
border-radius: 3px;
|
||||
padding-top:2px;
|
||||
font-size:14px;
|
||||
background-color:#CC3333;
|
||||
color:white;
|
||||
overflow:hidden;
|
||||
height:45px;
|
||||
bottom: 0;
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
.confirmView{
|
||||
background-color:#3f72af;
|
||||
color:white;
|
||||
border-radius: 15rpx;
|
||||
width: 710rpx;
|
||||
margin-top: 15rpx;
|
||||
}
|
238
miniprogram/pages/showPwd/showPwd.js
Normal file
@ -0,0 +1,238 @@
|
||||
// miniprogram/pages/showPwd/showPwd.js
|
||||
const db = wx.cloud.database()
|
||||
const app=getApp()
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
handle: '',
|
||||
_openid: '',
|
||||
_hash: '',
|
||||
passwd: '',
|
||||
_id: '',
|
||||
id: '',
|
||||
user: '',
|
||||
changPPPWD :"",
|
||||
changePwd: false,
|
||||
changeId: false,
|
||||
changeUser: false,
|
||||
mHidden: true,
|
||||
if_changed: false
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
this.setData({
|
||||
_hash: options.hash,
|
||||
_openid: options.openid,
|
||||
id: options.id,
|
||||
_id: options._id,
|
||||
user: options.user,
|
||||
handle: options.handle
|
||||
})
|
||||
//this.showPwd()
|
||||
},
|
||||
copyPwd: function(){
|
||||
wx.setClipboardData({
|
||||
data: this.data.passwd,
|
||||
success: function(res) {
|
||||
wx.showToast({
|
||||
title: '复制成功',
|
||||
icon: 'success',
|
||||
duration: 1000
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
onShow: function(){
|
||||
if (this.data.changePwd) {
|
||||
wx.cloud.callFunction({
|
||||
name: "passwd",
|
||||
data: {
|
||||
method: "deleter",
|
||||
argv: {
|
||||
handle: this.data._hash,
|
||||
openid: this.data._openid
|
||||
}
|
||||
},
|
||||
success: res => {
|
||||
}
|
||||
})
|
||||
wx.cloud.callFunction({
|
||||
name: "passwd",
|
||||
data: {
|
||||
method: "customer",
|
||||
argv: {
|
||||
handle: this.data._hash,
|
||||
openid: this.data._openid,
|
||||
tag: this.data.id,
|
||||
passwd: this.data.changPPPWD
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
if(this.data.if_changed){
|
||||
db.collection('gaoziqi_test02').doc(this.data._id).update({
|
||||
data: {
|
||||
id: this.data.id,
|
||||
handle: this.data._hash,
|
||||
user: this.data.user
|
||||
},
|
||||
complete: res => {
|
||||
console.log("更新数据库信息成功")
|
||||
}
|
||||
})
|
||||
}
|
||||
if (this.data.if_changed || this.data.passwd == ''){
|
||||
this.showPwd()
|
||||
}
|
||||
this.setData({
|
||||
if_changed: false
|
||||
})
|
||||
},
|
||||
confirmFunc: function(e){
|
||||
this.cancel()
|
||||
this.setData({
|
||||
mHidden: true
|
||||
})
|
||||
},
|
||||
cancelFunc: function(e){
|
||||
this.setData({
|
||||
mHidden: true
|
||||
})
|
||||
},
|
||||
clickCancel: function(){
|
||||
/*this.setData({
|
||||
mHidden: false
|
||||
})*/
|
||||
let that = this
|
||||
wx.showModal({
|
||||
title: '你要删除这条标签对吗?',
|
||||
content: "“" + "你确定删.除.这.条.标.签" + '”,对吗?',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
that.confirmFunc()
|
||||
}
|
||||
else{
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
cancel: function(e){
|
||||
wx.cloud.callFunction({
|
||||
name: "passwd",
|
||||
data: {
|
||||
method: "deleter",
|
||||
argv: {
|
||||
handle: this.data._hash,
|
||||
openid: app.globalData.openid
|
||||
}
|
||||
},
|
||||
complete: res=>{
|
||||
console.log(res)
|
||||
if(res.result.status == "ok"){
|
||||
console.log("[云函数][passwd]deleter方法成功删除便签关联密码")
|
||||
}
|
||||
}
|
||||
})
|
||||
db.collection('gaoziqi_test02').doc(this.data._id).remove({
|
||||
success: res => {
|
||||
this.setData({
|
||||
handle: '',
|
||||
_openid: '',
|
||||
passwd: '',
|
||||
id: '',
|
||||
_id: '',
|
||||
user: '',
|
||||
})
|
||||
},
|
||||
})
|
||||
wx.navigateBack({
|
||||
success: res=>{
|
||||
wx.showToast({
|
||||
title: '删除成功',
|
||||
duration: 1000
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
showPwd:function(res){
|
||||
wx.cloud.callFunction({
|
||||
name : "passwd",
|
||||
data : {
|
||||
method : "decoder",
|
||||
argv : {
|
||||
handle : this.data._hash,
|
||||
openid : this.data._openid
|
||||
}
|
||||
},
|
||||
success: res=>{
|
||||
if (res.result.status == "ok") {
|
||||
console.log("[云函数][passwd]decoder方法成功解密用户密码")
|
||||
}
|
||||
this.setData({
|
||||
passwd:res.result.passwd
|
||||
})
|
||||
},
|
||||
fail: err=>{
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
tapEdit:function(e){
|
||||
var content = e.target.id
|
||||
var count = e.currentTarget.dataset.experienced
|
||||
wx.navigateTo({
|
||||
url:'../showEdit/showEdit?content='+content+'&&count='+count,
|
||||
success: function (res) { },
|
||||
fail: function (res) { },
|
||||
complete: function (res) { },
|
||||
})
|
||||
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
3
miniprogram/pages/showPwd/showPwd.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
24
miniprogram/pages/showPwd/showPwd.wxml
Normal file
@ -0,0 +1,24 @@
|
||||
<!--miniprogram/pages/showPwd/showPwd.wxml-->
|
||||
<view class ='overall'>
|
||||
<view class = "tag-show animated fadeInRight">
|
||||
<view class='show'>{{id}}</view>
|
||||
<button class ='edit-title' bindtap ='tapEdit' id = "{{id}}" data-experienced = "{{1}}">
|
||||
编辑
|
||||
</button>
|
||||
</view>
|
||||
<view class = "user-show animated fadeInRight">
|
||||
<label>{{user}}</label>
|
||||
<button class='edit' bindtap ='tapEdit' id = "{{user}}" data-experienced = "{{2}}">
|
||||
编辑
|
||||
</button>
|
||||
</view>
|
||||
<view class = "passwd-show animated fadeInRight" wx:if='{{passwd != ""}}'>
|
||||
<view class="passwd-text">密码: {{passwd}}</view>
|
||||
</view>
|
||||
<view class ="passwd-copy animated fadeInRight delay-1s" bindtap='copyPwd' wx:if='{{passwd != ""}}'>复制密码</view>
|
||||
</view>
|
||||
<view class = "icon-group">
|
||||
<icon class = "iconfont icon-shanchu" bindtap='clickCancel' ></icon>
|
||||
<modal title = "您确定要删除这条记录?" confirm-text = "确定" cancel-text = "取消"
|
||||
hidden = "{{mHidden}}" bindconfirm = "confirmFunc" bindcancel = "cancelFunc"></modal>
|
||||
</view>
|
122
miniprogram/pages/showPwd/showPwd.wxss
Normal file
@ -0,0 +1,122 @@
|
||||
/* miniprogram/pages/showPwd/showPwd.wxss */
|
||||
.overall{
|
||||
left:20rpx;
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
background-color: #d8f3fa;
|
||||
height:100%;
|
||||
word-break:break-all;
|
||||
}
|
||||
.container{
|
||||
margin-top: 15rpx;
|
||||
display: flex;
|
||||
/*row 横向 column 列表 */
|
||||
flex-direction: row;
|
||||
background-color: #f7f8f9;
|
||||
border-radius: 15rpx;
|
||||
margin-left:15rpx;
|
||||
margin-right:15rpx;
|
||||
}
|
||||
|
||||
.edit-title{
|
||||
position: fixed;
|
||||
color: #3f72af;
|
||||
bottom: 20rpx;
|
||||
right: 0;
|
||||
text-align: right;
|
||||
height: 70rpx;
|
||||
}
|
||||
.edit{
|
||||
position: fixed;
|
||||
color: #3f72af;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
text-align: right;
|
||||
}
|
||||
.show{
|
||||
position: fixed;
|
||||
font-size: 40rpx;
|
||||
font-weight:bold;
|
||||
width: 80%;
|
||||
bottom: 20rpx;
|
||||
left: 10rpx;
|
||||
|
||||
}
|
||||
.isRuleShow {
|
||||
opacity: 1;
|
||||
}
|
||||
.isRuleHide {
|
||||
opacity: 0;
|
||||
}
|
||||
.tag-show{
|
||||
display: flex;
|
||||
flex-direction: rows;
|
||||
margin-top: 15rpx;
|
||||
width : 735rpx;
|
||||
height : 80rpx;
|
||||
background-color: #85C1E9;
|
||||
border-style: solid;
|
||||
border-width: 10rpx;
|
||||
border-color: #3f72af;
|
||||
}
|
||||
|
||||
.user-show{
|
||||
width : 735rpx;
|
||||
height : 450rpx;
|
||||
background-color: #fcfcfc;
|
||||
border-style: solid;
|
||||
border-width: 10rpx;
|
||||
border-color: #3f72af;
|
||||
|
||||
}
|
||||
|
||||
.passwd-show{
|
||||
display: flex;
|
||||
flex-direction: rows;
|
||||
margin-top: 25rpx;
|
||||
width : 750rpx;
|
||||
height : 70rpx;
|
||||
background-color: #85C1E9;
|
||||
font-size: 50rpx;
|
||||
font-weight:bold;
|
||||
border-style: solid;
|
||||
border-width: 2rpx;
|
||||
border-color: #3f72af;
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
}
|
||||
|
||||
.icon-group{
|
||||
width:100%;
|
||||
border-radius: 3px;
|
||||
padding-top:2px;
|
||||
font-size:14px;
|
||||
color:red;
|
||||
overflow:hidden;
|
||||
height:45px;
|
||||
bottom: 0;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.passwd-copy{
|
||||
position: fixed;
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
font-size:50rpx;
|
||||
vertical-align: middle;
|
||||
border-style: solid;
|
||||
border-width: 1rpx;
|
||||
border-radius: 15rpx;
|
||||
width: 200rpx;
|
||||
right: 0;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.passwd-text{
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.icon-font{
|
||||
position: fixed;
|
||||
left:233rpx;
|
||||
bottom:0%
|
||||
}
|
7
miniprogram/sitemap.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"desc": "密码记事本",
|
||||
"rules": [{
|
||||
"action": "allow",
|
||||
"page": "*"
|
||||
}]
|
||||
}
|
144
miniprogram/style/guide.wxss
Normal file
@ -0,0 +1,144 @@
|
||||
page {
|
||||
background: #f6f6f6;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.list {
|
||||
margin-top: 40rpx;
|
||||
height: auto;
|
||||
width: 100%;
|
||||
background: #fff;
|
||||
padding: 0 40rpx;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
transition: all 300ms ease;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
line-height: 104rpx;
|
||||
font-size: 34rpx;
|
||||
color: #007aff;
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-content: center;
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.list-item:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.list-item image {
|
||||
max-width: 100%;
|
||||
max-height: 20vh;
|
||||
margin: 20rpx 0;
|
||||
}
|
||||
|
||||
.request-text {
|
||||
color: #222;
|
||||
padding: 20rpx 0;
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.guide {
|
||||
width: 100%;
|
||||
padding: 40rpx;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.guide .headline {
|
||||
font-size: 34rpx;
|
||||
font-weight: bold;
|
||||
color: #555;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
|
||||
.guide .p {
|
||||
margin-top: 20rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 36rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.guide .code {
|
||||
margin-top: 20rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 36rpx;
|
||||
color: #666;
|
||||
background: white;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.guide .code-dark {
|
||||
margin-top: 20rpx;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
padding: 20rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 36rpx;
|
||||
border-radius: 6rpx;
|
||||
color: #fff;
|
||||
white-space: pre
|
||||
}
|
||||
|
||||
.guide image {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.guide .image1 {
|
||||
margin-top: 20rpx;
|
||||
max-width: 100%;
|
||||
width: 356px;
|
||||
height: 47px;
|
||||
}
|
||||
|
||||
.guide .image2 {
|
||||
margin-top: 20rpx;
|
||||
width: 264px;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.guide .flat-image {
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.guide .code-image {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.guide .copyBtn {
|
||||
width: 180rpx;
|
||||
font-size: 20rpx;
|
||||
margin-top: 16rpx;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.guide .nav {
|
||||
margin-top: 50rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-content: space-between;
|
||||
}
|
||||
|
||||
.guide .nav .prev {
|
||||
margin-left: unset;
|
||||
}
|
||||
|
||||
.guide .nav .next {
|
||||
margin-right: unset;
|
||||
}
|
||||
|
19
miniprogram/until/until.js
Normal file
@ -0,0 +1,19 @@
|
||||
const formatTime = date => {
|
||||
const year = date.getFullYear()
|
||||
const month = date.getMonth() + 1
|
||||
const day = date.getDate()
|
||||
const hour = date.getHours()
|
||||
const minute = date.getMinutes()
|
||||
const second = date.getSeconds()
|
||||
|
||||
return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':')
|
||||
}
|
||||
|
||||
const formatNumber = n => {
|
||||
n = n.toString()
|
||||
return n[1] ? n : '0' + n
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatTime: formatTime
|
||||
}
|
46
project.config.json
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"miniprogramRoot": "miniprogram/",
|
||||
"cloudfunctionRoot": "cloudfunctions/",
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"es6": true,
|
||||
"postcss": true,
|
||||
"minified": true,
|
||||
"newFeature": true,
|
||||
"autoAudits": false,
|
||||
"uglifyFileName": true
|
||||
},
|
||||
"appid": "wx252ae6ca7d168bf5",
|
||||
"projectname": "%E5%AF%86%E7%A0%81%E8%AE%B0%E4%BA%8B%E6%9C%AC",
|
||||
"libVersion": "2.2.5",
|
||||
"simulatorType": "wechat",
|
||||
"simulatorPluginLibVersion": {},
|
||||
"cloudfunctionTemplateRoot": "cloudfunctionTemplate",
|
||||
"condition": {
|
||||
"search": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"conversation": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"plugin": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"game": {
|
||||
"list": []
|
||||
},
|
||||
"miniprogram": {
|
||||
"current": 0,
|
||||
"list": [
|
||||
{
|
||||
"id": -1,
|
||||
"name": "db guide",
|
||||
"pathName": "pages/databaseGuide/databaseGuide"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|