123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- <template>
- <view class="container login">
- <view class="login-main"> <image class="logo" :src="staticUrl + 'logo@2x.png'" mode=""></image> </view>
- <view class="login-input">
- <keyInput
- borderValueColor="#E1E1E1"
- borderActiveColor="#E1E1E1"
- ref="vcodeInputRef"
- @vcodeInput="keyInput"
- @vcodeChange="keyInputChangeHandle"
- sum="6"
- >
- </keyInput>
- </view>
- <button class="login-btn" @click.stop="goLogin" :class="isDisabled ? 'disabled' : ''" :disabled="isDisabled">
- 邀请码登录
- </button>
- <view class="login-tips">
- <text class="h1">注意事项:</text>
- <text class="p"
- >邀请码是为了方便机构内成员互相邀请并快速注册【丽格集采联盟】小程序而推出的一项邀请机制。</text
- >
- <text class="p"
- >机构已注册了账号的成员,可在其个人中心添加其他机构成员,系统会自动为添加的每一个成员生成邀请码。其他成员使用邀请码可直接登录【丽格集采联盟】小程序。</text
- >
- </view>
- </view>
- </template>
- <script>
- import authorize from '@/common/config/authorize.js'
- import wxLogin from '@/common/config/wxLogin.js'
- import { mapState, mapMutations } from 'vuex'
- import keyInput from '@/components/uni-keyinput/uni-keyinput'
- import shareMixin from '@/mixins/shareMixin.js'
- export default {
- mixins: [ shareMixin ],
- components: {
- keyInput
- },
- data() {
- return {
- staticUrl: this.global.staticUrl,
- params: {
- invitationCode: '', //获取用户登录的邀请码
- unionId: 0,
- nickName: '',
- avatarUrl: '',
- organizeId: 4
- }
- }
- },
- onLoad(option) {},
- computed: {
- ...mapState(['isWxAuthorize', 'isLoginType', 'isLoginProductId', 'isLoginOrderId']),
- isDisabled() {
- // 邀请码长度是否符合要求
- return this.params.invitationCode.trim().length < 6
- }
- },
- methods: {
- ...mapMutations(['login', 'wxLogin']),
- goLogin() {
- if (this.params.invitationCode == '') {
- this.$util.msg('请输入邀请码', 2000)
- return
- }
- this.params.unionId = uni.getStorageSync('unionId')
- this.bindingWechat(this.params)
- },
- async bindingWechat(params) {
- //邀请码登录并绑定微信
- try{
- const res = await this.UserService.usrInvitationLogin(params)
- const data = res.data
- uni.setStorageSync('token', data.token)
- this.$store.commit('updateStatus', data)
- this.login(data)
- // 登录成功处理
- const url = uni.getStorageSync('LOGIN_REDIRECT_URL')
- if (url) {
- if (url.indexOf('tabBar') > -1) {
- uni.switchTabTo(url)
- } else {
- this.$api.redirectTo(url)
- }
- } else {
- this.$api.switchTabTo('/pages/tabBar/user/user')
- }
- uni.removeStorageSync('LOGIN_REDIRECT_URL')
- }catch(error){
- this.$util.msg(error.msg, 2000)
- }
- },
- keyInput(val) {
- // 输入框输入介绍
- // this.params.invitationCode = val
- console.log(val)
- },
- keyInputChangeHandle(val) {
- // 输入框输入事件
- this.params.invitationCode = val
- // console.log(val)
- },
- setFocus() {
- // 控制组件获取焦点
- this.$refs.VcodeInput.setFocus()
- },
- setBlur() {
- // 控制组件失去焦点
- this.$refs.VcodeInput.setBlur()
- },
- clearValue() {
- // 清除已输入
- this.$refs.VcodeInput.clearValue()
- },
- InitAuthorize() {
- //是否已授权 0:为取消授权 1:为已授权 2:为未操作
- wxLogin.wxLoginQuick()
- }
- },
- onShow() {
-
- this.InitAuthorize()
- }
- }
- </script>
- <style lang="scss">
- .login {
- width: 100%;
- height: auto;
- .model-warp.none {
- display: none;
- }
- .model-warp.show {
- display: block;
- }
- .login-main {
- width: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- height: 206rpx;
- padding: 60rpx 0 40rpx 0;
- margin: 70rpx 0;
- .logo {
- width: 358rpx;
- height: 206rpx;
- display: block;
- }
- }
- .login-input {
- width: 600rpx;
- height: 88rpx;
- padding: 24rpx 0;
- margin: 30rpx auto;
- margin-bottom: 30rpx;
- background: #ffffff;
- position: relative;
- }
- .login-row {
- padding: 0 75rpx;
- font-size: $font-size-28;
- line-height: 40rpx;
- color: #ff5b00;
- margin-bottom: 48rpx;
- text-align: right;
- }
- .login-btn {
- width: 600rpx;
- height: 88rpx;
- border-radius: 44rpx;
- font-size: $font-size-28;
- line-height: 88rpx;
- color: #ffffff;
- margin: 0 auto;
- text-align: center;
- background: $btn-confirm;
- &.disabled {
- background: #e1e1e1;
- }
- }
- .login-btn-last {
- width: 600rpx;
- height: 86rpx;
- border-radius: 44rpx;
- font-size: $font-size-28;
- line-height: 88rpx;
- color: $color-system;
- margin: 0 auto;
- text-align: center;
- border: 1px solid $color-system;
- margin-top: 20rpx;
- }
- .login-tips {
- width: 100%;
- height: auto;
- margin-top: 80rpx;
- box-sizing: border-box;
- padding: 0 75rpx;
- .h1 {
- line-height: 44rpx;
- font-size: $font-size-24;
- color: #666666;
- text-align: justify;
- display: inline-block;
- }
- .p {
- line-height: 44rpx;
- font-size: $font-size-24;
- color: #999999;
- text-align: justify;
- margin-bottom: 20rpx;
- display: inline-block;
- }
- }
- .model-authorization {
- width: 100%;
- height: 100%;
- position: fixed;
- top: 0;
- left: 0;
- z-index: 999;
- .authorization {
- width: 518rpx;
- height: 320rpx;
- position: absolute;
- background: rgba(255, 255, 255, 0.7);
- left: 0;
- right: 0;
- bottom: 0;
- top: 0;
- margin: auto;
- .to-btn {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- margin: auto;
- width: 70%;
- height: 88rpx;
- font-size: $font-size-28;
- line-height: 88rpx;
- color: #ffffff;
- text-align: center;
- border-radius: 44rpx;
- }
- }
- }
- }
- </style>
|