123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 |
- <template>
- <view class="content">
- <view class="title">
- <text class="thing" style="width: 100rpx;"></text>
- <text class="name">用户登录</text>
- <text class="thing" style="width: 300rpx;"></text>
- </view>
- <view class="form-box">
- <view class="row-input">
- <u-icon name="account" color="#2979ff" size="50" style="padding: 0 20rpx;"></u-icon>
- <input v-model="account" placeholder="请输入用户账号" maxlength="18" clearable />
- </view>
- <view class="row-input">
- <u-icon name="lock" color="#2979ff" size="50" style="padding: 0 20rpx;"></u-icon>
- <input v-model="password" placeholder="登陆密码" clearable :password="!isShowPassword" />
- <u-icon name="eye-fill" color="#2979ff" size="50" style="padding-right:20rpx" v-if="isShowPassword"
- @click="showOrHide"></u-icon>
- <u-icon name="eye-off" color="#2979ff" size="50" style="padding-right:0rpx" v-else @click="showOrHide">
- </u-icon>
- </view>
- <!-- <view class="rowinputcaptcha">
- <u-icon name="hourglass" color="#2979ff" size="50" style="padding: 0 20rpx;"></u-icon>
- <input class="captchainput" v-model="captcha" placeholder="验证码"/>
- <u--image :showLoading="true" :src="captchaPath" width="150px" height="35px" @click="getCaptcha"></u--image>
- </view> -->
- <!-- <view class="menu-link">
- <text @click="forget">找回密码</text>
- </view> -->
- <view class="login-btn" @click="loginbtn">登录</view>
- <!-- <view class="tip-link">
- 还没有账号?<text @click="register">注册</text>
- </view> -->
- </view>
-
- <view class="Userprotocol">
- <view class="Userprotocolchecked">
- <checkbox :checked="isChecked" @click="isChecked=!isChecked" />
- </view>
- <view class="Userprotocoltext" @click="Userprotocol">
- 我已阅读并同意用户协议和隐私政策
- </view>
- </view>
- <u-toast ref="uToast" />
- <u-notify ref="uNotify" message="" ></u-notify>
- </view>
- </template>
- <script>
-
- // function getUUID() {
- // return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
- // return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
- // })
- // }
- //const BaseApi= require("@/http/baseApi.js");
- export default {
-
- data() {
- return {
- isChecked:true,
- isShowPassword: false,
- account: '',
- password: '',
- captcha: '',
- uuid: '',
- captchaPath: '',
-
- }
- },
- onLoad() {
- // this.getCaptcha();
- },
- onUnload() {
- //触发水印显示
- uni.$emit('ly-show-watermark');
- },
- methods: {
- // 获取验证码
- // getCaptcha() {
- // this.uuid = getUUID();
- // this.captchaPath =BaseApi.BaseApi+ `/captcha?uuid=${this.uuid}`;
- // },
- loginbtn() {
- if(this.isChecked){
-
- if (this.account == '') {
- this.$refs.uToast.show({
- type: 'error',
- message: "请输入账号",
- })
- // uni.showToast({
- // title: "请输入账号",
- // icon:'error',
- // duration: 1000,
- // })
- } else if (this.password == '') {
- this.$refs.uToast.show({
- type: 'error',
- message: "请输入密码",
- })
- }
-
- let formData = {
- username: this.account,
- password: this.password,
- // uuid:this.uuid,
- // captcha:this.captcha,
- }
- //登录功能
- this.$api.post('/login', formData)
- .then(res => {
-
- if (res.data.code == 0) {
-
- uni.setStorageSync('tokendata', res.data.data.token); //token
- uni.setStorageSync('Userinformation', formData); //用户信息
-
- //获取用户的信息,如组织架构,个人信息,权限等
- Promise.all([this.getpermissions(), this.getDictList(), this.getuserInfo(), ]).then(() => {
-
- // uni.switchTab({
- // url: '/pages/index/index',
- // success: res => {},
- // fail: () => {},
- // complete: () => {},
- // })
- uni.navigateTo({
- url: '/pages/index/index'
- })
- });
-
-
- } else {
- this.$refs.uToast.show({
- type: 'error',
- message: "账号或者密码错误,请重新输入",
- })
- }
- })
-
- }else{
- this.$refs.uNotify.error('您尚未同意用户协议')
- }
- },
- getpermissions() {
- console.log('权限功能', )
- //获取用户权限功能
- return new Promise((resolve, reject) => {
- this.$api.get('/menu/permissions', {}).then((res) => {
- uni.setStorageSync('ButtonPermissions', res.data.data);
- resolve(res);
- // console.log('111111111111111111', res)
- }).catch(e => {
- reject(e)
- })
- });
- // this.$api.get('/menu/permissions', {})
- // .then(res1 => {
- // uni.setStorageSync('ButtonPermissions', res1.data.data); //权限列表
- // })
- },
- getDictList() {
- //获取字典列表, 添加并全局变量保存
- return new Promise((resolve, reject) => {
- this.$api.get('/all', {}).then((res) => {
- uni.setStorageSync('getDictDataList', res.data.data);
- resolve(res);
- // console.log('222222', res)
- }).catch(e => {
- reject(e)
- })
- });
- // this.$api.get('/all', {})
- // .then(res => {
- // // console.log('88888', res.data.data)
- // uni.setStorageSync('getDictDataList', res.data.data);
- // })
- },
- getuserInfo() {
- //获取用户信息
- return new Promise((resolve, reject) => {
- this.$api.get('/user/userInfo', {}).then((res) => {
- uni.setStorageSync('getuserInfo', res.data.data);
- resolve(res);
- //console.log('333333', res)
- }).catch(e => {
- reject(e)
- })
- });
- // this.$api.get('/user/userInfo', {})
- // .then(res => {
- // // console.log('88888', res.data.data)
- // uni.setStorageSync('getuserInfo', res.data.data);
- // })
- },
- // 密码显示/密码隐藏
- showOrHide() {
- this.isShowPassword = !this.isShowPassword
- },
- Userprotocol(){
- uni.navigateTo({
- url: '/pages/login/Privacyagreement',
- success: res => {},
- fail: () => {},
- complete: () => {},
- })
- },
- // 找回密码
- forget() {
- uni.navigateTo({
- url: '/pages/login/forget',
- success: res => {},
- fail: () => {},
- complete: () => {},
- })
- },
- // 注册
- register() {
- uni.navigateTo({
- url: '/pages/login/register',
- success: res => {},
- fail: () => {},
- complete: () => {},
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .Userprotocol{
- display: flex;
- align-items: center;
- justify-content: center;
- position: fixed;
- bottom: 20rpx;
- left: 0rpx;
- right: 0rpx;
- }
- .Userprotocolchecked{
-
- }
- .Userprotocoltext{
- color: #fff;
- padding-left: 10rpx;
- }
-
- page {
- background-color: #0b0c14;
- }
- .content {
- padding: 100rpx 40rpx;
- }
- .title {
- display: flex;
- flex-direction: column;
- height: 200rpx;
- .thing {
- height: 8rpx;
- background-image: linear-gradient(to right, #3feaea, #0168e6);
- }
- .name {
- font-weight: bold;
- font-size: 50rpx;
- line-height: 120rpx;
- background: linear-gradient(to right, #3feaea, blue);
- background-clip: text;
- color: transparent;
- letter-spacing: 5rpx;
- }
- }
- .form-box {
- .rowinputcaptcha {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- height: 110rpx;
- //background-color: #2b2f41;
- border-radius: 8rpx;
- margin-bottom: 50rpx;
- input {
- width: 300rpx;
- font-size: 30rpx;
- color: #a1a2a3;
- }
- }
- .row-input {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- height: 110rpx;
- background-color: #2b2f41;
- border-radius: 8rpx;
- margin-bottom: 50rpx;
- image {
- margin: 0 30rpx;
- flex-shrink: 0;
- width: 38rpx;
- height: 38rpx;
- }
- input {
- width: 460rpx;
- font-size: 30rpx;
- color: #a1a2a3;
- }
- }
- .menu-link {
- display: flex;
- justify-content: flex-end;
- align-items: center;
- font-size: 28rpx;
- color: #676c7f;
- }
- .login-btn {
- margin-top: 60rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 35rpx;
- letter-spacing: 15rpx;
- color: #FFFFFF;
- height: 110rpx;
- border-radius: 8rpx;
- background-image: linear-gradient(to right, #3feaea, #0168e6);
- }
- .tip-link {
- position: fixed;
- letter-spacing: 4rpx;
- bottom: 50rpx;
- left: 40rpx;
- font-size: 28rpx;
- color: #a1a2a3;
- text {
- padding-left: 10rpx;
- color: #226ef0;
- }
- }
- }
- .captchainput {
- width: 300rpx;
- }
- </style>
|