123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <template>
- <view class="login">
- <view class="app_top">
- <view class="welcome animated bounceIn">
- <view class="desc">您好,</view>
- <view class="desc">欢迎来到天保物流</view>
- </view>
- <image src="../../static/images/my.png" mode="widthFix" class="img"></image>
- </view>
- <view class="dk animated fadeInDown">
- <view class="bg">
- <text class="icon"></text>
- <input type="number" v-model="item.phone" maxlength="11" placeholder="请输入手机号" />
- </view>
- <view class="bg">
- <text class="icon"></text>
- <input :password="show" v-model="item.password" placeholder="请输入密码" />
- <view class="label"><view class="icon" :class="{ active: !show }" @click="show = !show"></view></view>
- </view>
- <view class="xy">
- <u-checkbox-group class="checkbox" v-model="item.checked">
- <u-checkbox size="15" shape="circle" label="我已阅读并同意" labelSize="13" name="true"></u-checkbox>
- </u-checkbox-group>
- <text class="a" @click="go('/pages/login/userAgreement?id=1')">《用户协议》</text>
- <text>和</text>
- <text class="a" @click="go('/pages/login/userAgreement?id=2')">《隐私政策》</text>
- </view>
- <button class="btn" @click="submit()">登录</button>
- <!-- <button class="btn register" @click="go('/pages/login/chooseRole')">注册</button> -->
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- show: true,
- item: {phone:'',password:'',checked:[]}
- };
- },
- onLoad() {
- //自动登陆
- if (uni.getStorageSync('token')) {
- uni.switchTab({ url: '/pages/index/index' });
- return;
- }
- //获取版本号和设备信息
- uni.getSystemInfo({
- success: res => {
- this.item.deviceMode = res.model + ' ' + res.system;
- // #ifdef APP-PLUS
- plus.runtime.getProperty(plus.runtime.appid, wgtinfo => {
- this.item.appVersion = wgtinfo.versionCode;
- });
- // #endif
- }
- });
- },
- methods: {
- toFaceLogin(){
- if(this.item.checked.length==0){
- this.common.toast('请同意并勾选协议');
- return;
- }
- this.common.to('/pages/login/faceLogin');
- },
- submit() {
- uni.clearStorageSync();
- let rule = [
- { name: 'phone', checkType: 'notnull', errorMsg: '手机号不能为空' },
- { name: 'phone', checkType: 'phoneno', errorMsg: '请输入正确的手机号' },
- { name: 'password', checkType: 'notnull', errorMsg: '请输入密码' },
- { name: 'checked', checkType: 'notnull', errorMsg: '请同意并勾选协议' }
- ];
- if (!this.verify.check(this.item, rule)) {
- uni.showModal({ content: this.verify.error, showCancel: false });
- return false;
- }
- let item = JSON.parse(JSON.stringify(this.item));
- item.phone = this.util.encrypt(this.item.phone);
- item.password = this.util.encrypt(this.item.password);
- this.http.request({
- url: '/sp-admin/app/AppUser/login',
- data: item,
- method: 'POST',
- success: res => {
- let data = res.data.data;
- uni.setStorageSync('token', data.tokenInfo.tokenValue);
- uni.setStorageSync('info', data.appUser);
- uni.setStorageSync('menu', data.per_list);
- uni.showToast({ title: '登录成功' });
- setTimeout(() => {
- uni.$emit('getMenu');
- uni.switchTab({ url: '/pages/index/index' });
- }, 1000);
- }
- });
- },
- go(url) {
- uni.navigateTo({ url: url });
- }
- }
- };
- </script>
- <style lang="scss"></style>
|