app和验证码登录
This commit is contained in:
parent
8281eff236
commit
d4c786a126
|
@ -2,6 +2,10 @@
|
|||
// launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
|
||||
"version": "0.0",
|
||||
"configurations": [{
|
||||
"app-plus" :
|
||||
{
|
||||
"launchtype" : "remote"
|
||||
},
|
||||
"default" :
|
||||
{
|
||||
"launchtype" : "remote"
|
||||
|
|
28
App.vue
28
App.vue
|
@ -5,6 +5,7 @@
|
|||
appid: 'wxf7d6140f507466be'
|
||||
},
|
||||
onLaunch() {
|
||||
var that = this
|
||||
// 1.1.0版本之前关于http拦截器代码,已平滑移动到/common/http.interceptor.js中
|
||||
// 注意,需要在/main.js中实例化Vue之后引入如下(详见文档说明):
|
||||
// import httpInterceptor from '@/common/http.interceptor.js'
|
||||
|
@ -56,6 +57,33 @@
|
|||
}
|
||||
});
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
uni.showLoading({
|
||||
title: '自动登录中...',
|
||||
mask: true
|
||||
})
|
||||
uni.getStorage({
|
||||
key: 'mySecret',
|
||||
success: function (res) {
|
||||
let secret = res.data
|
||||
if(secret){
|
||||
that.$u.api.loginSecret(JSON.parse(secret)).then(res=>{
|
||||
that.$u.api.getUserInfo().then(res => {
|
||||
that.$u.vuex('vuex_user', res)
|
||||
// 修改资源请求地址
|
||||
})
|
||||
uni.reLaunch({
|
||||
url: '/pages/home/home_'
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
complete() {
|
||||
uni.hideLoading()
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -18,6 +18,7 @@ const install = (Vue, vm) => {
|
|||
|
||||
let login = (data = {}) => vm.$u.post('auth/token/', data); //账户密码登录
|
||||
let loginOut = () => vm.$u.post('/auth/logout/'); //账户密码退出
|
||||
let loginSecret = (data = {}) => vm.$u.post('/auth/login_secret/', data); //App密钥登录
|
||||
// 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下
|
||||
|
||||
let wxmplogin = (data = {}) => vm.$u.post('auth/login_wxmp/', data); //微信登录
|
||||
|
@ -25,6 +26,9 @@ const install = (Vue, vm) => {
|
|||
let bindmp = (data = {}) => vm.$u.post('/system/user/bind_wxmp/', data); //微信小程序绑定
|
||||
|
||||
let unbindmp = (data = {}) => vm.$u.post('/system/user/unbind_wxmp/', data); //微信小程序解绑
|
||||
let bindSecret = (data = {}) => vm.$u.post('/system/user/bind_secret/', data); //App密钥绑定
|
||||
|
||||
|
||||
let getDickey = (params = {}) => vm.$u.get('/system/dict/', params); //查询字典
|
||||
let userList = (params = {}) => vm.$u.get('/system/user/', params); //
|
||||
let deptList = (params = {}) => vm.$u.get('/system/dept/', params); //
|
||||
|
@ -75,6 +79,9 @@ const install = (Vue, vm) => {
|
|||
wxmplogin,
|
||||
bindmp,
|
||||
unbindmp,
|
||||
bindSecret,
|
||||
loginSecret,
|
||||
|
||||
userList,
|
||||
deptList,
|
||||
ticketCreate,
|
||||
|
|
|
@ -50,7 +50,7 @@ const install = (Vue, vm) => {
|
|||
})
|
||||
}else{
|
||||
uni.reLaunch({
|
||||
url:'/pages/login/login'
|
||||
url:'/pages/login/login_'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name" : "共享平台",
|
||||
"name" : "曲阳金隅EHS",
|
||||
"appid" : "__UNI__B00D419",
|
||||
"description" : "共享平台",
|
||||
"description" : "曲阳金隅EHS",
|
||||
"versionName" : "1.0.0",
|
||||
"versionCode" : "100",
|
||||
"transformPx" : false,
|
||||
|
@ -70,7 +70,13 @@
|
|||
"speech" : {
|
||||
"ifly" : {}
|
||||
},
|
||||
"ad" : {}
|
||||
"ad" : {},
|
||||
"push" : {
|
||||
"unipush" : {
|
||||
"version" : "2",
|
||||
"offline" : false
|
||||
}
|
||||
}
|
||||
},
|
||||
"orientation" : [ "portrait-primary" ]
|
||||
}
|
||||
|
|
56
pages.json
56
pages.json
|
@ -13,49 +13,49 @@
|
|||
"pages": [{
|
||||
"path": "pages/login/login_",
|
||||
"style": {
|
||||
"navigationBarTitleText": "密码登录",
|
||||
"navigationBarTitleText": "曲阳金隅EHS-密码登录",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
},{
|
||||
"path": "pages/login/userRegister",
|
||||
"style": {
|
||||
"navigationBarTitleText": "新用户注册",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/login/login",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText": "验证码登录",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/login/login_password",
|
||||
"style": {
|
||||
"navigationBarTitleText": "密码登录",
|
||||
"navigationBarTitleText": "曲阳金隅EHS-新用户注册",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
},
|
||||
// {
|
||||
// "path" : "pages/login/login",
|
||||
// "style" :
|
||||
// {
|
||||
// "navigationBarTitleText": "验证码登录",
|
||||
// "enablePullDownRefresh": false
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// "path": "pages/login/login_password",
|
||||
// "style": {
|
||||
// "navigationBarTitleText": "密码登录",
|
||||
// "enablePullDownRefresh": false
|
||||
// }
|
||||
// },
|
||||
{
|
||||
"path": "pages/home/home_",
|
||||
"style": {
|
||||
"navigationBarTitleText": "主页",
|
||||
// "navigationBarTitleText": "曲阳金隅EHS主页",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/home/list/ticket",
|
||||
"style": {
|
||||
"navigationBarTitleText": "代办事件",
|
||||
"navigationBarTitleText": "曲阳金隅EHS-待办工单",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/home/list/warning",
|
||||
"style": {
|
||||
"navigationBarTitleText": "实时报警",
|
||||
"navigationBarTitleText": "曲阳金隅EHS-实时报警",
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
|
@ -63,7 +63,7 @@
|
|||
{
|
||||
"path": "pages/home/detail/ticketHandle",
|
||||
"style": {
|
||||
"navigationBarTitleText": "工作流审批",
|
||||
"navigationBarTitleText": "曲阳金隅EHS-工单处理",
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
|
@ -79,7 +79,7 @@
|
|||
{
|
||||
"path": "pages/home/detail/warningHandle",
|
||||
"style": {
|
||||
"navigationBarTitleText": "报警处理",
|
||||
"navigationBarTitleText": "曲阳金隅EHS-报警处理",
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
|
@ -87,14 +87,14 @@
|
|||
{
|
||||
"path": "pages/workSpace/workSpace",
|
||||
"style": {
|
||||
"navigationBarTitleText": "工作台",
|
||||
"navigationBarTitleText": "曲阳金隅EHS-工作台",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/workSpace/rpj/rpjLisst",
|
||||
"style": {
|
||||
"navigationBarTitleText": "入厂项目",
|
||||
"navigationBarTitleText": "曲阳金隅EHS-入厂项目",
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
|
@ -127,7 +127,7 @@
|
|||
{
|
||||
"path": "pages/workSpace/operation/operationList",
|
||||
"style": {
|
||||
"navigationBarTitleText": "作业列表",
|
||||
"navigationBarTitleText": "曲阳金隅EHS-作业列表",
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
|
@ -151,7 +151,7 @@
|
|||
{
|
||||
"path": "pages/workSpace/visit/visitList",
|
||||
"style": {
|
||||
"navigationBarTitleText": "来访项目",
|
||||
"navigationBarTitleText": "曲阳金隅EHS-来访项目",
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
|
@ -183,7 +183,7 @@
|
|||
{
|
||||
"path": "pages/my/my",
|
||||
"style": {
|
||||
"navigationBarTitleText": "个人中心",
|
||||
"navigationBarTitleText": "曲阳金隅EHS-个人中心",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
},
|
||||
|
@ -198,7 +198,7 @@
|
|||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "曲阳金隅智慧安全",
|
||||
"navigationBarTitleText": "曲阳金隅EHS",
|
||||
"navigationBarBackgroundColor": "#F8F8F8",
|
||||
// "navigationStyle": "custom",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
|
|
|
@ -37,18 +37,19 @@
|
|||
</form>
|
||||
</view>
|
||||
<view class="login-area" v-if="isMessage">
|
||||
<form style="display: block;" @submit="formSubmit">
|
||||
<form style="display: block;" @submit="formSubmit2">
|
||||
<view class="login-item">
|
||||
<image class="login-icon" src="../../static/login/avatar.png" mode=""></image>
|
||||
<input placeholder-style="color: #2c6fd9;" style="color: #2c6fd9;" class="loginItemInput"
|
||||
type="text" name="phoneNumber" v-model="phoneNumber" placeholder="请输入手机号" />
|
||||
type="text" name="phone" v-model="phoneNumber" placeholder="请输入手机号" />
|
||||
</view>
|
||||
<view class="login-item">
|
||||
<image class="login-icon" src="../../static/login/password.png" mode=""></image>
|
||||
<input placeholder-style="color: #2c6fd9;" style="color: #2c6fd9;" class="loginItemInput"
|
||||
type="text" name="message" password placeholder="请输入验证码" />
|
||||
type="text" name="code" placeholder="请输入验证码" />
|
||||
<button class="getMessageCode" @click="getCode">{{codeTips}}</button>
|
||||
</view>
|
||||
<u-verification-code seconds="30" ref="uCode" @change="codeChange"></u-verification-code>
|
||||
<view class="privacy">
|
||||
<view class="privacyIn">
|
||||
<u-checkbox-group>
|
||||
|
@ -67,7 +68,7 @@
|
|||
</view>
|
||||
<view class="wxBig">
|
||||
<view class="Wxtitle">
|
||||
<view class="WxtitleIn">新用户注册</view>
|
||||
<view class="WxtitleIn">访客注册</view>
|
||||
</view>
|
||||
<view class="wx" @click="userRegister">
|
||||
<image src="/static/login/userRegister.png" mode=""></image>
|
||||
|
@ -296,6 +297,21 @@
|
|||
url: '/pages/login/userRegister'
|
||||
})
|
||||
},
|
||||
ranStr(e) {
|
||||
//形参e,需要产生随机字符串的长度
|
||||
//如果没有传参,默认生成32位长度随机字符串
|
||||
e = e || 32;
|
||||
//模拟随机字符串库
|
||||
var t = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz0123456789",
|
||||
a = t.length,//字符串t的长度,随机数生成最大值
|
||||
n = "";
|
||||
for (let i = 0; i < e; i++) {
|
||||
//随机生成长度为e的随机字符串拼接
|
||||
n += t.charAt(Math.floor(Math.random() * a));
|
||||
}
|
||||
//返回随机组合字符串
|
||||
return n
|
||||
},
|
||||
formSubmit(e) {
|
||||
var that = this;
|
||||
const obj = e.target.value;
|
||||
|
@ -311,18 +327,48 @@
|
|||
that.$u.vuex('vuex_user', res)
|
||||
// 修改资源请求地址
|
||||
})
|
||||
// #ifdef APP-PLUS
|
||||
let secret = that.ranStr(12)
|
||||
let mySecret = {'username': obj.username, 'secret': secret}
|
||||
that.$u.api.bindSecret({secret: secret}).then(res=>{
|
||||
uni.setStorageSync('mySecret', JSON.stringify(mySecret))
|
||||
}).catch(e=>{})
|
||||
// #endif
|
||||
|
||||
uni.reLaunch({
|
||||
url: '/pages/home/home_'
|
||||
})
|
||||
}).catch(e => {
|
||||
console.log(e)
|
||||
uni.showToast({
|
||||
title: '账户密码错误',
|
||||
icon: 'none'
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
formSubmit2(e) {
|
||||
var that = this;
|
||||
const obj = e.target.value;
|
||||
console.log(obj)
|
||||
that.$u.api.codeLogin(obj).then(res => {
|
||||
that.$u.vuex('vuex_token', res.access)
|
||||
that.$u.vuex('vuex_refresh', res.refresh)
|
||||
// let data = {openid: uni.getStorageSync('wxmp_openid')}
|
||||
// that.$u.api.bindmp(data).then(res=>{})
|
||||
that.$u.api.getUserInfo().then(res => {
|
||||
that.$u.vuex('vuex_user', res)
|
||||
// 修改资源请求地址
|
||||
})
|
||||
// #ifdef APP-PLUS
|
||||
let secret = that.ranStr(12)
|
||||
let mySecret = {'username': obj.username, 'secret': secret}
|
||||
that.$u.api.bindSecret({secret: secret}).then(res=>{
|
||||
uni.setStorageSync('mySecret', JSON.stringify(mySecret))
|
||||
}).catch(e=>{})
|
||||
// #endif
|
||||
|
||||
uni.reLaunch({
|
||||
url: '/pages/home/home_'
|
||||
})
|
||||
}).catch(e => {
|
||||
})
|
||||
},
|
||||
codeChange(text) {
|
||||
this.codeTips = text;
|
||||
},
|
||||
|
@ -331,21 +377,23 @@
|
|||
debugger;
|
||||
console.log(this.phoneNumber)
|
||||
if (this.phoneNumber !== '') {
|
||||
uni.showLoading({
|
||||
title: '正在获取验证码',
|
||||
mask: true
|
||||
})
|
||||
this.$u.api.getCode({
|
||||
phone: this.phoneNumber
|
||||
}).then(res => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
// 这里此提示会被this.start()方法中的提示覆盖
|
||||
this.$u.toast('验证码已发送');
|
||||
// 通知验证码组件内部开始倒计时
|
||||
this.$refs.uCode.start();
|
||||
}, 2000);
|
||||
})
|
||||
if (this.$refs.uCode.canGetCode){
|
||||
uni.showLoading({
|
||||
title: '正在获取验证码',
|
||||
mask: true
|
||||
})
|
||||
this.$u.api.getCode({
|
||||
phone: this.phoneNumber
|
||||
}).then(res => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
// 这里此提示会被this.start()方法中的提示覆盖
|
||||
this.$u.toast('验证码已发送');
|
||||
// 通知验证码组件内部开始倒计时
|
||||
this.$refs.uCode.start();
|
||||
}, 2000);
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// this.$u.toast('倒计时结束后再发送');
|
||||
this.$u.toast('请输入手机号');
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
</view>
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<u-avatar :src="vuex_user.avatar" size="124"></u-avatar>
|
||||
<u-avatar :src="vuex_user.avatar" size="100"></u-avatar>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
<view>
|
||||
|
@ -257,6 +257,11 @@
|
|||
var that = this;
|
||||
this.$u.api.loginOut().then(()=>{
|
||||
that.$u.vuex('vuex_token', null);
|
||||
try {
|
||||
uni.removeStorageSync('mySecret');
|
||||
} catch (e) {
|
||||
// error
|
||||
}
|
||||
uni.reLaunch({
|
||||
url:'/pages/login/login_'
|
||||
})
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
style="position: absolute;top:0;left:0;bottom:0;right:0;height: 290rpx;background-image: url(../../static/workSpace/bgimg.png);background-position: center bottom;background-size: 100%;">
|
||||
</view>
|
||||
<view class="top-title" style="display: flex;">
|
||||
<block v-for="(item,index) in routerList" :key="item.index">
|
||||
<block v-for="(item,index) in routerList" :key="index">
|
||||
<view class="title-item" @click="goInto(index)">
|
||||
<view class="title-icon">
|
||||
<image :src="require('@/static/workSpace/'+item.icon+'')" mode="widthFix"></image>
|
||||
|
|
Loading…
Reference in New Issue