import request from '../request'

//用户模块
const user = {
	/**
	 * 用户登录获取token
	 */
	async login() {
		//#ifdef MP-TOUTIAO
		let res = await wx.login()
		res  = res[1]
		//#endif
		//#ifdef MP-WEIXIN
		let res = await wx.login()
		//#endif
		
		console.log(res)
		return request({
			url: `${process.env.NODE_ENV==='development'?'https://jpcj-admin1.zzxcx.net/twzd-admin':'https://jpcj-admin.zzxcx.net/twzd-admin'}/login/jscode`,
			method: 'post',
			params: {
				jscode: res.code
			},
			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
		})
	}
}

export default user
