123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <template>
- <view>
- <!--<view class="l_top"><image src="" mode="aspectFill"></image></view>-->
- <view class="bg">
- <view class="login">
- <view class="form_group">
- <view class="lable"><text class="icon"></text></view>
- <input type="text" placeholder="邮箱/名字/工号/手机号" v-model="item.username" />
- </view>
- <view class="form_group">
- <view class="lable"><text class="icon"></text></view>
- <input type="password" placeholder="密码" v-model="item.password" />
- </view>
- <view class="form_group" v-if="checkcodeImg !=''">
- <view class="lable" style="width: 25%;">
- <image :src=checkcodeImg style="height: 70rpx;"></image>
- </view>
- <input type="text" placeholder="验证码" v-model="item.checkcode" />
- </view>
- <button class="btn" @click="login()">登陆</button>
- <navigator url="/pages/find_pass" class="pass" hover-class="none">找回密码</navigator>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- item: {
- domainName: '柳工',
- remember: '0',
- debug: 'false',
- checkcode: '',
- language: 'CN',
- url: '/obpm'
- },
- uitem: {},
- checkcodeImg: ''
- };
- },
- onLoad(e) {
- //刷新
- uni.$on('index', res => {
- //this.refresh();
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- });
- },
- mounted() {
- //自动登陆
- if (this.hasLogin()) {
- //uni.redirectTo({ url: '/pages/index/index' ,
- // });
- }
- },
- methods: {
- //登陆
- login() {
- let rule = [{
- name: 'username',
- checkType: 'notnull',
- errorMsg: '请输入账号'
- }, {
- name: 'password',
- checkType: 'notnull',
- errorMsg: '请输入密码'
- }];
- //if (!vm.verify.check(this.item, rule)) {
- // uni.showModal({ content: this.verify.error, showCancel: false });
- // return false;
- // }
- this.item.password = window.btoa(this.item.password);
- var p1 = this.item.password.slice(2);
- var p2 = this.item.password.substring(0, 2)
- this.item.password = p1 + p2;
- //console.log("this.item:"+this.item);
- this.http.request({
- url: this.http.urls.login,
- data: this.item,
- method: 'post',
- success: res => {
- console.log("gfgh===" + JSON.stringify(res.data));
- if (res.data.resultCode == 1) {
- uni.removeStorageSync('user');
- uni.setStorageSync('user', res.data);
- this.myprofile();
- } else {
- this.checkcodeImg = res.data.checkcodeImg;
- }
- }
- });
- }, //登陆
- myprofile() {
- this.http.request({
- url: this.http.urls.myprofile,
- data: this.item,
- success: res => {
- if (res.data.errmsg == 'ok') {
- var accessToken = this.getUser().accessToken;
- res.data.data.accessToken = accessToken;
- uni.removeStorageSync('user');
- //console.log("gfgh==="+JSON.stringify(res.data.data));
- uni.setStorageSync('user', res.data.data);
- uni.$emit('index');
- uni.redirectTo({
- url: '/',
- });
- console.log("res.data.resultCode===" + res.data.errcode);
- }
- }
- });
- },
- }
- };
- </script>
- <style lang="scss">
- .bg {
- padding: 15px;
- image {
- width: 100%;
- height: 10px;
- border-radius: 5px;
- }
- .login {
- .form_group {
- border: 1px solid $line;
- border-radius: 5px;
- margin-top: 10px;
- .lable {
- width: 10px;
- }
- input {
- border: 0px;
- }
- }
- .btn {
- margin-top: 25px;
- width: 82%;
- }
- .pass {
- width: 90%;
- text-align: right;
- padding-top: 20px;
- //color: $cor;
- }
- }
- }
- </style>
|