|
|
@@ -5,11 +5,12 @@
|
|
|
<icon class="bjcx-logo-box"></icon>
|
|
|
<view class="bjcx-logo-title">家政学</view>
|
|
|
</view>
|
|
|
+ <!-- 合同分享下 -->
|
|
|
<view v-if="fromAppShare" class="wechat-auth-box">
|
|
|
<view class="auth-tips">欢迎使用小程序</view>
|
|
|
-
|
|
|
-
|
|
|
- <!-- 协议勾选框和按钮 -->
|
|
|
+ <button class="wechat-auth-btn" open-type="getPhoneNumber" @getphonenumber="onWechatAuth">
|
|
|
+ 微信一键登录
|
|
|
+ </button>
|
|
|
<view class="agreement-checkbox-box">
|
|
|
<checkbox-group @change="handleChange">
|
|
|
<checkbox class="agreement-checkbox-input" color="#3fd2a1" value="agree" :checked="isAgreed"
|
|
|
@@ -20,18 +21,10 @@
|
|
|
@click="agreeBtn('ystk')" class="agreement-text">《诚祥学隐私政策》</view>,如您同意,请勾选后开始使用
|
|
|
</view>
|
|
|
</view>
|
|
|
-
|
|
|
- <button v-if="!isAgreed">微信一键登录</button>
|
|
|
- <button v-else class="wechat-auth-btn" open-type="getPhoneNumber" @getphonenumber="onWechatAuth">
|
|
|
- 微信一键登录
|
|
|
- </button>
|
|
|
-
|
|
|
<button @click="handleChangeFangshi">
|
|
|
- 切换微信一键登录
|
|
|
+ 切换微信一键登录
|
|
|
</button>
|
|
|
-
|
|
|
</view>
|
|
|
- <!-- <view @click="ceshi" class="auth-tips">欢迎使用小程序12312312312312</view> -->
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
@@ -67,46 +60,14 @@
|
|
|
const openId = ref('');
|
|
|
|
|
|
// 新增变量
|
|
|
- const fromAppShare = ref(false) // 是否来自APP分享
|
|
|
+ const fromAppShare = ref(true) // 是否来自APP分享
|
|
|
|
|
|
const store = useIsCanBack();
|
|
|
|
|
|
onLoad((options) => {
|
|
|
- if (options.from === 'appcx') {
|
|
|
- id.value = options.id
|
|
|
- fromPage.value = options.from;
|
|
|
- }
|
|
|
- uni.login().then(res1 => {
|
|
|
- console.log('res1', res1);
|
|
|
- code.value = res1.code
|
|
|
- httpApi.loginApplet({
|
|
|
- code: res1.code,
|
|
|
- }).then(result => {
|
|
|
- console.log('result', result);
|
|
|
- openId.value = result.data.openId
|
|
|
- if (result.data.bind) {
|
|
|
- // 保存用户信息
|
|
|
- if (result.data.loginVo.type == 4) {
|
|
|
- cacheManager.set('auth', result.data.loginVo)
|
|
|
- store.setIsCanBack(false)
|
|
|
- gotoPage();
|
|
|
- } else if (result.data.loginVo.type == 6) {
|
|
|
- cacheManager.set('auth', result.data.loginVo)
|
|
|
- store.setIsCanBack(false)
|
|
|
- gotoPage2();
|
|
|
- } else {
|
|
|
- toast('登录失败,您的身份有误,请联系管理员。')
|
|
|
- return
|
|
|
- }
|
|
|
- } else {
|
|
|
- fromAppShare.value = true
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
getAllImg();
|
|
|
})
|
|
|
|
|
|
- // 你原有的所有方法都不变
|
|
|
function handleChange() {
|
|
|
isAgreed.value = !isAgreed.value
|
|
|
}
|
|
|
@@ -122,8 +83,34 @@
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ function handleChangeFangshi() {
|
|
|
+ let str = ``;
|
|
|
+ if (id.value) {
|
|
|
+ str = str + `id=${id.value}`
|
|
|
+ }
|
|
|
+ if (id.value && fromPage.value) {
|
|
|
+ str = str + `&from=${fromPage.value}`
|
|
|
+ } else if (!id.value && fromPage.value) {
|
|
|
+ str = str + `from=${fromPage.value}`
|
|
|
+ }
|
|
|
+
|
|
|
+ if (str) {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: `/pages/Login/test?${str}`
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: `/pages/Login/test`
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
// 微信授权登录
|
|
|
function onWechatAuth(e) {
|
|
|
+ if (!isAgreed.value) {
|
|
|
+ toast('请先阅读并同意用户协议和隐私政策')
|
|
|
+ return // 直接返回,不执行后面的授权逻辑
|
|
|
+ }
|
|
|
if (e.detail.errMsg.includes('fail')) {
|
|
|
toast('授权失败')
|
|
|
return
|
|
|
@@ -131,25 +118,51 @@
|
|
|
uni.showLoading({
|
|
|
title: '登录中'
|
|
|
})
|
|
|
- console.log('e123123123', e);
|
|
|
try {
|
|
|
- httpApi.bindApplet({
|
|
|
- code: e.detail.code,
|
|
|
- openId: openId.value,
|
|
|
- }).then(result => {
|
|
|
- if (result.data.type == 4) {
|
|
|
- cacheManager.set('auth', result.data)
|
|
|
- store.setIsCanBack(false)
|
|
|
- gotoPage();
|
|
|
- } else if (result.data.type == 6) {
|
|
|
- cacheManager.set('auth', result.data)
|
|
|
- store.setIsCanBack(false)
|
|
|
- gotoPage2();
|
|
|
- } else {
|
|
|
- toast('登录失败,您的身份有误,请联系管理员。')
|
|
|
- }
|
|
|
+ uni.login().then(res1 => {
|
|
|
+ console.log('res2222222', res1);
|
|
|
+ code.value = res1.code
|
|
|
+ httpApi.loginApplet({
|
|
|
+ code: res1.code,
|
|
|
+ }).then(result => {
|
|
|
+ console.log('result2222', result);
|
|
|
+ openId.value = result.data.openId
|
|
|
+ if (result.data.bind) {
|
|
|
+ // 保存用户信息
|
|
|
+ if (result.data.loginVo.type == 4) {
|
|
|
+ cacheManager.set('auth', result.data.loginVo)
|
|
|
+ store.setIsCanBack(false)
|
|
|
+ gotoPage();
|
|
|
+ } else if (result.data.loginVo.type == 6) {
|
|
|
+ cacheManager.set('auth', result.data.loginVo)
|
|
|
+ store.setIsCanBack(false)
|
|
|
+ gotoPage2();
|
|
|
+ } else {
|
|
|
+ toast('登录失败,您的身份有误,请联系管理员。')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log('1231');
|
|
|
+ //.value = true
|
|
|
+ httpApi.bindApplet({
|
|
|
+ code: e.detail.code,
|
|
|
+ openId: openId.value,
|
|
|
+ }).then(result => {
|
|
|
+ if (result.data.type == 4) {
|
|
|
+ cacheManager.set('auth', result.data)
|
|
|
+ store.setIsCanBack(false)
|
|
|
+ gotoPage();
|
|
|
+ } else if (result.data.type == 6) {
|
|
|
+ cacheManager.set('auth', result.data)
|
|
|
+ store.setIsCanBack(false)
|
|
|
+ gotoPage2();
|
|
|
+ } else {
|
|
|
+ toast('登录失败,您的身份有误,请联系管理员。')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
-
|
|
|
} catch (error) {
|
|
|
toast('bindApplet失败')
|
|
|
} finally {
|
|
|
@@ -160,11 +173,11 @@
|
|
|
function gotoPage() {
|
|
|
console.log('ididid', id.value);
|
|
|
if (id.value) {
|
|
|
- uni.redirectTo({
|
|
|
+ uni.navigateTo({
|
|
|
url: `/pages/client/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
|
|
|
})
|
|
|
} else {
|
|
|
- uni.redirectTo({
|
|
|
+ uni.navigateTo({
|
|
|
url: `/pages/client/ShouYe/shouye`
|
|
|
})
|
|
|
}
|
|
|
@@ -173,12 +186,12 @@
|
|
|
function gotoPage2() {
|
|
|
console.log('ididid222222', id.value);
|
|
|
if (id.value) {
|
|
|
- uni.redirectTo({
|
|
|
+ uni.navigateTo({
|
|
|
url: `/pages/kehu/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
|
|
|
})
|
|
|
} else {
|
|
|
- uni.redirectTo({
|
|
|
- url: `/pages/kehu/shouye/shouye`
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pages/kehu/shouYe/shouye`
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
@@ -188,29 +201,6 @@
|
|
|
cacheManager.set('projectImg', res.data)
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- function handleChangeFangshi() {
|
|
|
- let str = ``;
|
|
|
- if (id.value) {
|
|
|
- str = str+`id=${id.value}`
|
|
|
- }
|
|
|
- if ( id.value && fromPage.value ) {
|
|
|
- str = str +`&from=${fromPage.value}`
|
|
|
- } else if (!id.value && fromPage.value) {
|
|
|
- str = str + `from=${fromPage.value}`
|
|
|
- }
|
|
|
-
|
|
|
- if (str) {
|
|
|
- uni.redirectTo({
|
|
|
- url: `/pages/Login/test?${str}`
|
|
|
- })
|
|
|
- } else {
|
|
|
- uni.redirectTo({
|
|
|
- url: `/pages/Login/test`
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|