| | |
| | | </view> |
| | | <view class="bg_w rd8 ptb30 pl40 bbox com-input flex input-height"> |
| | | <image src="@/static/login_ic_code@2x.png" mode="" class="img40 mr25"></image> |
| | | <u--input placeholder="企业代码" border="none" v-model="loginForm.companyId"></u--input> |
| | | <u--input placeholder="企业代码" border="none" v-model="from.companyId"></u--input> |
| | | </view> |
| | | <view class="bg_w rd8 ptb30 pl40 bbox mt40 flex input-height"> |
| | | <image src="@/static/login_ic_phone@2x.png" mode="" class="img40 mr25"></image> |
| | | <u--input placeholder="手机号" border="none" v-model="loginForm.account"></u--input> |
| | | <u--input placeholder="手机号" border="none" v-model="from.username"></u--input> |
| | | </view> |
| | | <view class="bg_w rd8 ptb30 pl40 bbox mt40 flex input-height"> |
| | | <image src="@/static/login_ic_password@2x.png" mode="" class="img40 mr25"></image> |
| | | <u--input placeholder="密码" border="none" v-model="loginForm.password"></u--input> |
| | | <u--input placeholder="密码" border="none" v-model="from.password"></u--input> |
| | | </view> |
| | | <view class="login-btn mt80" @click="loginAction">立即登录</view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import { wxLogin, wxAccountLogin, getUserInfo, wxProgramLogin } from '@/util/api/index.js'; |
| | | export default { |
| | | data() { |
| | | return { |
| | | loginForm: { |
| | | from: { |
| | | openid: '', |
| | | unionid: '', |
| | | companyId: '', |
| | | account: '', |
| | | username: '', |
| | | password: '' |
| | | } |
| | | }; |
| | | }, |
| | | onLoad() { |
| | | var that = this |
| | | uni.login({ |
| | | provider: 'weixin', |
| | | success: function (loginRes) { |
| | | wxProgramLogin({ code: loginRes.code }) |
| | | .then(async (res) => { |
| | | if (res.code === 200) { |
| | | // 免登录,直接跳首页 |
| | | if (res.data.loginStatus == 0) { |
| | | that.$store.commit('SETSESSION', res.data.session) |
| | | let info = await getUserInfo() |
| | | if (info.code === 200) { |
| | | await that.$store.commit('setEntrance', 'WX') |
| | | await that.$store.commit('SETUSERINFO', info.data) |
| | | await that.$store.dispatch('getMenuList', 2) |
| | | uni.switchTab({ |
| | | url: '/pages/workbench/workbench' |
| | | }); |
| | | } |
| | | } else { |
| | | that.from.openid = res.data.openid |
| | | that.from.unionid = res.data.unionid |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }); |
| | | }, |
| | | methods: { |
| | | loginAction() { |
| | | uni.reLaunch({ |
| | | url: '/pages/workbench/workbench' |
| | | }) |
| | | async loginAction() { |
| | | if (!this.from.companyId) return uni.showToast({ title: '企业代码不能为空', icon:"error", duration: 2000 }); |
| | | if (!this.from.username) return uni.showToast({ title: '手机号不能为空', icon:"error", duration: 2000 }); |
| | | if (!this.from.password) return uni.showToast({ title: '密码不能为空', icon:"error", duration: 2000 }); |
| | | let res = await wxAccountLogin(this.from) |
| | | if (res.code === 200) { |
| | | await this.$store.commit('SETSESSION', res.data) |
| | | let user = await getUserInfo({}) |
| | | if (user.code === 200) { |
| | | await this.$store.commit('SETUSERINFO', user.data) |
| | | await this.$store.dispatch('getMenuList', 2) |
| | | uni.switchTab({ |
| | | url: '/pages/workbench/workbench' |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | height: 100%; |
| | | } |
| | | .login-log { |
| | | // margin-top: ; |
| | | margin: 356rpx auto 0 auto ; |
| | | left: 0; |
| | | right: 0; |
| | |
| | | } |
| | | } |
| | | .input-height { |
| | | height: 100rpx; |
| | | height: 100rpx; |
| | | } |
| | | .com-input { |
| | | margin-top: -60px; |