APP登录

This commit is contained in:
Vinjor 2024-10-16 17:14:49 +08:00
parent 74c7cf99a6
commit 79969b5827
9 changed files with 354 additions and 386 deletions

View File

@ -79,13 +79,13 @@ export function loginAppuserName(data) {
})
}
// 使用租户域名(标识),获得租户编号
export function getTenantIdByWebsite(website) {
// 使用手机号查询所在的租户获得租户编号
export function getTenantIdByPhone(phone) {
return request({
url: '/admin-api/system/tenant/getListByWebsite',
url: '/app-api/system/user/getListByPhone',
method: 'get',
params: {
website
phone
}
})
}

View File

@ -14,13 +14,13 @@
</view>
<view class="">工单处理</view>
</view>
<view class="box" :class="{active: aindex == 3}" @click="getgogo(3)">
<view class="imgs">
<image mode="aspectFit" src="@/static/icons/tabbar/my.png" v-show="aindex != 3"></image>
<image mode="aspectFit" src="@/static/icons/tabbar/my-checked.png" v-show="aindex == 3"></image>
</view>
<view class="">我的</view>
</view>
<!-- <view class="box" :class="{active: aindex == 3}" @click="getgogo(3)">-->
<!-- <view class="imgs">-->
<!-- <image mode="aspectFit" src="@/static/icons/tabbar/my.png" v-show="aindex != 3"></image>-->
<!-- <image mode="aspectFit" src="@/static/icons/tabbar/my-checked.png" v-show="aindex == 3"></image>-->
<!-- </view>-->
<!-- <view class="">我的</view>-->
<!-- </view>-->
</view>
</template>

View File

@ -1,7 +1,7 @@
// 应用全局配置
module.exports = {
baseUrl: 'https://www.nuoyunr.com',
// baseUrl: 'http://192.168.1.4:48080',
// baseUrl: 'https://www.nuoyunr.com',
baseUrl: 'http://192.168.1.17:48080',
// baseUrl: "http://localhost:48080",
imagesUrl: 'http://shequ.0315e.com/static/images/pages/',
baseImageUrl: 'https://www.nuoyunr.com/minio/',

View File

@ -3,13 +3,14 @@
<!--<VNavigationBar style="position: relative;z-index: 99;" leftTitle="true" backgroundColor="rgba(0,0,0,0)" title-color="#fff" title=" "></VNavigationBar>-->
<view class="bodyTopBg"></view>
<view class="body">
<view class="userInfoBox">
<image style="width: 104rpx;height: 104rpx" :src="userInfo.avatarUrl || defaultAvatar" mode="aspectFill" @error="avatarErr"></image>
<view class="userInfoBox" @click="showUserDetail">
<image style="width: 104rpx;height: 104rpx;border-radius: 50%;" v-if="''==userInfo.avatar || null == userInfo.avatar" :src="defaultAvatar" mode="scaleToFill" @error="avatarErr"></image>
<image style="width: 104rpx;height: 104rpx;border-radius: 50%;" v-else :src="imgUrlPrex+userInfo.avatar" mode="scaleToFill" @error="avatarErr"></image>
<view class="userInfo">
<text class="userName">{{ userInfo.userName }}</text>
<text class="userType">{{ userInfo.userType }}</text>
<text class="userName">{{ userInfo.nickname }}</text>
<!-- <text class="userType">{{ userInfo.userType }}</text>-->
</view>
<image @click="showUserDetail" style="width: 48rpx;height: 48rpx" src="/static/icons/more.png" mode="aspectFita"></image>
<image style="width: 48rpx;height: 48rpx" src="/static/icons/more.png" mode="aspectFita"></image>
</view>
<view class="body-top-grid">
<view v-for="(item, index) in menuList" :key="index" class="body-top-item" @click="gotoPage(item)">
@ -43,6 +44,11 @@
import tabBarVue from '@/components/tabBar/tabBar.vue'
import VNavigationBar from '@/components/VNavigationBar.vue'
import OrderCard from "@/components/orderCard.vue";
import config from '@/config'
import {
getToken,
getUserInfo
} from '@/utils/auth'
export default {
components: {
@ -52,10 +58,10 @@ export default {
},
data() {
return {
imgUrlPrex:config.baseImageUrl,
userInfo: {
avatarUrl: undefined,
userName: '曾廷',
userType: '服务顾问'
avatar: undefined,
nickname: '曾廷'
},
menuList: [
{
@ -103,7 +109,15 @@ export default {
defaultAvatar: require('@/static/icons/avatar.png')
}
},
onShow() {
onLoad() {
if(!getToken()){
uni.reLaunch({
url: '/pages/login/login'
})
}else{
//
this.userInfo = getUserInfo()
}
},
methods: {
gotoPage(menu) {
@ -113,7 +127,7 @@ export default {
},
avatarErr(err) {
console.log('err', err)
this.userInfo.avatarUrl = this.defaultAvatar
this.userInfo.avatar = this.defaultAvatar
},
showUserDetail() {
uni.navigateTo({

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -17,7 +17,7 @@
},
onLoad() {
uni.reLaunch({
url: '/pages-home/home/home'
url: '/pages/login/login'
})
},
methods: {

View File

@ -1,241 +1,203 @@
<template>
<view class="content">
<view class="kuang">
<view class="land">您好</view>
<view class="land">欢迎登录智修小助手</view>
</view>
<view class="xiaoannoi">
<u-button v-if="privacyPolicyChecked == true" text="手机号快捷登录" class="dl" :customStyle="{color:'#ffffff'}"
color="#0D2E8D" open-type='getPhoneNumber'
@getphonenumber="getPhone"></u-button>
<u-button v-else text="手机号快捷登录" class="dl" :customStyle="{color:'#ffffff'}"
color="#0D2E8D" @click="shibai()" ></u-button>
</view>
<view class="dbottom">
<view class="axquan" v-if="privacyPolicyChecked == false" @click="privacyPolicyChecked = true"></view>
<view class="axquanl" v-if="privacyPolicyChecked == true" @click="privacyPolicyChecked = false">
<uni-icons type="checkmarkempty" color="#ffffff" size="14"></uni-icons>
<!-- #ifdef APP-PLUS || H5 -->
<view class="top">
<view class="touxiang">
<image src="../../static/xinlogo.png" mode=""></image>
</view>
<text>请您认真阅读</text>
<text class="lan" @click="goPolicy()">用户协议</text>
<view class="twotap">
<view :class="{'blck':activeid == index}" v-for="(item,index) in qh " :key="index"
@click="getxz(index)">{{item.text}}</view>
</view>
<view class="inputs" v-if="activeid == 0 || activeid == 2 ">
<input type="text" v-model="tel" placeholder="请输入手机号">
</view>
<view class="inputs" v-if="activeid == 1">
<input type="text" v-model="tel" placeholder="请输入手机号">
</view>
<view class="inputs" style="justify-content: space-between; " v-if="activeid == 1">
<input type="text" v-model="yzm" placeholder="请输入验证码">
<button class="jsq" :disabled="isButtonDisabled" @click="sendVerificationCode">{{ buttonText }}</button>
</view>
<view class="inputs" v-if="activeid == 0 || activeid == 2 ">
<input type="password" v-model="wrod" placeholder="请输入密码">
</view>
<view class="wjworb" v-if="activeid == 0 || activeid == 2" @click="goforgot()">
<view class="">忘记密码</view>
</view>
</view>
<view class="dl" @click="getlogin()">
<text> </text>
</view>
<!-- #endif -->
<view class="dbottom">
<view class="quanzi" v-if="qindex == false " @click="qindex =! qindex"></view>
<view class="lanquanzi" v-if="qindex == true" @click="qindex =! qindex"><u-icon name="checkbox-mark"
color="#ffffff" size="14"></u-icon></view>
<text>请仔细阅读</text>
<text class="lan">用户协议</text>
<text></text>
<text class="lan" @click="goPolicy()">隐私政策</text>
<text class="lan">隐私政策</text>
</view>
</view>
</template>
<script>
import request from '../../utils/request';
import {setToken} from '@/utils/auth.js'
export default{
data(){
return{
yd : false,
shenfen:'jcyh',
show:false,
baseUrl:this.$baseUrl,
privacyPolicyChecked:false,
import request from '@/utils/request';
import {
loginApp
} from '@/api/login';
import {
setToken,
setTenantId,
setUserInfo
} from '@/utils/auth'
import {
login,
getInfo,
getTenantIdByPhone
} from '@/api/login'
export default {
data() {
return {
//
sysCode:"weixiu",
phoneNumber: "",
baseUrl: this.$baseUrl,
isButtonDisabled: false,
countdownTime: 60,
qh:[
{text:'密码登录'},
{text:'验证码登录'}
qh: [{
text: '密码登录'
},
{
text: '验证码登录'
},
],
columns: [
['用户','代办' ]
],
tel:'',
yzm:'',
wrod:'',
activeid:0
qindex: false,
tel: '',
yzm: '',
wrod: '',
activeid: 0
}
},
onLoad() {
this.wxlogin()
},
computed: {
buttonText() {
if (this.isButtonDisabled) {
return `${this.countdownTime}s 后重新发送`;
} else {
return "获取验证码";
}
},
},
methods:{
async getsxshenfen(){
let data = {
roleCode : this.shenfen
}
let res = await request({
url:'/appInspection/userOwn/updateRole',
method:'post',
params: data
})
if(res.code == 200){
uni.redirectTo({
url: '/pages/detection/my'
})
buttonText() {
if (this.isButtonDisabled) {
return `${this.countdownTime}s 后重新发送`;
} else {
return "获取验证码";
}
},
getshenfen(text){
this.shenfen = text
},
open() {
// console.log('open');
},
close() {
// this.show = false
// uni.reLaunch({
// url: '/pages/detection/my'
// })
// // console.log('close');
},
goPolicy() {
uni.navigateTo({
url: "/pages/login/PrivacyPolicy"
})
},
},
mounted() {},
methods: {
wxlogin() {
uni.login({
provider: 'weixin',
success(res) {
console.log(543, res);
if (res.code) {
uni.setStorageSync('c1', res.code);
console.log('wxlogin:', res.code);
} else {
console.log('登录失败!' + res.errMsg)
}
}
})
},
async getAppinfo(){
let res = await request({
url:'/getAppInfo',
method:'get',
})
console.log('getappinfo',res);
},
//
authorize() {
uni.showToast({
icon: "none",
title: "请阅读并勾选用户协议",
duration: 2000
})
},
shibai(){
uni.showToast({
icon: "none",
title: "请阅读并勾选用户协议",
duration: 2000
})
},
getPhone(e) {
console.log('执行了');
if (this.privacyPolicyChecked == false) {
uni.showToast({
icon: "none",
title: "请阅读并勾选用户协议",
duration: 2000
})
return;
}
uni.checkSession({
success: () => {
uni.request({
url: this.baseUrl + "/userClient/repair/wxLogin",
method: "POST",
data: {
code: uni.getStorageSync('c1'),
encryptedIv: e.detail.iv,
encryptedData: e.detail.encryptedData,
inviteId: uni.getStorageSync('inviteId') ? uni.getStorageSync('inviteId') : null
},
success: (rex) => {
if (rex.data.code == 0) {
//token
setToken(rex.data.data.token)
if (rex.data.data.ifNeedFill) {
uni.reLaunch({
url: '/pages/my/register'
})
} else {
uni.reLaunch({
url: '/pages-home/home/home'
})
}
} else {
uni.showToast({
icon: 'none',
title: '登录失败,请联系管理人员'
})
}
},
fail: (res) => {
console.log("fail", res);
uni.showToast({
icon: "error",
title: "登录失败,请重新点击并授权!",
duration: 2000
})
}
})
},
fail: () => {
uni.showToast({
icon: 'error',
duration: 2000,
title: "登录状态过期,重新登录"
});
//
getlogin() {
if (this.qindex != true) {
uni.showToast({
icon: "none",
title: "请阅读并勾选用户协议",
duration: 2000
})
return;
}
if (this.tel == '') {
uni.showToast({
title: '手机号不能为空!',
icon: 'none'
})
return
}
const loginFun = () => {
let data;
if (this.activeid == 1) {
//
data = {
phone: this.tel,
code: this.yzm,
type: 1,
sysCode:this.sysCode
}
} else {
//
data = {
username: this.tel,
password: this.wrod,
type: 0,
sysCode:this.sysCode
}
}
})
},
userinfo(){
console.log('执行了');
request({
url: '/getAppInfo',
method: 'get',
}).then((res)=>{
let userJson = {}
userJson.userId = res.user.userId
console.log('身份信息',res,res.role.length);
uni.setStorageSync('role',res.role)
uni.setStorageSync('userinfo',res.user)
if(!res.role||res.role.length==0){
this.show = true
}else{
uni.reLaunch({
url: '/pages/detection/my'
request({
url: '/app-api/company/staff/loginApp',
method: 'post',
data: data
}).then((res) => {
console.log(res)
if (res.code == 200) {
uni.showToast({
title: '登录成功',
icon: 'none'
})
setToken(res.data.loginResult.accessToken)
setUserInfo(res.data.userinfo)
//
uni.navigateTo({
url: '/pages-home/home/home'
})
}else{
uni.showToast({
title: res.msg,
icon: 'none'
})
}
})
}
//
getTenantIdByPhone(this.tel).then(res => {
if (res.code === 200 && res.data && res.data.length > 0) {
uni.showActionSheet({
itemList: res.data.map(m => m.name),
success: ({
tapIndex
}) => {
setTenantId(res.data[tapIndex].id)
loginFun()
}
})
} else {
//
uni.showToast({
title: '抱歉,您没有权限登录!',
icon: 'none'
})
}
})
},
getxz(index){
getxz(index) {
this.activeid = index
},
goregister(){
uni.redirectTo({
url:'/pages/login/register'
goregister() {
uni.navigateTo({
url: '/pages/login/register'
})
},
goforgot(){
uni.redirectTo({
url:'/pages/login/forgot'
})
},
goselect(){
console.log('执行');
uni.redirectTo({
url:'/pages/index/index'
goforgot() {
uni.navigateTo({
url: '/pages/login/forgot'
})
},
//
@ -249,151 +211,92 @@
this.tel = '';
return false;
}
if (this.isButtonDisabled) {
return; //
}
const data = {
phone:this.tel,
}
request({
url: '/loginSmsCode',
method: 'post',
params: data
}).then((res)=>{
console.log('验证码',res);
if(res.code == 200){
uni.showToast({
title:'验证码已发送 请注意查收',
icon:'none'
})
}else{
uni.showToast({
title:'网络不佳请稍后再试',
icon:'none'
})
}
if (this.isButtonDisabled) {
return; //
}
const data = {
phone: this.tel,
sysCode:this.sysCode,
}
request({
url: '/app-api/company/staff/loginSmsCode',
method: 'post',
params: data
}).then((res) => {
console.log('验证码', res);
if (res.code == 200) {
this.disableButton(); //
this.startCountdown(); //
uni.showToast({
title: '验证码已发送 请注意查收',
icon: 'none'
})
this.disableButton(); //
this.startCountdown(); //
} else {
uni.showToast({
title: '网络不佳请稍后再试',
icon: 'none'
})
}
})
},
disableButton() {
this.isButtonDisabled = true;
this.isButtonDisabled = true;
},
enableButton() {
this.isButtonDisabled = false;
this.isButtonDisabled = false;
},
startCountdown() {
let countdown = setInterval(() => {
this.countdownTime--;
if (this.countdownTime === 0) {
clearInterval(countdown);
this.enableButton(); //
}
}, 1000);
let countdown = setInterval(() => {
this.countdownTime--;
if (this.countdownTime === 0) {
clearInterval(countdown);
this.enableButton(); //
}
}, 1000);
},
}
}
</script>
<style scoped lang="scss">
.jsq{
.jsq {
border: none !important;
font-size: 14px;
font-weight: 400;
color: #0078FF;
}
.anniu{
width: 150px;
height: 40px;
border-radius: 50px;
display: flex;
align-items: center;
justify-content: center;
color: white;
background: #0D2E8D;
color: #FFFFFF;
margin: 0 auto;
}
.cont-popup{
height: 250px;
width: 300px;
background-color: #FFFFFF;
box-sizing: border-box;
padding: 15px;
border-radius: 10px;
}
.popup-title{
width: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
font-weight: bold;
color: #0D2E8D;
}
.dix{
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
margin: 20px 0px;
font-size: 18px;
font-weight: bold;
}
.lqiu{
width: 15px;
height: 15px;
border-radius: 50%;
border: 1px solid #0D2E8D;
background: #0D2E8D;
color: white;
display: flex;
align-items: center;
justify-content: center;
}
.qiu{
width: 15px;
height: 15px;
border-radius: 50%;
border: 1px solid #E8E8E8;
}
button {
border: none !important;
background: none !important;
margin: 0px;
display: block;
border: none !important;
background: none !important;
margin: 0px;
display: block;
}
button:focus {
color: #0078FF;
outline: none;
box-shadow: none;
outline: none;
box-shadow: none;
}
.content{
box-sizing: border-box;
padding-top: 1px;
background-image: url('http://www.nuoyunr.com/lananRsc/jdc-bj.png');
background-size: cover;
width: 100%;
height: calc(100vh);
.content {
box-sizing: border-box;
}
.top{
.top {
box-sizing: border-box;
padding: 0px 27px;
padding-top: 100px;
background-image: url('../../static/loginbj.png');
// background-color:lightseagreen;
// background-image: url('../../static/loginbj.png');
background-size: cover;
background-position: center;
width: 100%;
// height: 385px;
}
.touxiang{
.touxiang {
width: 88px;
height: 88px;
border-radius: 10px;
@ -401,16 +304,19 @@
margin: 0 auto;
margin-bottom: 40px;
overflow: hidden;
image{
image {
width: 100%;
height: 100%;
}
}
.twotap{
.twotap {
width: 100%;
display: flex;
align-items: center;
view{
view {
font-size: 15px;
font-family: Microsoft YaHei;
font-weight: 400;
@ -418,19 +324,22 @@
margin-right: 38.5px;
}
}
.blck{
.blck {
color: #333333 !important;
font-weight: bold !important;
}
.inputs{
.inputs {
box-sizing: border-box;
padding: 16px 0px;
display: flex;
align-items: center;
border-bottom: 2px solid #E8E8E8 ;
border-bottom: 2px solid #E8E8E8;
margin-top: 20px;
}
.wjworb{
.wjworb {
margin-top: 5px;
width: 100%;
display: flex;
@ -440,28 +349,22 @@
align-items: center;
}
.dl{
.dl {
width: 90%;
height: 44px;
background-color: #0D2E8D;
border-radius: 50px;
background: linear-gradient(-46deg, #0853C4 0%, #4282D8 80%);
border-radius: 5px;
margin: 0 auto;
font-size: 16px;
color: #FFFFFF;
display: flex;
justify-content: center;
align-items: center;
margin-top: 300px;
margin-top: 22px;
}
.xiaoannoi{
width: 90%;
height: 40px;
margin: 0 auto;
border-radius: 50px;
overflow: hidden;
margin-top: 300px;
}
.hging{
.hging {
width: 100%;
text-align: center;
font-size: 14px;
@ -469,26 +372,30 @@
color: #636363;
margin-top: 20px;
}
.wx{
.wx {
width: 38px;
height: 38px;
overflow: hidden;
box-sizing: border-box;
margin: 0px auto;
margin-top: 20px;
image{
image {
width: 100%;
height: 100%;
}
}
.hui{
.hui {
font-size: 10px;
width: 100%;
text-align: center;
font-weight: 400;
color: #666666;
}
.dbottom{
.dbottom {
width: 100%;
text-align: center;
font-size: 12px;
@ -497,38 +404,73 @@
position: fixed;
bottom: 25px;
display: flex;
align-items: center;
justify-content: center;
}
.quanzi {
width: 14px;
height: 14px;
border: 1px solid #666666;
border-radius: 50%;
margin-right: 10px;
}
.lanquanzi {
width: 14px;
height: 14px;
border: 1px solid #0078FF;
border-radius: 50%;
margin-right: 10px;
background: #0078FF;
color: white;
}
.lan {
color: #0078FF;
}
.jiuzhong {
width: 90%;
margin: 10px auto;
display: flex;
align-items: center;
}
.lan{
color: #0D2E8D;
.dist {
display: flex;
align-items: center;
margin: 0px 10px;
}
.land{
font-size: 25px;
font-weight: bold;
color: #0D2E8D;
margin-bottom: 5px;
.d-zi {
font-size: 14px;
}
.kuang{
width: 90%;
margin: 0 auto;
margin-top: 100px;
}
.axquan{
width: 18px;
height: 18px;
border-radius: 50%;
border: 1px solid #AAAAAA;
.d-qian {
width: 14px;
height: 14px;
margin-right: 5px;
}
.axquanl{
width: 18px;
height: 18px;
overflow: hidden;
border-radius: 50%;
border: 1px solid #AAAAAA;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid #666666;
color: white;
}
.d-qian-lan {
width: 14px;
height: 14px;
margin-right: 5px;
background-color: #0D2E8D;
overflow: hidden;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
background: #0078FF;
border: 1px solid #0078FF;
color: white;
}
</style>

View File

@ -17,12 +17,20 @@
<text class="formValue">{{ customInfo.name }}</text>
<u-icon color="#999" name="arrow-right" size="12"></u-icon>
</view>
<view style="padding-bottom: 60rpx;border-bottom: 1px solid #ddd" class="formItem">
<view class="formItem">
<image class="formIcon" mode="aspectFit" src="/static/icons/userInfo_3.png"></image>
<text class="formLabel">绑定电话</text>
<text class="formValue">{{ customInfo.phone }}</text>
<u-icon color="#999" name="arrow-right" size="12"></u-icon>
</view>
<view class="formItem">
<image class="formIcon" mode="aspectFit" src="/static/icons/userInfo_3.png"></image>
<text class="formLabel">我的邀请码</text>
<text class="formValue"></text>
</view>
<view style="padding-bottom: 60rpx;border-bottom: 1px solid #ddd;" class="formItem">
<image style="width: 200px; height: 200px;margin: auto" class="formIcon" mode="scaleToFill" src="@/pages-home/static/yaoqingma.png"></image>
</view>
<view class="btn">
退出登录

View File

@ -32,9 +32,13 @@ export function hasRole(roleCode) {
}
export function getUserInfo() {
return uni.getStorageSync(UserInfo)
if(uni.getStorageSync(UserInfo)){
return JSON.parse(uni.getStorageSync(UserInfo))
}else{
return undefined;
}
}
export function setUserInfo(userInfo) {
return uni.setStorageSync(UserInfo, userInfo)
export function setUserInfo(dataObj) {
return uni.setStorageSync(UserInfo, JSON.stringify(dataObj))
}