<template>
	<view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			
		},
		onLoad(){
			let _this=this
			uni.getProvider({
				service: 'oauth',
				success(proRes){
					uni.login({
					  provider:proRes.provider[0],
					  success: function (res) {
							if(res.code){
								let source=""
								if(proRes.provider[0]=="weixin"){
									source=3
								}else if(proRes.provider[0]=="alipay"){
									source=4
								}
								let data={
									code:res.code,
									source,//微信小程序3，支付宝小程序4
								}
								_this.$request('wechat/wx/getUserInfoByCode',data).then(res => {
									if(res.code=='00'){
										let openid=res.data.openid
										uni.setStorageSync('openid',openid)
										uni.navigateBack({
											delta:1
										})
									}else{
										uni.removeStorageSync('openid')
										uni.showToast({
											title:res.message,
											icon:"none"
										})
									}
								  }).catch((err)=>{
									  uni.removeStorageSync('openid')
								})
							}
					   }
					})
				}
			})
			
		},
	}
</script>

<style>

</style>
