import request from '../request'

//用户模块
const user = {
	/**
	 * 用户登录获取token
	 */
	async login() {
		
		let res = await wx.login()
		let query =uni.getLaunchOptionsSync().query
		let scene = uni.getLaunchOptionsSync().scene
		console.log('参数开始',query,scene,'参数结束')
		console.log('pUnionId:'+(query.pUnionId||query.scene||""))
		
		return request({
	
			url: `/login/jscode`,
			method: 'post',
			params: {
				
				jscode: res.code,
				pUnionId:(query.pUnionId||query.scene||"")
				
			},
			headers: {
				isLogin: true
			}
		})
	},
	/**
	 * 更新用户信息
	 * @param {Object} data
	 */
	updateUserInfo(data) {
		return request({
			url: '/student/xcx/user',
			method: 'post',
			data
		})
	},
	/**
	 * 获取用户详细信息
	 */
	getInfo() {
		return request({
			url: '/student/user/info',
			method: 'get'
		})
	},
	/**
	 * 退出登录
	 */
	logout() {
		return request({
			url: '/logout',
			method: 'post'
		})
	},
	/**
	 * 绑定用户身份证信息
	 * @param {Object} data
	 */
	bindUserCard(data) {
		return request({
			url: '/gzpt/userInfo/bind',
			method: 'put',
			data
		})
	},
	//更新用户真实姓名
	studentUserRealname(params) {
		return request({
			url: '/student/user/realname',
			method: 'put',
			params
		})
	},
	//是否是vip的数据(抖音小程序)
	userInfoVipInfo(){
		return request({
			url:'/user/info/vipInfo',
			method:'GET'
		})

	},
	//更新昵称、手机号码、头像
	userInfoUserInfo(params){
		return request({
			url:'/user/info/userInfo',
			method:'PUT',
			params
		})

	},
	//查询当前用户考试会员列表
	studentVipExamList(params){
		return request({
			url:'/student/vip/exam/list',
			method:'GET',
			params
		})
	},
	//根据code获取手机号
	userInfoGetPhoneByCode(params){
		return request({
			url:"user/info/getPhoneByCode",
			method:'GET',
			params
		})

	},
	//生成推荐二维码
	userInfoGetWxacodeunLimit(params){
		return request({
			url:"/user/info/getWxacodeunLimit",
			method:'GET',
			params
		})
	}
}

export default user
