<style lang="scss">
    /* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
    @import "uview-ui/index.scss";
</style>
<script>
    export default {
        onLaunch: function () {
            let that = this;
            wx.login({
                success(re) {
                    that.$api.wxLogin({code: re.code}).then(res => {
                        console.log('++++++++++登录返回了++++++++++++++++', res)
                        uni.setStorageSync('userInfo', res.data.data.userInfo)
                        uni.setStorageSync('accessToken', res.data.data.access_token)
                        uni.removeStorageSync('parent_member_id');


                        //用户分享用户绑定
                        let shareUserId = uni.getStorageSync('shareUserId')
                        if (shareUserId) {
                            that.$api.scanCode({
                                openId: res.data.data.userInfo.otherId,
                                memberId: shareUserId
                            }).then(res => {
                                console.log('用户分享用户绑定成功', res)
                                uni.removeStorageSync('shareUserId');
                            })
                        }


                        //拓客端或者技师端扫码用户绑定
                        let expandParam = uni.getStorageSync('expandParam')
                        if (expandParam) {
                            //用户扫码拓客端进入小程序
                            that.$api.userBindMember(
                                {
                                    ...expandParam,
                                    memberId: res.data.data.userInfo.id
                                }
                            ).then(res1 => {
                                console.log('拓客端推广用户绑定成功！')
                                uni.removeStorageSync('expandParam');
                            })
                        }

                        //用户扫码技师端进入小程序 暂无操作
                        let promotionParam = uni.getStorageSync('promotionParam')


                    })
                },
            })
            console.log('App Launch')
        },
        onShow: function () {
            console.log('App Show 小程序显示了+++++++++++++++++++++++')
        },
        onHide: function () {
            console.log('App Hide')
        }
    }
</script>


