Commit d90f8f65 authored by 徐一鸣's avatar 徐一鸣

服务申请

parent 8e00cfa1
......@@ -258,6 +258,7 @@ export default {
query: {
service_id: parseFloat(this.data.service_id),
spec_id: this.specification.id,
spcs_type: this.specification.spcs_type,
duration: this.duration,
duration_unit: this.type,
},
......
......@@ -37,8 +37,8 @@ export default {
preson: "",
phone: "",
},
all_cost:'',
now_money:'',
all_cost: 0,
now_money: 0,
module_arr: [
{
title: "服务申请",
......@@ -122,7 +122,7 @@ export default {
} else if (this.$route.query.app_id) {
this.get_one_app(this.$route.query);
} else {
console.log(JSON.parse(window.sessionStorage.getItem("shoppingCart")));
// console.log(JSON.parse(window.sessionStorage.getItem("shoppingCart")));
var temp_arr = [];
JSON.parse(window.sessionStorage.getItem("shoppingCart")).forEach((e) => {
temp_arr.push(e.id);
......@@ -136,9 +136,8 @@ export default {
get_account_money(){
this.$http
.get(`/apaas/backmgt/user/myAccount`).then(res=>{
console.log(res);
if(res.data.success){
this.now_money = res.data.data.account_balance
this.now_money = res.data.data.account_balance || 0
}
})
},
......@@ -201,21 +200,26 @@ export default {
},
];
this.service_arr[0]["auth"] = data.organization_name;
this.service_arr[0]["size"] = "规格:";
this.service_arr[0]["size"] = "";
this.service_arr[0]["count"] = "";
data.request_spcs_info.forEach((el) => {
if (service_data.spec_id == el.id) {
this.service_arr[0]["size"] =
this.service_arr[0]["size"] +
"访问次数:" +
el.count +
",访问量:" +
el.pv +
",";
let size = "";
if (el.spcs_type==1) {
size = `${el.money}金币/${el.spcs_count}次`
this.service_arr[0]["num"] = "不限时长"
} else {
size = `${el.money}金币/${el.duration_unit == 1 ? "" : ""}`
this.service_arr[0]["num"] = service_data.duration;
}
this.service_arr[0]["size"] = size;
this.service_arr[0]["count"] = service_data.duration*el.money+'金币';
}
});
this.service_arr[0]["applytype"] =
"申请方式:" + (service_data.duration_unit == 1 ? "" : "");
this.service_arr[0]["num"] = service_data.duration;
this.service_arr[0]["isMg"] = data.openness == 3;
this.service_arr[0]["data"] = JSON.parse(data.res_fields);
console.log(this.service_arr[0]["data"]);
......@@ -377,7 +381,7 @@ export default {
this.service_arr[l]["count"] = e.duration*parseFloat(e.application.price)+'金币';
this.service_arr[l]["isMg"] = false;
this.service_arr[l]["isapp"] = true;
temp_cost = temp_cost + e.duration*parseFloat(e.application.price)
temp_cost = this.floatAdd(temp_cost, e.duration*parseFloat(e.application.price))
} else {
//服务
this.service_arr[l]["img"] = e.service.cover;
......@@ -390,21 +394,30 @@ export default {
},
];
this.service_arr[l]["auth"] = e.service.organization_name;
this.service_arr[l]["size"] = "规格:";
e.service.request_spcs_info.forEach((el) => {
this.service_arr[l]["size"] = "";
this.service_arr[l]["count"] = "";
let spcs_type_1 = e.service.request_spcs_info.spcs_type_1 || [];
let spcs_type_2 = e.service.request_spcs_info.spcs_type_2 || [];
spcs_type_1.forEach((el,ind) => {
if (e.spec_id == el.id) {
this.service_arr[l]["size"] = `时长收费:${el.money}金币/${el.spcs_count}次 * ${e.duration}`;
this.service_arr[l]["num"] = "不限时长";
this.service_arr[l]["count"] = e.duration*el.money+'金币';
temp_cost = this.floatAdd(temp_cost, e.duration*el.money);
}
});
spcs_type_2.forEach((el,ind) => {
if (e.spec_id == el.id) {
this.service_arr[l]["size"] =
this.service_arr[l]["size"] +
"访问次数:" +
el.count +
",访问量:" +
el.pv +
",";
this.service_arr[l]["size"] = `应用镜像部署权限:${el.money}金币/${el.duration_unit == 1 ? "" : ""}`;
this.service_arr[l]["num"] = e.duration;
this.service_arr[l]["count"] = e.duration*el.money+'金币';
temp_cost = this.floatAdd(temp_cost, e.duration*el.money);
}
});
this.service_arr[l]["applytype"] =
"申请方式:" + (e.duration_method == 1 ? "" : "");
this.service_arr[l]["num"] = e.duration;
this.service_arr[l]["isMg"] = e.service.openness == 3;
this.service_arr[l]["data"] = e.service.res_fields
? JSON.parse(e.service.res_fields)
......@@ -418,7 +431,39 @@ export default {
})
.catch((response) => {});
},
floatAdd(arg1, arg2) {
let r1, r2, m, c;
try {
r1 = arg1.toString().split(".")[1].length;
} catch (e) {
r1 = 0;
}
try {
r2 = arg2.toString().split(".")[1].length;
} catch (e) {
r2 = 0;
}
c = Math.abs(r1 - r2);
m = Math.pow(10, Math.max(r1, r2));
if (c > 0) {
let cm = Math.pow(10, c);
if (r1 > r2) {
arg1 = Number(arg1.toString().replace(".", ""));
arg2 = Number(arg2.toString().replace(".", "")) * cm;
} else {
arg1 = Number(arg1.toString().replace(".", "")) * cm;
arg2 = Number(arg2.toString().replace(".", ""));
}
} else {
arg1 = Number(arg1.toString().replace(".", ""));
arg2 = Number(arg2.toString().replace(".", ""));
}
return (arg1 + arg2) / m;
},
}
};
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment