/**
 *@des 公共接口
 *@author zhengjinyi
 *@date 2020/03/19 14:56:57
 *@param registerByPass
 */
import requestUrl from '@/common/config/config.js'
import request from '@/common/config/caimeiApi.js'
import $reg from '@/common/config/common.js'


/**
 *获取省市区列表
 */
export function queryAddressInformation() {
	return new Promise(function(resolve,reject) {
		request.get("/club/address",{}, res => {
			if(res.code == 0){
				resolve(res);
			}else{
				reject(res)
			}
		})
	});
}
/**
 * @新分类下的商品列表
 * @param:tinyTypeID 三级分类ID
 * @param:pageNum	页码
 * @param:pageSize	每页显示条数
 */
export function searchQueryTinyType(url,params) {
	return new Promise(function(resolve,reject) {
		request.lodingGet(url,params, res => {
			if(res.code == 0){
				resolve(res);
			}else{
				reject(res)
			}
		})
	});
}
/**
 *获取协议
 */
export function queryProtocol() {
	return new Promise(function(resolve,reject) {
		request.get("/club/protocol",{}, res => {
			if(res.code == 0){
				resolve(res);
			}else{
				reject(res)
			}
		})
	});
}
/**
 *获取邮箱验证码
 */
export function getEmailCode(params) {
	return new Promise(function(resolve,reject) {		
		request.get("/user/mailbox",params, res => {
			if(res.code == 0){
				resolve(res);
			}else{
				reject(res)
			}
		})
	});
}
/**
 *注册专用获取验证码
 */
export function getRegisterMobileCode(params) {
	return new Promise(function(resolve,reject) {
		request.get("/club/captcha",params, res => {
			if(res.code == 0){
				resolve(res);
			}else{
				reject(res)
			}
		})
	});
}
/**
 *会所资料修改手机号
 *旧手机号获取验证码
 */
export function getClubMobileCode(params) {
	return new Promise(function(resolve,reject) {
		request.get("/club/modifyPhoneNumber",params, res => {
			if(res.code == 0){
				resolve(res);
			}else{
				reject(res)
			}
		})
	});
}
/**
 *会所资料修改手机号
 *新手机号获取验证码
 */
export function getClubNewMobileCode(params) {
	return new Promise(function(resolve,reject) {
		request.get("/club/modifyPhoneNumber",params, res => {
			if(res.code == 0){
				resolve(res);
			}else{
				reject(res)
			}
		})
	});
}
/**
 *小程序机构账号绑定微信,PC微信绑定机构账号
 */
export function getbindWechatCode(params) {
	return new Promise(function(resolve,reject) {
		request.get("/user/note",params, res => {
			if(res.code == 0){
				resolve(res);
			}else{
				reject(res)
			}
		})
	});
}
/**
 *通过邀请链接绑定运营人员获取手机短信
 */
export function getbindOperatorCode(params) {
	return new Promise(function(resolve,reject) {
		request.get("/seller/note",params, res => {
			if(res.code == 0){
				resolve(res);
			}else{
				reject(res)
			}
		})
	});
}
/**
 *上传图片
 */
export function uploadFileImage() {
	return new Promise(function(resolve,reject) {
		uni.chooseImage({
			count: 1, //默认1
			sizeType: ['original','compressed'], //可以指定是原图还是压缩图，默认二者都有
			sourceType: ['album'], //从相册选择
			success: (res) => {
				const tempFilePaths = res.tempFilePaths;
				const uploadTask = uni.uploadFile({
					url : requestUrl+'/formData/MultiPictareaddData',
					filePath: tempFilePaths[0],
					name: 'file',
					header: {
					    "Content-Type": "multipart/form-data",
					},
					formData: {
						'user': 'test'
					},
					success: function (res) {
						resolve(res);
					},
					error : function(e){
						reject(res)
					}
				})
			}
		});
	});
}
