首页分享提交code

This commit is contained in:
wangxiaowei 2024-06-21 16:09:49 +08:00
parent 90db7a6e21
commit f765c1dbbd
2 changed files with 32 additions and 4 deletions

@ -49,20 +49,20 @@
this.wxShare()
}
},
async bindCode(options) {
async bindCode(options, code) {
if(!options.query) return
let invite_code = options.query.invite_code || strToParams(decodeURIComponent(options.query.scene))
.invite_code
if (invite_code) {
const wxCode = await getWxCode();
uni.setStorageSync('invite_code', invite_code)
const {
data,
code
} = await bindSuperior({
code: wxCode,
code: code || await getWxCode(),
invite_code
})
if (code == -1) {
Cache.set(INVITE_CODE, invite_code)
}

@ -47,6 +47,7 @@
分类
</view>
</router-link>
</view>
</view>
@ -67,6 +68,7 @@
</view>
</template>
</view>
</view>
<!-- #ifdef APP-PLUS -->
<!-- <lyg-popup v-if="appConfig.app_agreement" title="服务协议和隐私政策"
@ -96,6 +98,12 @@
import {
getRect
} from '@/utils/tools'
import {
bindSuperior
} from '@/api/user'
import Cache from '@/utils/cache'
import { getWxCode } from "@/utils/login"
import {INVITE_CODE} from '@/config/cachekey'
const app = getApp()
const homeItem = {
name: '首页'
@ -125,6 +133,8 @@
// #ifdef MP-WEIXIN
this.getLiveListsFun()
// #endif
this.bindCode()
},
onUnload() {
uni.$off('refreshhome')
@ -146,6 +156,24 @@
},
methods: {
...mapActions(['getCartNum']),
async bindCode() {
let _that = this;
uni.login({
success(res) {
if (res.code && uni.getStorageSync('invite_code')) {
getHome({
code: res.code,
invite_code: uni.getStorageSync('invite_code')
})
}
},
fail(res) {
reject(res);
}
});
},
// #ifdef MP
offPromptFunc() {
let time = 8;