123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <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>
- <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:{}
- };
- },
- onLoad(e) {
-
-
- //刷新
- uni.$on('index', res => {
- //this.refresh();
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- });
-
- },
-
- mounted() {
- //自动登陆
-
- if (this.hasLogin()) {
- uni.switchTab({ 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));
- if(res.data.resultCode==1){
-
- uni.removeStorageSync('user');
- uni.setStorageSync('user', res.data);
- uni.$emit('index');
- uni.redirectTo({ url: '/pages/index/index' ,
-
- });
- console.log("res.data.resultCode==="+res.data.resultCode);
- }
- }
- });
- },
-
- }
- };
- </script>
- <style lang="scss">
- .bg {
- padding: 15px;
- image {
- width: 100%;
- height: 170px;
- 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>
|