| | |
| | | </view> |
| | | <view class="login_btn"> |
| | | <!-- #ifdef MP-WEIXIN || MP-QQ || MP-BAIDU --> |
| | | <button v-if="canIUseGetPhoneNumber" class="uni-tip-button" style="backgroundColor:#fece01;borderColor:#fece01" |
| | | @click="mobileAuthLogin">授权并登录</button> |
| | | <button style="backgroundColor:#fece01;borderColor:#fece01" v-else open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" |
| | | class="uni-tip-button">授权并登录</button> |
| | | <button v-if="canIUseGetPhoneNumber" class="uni-tip-button" |
| | | style="backgroundColor:#fece01;borderColor:#fece01" @click="mobileAuthLogin">授权并登录</button> |
| | | <button style="backgroundColor:#fece01;borderColor:#fece01" v-else open-type="getPhoneNumber" |
| | | @getphonenumber="getPhoneNumber" class="uni-tip-button">授权并登录</button> |
| | | <view class="no_login" @click="back" style="color:#fece01;borderColor:#fece01"> |
| | | 暂不授权 |
| | | </view> |
| | |
| | | </checkbox-group> |
| | | </view> |
| | | </view> |
| | | <uni-popup ref="popup" type="center"> |
| | | <view class="bind-wrap"> |
| | | <!-- #ifdef MP-WEIXIN || MP-QQ || MP-BAIDU --> |
| | | <view class="heard">提示</view> |
| | | <view class="bind-tips">为了方便您接收通知消息,需要您完成授权</view> |
| | | <view class="auth-login ns-btn-default-all color-base-bg" @click="toWeb"> |
| | | 去授权 |
| | | </view> |
| | | <!-- <button open-type="getPhoneNumber" class="auth-login ns-btn-default-all color-base-bg" |
| | | @getphonenumber="mobileAuthLogin"><text>点击绑定手机号码</text></button> --> |
| | | <!-- #endif --> |
| | | </view> |
| | | </uni-popup> |
| | | <uni-popup ref="bindMobile"> |
| | | <view class="bind-wrap"> |
| | | <!-- #ifdef MP-WEIXIN || MP-QQ || MP-BAIDU --> |
| | | <view class="heard">提示</view> |
| | | <view class="bind-tips">为了方便联系您,需要绑定您的手机号码</view> |
| | | <button open-type="getPhoneNumber" class="auth-login ns-btn-default-all color-base-bg" |
| | | @getphonenumber="mobileAuthLogin"><text>点击绑定手机号码</text></button> |
| | | <!-- #endif --> |
| | | </view> |
| | | </uni-popup> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import { |
| | | mapActions, |
| | | mapGetters, |
| | | mapMutations |
| | | } from 'vuex' |
| | | export default { |
| | | data() { |
| | | return { |
| | | isChecked: false, |
| | | isCheckedSan: false, |
| | | canIUseGetPhoneNumber: false |
| | | }; |
| | | }, |
| | |
| | | // #endif |
| | | }, |
| | | onShow() { |
| | | if (uni.getStorageSync('wx_openid_set') && uni.getStorageSync('wx_openid_set') == 1) { |
| | | uni.showLoading({ |
| | | title: '加载中', |
| | | mask: true |
| | | }) |
| | | this.$api.temLogin({ |
| | | data: { |
| | | uid: uni.getStorageSync('authInfo').id |
| | | }, |
| | | success: res => { |
| | | |
| | | if (res.code == 1) { |
| | | // uni.hideLoading() |
| | | // if (res.data.openid) this.authInfo.weapp_openid = res.data.openid; |
| | | // if (res.data.unionid) this.authInfo.wx_unionid = res.data.unionid; |
| | | if (res.data.wx_openid) { |
| | | this.$util.showToast({ |
| | | title: "登录成功", |
| | | icon: "success" |
| | | }) |
| | | |
| | | uni.setStorage({ |
| | | key: 'uid', |
| | | data: res.data.id, |
| | | success: () => { |
| | | uni.removeStorageSync('wx_openid_set'); |
| | | uni.removeStorageSync('source_member'); |
| | | uni.removeStorageSync('authInfo'); |
| | | this.$api.temLogin({ |
| | | data: { |
| | | uid: res.data.id, |
| | | }, |
| | | success: res => { |
| | | if (res.code == 1) { |
| | | console.log(res) |
| | | uni.setStorageSync( |
| | | 'is_perfect_user', '1') |
| | | } else { |
| | | uni.setStorageSync( |
| | | 'is_perfect_user', res.code |
| | | ) |
| | | } |
| | | }, |
| | | fail: res => { |
| | | this.$util.showToast({ |
| | | title: "接口错误" |
| | | }); |
| | | } |
| | | }); |
| | | // this.$store.dispatch('getCartNumber'); |
| | | setTimeout(() => { |
| | | this.$util.redirectTo( |
| | | '/pages/index/index', {}, |
| | | 'tabbar') |
| | | }, 1000) |
| | | } |
| | | }); |
| | | } else { |
| | | this.$util.showToast({ |
| | | title: '授权失败' |
| | | }); |
| | | } |
| | | if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); |
| | | } else { |
| | | uni.removeStorageSync('uid') |
| | | this.$forceUpdate() |
| | | this.$util.showToast({ |
| | | title: res.msg |
| | | }); |
| | | if (this.$refs.loadingCover) this.$refs.loadingCover.hide(); |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | methods: { |
| | | ...mapActions([ |
| | | 'getUserInfo' |
| | | ]), |
| | | toArticle(type) { |
| | | if(type==1){ |
| | | uni.navigateTo({ |
| | | url:'/pages/article/article' |
| | | }) |
| | | }else{ |
| | | uni.navigateTo({ |
| | | url:'/pages/article/privacy' |
| | | }) |
| | | } |
| | | |
| | | uni.navigateTo({ |
| | | url: '/pages/article/article' |
| | | }) |
| | | }, |
| | | changeAgree(e) { |
| | | console.log(e) |
| | |
| | | this.isChecked = false |
| | | } |
| | | }, |
| | | toWeb() { |
| | | if (!this.isChecked) { |
| | | return this.$util.showToast({ |
| | | title: "请先同意协议" |
| | | }) |
| | | } |
| | | uni.setStorageSync('wx_openid_set', 1) |
| | | this.$util.redirectTo('/otherPages/member/webView/webView', { |
| | | uid: uni.getStorageSync('authInfo').id |
| | | }) |
| | | }, |
| | | back() { |
| | | uni.navigateBack() |
| | | }, |
| | | getPhoneNumber(e) { |
| | | if (!this.isChecked) { |
| | | return this.$common.showToast({ |
| | | title: "请先同意协议" |
| | | }) |
| | | } |
| | | if (e.detail.errMsg == 'getPhoneNumber:ok') { |
| | | this.$db.set('queryPhoneNumber', 'getPhoneNumber:ok'); |
| | | uni.login({ |
| | |
| | | this.$api.CreateUser(obj).then(result => { |
| | | if (result.code == 1) { |
| | | this.$db.set('userToken', result.data.accessToken); |
| | | this.$api.getUser().then(res => { |
| | | this.$db.set('userInfo', JSON.stringify(res.data)) |
| | | }) |
| | | this.getUserInfo() |
| | | this.$util.redirectTo( |
| | | '/pages/index/index', {}, |
| | | 'tabbar') |
| | |
| | | title: "请先同意协议" |
| | | }) |
| | | } |
| | | |
| | | uni.login({ |
| | | provider: 'weixin', |
| | | timeout: 3000, |
| | | success: res => { |
| | | this.$api.temLogin(res.code).then((result) => { |
| | | if (result.code == 1) { |
| | | this.$api.getUser().then(res => { |
| | | this.$db.set('userInfo', JSON.stringify(res.data)) |
| | | }) |
| | | this.$db.set('userToken', result.data.accessToken); |
| | | this.getUserInfo() |
| | | this.$util.redirectTo( |
| | | '/pages/index/index', {}, |
| | | 'tabbar') |
| | | } else { |
| | | this.$util.showToast({ |
| | | title: result.msg |
| | | title: result.msg ? result.msg : result.error |
| | | }); |
| | | } |
| | | }).catch((err) => { |