This commit is contained in:
Iruka 2025-02-07 16:16:29 +08:00
parent 340f15f7c9
commit bb40bf6ab4
9 changed files with 505 additions and 219 deletions

11
App.vue
View File

@ -12,9 +12,9 @@
export default {
data() {
return {
ijs: new indexUtil(), //
dc: new deviceControl(2, this.dcEventHandler), //
mqtt: new mqttUtil(mqttUrl, this.mqttStateHandler, this.mqttMsgHandler), //Mqtt
ijs: null, //
dc: null, //
mqtt: null, //Mqtt
isFirseLink: true, //Mqtt
mqttFun: {},
landFun: {},
@ -48,6 +48,11 @@
console.log('App Hide')
},
methods: {
initData() {
this.ijs = new indexUtil(); //
this.dc = new deviceControl(2, this.dcEventHandler); //
this.mqtt = new mqttUtil(mqttUrl, this.mqttStateHandler, this.mqttMsgHandler); //Mqtt
},
//
on(type, key, callBack) {
switch (type) {

View File

@ -5,6 +5,12 @@
// }
// },
"pages": [{
"path": "pages/agreement",
"style": {
"navigationBarTitleText": "协议",
"navigationStyle": "custom"
}
}, {
"path": "pages/login",
"style": {
"navigationBarTitleText": "登录",

254
pages/agreement.vue Normal file
View File

@ -0,0 +1,254 @@
<template>
<view class="login-container">
<view class="title">
<image :src="appInfo.logo"></image>
<text>{{appInfo.name}}</text>
</view>
<view class="login-form-content" v-if="!showPop">
数据加载中
</view>
<view class="bottom_text">
<view>浙ICP备2023018079号-2A</view>
<view>浙江及时雨智能灌溉设备有限责任公司</view>
</view>
</view>
<!-- 协议弹窗 -->
<u-popup mode="center" :show="showPop" :is-mask-click="false">
<view style="background: #f3f3f3;max-width: 70vw;">
<view style="text-align: center;font-weight: bold;padding-top: 10px;">
<text>用户协议和隐私协议</text>
</view>
<view style="height: 400px;padding: 10px 10px 10px 10px;">
我们依据相关法律制定了
<text class="text-blue" @click="handleUserAgrement">用户协议</text>
<text class="text-blue" @click="handlePrivacy">隐私协议</text>
,请您在点击同意之前仔细阅读并充分理解相关条款为了便于您理解隐私政策,特向您说明如下:
<br>
1为了向您提供服务,我们需要收集您的设备信息和操作日志;
<br>
2我们会采取业界先进的安全措施保护您的信息安全,未经您同意,我们不会向第三方共享您的信息;
<br>
3您可以对上述信息进行查询更正删除我们也在政策中提供专门的个人信息保护联系方式
<br>
<br>
如您同意以上协议内容,请点击"同意"接受并开始使用我们的服务
</view>
<view style="position: absolute;bottom: 0; width: 100%;">
<u-button size="large" text="暂不使用" @click="closeApp" style="width: 50%!important;float: left;" />
<u-button type="success" size="large" text="同意" @click="toLogin"
style="width: 50%!important;float: right;" />
</view>
</view>
</u-popup>
</template>
<script setup>
import {
ref,
watch,
computed
} from "vue";
import {
onLoad,
onShow,
} from "@dcloudio/uni-app"
import {
getToken
} from '@/utils/auth'
import {
hasToken,
getInfo
} from '@/utils/login.js'
import config from '@/config.js'
const appInfo = config.appInfo;
const showPop = ref(false);
onLoad(() => {
hasToken().then(() => {
showPop.value = false;
//
getInfo().then(() => {}).catch(error => {
proxy.$toast(error);
})
}).catch(error => {
showPop.value = true;
// #ifdef H5
toLogin()
// #endif
})
})
// 使
function closeApp() {
// #ifdef APP-PLUS
plus.runtime.quit();
// #endif
}
//
function toLogin() {
uni.redirectTo({
url: `/pages/login`
});
}
const globalConfig = ref(config);
//
function handlePrivacy() {
let site = globalConfig.value.appInfo.agreements[0];
uni.navigateTo({
url: `/pages/common/webview/index?title=${site.title}&url=${site.url}`
});
};
//
function handleUserAgrement() {
let site = globalConfig.value.appInfo.agreements[1]
uni.navigateTo({
url: `/pages/common/webview/index?title=${site.title}&url=${site.url}`
});
};
</script>
<style lang="scss" scoped>
uni-page-wrapper {
max-height: 100%;
overflow: hidden;
}
page {
background-color: #ffffff;
}
.u-checkbox {
margin: 0;
}
::v-deep .u-checkbox__icon-wrap.u-checkbox__icon-wrap--square {
width: 15px !important;
height: 15px !important;
}
.login-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
align-items: center;
background-image: url(../static/images/login/login_bg.png);
background-size: 100% 100%;
background-position: 30% 30%;
background-repeat: no-repeat;
::v-deep .u-tabs__wrapper__nav__item__text {
font-size: 32rpx;
}
.title {
margin: 80px 0 30px;
font-size: 44rpx;
color: #39ac4f;
text-align: center;
image {
width: 120rpx;
height: 120rpx;
margin-bottom: 20px;
}
text {
display: block;
}
}
.login-form-content {
text-align: center;
margin: 10px auto 20px;
width: 80%;
.input-item {
background-color: transparent !important;
border-bottom: 1px solid #39ac4f;
border-image: linear-gradient(to left, transparent, #39ac4f, transparent)1;
margin: 0px auto;
height: 45px;
border-radius: 20px;
.icon {
color: #39ac4f;
font-size: 48rpx;
}
.input {
width: 100%;
font-size: 30rpx;
line-height: 20px;
text-align: left;
padding-left: 15px;
}
}
.login-code {
margin-top: 10px;
display: flex;
justify-content: space-around;
.login-code-button {
width: 96px;
height: 38px;
white-space: nowrap
}
}
.tip-text {
font-size: 28rpx;
color: #c0c4cc;
margin: 10px 0;
width: 100%;
overflow: hidden;
}
.red-tip {
font-size: 28rpx;
color: #ff1e35;
}
.remember-password {
margin-top: 20px;
display: flex;
justify-content: space-between;
.forget-password {
color: #39ac4f;
font-size: 28rpx;
}
}
.login-btn {
margin-top: 40px;
height: 45px;
}
}
.account_agreement {
text-align: left;
margin: 20px 15px;
font-size: 20rpx;
font-weight: bold;
color: red;
}
.bottom_text {
text-align: center;
margin: auto auto 10px auto;
font-size: 20rpx;
color: #000;
}
}
</style>

View File

@ -1,8 +1,7 @@
<template>
<custom-nav-bar :left="true" :title="params.title" />
<view v-if="params.url">
<web-view style="margin-top: 45px;" :webview-styles="webviewStyles"
:src="`${params.url}`"></web-view>
<web-view style="margin-top: 45px;" :webview-styles="webviewStyles" :src="`${params.url}`"></web-view>
</view>
</template>
@ -34,15 +33,17 @@
// }
},
onReady() {
uni.showLoading()
// #ifdef APP-PLUS
//html5plusplus.webview.currentWebview()uni-appvue使plus.webview.currentWebview()
var currentWebview = this.$scope.$getAppWebview()
setTimeout(function() {
wv = currentWebview.children()[0]
wv.setStyle({
top: 60
top: 70
})
}, 100); //
uni.hideLoading()
}, 500); //
// #endif
}
}

View File

@ -50,13 +50,13 @@
</view>
</view>
<view class="xieyi" style="display: flex; align-items: center;">
<!-- <view class="xieyi" style="display: flex; align-items: center;">
<u-checkbox-group placement="row" v-model="checkboxGroup">
<u-checkbox name="reading1" />
<text class="text-blue" @click="handleUserAgrement">用户协议</text>
<text class="text-blue" @click="handlePrivacy">隐私协议</text>
</u-checkbox-group>
</view>
</view> -->
<view class="account_agreement">
<view>账号安全提醒系统账号是您登录系统唯一授权凭证如果因为账号丢失或转交给别人导致设备运行风险平台方概不负责</view>
</view>
@ -68,36 +68,30 @@
</template>
<script setup>
import {
ref,
watch,
computed
} from "vue";
import {
onLoad,
} from "@dcloudio/uni-app"
import {
loginHandle
} from '@/utils/login.js'
import plugin from "@/plugins"
import store from '@/store'
import config from '@/config.js'
const appInfo = config.appInfo;
import {
getCurrentInstance
} from 'vue';
const {
proxy
} = getCurrentInstance();
import {
ref,
watch,
computed
} from "vue";
import plugin from "@/plugins"
import {
onLoad,
} from "@dcloudio/uni-app"
import store from '@/store'
import {
getToken,
setToken,
removeToken
} from '@/utils/auth'
import {
rsaEncrypt,
rsaDecrypt
} from "@/utils/rsa"
import config from '@/config.js'
const appInfo = config.appInfo;
import {
getCodePhone,
phoneLogin
// phoneLogin
} from "@/api/login";
const loginForm = ref({
loginName: "",
@ -120,11 +114,6 @@
}
// //
// getApp().globalData.updateApp = false;
// token
if (getToken()) {
loginSuccess()
}
})
// tabs
@ -174,7 +163,6 @@
}
}
//
function rememberPasswordChange(e) {
if (e.length) {
@ -216,7 +204,6 @@
setCodeTimer();
}
});
};
//
function checkTelephone(telephone) {
@ -253,13 +240,10 @@
//
async function handleLogin() {
if (!checkboxGroup.value.length) {
proxy.$toast("请先阅读并同意《用户协议》与《隐私协议》");
return;
}
uni.showLoading({
mask: true
});
// if (!checkboxGroup.value.length) {
// proxy.$toast("");
// return;
// }
let loginObj = Object.assign({}, loginForm.value);
let loginAPI = null;
if (curNow.value == 0) {
@ -283,86 +267,22 @@
if (!loginAPI) {
return;
}
store
.dispatch(loginAPI.url, loginAPI.data)
.then(res => {
//
if (rememberPassword.value) {
uni.setStorageSync("jsy_remember", true)
uni.setStorageSync("jsy_username", loginForm.value.loginName)
uni.setStorageSync("jsy_password", loginForm.value.password)
} else {
uni.removeStorageSync("jsy_remember")
uni.removeStorageSync("jsy_username")
uni.removeStorageSync("jsy_password")
}
loginSuccess()
})
.catch(error => {
proxy.$toast(error);
})
.finally(() => {})
}
//
async function loginSuccess() {
uni.showLoading({
mask: true
});
//
store.dispatch("GetInfo").then(result => {
if (result.code == 200) {
toIndex(result.user.userId);
//
loginHandle(loginAPI).then(res => {
//
if (rememberPassword.value) {
uni.setStorageSync("jsy_remember", true)
uni.setStorageSync("jsy_username", loginForm.value.loginName)
uni.setStorageSync("jsy_password", loginForm.value.password)
} else {
proxy.$toast(result.msg);
uni.removeStorageSync("jsy_remember")
uni.removeStorageSync("jsy_username")
uni.removeStorageSync("jsy_password")
}
}).catch(error => {
proxy.$toast(error);
})
//
store
.dispatch("getUserRoles")
.then(res => {})
.catch(error => {
proxy.$toast("获取用户权限失败");
})
.finally(() => {})
}
//
function toIndex(userId) {
// MQTTH5
// #ifdef APP-PLUS
getApp().mqttLink(userId);
// #endif
uni.switchTab({
url: '/pages/index',
success: () => {
// //
// getApp().ijs.initData(userId, (land, wo) => {
// getApp().getWoList(land, wo);
// });
uni.hideLoading();
},
fail: () => {},
complete: () => {}
});
}
const globalConfig = ref(config);
//
function handlePrivacy() {
let site = globalConfig.value.appInfo.agreements[0];
uni.navigateTo({
url: `/pages/common/webview/index?title=${site.title}&url=${site.url}`
});
};
//
function handleUserAgrement() {
let site = globalConfig.value.appInfo.agreements[1]
uni.navigateTo({
url: `/pages/common/webview/index?title=${site.title}&url=${site.url}`
});
};
</script>
<style lang="scss" scoped>
@ -374,7 +294,11 @@
page {
background-color: #ffffff;
}
.u-checkbox{margin: 0;}
.u-checkbox {
margin: 0;
}
::v-deep .u-checkbox__icon-wrap.u-checkbox__icon-wrap--square {
width: 15px !important;
height: 15px !important;

View File

@ -2,105 +2,109 @@
<!-- 顶部导航栏 -->
<custom-nav-bar :left="true" leftText="" @leftClick="" title="应用设置">
</custom-nav-bar>
<view class="setting-container" :style="{height: `${windowHeight}px`}">
<view class="menu-list">
<view class="list-cell list-cell-arrow" @click="handleToPwd">
<view class="menu-item-box">
<view class="iconfont icon-password menu-icon"></view>
<view>修改密码</view>
</view>
</view>
<view class="list-cell list-cell-arrow" @click="handleToUpgrade">
<view class="menu-item-box">
<view class="iconfont icon-refresh menu-icon"></view>
<view>检查更新</view>
</view>
</view>
<view class="list-cell list-cell-arrow" @click="handleCleanTmp">
<view class="menu-item-box">
<view class="iconfont icon-clean menu-icon"></view>
<view>清理缓存</view>
</view>
</view>
</view>
<view class="cu-list menu">
<view class="item-box">
<u-button class="bg-red" type="success" size="large" text="退出登录" @click="handleLogout"/>
</view>
</view>
</view>
<view>
<uni-popup ref="popup" type="dialog">
<uni-popup-dialog type="info" cancelText="关闭" confirmText="退出"
title="通知" content="确定注销并退出系统吗"
@confirm="dialogConfirm"
@close="dialogClose">
</uni-popup-dialog>
</uni-popup>
</view>
<view class="setting-container" :style="{height: `${windowHeight}px`}">
<view class="menu-list">
<view class="list-cell list-cell-arrow" @click="handleToPwd">
<view class="menu-item-box">
<view class="iconfont icon-password menu-icon"></view>
<view>修改密码</view>
</view>
</view>
<view class="list-cell list-cell-arrow" @click="handleToUpgrade">
<view class="menu-item-box">
<view class="iconfont icon-refresh menu-icon"></view>
<view>检查更新</view>
</view>
</view>
<view class="list-cell list-cell-arrow" @click="handleCleanTmp">
<view class="menu-item-box">
<view class="iconfont icon-clean menu-icon"></view>
<view>清理缓存</view>
</view>
</view>
</view>
<view class="cu-list menu">
<view class="item-box">
<u-button class="bg-red" type="success" size="large" text="退出登录" @click="handleLogout" />
</view>
</view>
</view>
<view>
<uni-popup ref="popup" type="dialog">
<uni-popup-dialog type="info" cancelText="关闭" confirmText="退出" title="通知" content="确定注销并退出系统吗"
@confirm="dialogConfirm" @close="dialogClose">
</uni-popup-dialog>
</uni-popup>
</view>
</template>
<script setup>
import { ref } from "vue";
import store from '@/store'
const windowHeight=ref(uni.getSystemInfoSync().windowHeight) ;
const popup = ref(null);
function handleToPwd() {
uni.navigateTo({
url: '/pages/mine/pwd/index'
});
};
function handleToUpgrade() {
uni.showToast({
title: '模块建设中~',
mask: false,
icon:"none",
duration: 1000
});
};
function handleCleanTmp() {
uni.showToast({
title: '模块建设中~',
mask: false,
icon:"none",
duration: 1000
});
};
function handleLogout() {
popup.value.open();
};
function dialogConfirm() {
//console.log('----------------------------')
store.dispatch('LogOut').then(() => {
uni.reLaunch({
url: '/pages/login'
});
})
};
function dialogClose() {
//console.log('')
};
import {
ref
} from "vue";
import store from '@/store'
const windowHeight = ref(uni.getSystemInfoSync().windowHeight);
const popup = ref(null);
function handleToPwd() {
uni.navigateTo({
url: '/pages/mine/pwd/index'
});
};
function handleToUpgrade() {
uni.showToast({
title: '模块建设中~',
mask: false,
icon: "none",
duration: 1000
});
};
function handleCleanTmp() {
uni.showToast({
title: '模块建设中~',
mask: false,
icon: "none",
duration: 1000
});
};
function handleLogout() {
popup.value.open();
};
function dialogConfirm() {
//console.log('----------------------------')
store.dispatch('LogOut').then(() => {
uni.reLaunch({
// url: '/pages/login'
url: '/pages/agreement'
});
})
};
function dialogClose() {
//console.log('')
};
</script>
<style lang="scss" scoped>
.page {
background-color: #f8f8f8;
}
.page {
background-color: #f8f8f8;
}
.item-box {
margin: 30rpx;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 10rpx;
border-radius: 8rpx;
color: #303133;
font-size: 32rpx;
}
</style>
.item-box {
margin: 30rpx;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 10rpx;
border-radius: 8rpx;
color: #303133;
font-size: 32rpx;
}
</style>

92
utils/login.js Normal file
View File

@ -0,0 +1,92 @@
import store from '@/store'
import {
getToken
} from '@/utils/auth'
/**
* 登录成功逻辑
*/
export function loginHandle(loginAPI) {
uni.showLoading({
mask: true
});
return new Promise((resolve, reject) => {
store
.dispatch(loginAPI.url, loginAPI.data)
.then(res => {
uni.hideLoading();
getInfo().then(res => {
resolve();
}).catch(error => {
reject(error)
})
})
.catch(error => {
reject(error)
})
.finally(() => {})
})
}
/**
* 判断token
*/
export function hasToken() {
return new Promise((resolve, reject) => {
// 如果存在token则直接登录
if (getToken()) {
resolve();
} else {
reject();
}
})
}
/**
* 获取用户信息
*/
export function getInfo() {
//初始化app参数
getApp().initData();
getUserRoles();
//获取用户权限
return new Promise((resolve, reject) => {
uni.showLoading({
mask: true
});
// 保存用户基本信息
store.dispatch("GetInfo").then(result => {
if (result.code == 200) {
// 如果是手机端则自动链接MQTTH5手动链接防止重复链接
// #ifdef APP-PLUS
getApp().mqttLink(result.user.userId);
// #endif
uni.switchTab({
url: '/pages/index',
success: () => {
// // 初始化数据
// getApp().ijs.initData(userId, (land, wo) => {
// getApp().getWoList(land, wo);
// });
uni.hideLoading();
resolve()
},
fail: () => {},
complete: () => {}
});
} else {
uni.hideLoading();
reject(result.msg)
}
}).finally(() => {})
})
}
// 用户菜单
async function getUserRoles() {
store
.dispatch("getUserRoles")
.then(res => {})
.catch(error => {})
.finally(() => {})
}

View File

@ -51,7 +51,7 @@ const request = config => {
store.dispatch("LogOut").then(res => {
uni.reLaunch({
url: "/pages/login"
url: "/pages/agreement"
})
})
}

View File

@ -37,7 +37,7 @@ const upload = config => {
showConfirm("登录状态已过期,您可以继续留在该页面,或者重新登录?").then(res => {
if (res.confirm) {
store.dispatch('LogOut').then(res => {
uni.reLaunch({ url: '/pages/login/login' })
uni.reLaunch({ url: '/pages/agreement' })
})
}
})