import {
	http
} from './service.js'


const uploadFileUrl = '/blade-resource/oss/endpoint/put-file'

//文件上传
const uploadFile = (p) => http.upload(uploadFileUrl, {
	name: 'file',
	filePath: p
})

//手机验证码
const sms={
	send:p => http.post('/sms/sendSms'+p)
}


const notice = {
	detail: p => http.get('sing_active/activenotice/detail', {
		params: p
	}),
	list: p => http.get('sing_active/activenotice/list', {
		params: p
	}),
	//从缓存中获取
	getDetail: p => http.get('app/active/notice/getNotice', {
		params: p
	}),
}

const platform = {
	setting: p => http.get('blade-system/param/detail', {
		params: p
	}),
	getPlatformParams: p => http.get('/app/platformsetting/getPlatformValueByList', {
		params: p
	}),

	getPlatformValue: p => http.get('/app/platformsetting/getPlatformValue', {
		params: p
	}),
}

const activity = {
	getPromoteNum: p => http.get('app/active/help', {
		params: p
	}),
	getWorksList: p => http.get('/app/active/product/sortList', {
		params: p
	}),
	sortListQuery: p => http.get('/app/active/product/sortListQuery', {
		params: p
	}),
	indexList: p => http.get('app/active/product/list', {
		params: p
	}),
	searchWork: p => http.get('/app/active/product/search', {
		params: {
			keyword: p
		}
	}),
	getWorksDetail: id => http.get('/sing_active/activeproductrecord/detail', {
		params: {
			id
		}
	}),
	list: p => http.get('/sing_active/activeproductrecord/list', {
		params: p
	}),
	// getGiftList: p => http.get('/sing_goods/helpgoods/list', {
	// 	params: p
	// }),
	getGiftList: p => http.get('app/help/goods/getHelpGoodsList', {
		params: p
	}),
	getMyTotalHeat: p => http.get('/sing_active/activeproductrecord/getMyTotalHeat', {
		params: p
	}),
	submitForm: p => http.post('/sing_active/activeproductrecord/submit', p),
	mediaSave: p => http.post('/sing_active/activeproductrecord/save', {
		params: p
	}),
}

//微信api
const wxApp = {
	getOpenId: p => http.get('/wx-app/getOpenId', {
		params: p
	}),
	getOpenData: p => http.post('/wx-app/getOpenData', p),
	getGenerateScheme: p => http.get('/wx-app/getGenerateScheme', {
		params: p
	}),
}

//字典
const dict = {
	list: p => http.get('/blade-system/dict-biz/dictionary', {
		params: p
	}),
	parentList: p => http.get('/blade-system/dict-biz/parent-list', {
		params: p
	}),
	dictionaryTree: p => http.get('/blade-system/dict-biz/dictionary-tree', {
		params: p
	}),
}

const loginUser = {
	list: p => http.get('ldt_user/loginuser/list', {
		params: p
	}),
	submit: p => http.post('sing_user/loginuser/submit', p),
	updateInfo: p => http.post('sing_user/loginuser/updateInfo', p),
	login: p => http.post('/user/login/login', p),
	h5Login: p => http.post('/user/login/h5Login', p, {
		header: {
			'Content-Type': 'application/x-www-form-urlencoded'
		}
	}),
	savePhone: p => http.post('/user/login/savePhone', p, {
		header: {
			'Content-Type': 'application/x-www-form-urlencoded'
		}
	}),
	detail: p => http.get('sing_user/loginuser/detail', {
		params: p
	}),
	userHeatValueAndPufaPoint: p => http.get('/user/login/userHeatValueAndPufaPoint', {
		params: p
	}),

}

const CMCC = {
	isCMCC: p => http.get('/user/login/isCMCC', {
		params: p
	}),
	h5IsCMCC: p => http.get('/user/login/h5IsCMCC', {
		params: p
	}),
	queryCmccPoint: p => http.post('app/cmcc/queryCmccPoint' + p),
}

const points = {
	list: p => http.get('sing_point/pointrecord/list', {
		params: p
	}),
}

//我的助力
const help = {
	list: p => http.get('sing_active/activehelprecord/list', {
		params: p
	}),
}
//热力明细
const heatrecord = {
	list: p => http.get('sing_heat_value/heatrecord/list', {
		params: p
	}),
}



/**
 * 积分商城
 */
const pointgoods = {
	list: p => http.get('sing_goods/pointgoods/list', {
		params: p
	}),
	queryLogistics: p => http.post('app/point/queryLogistics', p, {
		header: {
			'Content-Type': 'application/x-www-form-urlencoded'
		}
	}),
	exchange: p => http.post('app/point/exchange', p, {
		header: {
			'Content-Type': 'application/x-www-form-urlencoded'
		}
	}),
}

/**
 * 兑换记录
 */
const goodsorder = {
	list: p => http.get('sing_goods/goodsorder/list', {
		params: p
	}),
	detail: p => http.get('sing_goods/goodsorder/detail', {
		params: p
	}),
	submit: p => http.post('sing_goods/goodsorder/submit', p),
}


/**
 * 道具
 */
const order = {
	sendCmccSms: p => http.post('/app/help/goods/sendCmccSms', p, {
		header: {
			'Content-Type': 'application/x-www-form-urlencoded'
		}
	}),
	create: p => http.post('/app/help/goods/createPropsOrder', p, {
		header: {
			'Content-Type': 'application/x-www-form-urlencoded'
		}
	}),
	exchange: p => http.post('/app/help/goods/exchangeProps', p, {
		header: {
			'Content-Type': 'application/x-www-form-urlencoded'
		}
	}),
}

/**
 * 用户地址
 */
const address = {
	list: p => http.get("sing_user/useraddress/list", {
		params: p
	}),
	detail: p => http.get("sing_user/useraddress/detail", {
		params: p
	}),
	submit: p => http.post('sing_user/useraddress/submitAddress', p),
	//获取地址信息
	getLocation: p => http.get("sing_user/useraddress/getLocation", {
		params: p
	}),
}

/**
 * 字典地址
 */
const area = {
	province: p => http.get('blade-system/region/lazy-tree?parentCode=00', {
		params: p
	}),
	list: p => http.get('blade-system/region/lazy-tree', {
		params: p
	}),
}

const census = {
	online: p => http.get('app/index/census/online', {
		params: p
	}),
	offline: p => http.get('app/index/census/offline', {
		params: p
	}),
}


//活动列表
const activerecord = {
	list: p => http.get('sing_active/activerecord/list', {
		params: p
	}),
	detail: p => http.get('sing_active/activerecord/detail', {
		params: p
	}),
}

//海报配置
const poster={
	detail: p => http.get('sing_active/activeposter/detail', {
		params: p
	})
}


export const api = {
	uploadFileUrl,
	sms,
	uploadFile,
	dict,
	wxApp,
	loginUser,
	activity,
	platform,
	points,
	help,
	heatrecord,
	CMCC,
	pointgoods,
	goodsorder,
	order,
	address,
	notice,
	area,
	census,
	activerecord,
	poster
}
