@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Eslint config file
|
||||
* Documentation: https://eslint.org/docs/user-guide/configuring/
|
||||
* Install the Eslint extension before using this feature.
|
||||
*/
|
||||
module.exports = {
|
||||
env: {
|
||||
es6: true,
|
||||
browser: true,
|
||||
node: true,
|
||||
},
|
||||
ecmaFeatures: {
|
||||
modules: true,
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 2018,
|
||||
sourceType: 'module',
|
||||
},
|
||||
globals: {
|
||||
wx: true,
|
||||
App: true,
|
||||
Page: true,
|
||||
getCurrentPages: true,
|
||||
getApp: true,
|
||||
Component: true,
|
||||
requirePlugin: true,
|
||||
requireMiniProgram: true,
|
||||
},
|
||||
// extends: 'eslint:recommended',
|
||||
rules: {},
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
{
|
||||
"cloud": true,
|
||||
"pages": [
|
||||
"pages/index/index",
|
||||
"pages/navigation/index/index",
|
||||
"pages/navigation/index/show_clothes/show_clothes",
|
||||
"pages/navigation/index/add/add",
|
||||
"pages/navigation/index/delete/delete",
|
||||
"pages/navigation/self/self",
|
||||
"pages/navigation/userinform/userinform",
|
||||
"pages/navigation/safety/safety",
|
||||
"pages/navigation/shezhi/shezhi",
|
||||
"pages/navigation/index/recommand/recommand",
|
||||
"pages/navigation/index/add/camera/camera"
|
||||
],
|
||||
"window": {
|
||||
"backgroundTextStyle": "light",
|
||||
"navigationBarBackgroundColor": "#fff",
|
||||
"navigationBarTitleText": "Weixin",
|
||||
"navigationBarTextStyle": "black"
|
||||
},
|
||||
"usingComponents": {
|
||||
"van-button": "pages/miniprogram_npm/@vant/weapp/button/index",
|
||||
"van-tabbar": "pages/miniprogram_npm/@vant/weapp/tabbar/index",
|
||||
"van-tabbar-item": "pages/miniprogram_npm/@vant/weapp/tabbar-item/index",
|
||||
"van-image": "pages/miniprogram_npm/@vant/weapp/image/index",
|
||||
"van-icon": "pages/miniprogram_npm/@vant/weapp/icon/index",
|
||||
"van-divider": "pages/miniprogram_npm/@vant/weapp/divider/index",
|
||||
"van-rate": "pages/miniprogram_npm/@vant/weapp/rate/index",
|
||||
"van-field": "pages/miniprogram_npm/@vant/weapp/field/index",
|
||||
"van-toast": "pages/miniprogram_npm/@vant/weapp/toast/index"
|
||||
},
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"tabBar": {
|
||||
"selectedColor": "#5001",
|
||||
"backgroundColor": "white",
|
||||
"borderStyle": "white",
|
||||
"list": [
|
||||
{
|
||||
"text": "首页",
|
||||
"pagePath": "pages/navigation/index/index",
|
||||
"iconPath": "pages/img/首页.png",
|
||||
"selectedIconPath": "pages/img/首页.png"
|
||||
},
|
||||
{
|
||||
"text": "我的",
|
||||
"pagePath": "pages/navigation/self/self",
|
||||
"iconPath": "pages/img/我的.png",
|
||||
"selectedIconPath": "pages/img/我的.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
/**app.wxss**/
|
||||
.container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 200rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"permissions": {
|
||||
"openapi": [
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
// 云函数入口文件
|
||||
const cloud = require('wx-server-sdk')
|
||||
|
||||
cloud.init() // 使用当前云环境
|
||||
const db=cloud.database()
|
||||
const MAX_LIMIT=100
|
||||
// 云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
const wxContext = cloud.getWXContext()
|
||||
//先取出集合记录总数
|
||||
const countResult=await db.collection('cloth').count()
|
||||
const total=countResult.total
|
||||
//计算分几次取
|
||||
const batchTimes = Math.ceil(total / 100)
|
||||
// 承载所有读操作的 promise 的数组
|
||||
const tasks = []
|
||||
for (let i = 0; i < batchTimes; i++) {
|
||||
const promise = db.collection('cloth').skip(i * MAX_LIMIT).limit(MAX_LIMIT).get()
|
||||
tasks.push(promise)
|
||||
}
|
||||
// 等待所有
|
||||
return (await Promise.all(tasks)).reduce((acc, cur) => {
|
||||
return {
|
||||
event,
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
unionid: wxContext.UNIONID,
|
||||
data: acc.data.concat(cur.data),
|
||||
errMsg: acc.errMsg,
|
||||
}
|
||||
})
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "get",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wx-server-sdk": "~2.6.3"
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"permissions": {
|
||||
"openapi": [
|
||||
"wxacode.get"
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
const cloud = require('wx-server-sdk');
|
||||
|
||||
cloud.init({
|
||||
env: cloud.DYNAMIC_CURRENT_ENV
|
||||
});
|
||||
|
||||
// 获取小程序二维码云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
// 获取小程序二维码的buffer
|
||||
const resp = await cloud.openapi.wxacode.get({
|
||||
path: 'pages/index/index'
|
||||
});
|
||||
const { buffer } = resp;
|
||||
// 将图片上传云存储空间
|
||||
const upload = await cloud.uploadFile({
|
||||
cloudPath: 'code.png',
|
||||
fileContent: buffer
|
||||
});
|
||||
return upload.fileID;
|
||||
};
|
@ -0,0 +1,17 @@
|
||||
const cloud = require('wx-server-sdk');
|
||||
|
||||
cloud.init({
|
||||
env: cloud.DYNAMIC_CURRENT_ENV
|
||||
});
|
||||
|
||||
// 获取openId云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
// 获取基础信息
|
||||
const wxContext = cloud.getWXContext();
|
||||
|
||||
return {
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
unionid: wxContext.UNIONID,
|
||||
};
|
||||
};
|
@ -0,0 +1,25 @@
|
||||
const getOpenId = require('./getOpenId/index');
|
||||
const getMiniProgramCode = require('./getMiniProgramCode/index');
|
||||
const createCollection = require('./createCollection/index');
|
||||
const selectRecord = require('./selectRecord/index');
|
||||
const updateRecord = require('./updateRecord/index');
|
||||
const sumRecord = require('./sumRecord/index');
|
||||
|
||||
|
||||
// 云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
switch (event.type) {
|
||||
case 'getOpenId':
|
||||
return await getOpenId.main(event, context);
|
||||
case 'getMiniProgramCode':
|
||||
return await getMiniProgramCode.main(event, context);
|
||||
case 'createCollection':
|
||||
return await createCollection.main(event, context);
|
||||
case 'selectRecord':
|
||||
return await selectRecord.main(event, context);
|
||||
case 'updateRecord':
|
||||
return await updateRecord.main(event, context);
|
||||
case 'sumRecord':
|
||||
return await sumRecord.main(event, context);
|
||||
}
|
||||
};
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "quickstartFunctions",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wx-server-sdk": "~2.4.0"
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
const cloud = require('wx-server-sdk');
|
||||
|
||||
cloud.init({
|
||||
env: cloud.DYNAMIC_CURRENT_ENV
|
||||
});
|
||||
const db = cloud.database();
|
||||
|
||||
// 查询数据库集合云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
// 返回数据库查询结果
|
||||
return await db.collection('sales').get();
|
||||
};
|
@ -0,0 +1,18 @@
|
||||
const cloud = require('wx-server-sdk');
|
||||
|
||||
cloud.init({
|
||||
env: cloud.DYNAMIC_CURRENT_ENV
|
||||
});
|
||||
const db = cloud.database();
|
||||
const $ = db.command.aggregate;
|
||||
|
||||
// 聚合记录云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
// 返回数据库聚合结果
|
||||
return db.collection('sales').aggregate()
|
||||
.group({
|
||||
_id: '$region',
|
||||
sum: $.sum('$sales')
|
||||
})
|
||||
.end();
|
||||
};
|
@ -0,0 +1,32 @@
|
||||
const cloud = require('wx-server-sdk');
|
||||
|
||||
cloud.init({
|
||||
env: cloud.DYNAMIC_CURRENT_ENV
|
||||
});
|
||||
const db = cloud.database();
|
||||
|
||||
// 修改数据库信息云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
try {
|
||||
// 遍历修改数据库信息
|
||||
for (let i = 0; i < event.data.length; i++) {
|
||||
await db.collection('sales').where({
|
||||
_id: event.data[i]._id
|
||||
})
|
||||
.update({
|
||||
data: {
|
||||
sales: event.data[i].sales
|
||||
},
|
||||
});
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
data: event.data
|
||||
};
|
||||
} catch (e) {
|
||||
return {
|
||||
success: false,
|
||||
errMsg: e
|
||||
};
|
||||
}
|
||||
};
|
After Width: | Height: | Size: 533 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 967 B |
After Width: | Height: | Size: 100 KiB |
After Width: | Height: | Size: 963 B |
After Width: | Height: | Size: 806 B |
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 1.7 MiB |
After Width: | Height: | Size: 75 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 172 KiB |
After Width: | Height: | Size: 110 KiB |
After Width: | Height: | Size: 252 KiB |
After Width: | Height: | Size: 140 KiB |
After Width: | Height: | Size: 119 KiB |
After Width: | Height: | Size: 132 KiB |
After Width: | Height: | Size: 170 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 158 KiB |
After Width: | Height: | Size: 171 KiB |
After Width: | Height: | Size: 150 KiB |
After Width: | Height: | Size: 193 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 180 KiB |
After Width: | Height: | Size: 125 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 112 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 115 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 1.2 MiB |
After Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 834 KiB |
After Width: | Height: | Size: 940 KiB |
After Width: | Height: | Size: 2.4 MiB |
After Width: | Height: | Size: 693 KiB |
After Width: | Height: | Size: 389 KiB |
After Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 357 KiB |
After Width: | Height: | Size: 382 KiB |
After Width: | Height: | Size: 118 KiB |
After Width: | Height: | Size: 596 KiB |
After Width: | Height: | Size: 273 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 441 KiB |
After Width: | Height: | Size: 102 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 8.1 KiB |
@ -1,180 +1,327 @@
|
||||
// pages/index/index.js
|
||||
import Toast from './@vant/weapp/toast/toast';
|
||||
var app=getApp();
|
||||
Page({
|
||||
data: {
|
||||
ip:'82.157.11.188' ,
|
||||
port:8080,
|
||||
password:'',
|
||||
islogin:1,
|
||||
inputipone:'',//登录注册时时输入的手机号
|
||||
compassiphone:'',//找回密码时输入的手机号
|
||||
loginbtnstate:true,
|
||||
strloginUser:'',//登录用户名
|
||||
strloginpassword:'',//用户密码
|
||||
switchChecked:'',//选中按钮
|
||||
},
|
||||
onLoad() {
|
||||
var _this = this;
|
||||
_this.setData({
|
||||
strloginUser: wx.getStorageSync("iphone"),
|
||||
strloginpassword: wx.getStorageSync("password"),
|
||||
switchChecked:wx.getStorageSync('checkedValue'),
|
||||
loginbtnstate:wx.getStorageSync('wxlogin'),
|
||||
})
|
||||
console.log(_this.data.strloginUser+_this.data.strloginpassword+_this.data.switchChecked)
|
||||
},
|
||||
//判断是否要记住密码
|
||||
bindswitchchange: function (event) {
|
||||
//得到值
|
||||
var checkedValue = event.detail.value;
|
||||
console.log("开关状态"+checkedValue);
|
||||
var _this = this;
|
||||
if (checkedValue == true){
|
||||
_this.setData({
|
||||
switchChecked:true,
|
||||
})
|
||||
// wx.setStorageSync("iphone",_this.data.strloginUser);
|
||||
// wx.setStorageSync("password",_this.data.strloginpassword);
|
||||
//wx.setStorageSync("checkedValue", _this.data.switchChecked);
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
|
||||
console.log(checkedValue);
|
||||
} else if (checkedValue == false) {
|
||||
_this.setData({
|
||||
switchChecked: false
|
||||
})
|
||||
// wx.setStorageSync("iphone","");
|
||||
// wx.setStorageSync("password","");
|
||||
}
|
||||
},
|
||||
//输入密码(登录界面判断有无)
|
||||
password1:function(event){
|
||||
var that = this
|
||||
var m=event.detail.value
|
||||
console.log(event.detail.value)
|
||||
|
||||
onload: function (){
|
||||
if(m!=''){
|
||||
this.setData({
|
||||
strloginpassword:m
|
||||
})
|
||||
if(this.data.strloginUser!=''&&(this.data.strloginUser.length==11))
|
||||
{
|
||||
this.setData({
|
||||
loginbtnstate:false
|
||||
})
|
||||
}
|
||||
else{
|
||||
this.setData({
|
||||
loginbtnstate:true,
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.setData({
|
||||
loginbtnstate:true,
|
||||
password:''
|
||||
})
|
||||
}
|
||||
},
|
||||
data: {
|
||||
user:"",//输入账号
|
||||
pwd:"",//输入密码
|
||||
default_user:"user",//默认账号
|
||||
default_pwd:"123456",//默认密码
|
||||
},
|
||||
//登录按钮
|
||||
log_on()
|
||||
{
|
||||
console.log("账号",this.data.user,this.data.pwd);
|
||||
if(this.data.user==this.data.default_user&& this.data.pwd==this.data.default_pwd)
|
||||
//输入手机号(登录界面判断有无)
|
||||
inputiphone1:function(event){
|
||||
console.log(event.detail.value)
|
||||
var m=event.detail.value
|
||||
|
||||
if(m!=''&&(m.length==11)){
|
||||
this.setData({
|
||||
strloginUser:m
|
||||
})
|
||||
if(this.data.strloginpassword!='')
|
||||
{
|
||||
wx.reLaunch({
|
||||
url: '/pages/navigation/index/index',
|
||||
this.setData({
|
||||
loginbtnstate:false
|
||||
})
|
||||
}
|
||||
else{
|
||||
this.setData({
|
||||
loginbtnstate:true,
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.setData({
|
||||
loginbtnstate:true,
|
||||
})
|
||||
}else{
|
||||
Toast.fail('账号或密码错误');
|
||||
}
|
||||
},
|
||||
//忘记密码
|
||||
forget()
|
||||
//输入密码(注册界面判断有无)
|
||||
password2:function(event){
|
||||
console.log(event.detail.value)
|
||||
var m=event.detail.value
|
||||
if(m!=''){
|
||||
this.setData({
|
||||
password:m
|
||||
})
|
||||
if(this.data.inputipone!=''&&(this.data.inputipone.length==11))
|
||||
{
|
||||
this.setData({
|
||||
loginbtnstate:false
|
||||
})
|
||||
}
|
||||
else{
|
||||
this.setData({
|
||||
loginbtnstate:true,
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.setData({
|
||||
loginbtnstate:true,
|
||||
password:''
|
||||
})
|
||||
}
|
||||
},
|
||||
//输入手机号(注册界面判断有无)
|
||||
inputiphone2:function(event){
|
||||
console.log(event.detail.value)
|
||||
var m=event.detail.value
|
||||
if(m!=''&&(m.length==11)){
|
||||
this.setData({
|
||||
inputipone:m
|
||||
})
|
||||
if(this.data.password!='')
|
||||
{
|
||||
this.setData({
|
||||
loginbtnstate:false
|
||||
})
|
||||
}
|
||||
else{
|
||||
this.setData({
|
||||
loginbtnstate:true,
|
||||
})
|
||||
|
||||
|
||||
//获取用户名
|
||||
getName(user) {
|
||||
console.log('获取输入的用户名', user.detail.value)
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.setData({
|
||||
name: user.detail.value
|
||||
loginbtnstate:true,
|
||||
inputipone:''
|
||||
})
|
||||
}
|
||||
},
|
||||
//获取用户账号
|
||||
getZhangHao(user) {
|
||||
console.log('获取输入的账号', user.detail.value)
|
||||
//找回密码输入框
|
||||
compass:function(event){
|
||||
console.log("找回密码"+event.detail.value)
|
||||
var m=event.detail.value
|
||||
if(m!=''&&(m.length==11)){
|
||||
this.setData({
|
||||
zhanghao: user.detail.value
|
||||
compassiphone:m,
|
||||
loginbtnstate:false
|
||||
})
|
||||
},
|
||||
// 获取密码
|
||||
getMiMa(pwd) {
|
||||
console.log('获取输入的密码', pwd.detail.value)
|
||||
}
|
||||
else{
|
||||
this.setData({
|
||||
mima: pwd.detail.value
|
||||
loginbtnstate:true,
|
||||
inputipone:''
|
||||
})
|
||||
}
|
||||
},
|
||||
//登录
|
||||
onlogin:function(e){
|
||||
var that=this
|
||||
//记住密码
|
||||
var checkedValue = that.data.switchChecked;
|
||||
console.log(checkedValue);
|
||||
//如果记住密码则向微信缓存写入账号密码
|
||||
//如果不记住密码则清空微信缓存存在的账号密码
|
||||
if (checkedValue == true) {
|
||||
wx.setStorageSync("iphone",that.data.strloginUser);
|
||||
wx.setStorageSync("password",that.data.strloginpassword);
|
||||
wx.setStorageSync("checkedValue", that.data.switchChecked);
|
||||
wx.setStorageSync("wxlogin", false);
|
||||
console.log(that.data.loginbtnstate)
|
||||
} else if (checkedValue == false) {
|
||||
wx.setStorageSync("iphone","");
|
||||
wx.setStorageSync("password","");
|
||||
wx.setStorageSync("checkedValue", false);
|
||||
wx.setStorageSync("wxlogin", true);
|
||||
}
|
||||
//开始检查用户名和密码是否一致
|
||||
var userinfos=wx.getStorageSync('userjobs') ||[];//找数组
|
||||
if(userinfos.iphone==that.data.strloginUser){
|
||||
if(userinfos.password==that.data.strloginpassword)
|
||||
{
|
||||
|
||||
|
||||
//注册
|
||||
zhuce() {
|
||||
let name = this.data.name
|
||||
let zhanghao = this.data.zhanghao
|
||||
let mima = this.data.mima
|
||||
console.log("点击了注册")
|
||||
console.log("name", name)
|
||||
console.log("zhanghao", zhanghao)
|
||||
console.log("mima", mima)
|
||||
//校验用户名
|
||||
if (name.length < 2) {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '用户名至少2位',
|
||||
title: '登录成功',
|
||||
duration:2000,
|
||||
}),
|
||||
wx.switchTab({
|
||||
url: '../navigation/index/index'
|
||||
})
|
||||
return
|
||||
|
||||
}
|
||||
if (name.length > 10) {
|
||||
else{
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '用户名最多10位',
|
||||
title: '密码错误',
|
||||
duration:2000
|
||||
})
|
||||
return
|
||||
}
|
||||
//校验账号
|
||||
if (zhanghao.length < 4) {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '账号至少4位',
|
||||
})
|
||||
return
|
||||
}
|
||||
//校验密码
|
||||
if (mima.length < 4) {
|
||||
else{
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '密码至少4位',
|
||||
title: '用户名不存在',
|
||||
duration:2000
|
||||
})
|
||||
return
|
||||
}
|
||||
//注册功能的实现
|
||||
wx.cloud.database().collection('user').add({
|
||||
},
|
||||
//注册
|
||||
formsubmit:function(e){
|
||||
var that=this
|
||||
console.log(e.detail.value)
|
||||
var obj={}
|
||||
obj.password=e.detail.value.inputpassword,
|
||||
obj.iphone=e.detail.value.iphone,
|
||||
console.log(obj)
|
||||
//存入多个注册用户
|
||||
//初始化云
|
||||
wx.cloud.init({
|
||||
env:'cloud1-5ggzbo3kcd4ea4e2'
|
||||
});
|
||||
//初始化数据库
|
||||
const db=wx.cloud.database();
|
||||
db.collection('user').add({
|
||||
data: {
|
||||
user:"",//账号
|
||||
pwd:"",//密码
|
||||
iphone:obj.iphone,
|
||||
password:obj.password,
|
||||
|
||||
},
|
||||
sucess:function(res){
|
||||
console.log("添加成功",res);
|
||||
},
|
||||
success(res) {
|
||||
console.log('注册成功', res)
|
||||
fail:function(res){
|
||||
console.log(res.errMsg,"添加失败")
|
||||
}
|
||||
})
|
||||
//var arr=wx.getStorageSync('userjobs') ||[];
|
||||
//arr.push(obj);
|
||||
wx.setStorageSync('userjobs', obj);
|
||||
wx.showToast({
|
||||
title: '注册成功',
|
||||
duration:1000,
|
||||
success:function(){
|
||||
that.setData({
|
||||
islogin:1
|
||||
})
|
||||
wx.navigateTo({
|
||||
url: '../login/login',
|
||||
}
|
||||
})
|
||||
},
|
||||
fail(res) {
|
||||
console.log('注册失败', res)
|
||||
//找回密码
|
||||
comebackpassword:function(e){
|
||||
var that =this
|
||||
let wsy=wx.getStorageSync('userjobs') || [];//找数组
|
||||
console.log("输入的手机号"+that.data.compassiphone)
|
||||
console.log("本地缓存的手机号"+wsy.iphone)
|
||||
if(wsy.iphone==that.data.compassiphone)
|
||||
{
|
||||
wx.setClipboardData({
|
||||
data: wsy.password,
|
||||
success (res) {
|
||||
wx.getClipboardData({
|
||||
success (res) {
|
||||
console.log(res.data) // data
|
||||
that.setData({
|
||||
islogin:1
|
||||
})
|
||||
wx.showToast({
|
||||
title: '密码已复制',
|
||||
duration:2000
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
else
|
||||
{
|
||||
wx.showToast({
|
||||
title: '该手机号码未注册',
|
||||
duration:2000
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
//转到注册
|
||||
register:function(event){
|
||||
var that = this
|
||||
that.setData({
|
||||
islogin:3
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
//转到登录
|
||||
denglu:function(event){
|
||||
var that = this
|
||||
that.setData({
|
||||
islogin:1
|
||||
})
|
||||
},
|
||||
//转到忘记密码
|
||||
forget:function(event){
|
||||
this.setData({
|
||||
islogin:2
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
})
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
@ -1 +1,67 @@
|
||||
/* pages/index/index.wxss */
|
||||
.photo1{
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: -999;
|
||||
}
|
||||
.header{
|
||||
height: 200rpx;
|
||||
padding:40rpx 30rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
color: white;
|
||||
}
|
||||
.title{
|
||||
font-size: 52rpx;
|
||||
font-weight: 700;
|
||||
padding: 20rpx;
|
||||
}
|
||||
.header .info{
|
||||
font-size:28rpx ;
|
||||
padding: 20rpx;
|
||||
}
|
||||
.body{
|
||||
padding: 40rpx;
|
||||
padding-top: 230rpx;
|
||||
}
|
||||
.input{
|
||||
margin-top: 20rpx;
|
||||
|
||||
}
|
||||
.one{
|
||||
height: 100rpx;
|
||||
margin-top: 20rpx;
|
||||
box-shadow: #77778a 0 0 5rpx;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
.two{
|
||||
border: solid 1rpx #73ccd8;
|
||||
margin-top: 40rpx;
|
||||
width: 100%;
|
||||
background-color: #73ccd8;
|
||||
border-radius: 40rpx;
|
||||
}
|
||||
.end{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 40rpx;
|
||||
color: #9f9f9f;
|
||||
}
|
||||
.end text{
|
||||
margin-left:30rpx;
|
||||
}
|
||||
.end-power{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.power{
|
||||
color: #d6d6d6;
|
||||
position: fixed;
|
||||
bottom: 50rpx;
|
||||
|
||||
}
|
||||
.remenber{
|
||||
margin-top: 20rpx;
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var button_1 = require("../mixins/button");
|
||||
(0, component_1.VantComponent)({
|
||||
mixins: [button_1.button],
|
||||
props: {
|
||||
show: Boolean,
|
||||
title: String,
|
||||
cancelText: String,
|
||||
description: String,
|
||||
round: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
zIndex: {
|
||||
type: Number,
|
||||
value: 100,
|
||||
},
|
||||
actions: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
overlay: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
closeOnClickOverlay: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
closeOnClickAction: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
safeAreaInsetBottom: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onSelect: function (event) {
|
||||
var _this = this;
|
||||
var index = event.currentTarget.dataset.index;
|
||||
var _a = this.data, actions = _a.actions, closeOnClickAction = _a.closeOnClickAction, canIUseGetUserProfile = _a.canIUseGetUserProfile;
|
||||
var item = actions[index];
|
||||
if (item) {
|
||||
this.$emit('select', item);
|
||||
if (closeOnClickAction) {
|
||||
this.onClose();
|
||||
}
|
||||
if (item.openType === 'getUserInfo' && canIUseGetUserProfile) {
|
||||
wx.getUserProfile({
|
||||
desc: item.getUserProfileDesc || ' ',
|
||||
complete: function (userProfile) {
|
||||
_this.$emit('getuserinfo', userProfile);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
onCancel: function () {
|
||||
this.$emit('cancel');
|
||||
},
|
||||
onClose: function () {
|
||||
this.$emit('close');
|
||||
},
|
||||
onClickOverlay: function () {
|
||||
this.$emit('click-overlay');
|
||||
this.onClose();
|
||||
},
|
||||
},
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-icon": "../icon/index",
|
||||
"van-popup": "../popup/index",
|
||||
"van-loading": "../loading/index"
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-action-sheet{color:var(--action-sheet-item-text-color,#323233);max-height:var(--action-sheet-max-height,90%)!important}.van-action-sheet__cancel,.van-action-sheet__item{background-color:var(--action-sheet-item-background,#fff);font-size:var(--action-sheet-item-font-size,16px);line-height:var(--action-sheet-item-line-height,22px);padding:14px 16px;text-align:center}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#f2f3f5}.van-action-sheet__cancel:after,.van-action-sheet__item:after{border-width:0}.van-action-sheet__cancel{color:var(--action-sheet-cancel-text-color,#646566)}.van-action-sheet__gap{background-color:var(--action-sheet-cancel-padding-color,#f7f8fa);display:block;height:var(--action-sheet-cancel-padding-top,8px)}.van-action-sheet__item--disabled{color:var(--action-sheet-item-disabled-text-color,#c8c9cc)}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__subname{color:var(--action-sheet-subname-color,#969799);font-size:var(--action-sheet-subname-font-size,12px);line-height:var(--action-sheet-subname-line-height,20px);margin-top:var(--padding-xs,8px)}.van-action-sheet__header{font-size:var(--action-sheet-header-font-size,16px);font-weight:var(--font-weight-bold,500);line-height:var(--action-sheet-header-height,48px);text-align:center}.van-action-sheet__description{color:var(--action-sheet-description-color,#969799);font-size:var(--action-sheet-description-font-size,14px);line-height:var(--action-sheet-description-line-height,20px);padding:20px var(--padding-md,16px);text-align:center}.van-action-sheet__close{color:var(--action-sheet-close-icon-color,#c8c9cc);font-size:var(--action-sheet-close-icon-size,22px)!important;line-height:inherit!important;padding:var(--action-sheet-close-icon-padding,0 16px);position:absolute!important;right:0;top:0}.van-action-sheet__loading{display:flex!important}
|
@ -0,0 +1,232 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var shared_1 = require("../picker/shared");
|
||||
var utils_1 = require("../common/utils");
|
||||
var EMPTY_CODE = '000000';
|
||||
(0, component_1.VantComponent)({
|
||||
classes: ['active-class', 'toolbar-class', 'column-class'],
|
||||
props: __assign(__assign({}, shared_1.pickerProps), { value: {
|
||||
type: String,
|
||||
observer: function (value) {
|
||||
this.code = value;
|
||||
this.setValues();
|
||||
},
|
||||
}, areaList: {
|
||||
type: Object,
|
||||
value: {},
|
||||
observer: 'setValues',
|
||||
}, columnsNum: {
|
||||
type: null,
|
||||
value: 3,
|
||||
}, columnsPlaceholder: {
|
||||
type: Array,
|
||||
observer: function (val) {
|
||||
this.setData({
|
||||
typeToColumnsPlaceholder: {
|
||||
province: val[0] || '',
|
||||
city: val[1] || '',
|
||||
county: val[2] || '',
|
||||
},
|
||||
});
|
||||
},
|
||||
} }),
|
||||
data: {
|
||||
columns: [{ values: [] }, { values: [] }, { values: [] }],
|
||||
typeToColumnsPlaceholder: {},
|
||||
},
|
||||
mounted: function () {
|
||||
var _this = this;
|
||||
(0, utils_1.requestAnimationFrame)(function () {
|
||||
_this.setValues();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
getPicker: function () {
|
||||
if (this.picker == null) {
|
||||
this.picker = this.selectComponent('.van-area__picker');
|
||||
}
|
||||
return this.picker;
|
||||
},
|
||||
onCancel: function (event) {
|
||||
this.emit('cancel', event.detail);
|
||||
},
|
||||
onConfirm: function (event) {
|
||||
var index = event.detail.index;
|
||||
var value = event.detail.value;
|
||||
value = this.parseValues(value);
|
||||
this.emit('confirm', { value: value, index: index });
|
||||
},
|
||||
emit: function (type, detail) {
|
||||
detail.values = detail.value;
|
||||
delete detail.value;
|
||||
this.$emit(type, detail);
|
||||
},
|
||||
parseValues: function (values) {
|
||||
var columnsPlaceholder = this.data.columnsPlaceholder;
|
||||
return values.map(function (value, index) {
|
||||
if (value &&
|
||||
(!value.code || value.name === columnsPlaceholder[index])) {
|
||||
return __assign(__assign({}, value), { code: '', name: '' });
|
||||
}
|
||||
return value;
|
||||
});
|
||||
},
|
||||
onChange: function (event) {
|
||||
var _this = this;
|
||||
var _a;
|
||||
var _b = event.detail, index = _b.index, picker = _b.picker, value = _b.value;
|
||||
this.code = value[index].code;
|
||||
(_a = this.setValues()) === null || _a === void 0 ? void 0 : _a.then(function () {
|
||||
_this.$emit('change', {
|
||||
picker: picker,
|
||||
values: _this.parseValues(picker.getValues()),
|
||||
index: index,
|
||||
});
|
||||
});
|
||||
},
|
||||
getConfig: function (type) {
|
||||
var areaList = this.data.areaList;
|
||||
return (areaList && areaList[type + "_list"]) || {};
|
||||
},
|
||||
getList: function (type, code) {
|
||||
if (type !== 'province' && !code) {
|
||||
return [];
|
||||
}
|
||||
var typeToColumnsPlaceholder = this.data.typeToColumnsPlaceholder;
|
||||
var list = this.getConfig(type);
|
||||
var result = Object.keys(list).map(function (code) { return ({
|
||||
code: code,
|
||||
name: list[code],
|
||||
}); });
|
||||
if (code != null) {
|
||||
// oversea code
|
||||
if (code[0] === '9' && type === 'city') {
|
||||
code = '9';
|
||||
}
|
||||
result = result.filter(function (item) { return item.code.indexOf(code) === 0; });
|
||||
}
|
||||
if (typeToColumnsPlaceholder[type] && result.length) {
|
||||
// set columns placeholder
|
||||
var codeFill = type === 'province'
|
||||
? ''
|
||||
: type === 'city'
|
||||
? EMPTY_CODE.slice(2, 4)
|
||||
: EMPTY_CODE.slice(4, 6);
|
||||
result.unshift({
|
||||
code: "" + code + codeFill,
|
||||
name: typeToColumnsPlaceholder[type],
|
||||
});
|
||||
}
|
||||
return result;
|
||||
},
|
||||
getIndex: function (type, code) {
|
||||
var compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
|
||||
var list = this.getList(type, code.slice(0, compareNum - 2));
|
||||
// oversea code
|
||||
if (code[0] === '9' && type === 'province') {
|
||||
compareNum = 1;
|
||||
}
|
||||
code = code.slice(0, compareNum);
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (list[i].code.slice(0, compareNum) === code) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
setValues: function () {
|
||||
var picker = this.getPicker();
|
||||
if (!picker) {
|
||||
return;
|
||||
}
|
||||
var code = this.code || this.getDefaultCode();
|
||||
var provinceList = this.getList('province');
|
||||
var cityList = this.getList('city', code.slice(0, 2));
|
||||
var stack = [];
|
||||
var indexes = [];
|
||||
var columnsNum = this.data.columnsNum;
|
||||
if (columnsNum >= 1) {
|
||||
stack.push(picker.setColumnValues(0, provinceList, false));
|
||||
indexes.push(this.getIndex('province', code));
|
||||
}
|
||||
if (columnsNum >= 2) {
|
||||
stack.push(picker.setColumnValues(1, cityList, false));
|
||||
indexes.push(this.getIndex('city', code));
|
||||
if (cityList.length && code.slice(2, 4) === '00') {
|
||||
code = cityList[0].code;
|
||||
}
|
||||
}
|
||||
if (columnsNum === 3) {
|
||||
stack.push(picker.setColumnValues(2, this.getList('county', code.slice(0, 4)), false));
|
||||
indexes.push(this.getIndex('county', code));
|
||||
}
|
||||
return Promise.all(stack)
|
||||
.catch(function () { })
|
||||
.then(function () { return picker.setIndexes(indexes); })
|
||||
.catch(function () { });
|
||||
},
|
||||
getDefaultCode: function () {
|
||||
var columnsPlaceholder = this.data.columnsPlaceholder;
|
||||
if (columnsPlaceholder.length) {
|
||||
return EMPTY_CODE;
|
||||
}
|
||||
var countyCodes = Object.keys(this.getConfig('county'));
|
||||
if (countyCodes[0]) {
|
||||
return countyCodes[0];
|
||||
}
|
||||
var cityCodes = Object.keys(this.getConfig('city'));
|
||||
if (cityCodes[0]) {
|
||||
return cityCodes[0];
|
||||
}
|
||||
return '';
|
||||
},
|
||||
getValues: function () {
|
||||
var picker = this.getPicker();
|
||||
if (!picker) {
|
||||
return [];
|
||||
}
|
||||
return this.parseValues(picker.getValues().filter(function (value) { return !!value; }));
|
||||
},
|
||||
getDetail: function () {
|
||||
var values = this.getValues();
|
||||
var area = {
|
||||
code: '',
|
||||
country: '',
|
||||
province: '',
|
||||
city: '',
|
||||
county: '',
|
||||
};
|
||||
if (!values.length) {
|
||||
return area;
|
||||
}
|
||||
var names = values.map(function (item) { return item.name; });
|
||||
area.code = values[values.length - 1].code;
|
||||
if (area.code[0] === '9') {
|
||||
area.country = names[1] || '';
|
||||
area.province = names[2] || '';
|
||||
}
|
||||
else {
|
||||
area.province = names[0] || '';
|
||||
area.city = names[1] || '';
|
||||
area.county = names[2] || '';
|
||||
}
|
||||
return area;
|
||||
},
|
||||
reset: function (code) {
|
||||
this.code = code || '';
|
||||
return this.setValues();
|
||||
},
|
||||
},
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-picker": "../picker/index"
|
||||
}
|
||||
}
|