| | |
| | | <view class="login"> |
| | | <view class="logo">无人值守</view> |
| | | <!--用户名密码登录--> |
| | | <user-password /> |
| | | <user-password :btnText='0'/> |
| | | <!-- 微信openid登录 --> |
| | | <view class="loginBtn"> |
| | | <u-button class="button" @click.stop="beforeLoginEvent" :disabled="btnLoading" :loading="btnLoading" type="primary" text="微信一键登录"></u-button> |
| | |
| | | </view> |
| | | </u-popup> |
| | | </view> |
| | | <!-- 询问是否绑定微信 --> |
| | | <view class="bindWxModel"> |
| | | <u-modal :show="bindWxModelShow" :title="bindWxModelTitle" showCancelButton :content="bindWxContent" @confirm="bindWxConfirm" @cancel="bindWxCancel"></u-modal> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import { apiLogin, apiLogin2, apiLoginPassword } from '@/api/publicInterface.js'; |
| | | import { apiLoginWx, apiLoginPassword } from '@/api/publicInterface.js'; |
| | | import { mapMutations } from 'vuex'; |
| | | import userPassword from './userPassword.vue'; |
| | | |
| | | import { setToken, setRefreshToken, setUsernameKey, setCustomerId, redirectHome } from '@/utils/status.js'; |
| | | export default { |
| | | data() { |
| | | return { |
| | | wxcode: '', // 司机1 |
| | | btnLoading: false, |
| | | loginPopupShow: false |
| | | loginPopupShow: false, |
| | | // 绑定微信模态框 |
| | | bindWxModelShow: false, |
| | | bindWxModelTitle: '提示', |
| | | bindWxContent: '如果已拥有系统账号,可以直接跳转绑定微信页面' |
| | | }; |
| | | }, |
| | | components: { |
| | |
| | | }, |
| | | // 登录接口 |
| | | apiLogin() { |
| | | // apiLogin2({ code: this.wxcode }) |
| | | // apiLoginWx({ code: this.wxcode }) |
| | | // .then(res => { |
| | | // console.log('请求登录', res); |
| | | // if (res.msg == '需绑定') { |
| | |
| | | */ |
| | | |
| | | wx.request({ |
| | | url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx30f254cbb0b90b3c&secret=938a068410796cda21e5e03b9435cdbf&js_code=${this.wxcode}&grant_type=authorization_code`, |
| | | url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx4a62fc1684c429a9&secret=ee90afe376cdcec2fdd947c0a4db961a&js_code=${this.wxcode}&grant_type=authorization_code`, |
| | | success(res) { |
| | | let id = res.data.openid; |
| | | uni.setStorageSync('openid', id); |
| | |
| | | }); |
| | | } |
| | | }); |
| | | this.loginPopupShow = false |
| | | this.$nextTick(() => { |
| | | apiLoginWx({ code: uni.getStorageSync('openid') }).then(res => { |
| | | if (res.code != 1) { |
| | | this.$u.toast('恭喜您,登录成功!'); |
| | | // 登陆成功,存储相关信息 |
| | | setToken(res.access_token); |
| | | setRefreshToken(res.refresh_token); |
| | | setUsernameKey(res.username); |
| | | //查询用户详细信息并储存 |
| | | this.$reqGet('getUserEntity').then(res => { |
| | | this.setUserTabbar(res.data.type); |
| | | uni.setStorageSync('roleType', res.data.type); |
| | | setCustomerId(res.data.customerid); |
| | | //跳转页面 |
| | | this.$nextTick(() => { |
| | | redirectHome(); |
| | | }); |
| | | }); |
| | | } else { |
| | | this.$u.toast(res.msg); |
| | | this.bindWxModelShow = true; |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | this.loginPopupShow = false; |
| | | }, |
| | | bindWxConfirm() { |
| | | uni.navigateTo({ |
| | | url: `/pages/login/wxLogin?code=${uni.getStorageSync('openid')}` |
| | | }); |
| | | this.bindWxModelShow = false; |
| | | }, |
| | | bindWxCancel() { |
| | | this.bindWxModelShow = false; |
| | | }, |
| | | // 弹出层时间 |
| | | closePopup() { |