js柯里化函数与promise请求
//柯里化函数
//request.js文件
const getOperateApi = apiName => curIndex =>para=> {
switch (+curIndex) {
case 1:
apiName = 'ChosenChannel_' + apiName//每日精选活动商品;
break;
case 2:
apiName = 'Advance_' + apiName//抢购活动商品
break;
case 3:
apiName = 'Presale_' + apiName//预售活动商品
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
apiName = 'SpecialActivity_' + apiName//专题活动商品;
break;
}
return new Promise((resolve, reject) => {
newFetchData({
type: 'post',
url: 'newapi/SpecialActivitySeller/' + apiName,
data: para,
success: (data) => {
resolve(data);
},
});
});
}
export const QueryActivityGoods = getOperateApi('QueryActivityGoods')// 查询
export const ExportActivityGoods = getOperateApi('ExportActivityGoods')// 导出
export const DeleteActivityGoods = getOperateApi('DeleteActivityGoods')// 删除
export const PauseActivityGoods = getOperateApi('PauseActivityGoods')// 暂停
export const GoonActivityGoods = getOperateApi('GoonActivityGoods')// 重启
export const EndActivityGoods = getOperateApi('EndActivityGoods')// 结束
vue文件
import {
PGetSkuMatrixPriceLList,
GetSpecialAreas,
DeleteSpecialArea,
QueryActivityGoods, // 查询
ExportActivityGoods, // 导出
DeleteActivityGoods, // 删除
PauseActivityGoods, // 暂停
GoonActivityGoods, // 重启
EndActivityGoods, // 结束
} from './myactivity.request.js';
methods:{
async getData(){
this.tableData = await QueryActivityGoods(this.curIndex)(objParams);
console.log('this.tableData :>> ', this.tableData);
}
}
注:以上内容仅用于日常学习