zhgdyunapp/pages/login/login.vue

321 lines
8.0 KiB
Vue
Raw Normal View History

2022-06-08 15:48:09 +08:00
<template>
2024-04-22 17:36:17 +08:00
<!-- <web-view src="http://niunian.hk.fq99.top"></web-view> -->
<view class="loginPage">
<!-- <view class="barBox" :style="{'height':systemInfo.statusBarHeight+'px'}"> -->
<view class="barBox">
</view>
<view class="loginBox">
<view class="loginTitle">
<image class="loginLogo" src="@/static/login/logo.pic.jpg" mode="heightFix"></image>
智慧工地服务平台
</view>
<view class="btns">
2024-05-05 14:10:07 +08:00
<view class="user feedback" @click="goto('user')">用户登录</view>
<!-- <view class="user feedback" @click="goto('user')">我是用户</view> -->
<!-- <view class="supplier feedback black" @click="goto('supplier')">我是供应商</view> -->
2024-04-22 17:36:17 +08:00
</view>
</view>
<!-- <view class="bottomTitle" @click="showModal=true">
云服务器设置
</view> -->
<!-- <view class="modalBox" v-show="showModal">
<view class="modalContent">
<view class="modalTitle">
云服务器设置
<uni-icons @click="showModal=false" class="closeImg" type="closeempty" size="26"></uni-icons>
</view>
<form @submit="saveServerData">
<view class="uni-form-item">
<input class="uni-input" name="ipPort" v-model="ipPort"
placeholder="格式为http://127.0.0.1:8080" />
</view>
<button form-type="submit" type="primary" class="btn">保存</button>
</form>
</view>
</view> -->
</view>
2022-06-08 15:48:09 +08:00
</template>
<script>
2024-04-22 17:36:17 +08:00
import Vue from 'vue'
import uniIcons from "@/components/uni-icons/uni-icons.vue"
2024-04-22 17:36:17 +08:00
export default {
components: {
uniIcons
},
data() {
return {
2024-04-22 17:36:17 +08:00
ipPort: '',
showModal: false,
systemInfo: {
statusBarHeight: 0
},
clientid: ''
}
},
onLoad() {
let _this = this;
// #ifdef APP-PLUS
// add:添加登录CID绑定功能 实现推送 2022年4月20日 10:47:41 罗劲章// add:添加登录CID绑定功能 实现推送 2022年4月20日 10:47:41 罗劲章
plus.push.getClientInfoAsync((info) => {
const clientid = info["clientid"];
console.log(clientid, "cidcidcidcidcid")
_this.clientid = clientid
2024-04-22 17:36:17 +08:00
});
2024-05-20 13:41:06 +08:00
plus.push.addEventListener('click', function(msg) {
uni.navigateTo({
url: '/pages/messageCenter/messageCenter'
})
}, false);
2024-04-22 17:36:17 +08:00
// #endif
if (uni.getStorageSync('userInfo')) {
let userInfo = JSON.parse(uni.getStorageSync('userInfo'));
let {
accountType
} = userInfo;
if (accountType == 5 || accountType == 6 || accountType == 10) {
// 用户端
uni.reLaunch({
url: '/pages/projectEnd/projectIndex/projectIndex'
})
} else if (accountType == 11) {
// 供应商
let company = uni.getStorageSync("company");
if (company) {
// 判断用户登录时是否选中了组织
uni.reLaunch({
url: '/pages/supplier/supplier'
})
} else {
// 未选中代表新注册用户 只看查看资质
uni.reLaunch({
url: "/pages/supplier/qualifications/qualifications?isNull=1"
})
}
2024-04-22 17:36:17 +08:00
} else {
// 集团
uni.redirectTo({
url: '/pages/projectManage/projectManage'
})
}
}
},
mounted() {
this.systemInfo = uni.getStorageSync('systemInfo')
uni.setStorageSync('language', 'zh_CN')
if (uni.getStorageSync('account')) {
this.account = uni.getStorageSync('account')
this.password = uni.getStorageSync('password')
}
if (uni.getStorageSync('ipPort')) {
this.ipPort = uni.getStorageSync('ipPort');
// let val={
// detail:{
// value:{
// account:this.account,
// password:this.password
// }
// }
// }
// this.formSubmit(val);
2024-04-22 17:36:17 +08:00
} else {
// this.ipPort='183.95.84.54:9500'
// uni.setStorageSync('ipPort',this.ipPort)
}
2022-08-02 15:11:04 +08:00
2024-04-22 17:36:17 +08:00
},
methods: {
goto(type) {
// 跳转用户和供应商注册页面 存储选择的类型
uni.setStorageSync("Type", type);
uni.navigateTo({
url: `/pages/login/compatibleLogin?type=${type}`
})
},
saveServerData(e) {
uni.setStorageSync('ipPort', e.detail.value.ipPort)
Vue.prototype.url_config = uni.getStorageSync('ipPort') + '/'
getApp().globalData.siteUrl = uni.getStorageSync('ipPort') + '/'
this.showModal = false
},
formSubmit(e) {
// console.log(e)
var json = {
account: e.detail.value.account,
password: e.detail.value.password,
clientId: this.clientid
}
this.sendRequest({
url: "xmgl/base/login",
data: json,
method: "POST",
success: (res) => {
// #ifdef APP-PLUS
// add:添加登录CID绑定功能 实现推送 2022年4月20日 10:47:41 罗劲章// add:添加登录CID绑定功能 实现推送 2022年4月20日 10:47:41 罗劲章
plus.push.getClientInfoAsync((info) => {
const cid = info["clientid"];
// console.log(cid,"cidcidcidcidcid")
// const cid = "f4b3246189fc051c5875a35e198ca223";
const userId = res.result.userId;
const jsonParams = {
clientId: cid,
alias: userId
}
//触发绑定请求
this.sendRequest({
url: "xmgl/push/bindAlias", //替换掉后端彭定生的接口
data: jsonParams,
method: "POST",
})
});
// #endif
uni.setStorageSync('account', e.detail.value.account);
uni.setStorageSync('password', e.detail.value.password);
uni.setStorageSync('userInfo', JSON.stringify(res.result));
if (res.result.accountType == 5 || res.result.accountType == 6 || res.result
.accountType == 10) {
if (res.result.styleType == 1) {
uni.redirectTo({
url: '/pages/projectEnd/projectIndex/projectIndex'
})
} else {
uni.redirectTo({
url: '/pages/projectEnd/projectIndex/projectIndex'
})
}
// uni.redirectTo({
// url: '/pages/workstation/workstationIndex/workstationIndex'
// })
} else {
uni.redirectTo({
url: '/pages/projectManage/projectManage'
// url: '/pages/projectEnd/projectIndex/projectIndex'
})
}
}
})
}
}
}
2022-06-08 15:48:09 +08:00
</script>
<style lang="scss" scoped>
2024-04-22 17:36:17 +08:00
.loginPage {
position: relative;
height: 100vh;
color: $uni-text-color;
background: url("@/static/WechatIMG15.jpg");
background-size: cover;
}
2022-06-08 15:48:09 +08:00
2024-04-22 17:36:17 +08:00
.feedback {
&:active {
position: relative;
overflow: hidden;
2024-04-22 17:36:17 +08:00
&::after {
content: "";
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: rgba(255, 255, 255, .08);
}
}
2024-04-22 17:36:17 +08:00
&.black {
&:active {
&::after {
background-color: rgba(0, 0, 0, .05);
}
}
}
}
2024-04-22 17:36:17 +08:00
.loginBox {
padding: 100px 0 0;
}
2022-06-08 15:48:09 +08:00
2024-04-22 17:36:17 +08:00
.loginTitle {
font-size: 30px;
font-weight: 500;
display: flex;
align-items: center;
justify-content: center;
2024-04-22 17:36:17 +08:00
.loginLogo {
height: 60rpx;
width: auto;
margin-right: 10rpx;
}
}
2024-04-22 17:36:17 +08:00
.btns {
padding: 40rpx 30rpx;
position: fixed;
left: 20rpx;
right: 20rpx;
2024-05-04 17:46:33 +08:00
bottom: 15%;
2024-04-22 17:36:17 +08:00
> view {
padding: 20rpx 0;
border-radius: 8rpx;
text-align: center;
margin-top: 60rpx;
}
2024-04-22 17:36:17 +08:00
.user {
background-color: #5e81ee;
color: #fff;
}
2024-04-22 17:36:17 +08:00
.supplier {
background-color: #f7f8f9;
color: #333;
}
}
2022-06-08 15:48:09 +08:00
2024-04-22 17:36:17 +08:00
.uni-input {
border-bottom: 1px solid #ddd;
padding: 10px 15px;
border-radius: 3px;
margin-bottom: 25px;
font-size: 16px;
}
2022-06-08 15:48:09 +08:00
2024-04-22 17:36:17 +08:00
.btn {
margin-top: 40px;
}
2022-06-08 15:48:09 +08:00
2024-04-22 17:36:17 +08:00
.bottomTitle {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
font-size: 15px;
}
2022-06-08 15:48:09 +08:00
2024-04-22 17:36:17 +08:00
.modalContent {
.uni-input {
border: 1px solid #ddd;
}
2022-06-08 15:48:09 +08:00
2024-04-22 17:36:17 +08:00
.btn {
margin-top: 0;
}
}
2022-06-08 15:48:09 +08:00
2024-04-22 17:36:17 +08:00
.barBox {
background-color: #2a2b5b;
}
</style>