1) 增加h5
This commit is contained in:
parent
a5c794eae7
commit
81c632cca4
|
@ -943,4 +943,9 @@ export const getCouponDetails = (id) => {
|
|||
return req("get", baseurl + `/coupon/${id}`);
|
||||
};
|
||||
|
||||
// 删除优惠券商品范围
|
||||
export const deleteGoodsScope = (id) => {
|
||||
return req("delete", baseurl + `/goods/${id}`);
|
||||
};
|
||||
|
||||
export { req };
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -33,6 +33,7 @@ import {
|
|||
queryPlans,
|
||||
queryKeyBatch,
|
||||
addCoupon,
|
||||
getCouponDetails,
|
||||
} from "@/assets/api.js";
|
||||
import { mulNum } from "@/tools/number";
|
||||
import "./style.less";
|
||||
|
@ -89,10 +90,10 @@ const tableColumn = [
|
|||
},
|
||||
{
|
||||
title: "有效时间段",
|
||||
width: "575px",
|
||||
name: "effectDate",
|
||||
prop: "effectDate",
|
||||
type: "normal",
|
||||
width: "auto",
|
||||
},
|
||||
{
|
||||
title: "创建时间",
|
||||
|
@ -159,19 +160,24 @@ const rule_rules = {
|
|||
};
|
||||
|
||||
const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||
const { type = 0, isAuditButton = true, isCopy = false } = props; // type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段)
|
||||
const {
|
||||
type = 0,
|
||||
isAuditButton = true,
|
||||
direct_reseller_id,
|
||||
editData,
|
||||
} = props; // type 入口类型 0优惠券新增 1计划、key批次 (是否显示两个字段)
|
||||
|
||||
useEffect(() => {
|
||||
if (type === 0) {
|
||||
delete info_rules.plan_id;
|
||||
delete info_rules.key_batch_id;
|
||||
} else {
|
||||
info_rules.plan_id = [{ type: "required", message: "请选择归属计划" }];
|
||||
info_rules.key_batch_id = [
|
||||
{ type: "required", message: "请选择归属key" },
|
||||
];
|
||||
}
|
||||
}, []);
|
||||
// useEffect(() => {
|
||||
// if (type === 0) {
|
||||
// delete info_rules.plan_id;
|
||||
// delete info_rules.key_batch_id;
|
||||
// } else {
|
||||
// info_rules.plan_id = [{ type: "required", message: "请选择归属计划" }];
|
||||
// info_rules.key_batch_id = [
|
||||
// { type: "required", message: "请选择归属key" },
|
||||
// ];
|
||||
// }
|
||||
// }, []);
|
||||
|
||||
const [state, setState] = useSetState({
|
||||
setup1_title: "基本信息",
|
||||
|
@ -196,29 +202,25 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
showScopePop: false,
|
||||
scopePopType: "",
|
||||
productData: {},
|
||||
direct_reseller_id: 23329,
|
||||
direct_reseller_id: direct_reseller_id ? direct_reseller_id : 0,
|
||||
tableLoading: false,
|
||||
table_index: -1,
|
||||
examinePopShow: false,
|
||||
payType: 3,
|
||||
payment_direction: ["对私账户", "对公账户", "预付款扣除"],
|
||||
isState: "",
|
||||
coupon_batch_id: "",
|
||||
editModel: {}, // 编辑数据
|
||||
});
|
||||
|
||||
// 获取计划数据
|
||||
useEffect(() => {
|
||||
queryPlans({ status: "3,4,5" }).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
let arr = req.map((item) => {
|
||||
return {
|
||||
key: { key: item.id, reseller_id: item.reseller_id },
|
||||
text: item.title,
|
||||
};
|
||||
});
|
||||
setState({
|
||||
plan_OPTIONS: arr,
|
||||
});
|
||||
});
|
||||
});
|
||||
(async function init() {
|
||||
// 如果是计划进入不执行以下数据
|
||||
if (type === 0) {
|
||||
await getPlanList(); // 获取计划
|
||||
await initEditAndCopy(); // 获取详情
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
// 基础信息
|
||||
|
@ -230,26 +232,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
});
|
||||
const form_info_el = useRef(null);
|
||||
|
||||
// 计划select改变
|
||||
const changePlan = (e) => {
|
||||
setForm_info_data({ plan_id: e });
|
||||
setState({ direct_reseller_id: e.key.reseller_id });
|
||||
queryKeyBatch({ status: "4,5", plan_id: e.key.key }).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
let arr = req.map((item) => {
|
||||
return {
|
||||
key: item.id,
|
||||
text: item.batch_name,
|
||||
};
|
||||
});
|
||||
|
||||
setState({
|
||||
key_OPTIONS: arr,
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 发放规则
|
||||
const [form_rule_data, setForm_rule_data] = useSetState({
|
||||
full: "",
|
||||
|
@ -260,6 +242,75 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
});
|
||||
const form_rule_el = useRef(null);
|
||||
|
||||
// 编辑
|
||||
useEffect(() => {
|
||||
if (editData !== "" && editData) {
|
||||
// 基本信息
|
||||
setForm_info_data({
|
||||
title: editData.title,
|
||||
date_time: [editData.begin_time, editData.end_time],
|
||||
});
|
||||
// 规则
|
||||
setForm_rule_data({
|
||||
full: editData.full,
|
||||
reduce: editData.reduce,
|
||||
quantity: editData.quantity,
|
||||
budget: editData.budget,
|
||||
restrict: editData.restrict,
|
||||
});
|
||||
// 商品范围
|
||||
// 商品的数组
|
||||
let goods_arr = editData.product.legal.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
type: 1,
|
||||
upstream: "直连天下",
|
||||
all_budget: Number(item.contract_price) * Number(item.quantity),
|
||||
effectDate: "-",
|
||||
};
|
||||
});
|
||||
|
||||
// 立减金
|
||||
let lj_arr = editData.product.reduce.map((item) => {
|
||||
let table_obj = {};
|
||||
table_obj.type = 2; // 类型
|
||||
table_obj.upstream = String(item.channel) === "1" ? "支付宝" : "微信"; // 上游平台
|
||||
|
||||
table_obj.only = item; // 存储就数据 编辑好用
|
||||
table_obj.product_id = item.channel_activity_id; // 商品编号
|
||||
table_obj.product_name = item.batch_goods_name; // 商品名
|
||||
table_obj.official_price = item.reduce_amount; // 官方价
|
||||
table_obj.contract_price = item.price; // 合同价格
|
||||
table_obj.quantity = Math.trunc(item.all_budget / item.reduce_amount); // 库存数量
|
||||
table_obj.channel_activity_id = item.channel_activity_id; // 批次号
|
||||
table_obj.all_budget = Number(item.all_budget); // 总预算
|
||||
table_obj.effectDate = `${item.time_limit.effect_time.end_time} 至 ${item.time_limit.effect_time.start_time}`; // 有效时间段
|
||||
table_obj.createDate = ""; // 创建时间
|
||||
return table_obj;
|
||||
});
|
||||
|
||||
let scope_data = goods_arr.concat(lj_arr);
|
||||
|
||||
scope_data = _.map(scope_data, (o) => {
|
||||
o.checked = true;
|
||||
return o;
|
||||
});
|
||||
|
||||
let arr = _.map(scope_data, (res) => {
|
||||
let obj = {};
|
||||
obj.key = res.product_id;
|
||||
obj.text = res.product_name;
|
||||
return obj;
|
||||
});
|
||||
|
||||
setState({
|
||||
rankoptions: arr,
|
||||
rank: arr,
|
||||
tableData: scope_data,
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 设置发放总量是否可用
|
||||
useEffect(() => {
|
||||
setIsQuantity();
|
||||
|
@ -274,8 +325,61 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
|
||||
useImperativeHandle(ref, () => ({
|
||||
submit: submit,
|
||||
getModel: getModel,
|
||||
}));
|
||||
|
||||
// 获取 计划
|
||||
const getPlanList = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
queryPlans({ status: "3,4,5" }).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
let arr = req.map((item) => {
|
||||
return {
|
||||
key: { key: item.id, reseller_id: item.reseller_id },
|
||||
text: item.title,
|
||||
};
|
||||
});
|
||||
setState({
|
||||
plan_OPTIONS: arr,
|
||||
});
|
||||
resolve(true);
|
||||
});
|
||||
});
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
// 编辑-复制流程
|
||||
const initEditAndCopy = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const isState = sessionStorage.getItem("isState"); /*复制1 编辑2 */
|
||||
const coupon_batch_id =
|
||||
sessionStorage.getItem("code_id"); /* 兑换码id */
|
||||
setState({
|
||||
isState: isState ? isState : "",
|
||||
coupon_batch_id: coupon_batch_id ? coupon_batch_id : "",
|
||||
});
|
||||
if (coupon_batch_id !== "undefined" && coupon_batch_id !== undefined) {
|
||||
getCouponDetails(coupon_batch_id).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
console.log("优惠券详情 =>", req);
|
||||
setState({ editModel: req });
|
||||
resolve(true);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
resolve(true);
|
||||
}
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 表单提交
|
||||
const submit = () => {
|
||||
let validator = false;
|
||||
|
||||
|
@ -285,7 +389,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
validator = true;
|
||||
} else {
|
||||
validator = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// 发放规则
|
||||
|
@ -294,7 +397,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
validator = true;
|
||||
} else {
|
||||
validator = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (validator) {
|
||||
|
@ -311,17 +413,50 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
});
|
||||
if (sum < Number(form_rule_data.quantity)) {
|
||||
Notify.error("所选商品库存总数小于发放量");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
// 第三步:判断提交类型 新建还是计划的新建
|
||||
if (type === 1) {
|
||||
return true;
|
||||
} else {
|
||||
setState({
|
||||
examinePopShow: true,
|
||||
});
|
||||
}
|
||||
|
||||
setState({
|
||||
examinePopShow: true,
|
||||
});
|
||||
} else {
|
||||
Notify.error(`请选择商品范围`);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return validator;
|
||||
};
|
||||
|
||||
// 获取数据
|
||||
const getModel = () => {
|
||||
let param = {
|
||||
title: form_info_data.title,
|
||||
begin_time: form_info_data.date_time[0],
|
||||
end_time: form_info_data.date_time[1],
|
||||
quantity: form_rule_data.quantity,
|
||||
budget: form_rule_data.budget,
|
||||
full: form_rule_data.full,
|
||||
reduce: form_rule_data.reduce,
|
||||
restrict: form_rule_data.restrict,
|
||||
product: {
|
||||
legal: [],
|
||||
reduce: [],
|
||||
},
|
||||
};
|
||||
let arr = state.tableData.filter((item) => item.checked);
|
||||
param.product.legal = arr.filter((item) => item.type === 1); // 商品
|
||||
let param_lj = arr.filter((item) => item.type === 2); // 立减金
|
||||
param.product.reduce = param_lj.map((item) => {
|
||||
return {
|
||||
...item.only,
|
||||
};
|
||||
});
|
||||
console.log("计划优惠券数据 => ", param);
|
||||
return param;
|
||||
};
|
||||
|
||||
const onAuditSubmit = () => {
|
||||
|
@ -342,7 +477,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
reduce: [],
|
||||
},
|
||||
};
|
||||
console.log("param =>", param);
|
||||
param.payment_direction = state.payment_direction[state.payType - 1]; // 扣款方式
|
||||
let arr = state.tableData.filter((item) => item.checked);
|
||||
param.product.legal = arr.filter((item) => item.type === 1); // 商品
|
||||
|
@ -354,12 +488,44 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
};
|
||||
});
|
||||
addCoupon(param).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
console.log("req =>", req);
|
||||
});
|
||||
handelResponse(
|
||||
res,
|
||||
(req, msg) => {
|
||||
Notify.success(res.message);
|
||||
setTimeout(() => {
|
||||
window.history.back();
|
||||
}, 2000);
|
||||
},
|
||||
(err) => {
|
||||
Notify.error(err);
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
// 计划select改变
|
||||
const changePlan = (e) => {
|
||||
setForm_info_data({ plan_id: e });
|
||||
setState({ direct_reseller_id: e.key.reseller_id });
|
||||
setForm_info_data({ key_batch_id: "" });
|
||||
queryKeyBatch({ status: "4,5", plan_id: e.key.key, bind_object: 2 }).then(
|
||||
(res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
console.log("req =>", req);
|
||||
let arr = req.map((item) => {
|
||||
return {
|
||||
key: item.id,
|
||||
text: item.batch_name,
|
||||
};
|
||||
});
|
||||
setState({
|
||||
key_OPTIONS: arr,
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const onReturn = () => {};
|
||||
const onChangeCombinedDate = (e) => {
|
||||
setForm_info_data({ date_time: e });
|
||||
|
@ -581,6 +747,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
};
|
||||
|
||||
const onRankChange = (e) => {
|
||||
console.log("e =>", e);
|
||||
let new_table_data = state.tableData.map((item) => {
|
||||
item.checked =
|
||||
e.findIndex((checks) => {
|
||||
|
@ -605,10 +772,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
obj.text = item.product_name;
|
||||
select_opt.push(obj);
|
||||
});
|
||||
console.log("select_opt =>", select_opt);
|
||||
|
||||
console.log("rank =>", state.rank);
|
||||
|
||||
let select_arr = [];
|
||||
new_table.map((item) => {
|
||||
console.log("item =>", item);
|
||||
|
@ -619,8 +782,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
select_arr.push(obj);
|
||||
}
|
||||
});
|
||||
console.log("select_arr =>", select_arr);
|
||||
|
||||
// 格式化商品范围
|
||||
setState({
|
||||
tableData: new_table,
|
||||
|
@ -708,7 +869,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
<div className="coupon-box">
|
||||
<Card style={{ margin: "10px auto" }} title={state.setup1_title}>
|
||||
<Form model={form_info_data} rules={info_rules} ref={form_info_el}>
|
||||
{type === 1 ? (
|
||||
{type === 0 ? (
|
||||
<FormItem labelname="归属计划" prop="plan_id">
|
||||
<Select
|
||||
clearable
|
||||
|
@ -724,7 +885,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
</FormItem>
|
||||
) : null}
|
||||
|
||||
{type === 1 ? (
|
||||
{type === 0 ? (
|
||||
<FormItem labelname="归属key" prop="key_batch_id">
|
||||
<Select
|
||||
clearable
|
||||
|
|
|
@ -600,7 +600,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
scopePopType: "addKnockGold",
|
||||
});
|
||||
}
|
||||
|
||||
// 第四步:获取商品数据
|
||||
let param = {
|
||||
reseller_id: direct_reseller_ids,
|
||||
|
@ -1146,6 +1145,8 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
{state.examinePopShow ? examinePop() : null}
|
||||
|
||||
<UseGoodsScopePop
|
||||
full={form_rule_data.full}
|
||||
reduce={form_rule_data.reduce}
|
||||
product_title={state.product_title}
|
||||
drawerVisible={state.showScopePop}
|
||||
type={state.scopePopType}
|
||||
|
|
|
@ -1,148 +0,0 @@
|
|||
import React, { forwardRef, useImperativeHandle, useRef } from "react"
|
||||
import { Card, Drawer, Button } from "zent"
|
||||
|
||||
import Productform from "@/pages/plan/product/add" /* 商品 */
|
||||
import KnockGold from "@/components/knockGold" /* 立减金 */
|
||||
import { divNum } from "@/tools/number"
|
||||
|
||||
const UseGoodsScopePop = forwardRef((props, ref) => {
|
||||
const {
|
||||
product_title,
|
||||
drawerVisible,
|
||||
onClose,
|
||||
type,
|
||||
productData,
|
||||
submit,
|
||||
tableData,
|
||||
table_index
|
||||
} = props
|
||||
|
||||
// 如果需要 通过ref 控制此组件 放开注释
|
||||
// useImperativeHandle(ref, () => ({
|
||||
// submit: submitPop,
|
||||
// }));
|
||||
|
||||
const product_el = useRef(null)
|
||||
const knockGold_el = useRef(null)
|
||||
|
||||
// 新建商品数据处理
|
||||
const format_product_model = () => {
|
||||
let new_tableData = tableData
|
||||
// 新增
|
||||
let form_model = product_el.current.state.form_data
|
||||
form_model.goods_type = 1
|
||||
form_model.upstream = "直连天下"
|
||||
form_model.all_budget =
|
||||
Number(form_model.contract_price) * Number(form_model.quantity)
|
||||
form_model.effectDate = "-"
|
||||
|
||||
if (product_title === "编辑商品") {
|
||||
if (table_index !== -1) {
|
||||
form_model.checked = false
|
||||
new_tableData[table_index] = form_model
|
||||
console.log("new_tableData =>", new_tableData)
|
||||
}
|
||||
} else {
|
||||
new_tableData.push(form_model)
|
||||
}
|
||||
|
||||
return new_tableData
|
||||
}
|
||||
|
||||
// 立减金数据处理
|
||||
const format_knockGold_model = () => {
|
||||
let channel_activity_id =
|
||||
knockGold_el.current.state.model.channel_activity_id
|
||||
let form_data_arr = JSON.parse(sessionStorage.getItem("knockGoldData"))
|
||||
let table_obj = {}
|
||||
let form_model = form_data_arr.find(
|
||||
(item) => item.channel_activity_id === channel_activity_id
|
||||
)
|
||||
if (form_model) {
|
||||
table_obj.only = form_model // 存储就数据 编辑好用
|
||||
table_obj.product_id = channel_activity_id // 商品编号
|
||||
table_obj.product_name = form_model.batch_goods_name // 商品名
|
||||
table_obj.official_price = form_model.reduce_amount // 官方价
|
||||
table_obj.contract_price = form_model.price // 合同价格
|
||||
table_obj.quantity = parseInt(
|
||||
(form_model.all_budget, form_model.reduce_amount)
|
||||
) // 库存数量
|
||||
table_obj.channel_activity_id = form_model.channel_activity_id // 批次号
|
||||
table_obj.all_budget = Number(form_model.all_budget) // 总预算
|
||||
table_obj.effectDate = `${form_model.time_limit.effect_time.end_time} 至 ${form_model.time_limit.effect_time.start_time}` // 有效时间段
|
||||
table_obj.createDate = "" // 创建时间
|
||||
table_obj.goods_type = 2 // 类型
|
||||
table_obj.upstream =
|
||||
String(form_model.channel) === "1" ? "支付宝" : "微信" // 上游平台
|
||||
// 格式化字段 适配table显示
|
||||
return table_obj
|
||||
}
|
||||
}
|
||||
|
||||
// 提交数据
|
||||
const submitPop = async () => {
|
||||
try {
|
||||
// 第一步:判断是立减金还是新建商品
|
||||
let visible = false
|
||||
if (type === "addProduct") {
|
||||
visible = await product_el.current.submit()
|
||||
} else {
|
||||
visible = await knockGold_el.current.submit()
|
||||
}
|
||||
if (visible) {
|
||||
// 第二步:获取商品或者立减金的数据 并格式化为table一样的字段 以商品数据为准 合并
|
||||
let form_data = {}
|
||||
if (type === "addProduct") {
|
||||
form_data = format_product_model()
|
||||
} else {
|
||||
form_data = format_knockGold_model()
|
||||
}
|
||||
console.log("form_data 1=>", form_data)
|
||||
submit(form_data)
|
||||
onClose()
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("err =>", err)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
className='draw'
|
||||
width={"86%"}
|
||||
title={product_title}
|
||||
footer={
|
||||
<div style={{ textAlign: "center" }}>
|
||||
<Button
|
||||
type='primary'
|
||||
onClick={(e) => {
|
||||
submitPop()
|
||||
}}>
|
||||
提交
|
||||
</Button>
|
||||
<Button onClick={(e) => onClose()}>取消</Button>
|
||||
</div>
|
||||
}
|
||||
visible={drawerVisible}
|
||||
onClose={(e) => onClose()}
|
||||
maskClosable={false}>
|
||||
<div className='draw2'>
|
||||
<Card
|
||||
className='borderNone'
|
||||
style={{ width: "95%", margin: "10px auto" }}>
|
||||
{type === "addKnockGold" ? (
|
||||
<KnockGold
|
||||
className='addKnockGold'
|
||||
data={productData}
|
||||
ref={knockGold_el}
|
||||
/>
|
||||
) : (
|
||||
<Productform data={productData} ref={product_el}></Productform>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
</Drawer>
|
||||
)
|
||||
})
|
||||
|
||||
export default UseGoodsScopePop
|
|
@ -15,6 +15,8 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
|
|||
submit,
|
||||
tableData,
|
||||
table_index,
|
||||
reduce,
|
||||
full,
|
||||
} = props;
|
||||
|
||||
// 如果需要 通过ref 控制此组件 放开注释
|
||||
|
@ -142,7 +144,12 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
|
|||
ref={knockGold_el}
|
||||
/>
|
||||
) : (
|
||||
<Productform data={productData} ref={product_el}></Productform>
|
||||
<Productform
|
||||
data={productData}
|
||||
ref={product_el}
|
||||
full={full}
|
||||
reduce={reduce}
|
||||
></Productform>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
import React, { useRef, useEffect } from "react";
|
||||
import { useSetState } from "ahooks";
|
||||
import { Button, CombinedDateRangePicker } from "zent";
|
||||
import { Sweetalert, Notify } from "zent";
|
||||
import _ from "lodash";
|
||||
import TabPage from "@/components/tabPage/main.js";
|
||||
import Ipt from "@/components/input/main";
|
||||
import Grid from "@/components/gird/main.js";
|
||||
|
||||
import { getCodeProductList, handelResponse } from "@/assets/api.js";
|
||||
import {
|
||||
getCodeProductList,
|
||||
handelResponse,
|
||||
deleteGoodsScope,
|
||||
} from "@/assets/api.js";
|
||||
import "./style.less";
|
||||
|
||||
const tableColumn = [
|
||||
|
@ -136,11 +140,44 @@ const UseCouponCommodity = () => {
|
|||
let param = getParam();
|
||||
getCodeProductList(param).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
setState({ tableData: req.data });
|
||||
console.log("res =>", req);
|
||||
let resData = [];
|
||||
req.data.map((item) => {
|
||||
/* type 1为商品 2为立减金 转译字符方便处理 */
|
||||
/* 此处only 商品为product_id 立减金为channel_activity_id */
|
||||
if (item.type === 1) {
|
||||
item.entity.upstream = "直连天下";
|
||||
item.entity.only = item.entity.product_id;
|
||||
item.entity.id = item.id;
|
||||
item.entity.weight = item.weight;
|
||||
item.entity.all_budget =
|
||||
Number(item.entity.contract_price) * Number(item.entity.quantity);
|
||||
item.entity.type = 1;
|
||||
resData.push(item.entity);
|
||||
} else if (item.type === 2) {
|
||||
resData.push({
|
||||
product_type_text: "立减金",
|
||||
only: item.entity.channel_activity_id,
|
||||
id: item.id,
|
||||
upstream: String(item.entity.channel) === "1" ? "支付宝" : "微信",
|
||||
code_batch_id: item.code_batch_id,
|
||||
contract_price: item.entity.price,
|
||||
create_time: item.create_time,
|
||||
official_price: item.entity.reduce_amount,
|
||||
channel_activity_id: item.entity.channel_activity_id,
|
||||
product_name: item.entity.batch_goods_name,
|
||||
quantity: item.stock,
|
||||
weight: item.weight,
|
||||
effectDate:
|
||||
item.entity.time_limit.effect_time.start_time +
|
||||
" 至 " +
|
||||
item.entity.time_limit.effect_time.end_time, //有效时间
|
||||
});
|
||||
}
|
||||
});
|
||||
console.log("resData =>", resData);
|
||||
setState({ tableData: resData });
|
||||
});
|
||||
});
|
||||
console.log("调用接口 ...", param);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -160,6 +197,34 @@ const UseCouponCommodity = () => {
|
|||
const tabChange = (data) => {
|
||||
setState({ page: 1, limit: 10, status: data, isQuery: !state.isQuery });
|
||||
};
|
||||
const deleteRow = (row) => {
|
||||
Sweetalert.confirm({
|
||||
type: "warning",
|
||||
closeBtn: true,
|
||||
title: "确认操作",
|
||||
content: <p>你确定要删除改条数据?</p>,
|
||||
onConfirm() {
|
||||
deleteGoodsScope(row.id)
|
||||
.then((res) => {
|
||||
handelResponse(
|
||||
res,
|
||||
(response, msg) => {
|
||||
Notify.clear();
|
||||
Notify.success(msg);
|
||||
setState({ isQuery: !state.isQuery });
|
||||
},
|
||||
(err) => {
|
||||
Notify.error(err);
|
||||
}
|
||||
);
|
||||
})
|
||||
.catch((err) => {});
|
||||
},
|
||||
onCancel() {},
|
||||
className: "questModal",
|
||||
parentComponent: this,
|
||||
});
|
||||
};
|
||||
return (
|
||||
<div className="table-box-app">
|
||||
<TabPage
|
||||
|
@ -203,13 +268,31 @@ const UseCouponCommodity = () => {
|
|||
countChange={(e) => onCountChange(e)}
|
||||
checkChange={(data) => selectionFun(data)}
|
||||
ComponentHandler={(com, rowData) => {
|
||||
if (com == "dates") {
|
||||
if (com === "dates") {
|
||||
return (
|
||||
<span>
|
||||
{rowData.begin_time} 至 {rowData.end_time}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
if (com === "opearo") {
|
||||
return (
|
||||
<div>
|
||||
<span
|
||||
style={{ color: "red" }}
|
||||
className="grid-link"
|
||||
onClick={() => deleteRow(rowData)}
|
||||
>
|
||||
删除
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (com === "type") {
|
||||
return <span>{rowData.type === 1 ? "商品" : "立减金"}</span>;
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -122,7 +122,6 @@ export default class add extends React.Component {
|
|||
} catch (err) {
|
||||
console.log("err =>", err);
|
||||
}
|
||||
|
||||
if (req.info) {
|
||||
sessionStorage.setItem("step1", JSON.stringify(req.info));
|
||||
this.refs.step1.edit(req.info);
|
||||
|
@ -133,10 +132,14 @@ export default class add extends React.Component {
|
|||
for (let i = 0; i < req.keys.length; i++) {
|
||||
this.addNewkey();
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
for (let i = 0; i < this.state.keys.length; i++) {
|
||||
this.refs["step2-" + i].edit(req.keys[i]);
|
||||
// 1兑换码 2优惠券
|
||||
if (Number(req.keys[0].bind_object[0]) === 2) {
|
||||
this.refs["step2-" + i].coupon_edit(req.keys[i]);
|
||||
} else {
|
||||
this.refs["step2-" + i].edit(req.keys[i]);
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
@ -147,7 +150,6 @@ export default class add extends React.Component {
|
|||
link: req.theme.theme_data.link,
|
||||
list: req.theme.theme_data.list,
|
||||
};
|
||||
|
||||
this.setState({ step3_data: theme_data });
|
||||
this.setState({ card_visible: true });
|
||||
this.setState({ curstep: 3 });
|
||||
|
@ -193,7 +195,7 @@ export default class add extends React.Component {
|
|||
setTimeout(() => {
|
||||
for (let i = 0; i < this.state.keys.length; i++) {
|
||||
// 1兑换码 2优惠券
|
||||
if (req.keys[0].bind_object[0] === "2") {
|
||||
if (Number(req.keys[0].bind_object[0]) === 2) {
|
||||
this.refs["step2-" + i].coupon_edit(req.keys[i]);
|
||||
} else {
|
||||
this.refs["step2-" + i].edit(req.keys[i]);
|
||||
|
@ -212,27 +214,17 @@ export default class add extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
// 优惠券格式数据
|
||||
coupon_format(data) {
|
||||
return data.keys;
|
||||
let new_data = data.map((item) => {
|
||||
return {
|
||||
products: 1,
|
||||
};
|
||||
});
|
||||
console.log("new_data =>", new_data);
|
||||
return new_data;
|
||||
}
|
||||
/* 转译 */
|
||||
tranFormData(req) {
|
||||
// 需要转译的类型
|
||||
let type = req.keys[0].bind_object[0];
|
||||
let type = Number(req.keys[0].bind_object[0]);
|
||||
sessionStorage.setItem("keyType", type);
|
||||
this.setState({
|
||||
keyType: Number(type),
|
||||
});
|
||||
if (type === "2") {
|
||||
// 优惠券的转译
|
||||
return this.coupon_format(req);
|
||||
if (type === 2) {
|
||||
// 优惠券的转译-弹窗已做了优化
|
||||
return req.keys;
|
||||
} else {
|
||||
// 兑换码的转译
|
||||
req.keys.map((item) => {
|
||||
|
@ -261,7 +253,9 @@ export default class add extends React.Component {
|
|||
item3.time_limit.effect_time.end_time; //有效时间
|
||||
obj.contract_price = item3.price; //单价
|
||||
obj.official_price = item3.reduce_amount; //官方价
|
||||
obj.quantity = Math.trunc(item3.all_budget / item3.reduce_amount); //总库存
|
||||
obj.quantity = parseInt(
|
||||
divNum(item3.all_budget, item3.reduce_amount)
|
||||
); //总库存
|
||||
obj.origin = item3;
|
||||
item1.products.push(obj);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* 新增营销计划 */
|
||||
import ReactDOM from "react-dom"
|
||||
import React, { Component } from "react"
|
||||
import { HashRouter as Router, Route, Link } from "react-router-dom"
|
||||
import ReactDOM from "react-dom";
|
||||
import React, { Component } from "react";
|
||||
import { HashRouter as Router, Route, Link } from "react-router-dom";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
|
@ -11,13 +11,13 @@ import {
|
|||
RadioGroup,
|
||||
smoothScroll,
|
||||
Sweetalert,
|
||||
Input
|
||||
} from "zent"
|
||||
import "./add.less"
|
||||
import Step1 from "./step1.js"
|
||||
import Step2 from "./step2.js"
|
||||
import Step3 from "./step3.js"
|
||||
import _ from "lodash"
|
||||
Input,
|
||||
} from "zent";
|
||||
import "./add.less";
|
||||
import Step1 from "./step1.js";
|
||||
import Step2 from "./step2.js";
|
||||
import Step3 from "./step3.js";
|
||||
import _ from "lodash";
|
||||
import {
|
||||
addPlanStep,
|
||||
handelResponse,
|
||||
|
@ -25,13 +25,13 @@ import {
|
|||
planSend,
|
||||
approvals,
|
||||
getDraftInfo,
|
||||
get_copy_data
|
||||
} from "../../../assets/api.js"
|
||||
import { divNum } from "@/tools/number"
|
||||
get_copy_data,
|
||||
} from "../../../assets/api.js";
|
||||
import { divNum } from "@/tools/number";
|
||||
|
||||
export default class add extends React.Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
super(props);
|
||||
this.state = {
|
||||
keys: [],
|
||||
step1_pagetitle: "新建计划",
|
||||
|
@ -45,10 +45,10 @@ export default class add extends React.Component {
|
|||
title: "key",
|
||||
child: [
|
||||
{ step: 1, title: "生成key" },
|
||||
{ step: 2, title: "绑定卡券" }
|
||||
]
|
||||
{ step: 2, title: "绑定卡券" },
|
||||
],
|
||||
},
|
||||
{ id: 3, title: "落地页", child: [{ step: 1, title: "绑定落地页" }] }
|
||||
{ id: 3, title: "落地页", child: [{ step: 1, title: "绑定落地页" }] },
|
||||
],
|
||||
phone_list: [],
|
||||
email_list: [],
|
||||
|
@ -70,43 +70,43 @@ export default class add extends React.Component {
|
|||
step1_data: null,
|
||||
step2_data: null,
|
||||
step3_data: null,
|
||||
disabled: false
|
||||
}
|
||||
disabled: false,
|
||||
keyType: 1,
|
||||
};
|
||||
}
|
||||
|
||||
submit() {
|
||||
this.refs.step1.submit()
|
||||
this.refs.step1.submit();
|
||||
}
|
||||
onReturn() {
|
||||
let self = this
|
||||
let self = this;
|
||||
Sweetalert.confirm({
|
||||
type: "warning",
|
||||
closeBtn: true,
|
||||
title: "确认操作",
|
||||
content: <p> 是否返回计划列表?</p>,
|
||||
onConfirm: () => {
|
||||
self.props.history.push("/home/plan-list/")
|
||||
self.props.history.push("/home/plan-list/");
|
||||
},
|
||||
onCancel: this.onCancel,
|
||||
className: "questModal",
|
||||
parentComponent: this
|
||||
})
|
||||
parentComponent: this,
|
||||
});
|
||||
}
|
||||
componentDidMount(e) {
|
||||
sessionStorage.setItem("white", 3)
|
||||
sessionStorage.setItem("plan_id", "")
|
||||
let plan_id_copy = sessionStorage.getItem("plan_id_copy")
|
||||
this.setState({ plan_id_detail: plan_id_copy })
|
||||
this.getDetails(plan_id_copy) // 获取详情
|
||||
sessionStorage.setItem("white", 3);
|
||||
sessionStorage.setItem("plan_id", "");
|
||||
let plan_id_copy = sessionStorage.getItem("plan_id_copy");
|
||||
this.setState({ plan_id_detail: plan_id_copy });
|
||||
this.getDetails(plan_id_copy); // 获取详情
|
||||
}
|
||||
/**
|
||||
* 获取详情
|
||||
* @param {id} id
|
||||
*/
|
||||
getDetails(plan_id) {
|
||||
let copy_count_golod = sessionStorage.getItem("copy_count_golod")
|
||||
let copy_count_golod = sessionStorage.getItem("copy_count_golod");
|
||||
get_copy_data(plan_id).then((res) => {
|
||||
console.log("res 1=>", res)
|
||||
handelResponse(
|
||||
res,
|
||||
(req, msg) => {
|
||||
|
@ -114,267 +114,277 @@ export default class add extends React.Component {
|
|||
getReseller(req.info.reseller_id).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
this.setState({
|
||||
direct_reseller_id: req.direct_reseller_id
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
direct_reseller_id: req.direct_reseller_id,
|
||||
});
|
||||
});
|
||||
});
|
||||
if (req.info) {
|
||||
req.info.title = `${req.info.title}_${Number(copy_count_golod) + 1}`
|
||||
sessionStorage.setItem("step1", JSON.stringify(req.info))
|
||||
this.refs.step1.edit(req.info)
|
||||
req.info.title = `${req.info.title}_${
|
||||
Number(copy_count_golod) + 1
|
||||
}`;
|
||||
sessionStorage.setItem("step1", JSON.stringify(req.info));
|
||||
this.refs.step1.edit(req.info);
|
||||
}
|
||||
if (req.keys.length > 0 && this.state.disabled == false) {
|
||||
this.setState({ curstep: 2 })
|
||||
this.setState({ curstep: 2 });
|
||||
//转译
|
||||
req.keys = this.tranFormData(req)
|
||||
|
||||
req.keys = this.tranFormData(req);
|
||||
console.log("req.keys =>", req.keys);
|
||||
for (let i = 0; i < req.keys.length; i++) {
|
||||
this.addNewkey()
|
||||
this.addNewkey();
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
for (let i = 0; i < this.state.keys.length; i++) {
|
||||
this.refs["step2-" + i].edit(req.keys[i])
|
||||
this.refs["step2-" + i].submit()
|
||||
// 1兑换码 2优惠券
|
||||
if (Number(req.keys[0].bind_object[0]) === 2) {
|
||||
this.refs["step2-" + i].coupon_edit(req.keys[i]);
|
||||
} else {
|
||||
this.refs["step2-" + i].edit(req.keys[i]);
|
||||
}
|
||||
|
||||
this.refs["step2-" + i].submit();
|
||||
}
|
||||
}, 500)
|
||||
}, 500);
|
||||
} else {
|
||||
this.addNewkey()
|
||||
this.addNewkey();
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
Notify.error(err)
|
||||
Notify.error(err);
|
||||
}
|
||||
)
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/* 转译 */
|
||||
tranFormData(req) {
|
||||
req.keys.map((item) => {
|
||||
item.code_batch.map((item1) => {
|
||||
item1.products = []
|
||||
})
|
||||
})
|
||||
// 需要转译的类型
|
||||
let type = Number(req.keys[0].bind_object[0]);
|
||||
this.setState({
|
||||
keyType: Number(type),
|
||||
});
|
||||
if (type === 2) {
|
||||
// 优惠券的转译-弹窗已做了优化
|
||||
return req.keys;
|
||||
} else {
|
||||
// 兑换码的转译
|
||||
req.keys.map((item) => {
|
||||
item.code_batch.map((item1) => {
|
||||
item1.products = [];
|
||||
});
|
||||
});
|
||||
req.keys.map((item) => {
|
||||
item.code_batch.map((item1) => {
|
||||
item1.product.legal.map((item2) => {
|
||||
item2.only = item2.product_id;
|
||||
item2.type = 1;
|
||||
item2.upstream = "直连天下";
|
||||
item1.products.push(item2);
|
||||
});
|
||||
item1.product.reduce.map((item3) => {
|
||||
let obj = {};
|
||||
obj.product_name = item3.batch_goods_name; //名字
|
||||
obj.channel_activity_id = item3.channel_activity_id; //批次号
|
||||
obj.only = item3.channel_activity_id;
|
||||
obj.type = 2; //类型
|
||||
obj.upstream = String(item3.channel) === "1" ? "支付宝" : "微信"; //上游
|
||||
obj.effectDate =
|
||||
item3.time_limit.effect_time.start_time +
|
||||
" 至 " +
|
||||
item3.time_limit.effect_time.end_time; //有效时间
|
||||
obj.contract_price = item3.price; //单价
|
||||
obj.official_price = item3.reduce_amount; //官方价
|
||||
obj.quantity = parseInt(
|
||||
divNum(item3.all_budget, item3.reduce_amount)
|
||||
); //总库存
|
||||
obj.origin = item3;
|
||||
item1.products.push(obj);
|
||||
});
|
||||
});
|
||||
});
|
||||
req.keys.map((item) => {
|
||||
item.code_batch.map((item1) => {
|
||||
item1.product = item1.products;
|
||||
delete item1.products;
|
||||
});
|
||||
});
|
||||
|
||||
req.keys.map((item) => {
|
||||
item.code_batch.map((item1) => {
|
||||
item1.product.legal.map((item2) => {
|
||||
item2.only = item2.product_id
|
||||
item2.type = 1
|
||||
item2.upstream = "直连天下"
|
||||
item1.products.push(item2)
|
||||
})
|
||||
|
||||
item1.product.reduce.map((item3) => {
|
||||
let obj = {}
|
||||
obj.product_name = item3.batch_goods_name //名字
|
||||
obj.channel_activity_id = item3.channel_activity_id //批次号
|
||||
obj.only = item3.channel_activity_id
|
||||
obj.type = 2 //类型
|
||||
obj.upstream = String(item3.channel) === "1" ? "支付宝" : "微信" //上游
|
||||
obj.effectDate =
|
||||
item3.time_limit.effect_time.start_time +
|
||||
" 至 " +
|
||||
item3.time_limit.effect_time.end_time //有效时间
|
||||
obj.contract_price = item3.price //单价
|
||||
obj.official_price = item3.reduce_amount //官方价
|
||||
obj.quantity = parseInt(divNum(item3.all_budget, item3.reduce_amount)) //总库存
|
||||
obj.origin = item3
|
||||
item1.products.push(obj)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
req.keys.map((item) => {
|
||||
item.code_batch.map((item1) => {
|
||||
item1.product = item1.products
|
||||
delete item1.products
|
||||
})
|
||||
})
|
||||
|
||||
return req.keys
|
||||
return req.keys;
|
||||
}
|
||||
}
|
||||
|
||||
onConfirm(e) {
|
||||
let plan_id = sessionStorage.getItem("plan_id")
|
||||
this.setState({ is_audit: true })
|
||||
this.setState({ audit_visible: false })
|
||||
let plan_id = sessionStorage.getItem("plan_id");
|
||||
this.setState({ is_audit: true });
|
||||
this.setState({ audit_visible: false });
|
||||
let data = {
|
||||
reseller_id: this.state.reseller.id,
|
||||
reseller_name: this.state.reseller.name,
|
||||
company_name: this.state.reseller.company_name,
|
||||
receive_email: this.state.email_list[0],
|
||||
payment_direction: this.state.payment_direction[this.state.paytype - 1]
|
||||
}
|
||||
|
||||
payment_direction: this.state.payment_direction[this.state.paytype - 1],
|
||||
};
|
||||
approvals(plan_id, data).then((res) => {
|
||||
handelResponse(
|
||||
res,
|
||||
(req, msg) => {
|
||||
Notify.success("成功发起审批")
|
||||
this.props.history.push("/home/plan-list/")
|
||||
this.setState({ is_audit: false })
|
||||
Notify.success("成功发起审批");
|
||||
this.props.history.push("/home/plan-list/");
|
||||
this.setState({ is_audit: false });
|
||||
},
|
||||
(err) => {
|
||||
Notify.error(err)
|
||||
Notify.error(err);
|
||||
}
|
||||
)
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
onPayTypeChange(e) {
|
||||
console.log("渠道类型", e.target.value)
|
||||
this.setState({ paytype: e.target.value })
|
||||
this.setState({ paytype: e.target.value });
|
||||
}
|
||||
|
||||
async onNextStep() {
|
||||
if (this.state.curstep >= 1) {
|
||||
if ((await this.refs.step1.submit()) == true) {
|
||||
this.setState({ isload: true })
|
||||
this.setState({ curstep: 2 })
|
||||
this.setState({ isload: true });
|
||||
this.setState({ curstep: 2 });
|
||||
} else {
|
||||
return
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.state.curstep >= 2) {
|
||||
let temp = []
|
||||
let temp = [];
|
||||
for (let i = 0; i < this.state.keys.length; i++) {
|
||||
let data = null
|
||||
let data = null;
|
||||
if (this.refs[this.state.keys[i]]) {
|
||||
data = this.refs[this.state.keys[i]].submit()
|
||||
data = this.refs[this.state.keys[i]].submit();
|
||||
} else {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
|
||||
if (data) {
|
||||
temp.push(data)
|
||||
temp.push(data);
|
||||
} else {
|
||||
return
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let obj = {
|
||||
info: JSON.parse(sessionStorage.getItem("step1")),
|
||||
key: temp
|
||||
}
|
||||
console.log("step 2 =>", obj)
|
||||
let plan_id = sessionStorage.getItem("plan_id")
|
||||
key: temp,
|
||||
};
|
||||
let plan_id = sessionStorage.getItem("plan_id");
|
||||
await addPlanStep(plan_id, obj).then((res) => {
|
||||
handelResponse(
|
||||
res,
|
||||
(req, msg) => {
|
||||
this.setState({ curstep: 3 })
|
||||
sessionStorage.setItem("step2", JSON.stringify(temp))
|
||||
this.setState({ card_visible: true })
|
||||
return
|
||||
this.setState({ curstep: 3 });
|
||||
sessionStorage.setItem("step2", JSON.stringify(temp));
|
||||
this.setState({ card_visible: true });
|
||||
return;
|
||||
},
|
||||
(err) => {
|
||||
Notify.error(err)
|
||||
Notify.error(err);
|
||||
}
|
||||
)
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
if (this.state.curstep == 3) {
|
||||
if (this.state.direct_reseller_id <= 0) {
|
||||
// 老数据不能进行新增商品操作
|
||||
Notify.error(`请添加映射分销商`)
|
||||
return
|
||||
Notify.error(`请添加映射分销商`);
|
||||
return;
|
||||
}
|
||||
|
||||
let data = this.refs.step3.submit()
|
||||
let data = this.refs.step3.submit();
|
||||
if (data) {
|
||||
let obj = {
|
||||
info: JSON.parse(sessionStorage.getItem("step1")),
|
||||
key: JSON.parse(sessionStorage.getItem("step2")),
|
||||
theme: data,
|
||||
complete: true
|
||||
}
|
||||
complete: true,
|
||||
};
|
||||
|
||||
let plan_id = sessionStorage.getItem("plan_id")
|
||||
let plan_id = sessionStorage.getItem("plan_id");
|
||||
addPlanStep(plan_id, obj).then((res) => {
|
||||
handelResponse(
|
||||
res,
|
||||
(req, msg) => {
|
||||
//获取电话 邮箱
|
||||
let id = obj.info.reseller_id
|
||||
let id = obj.info.reseller_id;
|
||||
getReseller(id).then((res) => {
|
||||
handelResponse(res, (req, msg) => {
|
||||
console.log("分销商数据")
|
||||
console.log(req)
|
||||
this.setState({ reseller: req })
|
||||
this.setState({ phone_list: req.contact_phone })
|
||||
this.setState({ email_list: req.contact_email })
|
||||
this.setState({ audit_visible: true })
|
||||
})
|
||||
})
|
||||
this.setState({ reseller: req });
|
||||
this.setState({ phone_list: req.contact_phone });
|
||||
this.setState({ email_list: req.contact_email });
|
||||
this.setState({ audit_visible: true });
|
||||
});
|
||||
});
|
||||
},
|
||||
(err) => {
|
||||
Notify.error(err)
|
||||
Notify.error(err);
|
||||
}
|
||||
)
|
||||
})
|
||||
);
|
||||
});
|
||||
} else {
|
||||
return
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
addNewkey() {
|
||||
let step = "step2-" + this.state.keys.length
|
||||
this.state.keys.push(step)
|
||||
this.setState({ keys: this.state.keys })
|
||||
this.setState({ isload: true })
|
||||
let step = "step2-" + this.state.keys.length;
|
||||
this.state.keys.push(step);
|
||||
this.setState({ keys: this.state.keys });
|
||||
this.setState({ isload: true });
|
||||
if (this.refs[this.state.keys[0]].state.model.style == 6) {
|
||||
this.setState({ whiteStyle: true })
|
||||
this.setState({ keyStyle: 6 })
|
||||
this.setState({ whiteStyle: true });
|
||||
this.setState({ keyStyle: 6 });
|
||||
} else {
|
||||
this.setState({ keyStyle: 1 })
|
||||
this.setState({ whiteStyle: false })
|
||||
this.setState({ keyStyle: 1 });
|
||||
this.setState({ whiteStyle: false });
|
||||
}
|
||||
}
|
||||
onStyleChange(e) {
|
||||
if (e.target.value == 6) {
|
||||
this.setState({ whiteStyle: true })
|
||||
this.setState({ keyStyle: 6 })
|
||||
sessionStorage.setItem("white", 1)
|
||||
this.setState({ whiteStyle: true });
|
||||
this.setState({ keyStyle: 6 });
|
||||
sessionStorage.setItem("white", 1);
|
||||
for (let i = 0; i < this.state.keys.length; i++) {
|
||||
if (this.refs[this.state.keys[i]]) {
|
||||
if (i > 0) {
|
||||
this.refs[this.state.keys[i]].setkeyStyle(6)
|
||||
this.refs[this.state.keys[i]].setkeyStyle(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sessionStorage.setItem("white", 3)
|
||||
sessionStorage.setItem("white", 3);
|
||||
for (let i = 0; i < this.state.keys.length; i++) {
|
||||
if (this.refs[this.state.keys[i]]) {
|
||||
if (i > 0) {
|
||||
this.refs[this.state.keys[i]].setkeyStyle(1)
|
||||
this.refs[this.state.keys[i]].setkeyStyle(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.setState({ whiteStyle: false })
|
||||
this.setState({ whiteStyle: false });
|
||||
}
|
||||
}
|
||||
onPhoneChange(e) {
|
||||
this.setState({ phone_radio: e.target.value })
|
||||
this.setState({ phone_radio: e.target.value });
|
||||
}
|
||||
onEmailChange(e) {
|
||||
this.setState({ email_radio: e.target.value })
|
||||
this.setState({ email_radio: e.target.value });
|
||||
}
|
||||
cancel(e) {
|
||||
this.setState({ audit_visible: false })
|
||||
this.setState({ audit_visible: false });
|
||||
}
|
||||
|
||||
closeStep(index) {
|
||||
this.state.keys[index] = ""
|
||||
this.setState({ keys: this.state.keys })
|
||||
this.state.keys[index] = "";
|
||||
this.setState({ keys: this.state.keys });
|
||||
}
|
||||
|
||||
send(e) {
|
||||
let plan_id = sessionStorage.getItem("plan_id")
|
||||
let plan_id = sessionStorage.getItem("plan_id");
|
||||
let data = {
|
||||
phone:
|
||||
this.state.phone_radio > -1
|
||||
|
@ -383,83 +393,85 @@ export default class add extends React.Component {
|
|||
email:
|
||||
this.state.email_radio > -1
|
||||
? this.state.email_list[this.state.email_radio]
|
||||
: this.state.email
|
||||
}
|
||||
: this.state.email,
|
||||
};
|
||||
|
||||
let phoneReg = new RegExp("^[1][3,4,5,6,7,8,9][0-9]{9}$")
|
||||
let phoneReg = new RegExp("^[1][3,4,5,6,7,8,9][0-9]{9}$");
|
||||
|
||||
if (!phoneReg.test(data.phone)) {
|
||||
Notify.error("手机号格式不正确")
|
||||
return
|
||||
Notify.error("手机号格式不正确");
|
||||
return;
|
||||
}
|
||||
|
||||
planSend(plan_id, data).then((res) => {
|
||||
handelResponse(
|
||||
res,
|
||||
(req, msg) => {
|
||||
Notify.success("发送成功,请在1-2分钟后查看")
|
||||
this.props.history.push("/home/plan-list/")
|
||||
Notify.success("发送成功,请在1-2分钟后查看");
|
||||
this.props.history.push("/home/plan-list/");
|
||||
},
|
||||
(err) => {
|
||||
Notify.error(err)
|
||||
this.props.history.push("/home/plan-list/")
|
||||
Notify.error(err);
|
||||
this.props.history.push("/home/plan-list/");
|
||||
}
|
||||
)
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
phoneChange = (e) => {
|
||||
this.setState({ phone: e.target.value })
|
||||
}
|
||||
this.setState({ phone: e.target.value });
|
||||
};
|
||||
emailChange = (e) => {
|
||||
this.setState({ email: e.target.value })
|
||||
}
|
||||
this.setState({ email: e.target.value });
|
||||
};
|
||||
|
||||
// 获取分销商 id
|
||||
getDirectResellerId = (data) => {
|
||||
this.setState({
|
||||
direct_reseller_id: data.direct_reseller_id
|
||||
})
|
||||
}
|
||||
direct_reseller_id: data.direct_reseller_id,
|
||||
});
|
||||
};
|
||||
render() {
|
||||
return (
|
||||
<div id='plan-add'>
|
||||
<div className='plan-left' style={{ paddingTop: "125px" }}>
|
||||
<div id="plan-add">
|
||||
<div className="plan-left" style={{ paddingTop: "125px" }}>
|
||||
{this.state.menuList.map((item, index) => {
|
||||
return (
|
||||
<div className='box-item' key={item.title}>
|
||||
<div className='main-title'>{item.title}</div>
|
||||
<div className="box-item" key={item.title}>
|
||||
<div className="main-title">{item.title}</div>
|
||||
{item.child.map((item2, index2) => {
|
||||
return (
|
||||
<div className='title-inline' key={index2}>
|
||||
<div className="title-inline" key={index2}>
|
||||
<div
|
||||
key={item2.title}
|
||||
className={
|
||||
this.state.curstep >= item.id
|
||||
? "child-title active"
|
||||
: "child-title"
|
||||
}>
|
||||
}
|
||||
>
|
||||
{item2.title}{" "}
|
||||
</div>
|
||||
{this.state.curstep >= item.id ? (
|
||||
<Icon type='check' className='checkIcon' />
|
||||
<Icon type="check" className="checkIcon" />
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
})}
|
||||
<div className='under-line'></div>
|
||||
<div className="under-line"></div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div className='plan-right'>
|
||||
<div className='action-panel'>
|
||||
<div id='step1' className='step1'>
|
||||
<div className='plan-title'>营销计划</div>
|
||||
<div className="plan-right">
|
||||
<div className="action-panel">
|
||||
<div id="step1" className="step1">
|
||||
<div className="plan-title">营销计划</div>
|
||||
<Card
|
||||
style={{ width: "100%" }}
|
||||
title={this.state.step1_pagetitle}>
|
||||
title={this.state.step1_pagetitle}
|
||||
>
|
||||
<Step1
|
||||
ref='step1'
|
||||
ref="step1"
|
||||
data={this.state.step1_data}
|
||||
onGetDirectResellerId={(data) =>
|
||||
this.getDirectResellerId(data)
|
||||
|
@ -469,39 +481,46 @@ export default class add extends React.Component {
|
|||
</div>
|
||||
|
||||
{this.state.curstep >= 2 ? (
|
||||
<div id='step2' className='step2'>
|
||||
<div className='plan-title'>key</div>
|
||||
<div id="step2" className="step2">
|
||||
<div className="plan-title">key</div>
|
||||
{this.state.keys.map((item, index) => {
|
||||
return item ? (
|
||||
<Card
|
||||
style={{
|
||||
width: "100%",
|
||||
height: "auto",
|
||||
marginBottom: "10px"
|
||||
marginBottom: "10px",
|
||||
}}
|
||||
key={index}
|
||||
title={this.state.step2_pagetitle}
|
||||
action={
|
||||
index > 0 ? (
|
||||
<span
|
||||
className='zent-link'
|
||||
target='_blank'
|
||||
className="zent-link"
|
||||
target="_blank"
|
||||
onClick={(e) => {
|
||||
this.closeStep(index)
|
||||
}}>
|
||||
this.closeStep(index);
|
||||
}}
|
||||
>
|
||||
关闭
|
||||
</span>
|
||||
) : null
|
||||
}>
|
||||
}
|
||||
>
|
||||
<Step2
|
||||
ref={item}
|
||||
addNewkey={() => {
|
||||
this.addNewkey()
|
||||
this.addNewkey();
|
||||
}}
|
||||
onStyleChange={(e) => {
|
||||
this.onStyleChange(e)
|
||||
this.onStyleChange(e);
|
||||
}}
|
||||
keyStyle={this.state.keyStyle}
|
||||
changeKeyType={(e) => {
|
||||
sessionStorage.setItem("keyType", e);
|
||||
this.setState({ keyType: e });
|
||||
}}
|
||||
keyType={this.state.keyType}
|
||||
isCopy={true}
|
||||
isload={this.state.isload}
|
||||
direct_reseller_id={this.state.direct_reseller_id}
|
||||
|
@ -509,77 +528,81 @@ export default class add extends React.Component {
|
|||
whiteStyle={this.state.whiteStyle}
|
||||
/>
|
||||
</Card>
|
||||
) : null
|
||||
) : null;
|
||||
})}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{this.state.card_visible ? (
|
||||
<div id='step3' className='step3'>
|
||||
<div id="step3" className="step3">
|
||||
<Card
|
||||
style={{ width: "100%", height: "auto" }}
|
||||
title={this.state.step3_pagetitle}>
|
||||
<Step3 ref='step3' />
|
||||
title={this.state.step3_pagetitle}
|
||||
>
|
||||
<Step3 ref="step3" />
|
||||
</Card>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{this.state.curstep == 3 ? (
|
||||
<div className='step-btn-group'>
|
||||
<Button type='primary' onClick={() => this.onNextStep()}>
|
||||
<div className="step-btn-group">
|
||||
<Button type="primary" onClick={() => this.onNextStep()}>
|
||||
提交审核
|
||||
</Button>
|
||||
<Button type='normal' onClick={() => this.onReturn()}>
|
||||
<Button type="normal" onClick={() => this.onReturn()}>
|
||||
取消
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className='step-btn-group'>
|
||||
<Button type='primary' onClick={() => this.onNextStep()}>
|
||||
<div className="step-btn-group">
|
||||
<Button type="primary" onClick={() => this.onNextStep()}>
|
||||
下一步
|
||||
</Button>
|
||||
<Button type='normal' onClick={() => this.onReturn()}>
|
||||
<Button type="normal" onClick={() => this.onReturn()}>
|
||||
取消
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{this.state.audit_visible ? (
|
||||
<div className='audit'>
|
||||
<div className='modal'> </div>
|
||||
<div className='audit-box'>
|
||||
<div className="audit">
|
||||
<div className="modal"> </div>
|
||||
<div className="audit-box">
|
||||
<Icon
|
||||
type='close'
|
||||
className='audit-close'
|
||||
type="close"
|
||||
className="audit-close"
|
||||
onClick={(e) => {
|
||||
this.setState({ audit_visible: false })
|
||||
this.setState({ audit_visible: false });
|
||||
}}
|
||||
/>
|
||||
<div className='audit-box-title'>提交审核</div>
|
||||
<div className='payType'>
|
||||
<div className="audit-box-title">提交审核</div>
|
||||
<div className="payType">
|
||||
<RadioGroup
|
||||
onChange={(e) => {
|
||||
this.onPayTypeChange(e)
|
||||
this.onPayTypeChange(e);
|
||||
}}
|
||||
value={this.state.paytype}
|
||||
className='audit-obj'>
|
||||
className="audit-obj"
|
||||
>
|
||||
<Radio value={3}>预付款扣除</Radio>
|
||||
<Radio value={1}>对私账户</Radio>
|
||||
<Radio value={2}>对公账户</Radio>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
<div className='audit-btn-group'>
|
||||
<div className="audit-btn-group">
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
this.setState({ audit_visible: false })
|
||||
}}>
|
||||
this.setState({ audit_visible: false });
|
||||
}}
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
<Button
|
||||
type='primary'
|
||||
type="primary"
|
||||
onClick={(e) => {
|
||||
this.onConfirm(e)
|
||||
}}>
|
||||
this.onConfirm(e);
|
||||
}}
|
||||
>
|
||||
确定
|
||||
</Button>
|
||||
</div>
|
||||
|
@ -589,6 +612,6 @@ export default class add extends React.Component {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import {
|
|||
getAccessVerification,
|
||||
getProductInfoSelect,
|
||||
} from "@/assets/api.js";
|
||||
|
||||
import { divNum } from "@/tools/number";
|
||||
import ProductForm from "../product/add"; /* 商品 */
|
||||
import KnockGold from "@/components/knockGold"; /* 立减金 */
|
||||
import UseCouponAddEdit from "@/components/UseCouponAddEdit"; /* 立减金 */
|
||||
|
@ -63,7 +63,6 @@ export default class acclist extends React.Component {
|
|||
},
|
||||
drawerVisible: false,
|
||||
drawerVisible2: false,
|
||||
checkedList: 1,
|
||||
productData: [],
|
||||
codeInfo: {
|
||||
//数据模型不可少
|
||||
|
@ -231,7 +230,7 @@ export default class acclist extends React.Component {
|
|||
submit() {
|
||||
let valide = false;
|
||||
// 兑换码
|
||||
if (this.state.checkedList === 1) {
|
||||
if (this.props.keyType === 1) {
|
||||
if (this.refs.form1.validator()) {
|
||||
/* 处理数据 区分立减金和商品 开始 2022-05-30 13:40*/
|
||||
const dataCopy = this.refs.tempdata.getSelectData();
|
||||
|
@ -258,7 +257,7 @@ export default class acclist extends React.Component {
|
|||
data.batch_name = this.state.model.batch_name;
|
||||
data.style = this.state.model.style;
|
||||
data.quantity = this.state.model.quantity;
|
||||
data.bind_object = [this.state.checkedList];
|
||||
data.bind_object = [this.props.keyType];
|
||||
data.allow_repetition = this.state.model.allow_repetition;
|
||||
data.allow_loss = this.state.model.allow_loss;
|
||||
data.merge_stock = this.state.model.merge_stock;
|
||||
|
@ -275,7 +274,7 @@ export default class acclist extends React.Component {
|
|||
data.batch_name = this.state.model.batch_name;
|
||||
data.style = this.state.model.style;
|
||||
data.quantity = this.state.model.quantity;
|
||||
data.bind_object = [this.state.checkedList];
|
||||
data.bind_object = [this.props.keyType];
|
||||
data.allow_repetition = this.state.model.allow_repetition;
|
||||
data.allow_loss = this.state.model.allow_loss;
|
||||
data.merge_stock = this.state.model.merge_stock;
|
||||
|
@ -293,8 +292,8 @@ export default class acclist extends React.Component {
|
|||
}
|
||||
|
||||
onCheckChange = ({ target }) => {
|
||||
this.setState({ checkedList: target.value });
|
||||
console.log(this.state.couponData);
|
||||
this.props.changeKeyType(target.value);
|
||||
// this.setState({ checkedList: target.value });
|
||||
};
|
||||
|
||||
onStyleChange(e) {
|
||||
|
@ -490,7 +489,7 @@ export default class acclist extends React.Component {
|
|||
: item.reduce_amount; //官方价
|
||||
newObj.quantity = item.quantity
|
||||
? item.quantity
|
||||
: Math.trunc(item.all_budget / item.reduce_amount); //总库
|
||||
: parseInt(divNum(item.all_budget, item.reduce_amount)); //总库
|
||||
newObj.origin = item?.origin ? item?.origin : item;
|
||||
return newObj;
|
||||
});
|
||||
|
@ -548,9 +547,8 @@ export default class acclist extends React.Component {
|
|||
}
|
||||
|
||||
codeSubmit() {
|
||||
console.log("checkedList =>", this.state.checkedList);
|
||||
// 优惠券数据
|
||||
if (this.state.checkedList === 2) {
|
||||
if (this.props.keyType === 2) {
|
||||
let coupon_validator = this.refs.addEditCouponEl.submit();
|
||||
if (coupon_validator) {
|
||||
let param = this.refs.addEditCouponEl.getModel();
|
||||
|
@ -605,8 +603,6 @@ export default class acclist extends React.Component {
|
|||
restrict: this.state.codeInfo.restrict,
|
||||
range: rank.toString(),
|
||||
};
|
||||
|
||||
console.log(productlist);
|
||||
let arr = _.map(productlist, (item) => {
|
||||
let obj = {};
|
||||
obj.product_id = item.product_id;
|
||||
|
@ -741,6 +737,34 @@ export default class acclist extends React.Component {
|
|||
this.setState({ isload: true });
|
||||
}
|
||||
|
||||
coupon_edit(data) {
|
||||
let model = {
|
||||
//数据模型不可少
|
||||
batch_name: data.batch_name,
|
||||
style: parseInt(data.style),
|
||||
quantity: data.quantity,
|
||||
allow_repetition: parseInt(data.allow_repetition),
|
||||
allow_loss: parseInt(data.allow_loss),
|
||||
merge_stock: data.merge_stock,
|
||||
draw_title: data.draw_title,
|
||||
coupon: data.coupon,
|
||||
};
|
||||
this.setState({ mobile_excel: data.mobile_excel });
|
||||
this.setState({ mobile_repeat: data.mobile_repeat });
|
||||
if (model.style == 6) {
|
||||
this.setState({ white_visible: true });
|
||||
}
|
||||
this.setState({ model: model });
|
||||
|
||||
let temp = _.map(data.coupon, (o) => {
|
||||
o.checked = true;
|
||||
return o;
|
||||
});
|
||||
|
||||
this.setState({ couponData: temp });
|
||||
this.setState({ isload: true });
|
||||
}
|
||||
|
||||
onUpload = (file, report) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let path = "";
|
||||
|
@ -836,7 +860,7 @@ export default class acclist extends React.Component {
|
|||
|
||||
rowItemClick(row, rowIndex) {
|
||||
// 兑换码
|
||||
if (this.state.checkedList === 1) {
|
||||
if (this.props.keyType === 1) {
|
||||
let codeInfo = {
|
||||
//数据模型不可少
|
||||
code_name: row.title,
|
||||
|
@ -999,7 +1023,6 @@ export default class acclist extends React.Component {
|
|||
}
|
||||
/* 商品范围列表编辑 */
|
||||
productEditShow(rowData) {
|
||||
console.log("rowData 12==>", rowData);
|
||||
if (this.props.direct_reseller_id > 0) {
|
||||
this.setState({
|
||||
tableLoading: true,
|
||||
|
@ -1009,7 +1032,6 @@ export default class acclist extends React.Component {
|
|||
sessionStorage.setItem("productsList", JSON.stringify(data));
|
||||
/* 区分立减金 */
|
||||
if (rowData.type === 2) {
|
||||
console.log("编辑立减金:", rowData.origin);
|
||||
let obj = rowData.origin;
|
||||
// 是否是复制操作
|
||||
if (this.state.isCopy) {
|
||||
|
@ -1311,13 +1333,13 @@ export default class acclist extends React.Component {
|
|||
) : null}
|
||||
<FormItem labelname="绑定类型" prop="bind_object" id="bind_object">
|
||||
<Radio.Group
|
||||
value={this.state.checkedList}
|
||||
value={this.props.keyType}
|
||||
onChange={(e) => {
|
||||
this.onCheckChange(e);
|
||||
}}
|
||||
>
|
||||
<Radio value={1} disabled={this.props.name !== 0}>
|
||||
兑换码 {this.props.name}{" "}
|
||||
兑换码
|
||||
</Radio>
|
||||
<Radio value={2} disabled={this.props.name !== 0}>
|
||||
优惠券
|
||||
|
@ -1326,7 +1348,7 @@ export default class acclist extends React.Component {
|
|||
</FormItem>
|
||||
|
||||
<FormItem labelname="" prop="btn" required={false}>
|
||||
{this.state.checkedList === 1 ? (
|
||||
{this.props.keyType === 1 ? (
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
this.checkIndex(0);
|
||||
|
@ -1351,12 +1373,12 @@ export default class acclist extends React.Component {
|
|||
isShowPageBar={false}
|
||||
spliteColor={"#fff"}
|
||||
tableData={
|
||||
this.state.checkedList === 1
|
||||
this.props.keyType === 1
|
||||
? this.state.distdata
|
||||
: this.state.couponData
|
||||
}
|
||||
Column={
|
||||
this.state.checkedList === 1
|
||||
this.props.keyType === 1
|
||||
? this.state.Column
|
||||
: this.state.Column_coupon
|
||||
}
|
||||
|
@ -1383,7 +1405,7 @@ export default class acclist extends React.Component {
|
|||
);
|
||||
}
|
||||
// 优惠券范围
|
||||
if (com === "product" && this.state.checkedList === 2) {
|
||||
if (com === "product" && this.props.keyType === 2) {
|
||||
return coupon_range(rowData.product);
|
||||
}
|
||||
if (com == "edit") {
|
||||
|
@ -1462,7 +1484,7 @@ export default class acclist extends React.Component {
|
|||
}}
|
||||
maskClosable={false}
|
||||
>
|
||||
{this.state.checkedList === 1 ? (
|
||||
{this.props.keyType === 1 ? (
|
||||
<div className="draw">
|
||||
<Card
|
||||
style={{ width: "95%", margin: "10px auto" }}
|
||||
|
@ -1591,7 +1613,7 @@ export default class acclist extends React.Component {
|
|||
this.onRankChange(e);
|
||||
}}
|
||||
/>
|
||||
{this.state.checkedList === 1 ? (
|
||||
{this.props.keyType === 1 ? (
|
||||
<>
|
||||
<Button
|
||||
type="primary"
|
||||
|
|
|
@ -54,10 +54,16 @@ export default class adduserinfo extends React.Component {
|
|||
describe_url: "",
|
||||
loadshow: false,
|
||||
productpic: [],
|
||||
keyType: 1,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.setState({
|
||||
keyType: sessionStorage.getItem("keyType")
|
||||
? Number(sessionStorage.getItem("keyType"))
|
||||
: 1,
|
||||
});
|
||||
mySwiper = new Swiper(".swiper-container", {
|
||||
slidesPerView: 1,
|
||||
centeredSlides: true,
|
||||
|
@ -471,6 +477,73 @@ export default class adduserinfo extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
isReduce() {
|
||||
let num = this.props.full;
|
||||
if (num !== "" && num) {
|
||||
num = Number(num);
|
||||
}
|
||||
|
||||
if (Number(this.state.model.official_price) >= num) {
|
||||
return (
|
||||
<div>
|
||||
<p className="mobile-money foot-money">
|
||||
<span style={{ fontSize: "14px" }}>¥</span>{" "}
|
||||
{this.state.model.official_price}
|
||||
</p>
|
||||
<p className="foot-mobile-infos">共省¥ {this.props.reduce}</p>;
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<p className="mobile-money foot-money" style={{ lineHeight: "40px" }}>
|
||||
<span style={{ fontSize: "14px" }}>¥</span>{" "}
|
||||
{this.state.model.official_price}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 优惠券H5
|
||||
couponH5() {
|
||||
return (
|
||||
<div>
|
||||
<div className="mobile-goods-info">
|
||||
<p className="mobile-money">
|
||||
<span style={{ fontSize: "14px" }}>¥</span>{" "}
|
||||
{this.state.model.official_price}
|
||||
</p>
|
||||
<p className="mobile-goods-name">{this.state.model.product_name}</p>
|
||||
<div className="mobile-line"></div>
|
||||
<div className="mobile_center"></div>
|
||||
</div>
|
||||
|
||||
<div className="mobile_bottom">
|
||||
{this.state.model.detail_url ? (
|
||||
<img src={this.state.model.detail_url} alt="" />
|
||||
) : null}
|
||||
</div>
|
||||
<div className="foot-mobile-box">
|
||||
<div className="mobile-center">{this.isReduce()}</div>
|
||||
<div className="mobile-pay-btn">立即支付</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 兑换码
|
||||
exchangecodeH5() {
|
||||
return (
|
||||
<div>
|
||||
<div className="mobile_center"></div>
|
||||
<div className="mobile_bottom">
|
||||
{this.state.model.detail_url ? (
|
||||
<img src={this.state.model.detail_url} alt="" />
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
//校验规则
|
||||
const rules = {
|
||||
|
@ -705,12 +778,8 @@ export default class adduserinfo extends React.Component {
|
|||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="mobile_center"></div>
|
||||
<div className="mobile_bottom">
|
||||
{this.state.model.detail_url ? (
|
||||
<img src={this.state.model.detail_url} alt="" />
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{this.state.keyType === 1 ? this.exchangecodeH5() : this.couponH5()}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -8,4 +8,58 @@
|
|||
|
||||
.good-image-upload-demo {
|
||||
width: 300px !important;
|
||||
}
|
||||
.mobile-goods-info{
|
||||
background-color: #fff;
|
||||
margin-top: 5px;
|
||||
}
|
||||
.mobile-line{
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
.mobile-money{
|
||||
font-size: 20px;
|
||||
font-weight: 500;
|
||||
color: #FF5533;
|
||||
padding: 20px 0 0 20px;
|
||||
}
|
||||
.foot-money{
|
||||
padding-top: 5px;
|
||||
}
|
||||
.mobile-goods-name{
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #000000;
|
||||
padding-left: 20px;
|
||||
padding-top: 5px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
.foot-mobile-box{
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.foot-mobile-infos{
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
color: #A2A3A8;
|
||||
padding-left: 20px;
|
||||
}
|
||||
.mobile-pay-btn{
|
||||
width: 120px;
|
||||
height: 50px;
|
||||
background: #FE6344;
|
||||
box-shadow: -1px -8px 8px 0px rgba(160,160,160,0.08);
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
line-height: 50px;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.mobile-center{
|
||||
|
||||
}
|
Loading…
Reference in New Issue