You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
406 lines
13 KiB
406 lines
13 KiB
let query = {}; //URL参数
|
|
let scr = $(location).prop('href').split("?")[1];
|
|
Array.prototype.myForEach = function myForEach(callback, context) {
|
|
context = context || window;
|
|
if (Array.prototype.forEach) {
|
|
// 调用forEach方法,不做任何处理
|
|
this.forEach(callback, context);
|
|
return;
|
|
}
|
|
}
|
|
if (scr) {
|
|
scr = scr.split("&").join("=").split("=")
|
|
scr.myForEach(function(item, index, arr) {
|
|
if (index % 2 === 0) {
|
|
query[item] = ""
|
|
} else {
|
|
query[scr[index - 1]] = item
|
|
}
|
|
});
|
|
}
|
|
// query.islicode = decodeURI(query.islicode);
|
|
query.username = decodeURI(query.username);
|
|
let newOrderisli = null;
|
|
let source_data = []; // 资源集
|
|
let source_data2 = []; // 资源集2
|
|
let target_data = []; // 单资源
|
|
let title_Name = null; //标的名称
|
|
let type_status = null; //判断状态
|
|
let disable = true
|
|
let listQuery = {
|
|
pay_type: 1, // 付费类型
|
|
// source_type: 8, // 资源类型
|
|
goods_islicode: query.list_isli, // 委托数据isli标识码
|
|
};
|
|
let listQuerys = {
|
|
goods_isli: query.list_isli, // 委托数据委托关联编码
|
|
use_years: 99, // 购买使用年限
|
|
user_isli: cookieHandler.get("isliCode"), // 用户isli编码
|
|
}
|
|
|
|
let new_total = null;
|
|
|
|
function entrust(data) {
|
|
if (data == "1") {
|
|
return "转让"
|
|
} else if (data == "2") {
|
|
return "授权"
|
|
} else {
|
|
return ""
|
|
}
|
|
};
|
|
|
|
function chargesType(data) {
|
|
if (data == "1") {
|
|
return "免费"
|
|
} else if (data == "2") {
|
|
return "付费"
|
|
} else {
|
|
return ""
|
|
}
|
|
};
|
|
|
|
function period(data) {
|
|
if (data == "1") {
|
|
return "永久性委托"
|
|
} else if (data == "2") {
|
|
return "一次性委托"
|
|
} else if (data == "3") {
|
|
return "阶段性委托"
|
|
} else {
|
|
return ""
|
|
}
|
|
};
|
|
|
|
function goodsType(data) {
|
|
if (data == "1") {
|
|
return "文化资源数据"
|
|
} else if (data == "2") {
|
|
return "文化数字内容"
|
|
} else {
|
|
return ""
|
|
}
|
|
};
|
|
|
|
|
|
function attestStatus(data) {
|
|
if (data == "0") {
|
|
return "认证中"
|
|
} else if (data == "1") {
|
|
return "认证成功"
|
|
} else if (data == "2") {
|
|
return "认证失败"
|
|
} else {
|
|
return ""
|
|
}
|
|
};
|
|
|
|
function FileSize(data) {
|
|
if (data === 0) {
|
|
return "0 B";
|
|
}
|
|
var k = 1024;
|
|
var sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
|
|
i = Math.floor(Math.log(data) / Math.log(k));
|
|
return (data / Math.pow(k, i)).toPrecision(3) + " " + sizes[i];
|
|
};
|
|
|
|
// AgencyAddress + 'order/queryRrder',
|
|
// 委托数据查询接口
|
|
// function searchGoods(data) {
|
|
// let postList = new AJAX_OBJ(AgencyAddress + "order/searchGoods", successGood, onUrlError);
|
|
// postList.postRequestData();
|
|
// }
|
|
|
|
//委托数据查询接口
|
|
function getUserName(UserName) {
|
|
let data = {
|
|
entrust_user_name: UserName,
|
|
goods_status: 1
|
|
};
|
|
var ajaxSearchUserName = new AJAX_OBJ(AgencyAddress + "order/searchGoods", entrustSearchUserName, onUrlError);
|
|
ajaxSearchUserName.postRequestData(JSON.stringify(data));
|
|
}
|
|
function entrustSearchUserName(xmlHttp) {
|
|
var res = eval('(' + xmlHttp.responseText + ')');
|
|
if (res.resultCode === "00000000") {
|
|
new_total = res.data.total;
|
|
searchGoods(listQuery);//委托数据详情接口
|
|
}
|
|
}
|
|
|
|
|
|
|
|
let Client_date = {
|
|
entrustingPartyName: "", //委托方名称
|
|
identityCode: "", //身份认证编码
|
|
entrustSignNumber: 0, //委托标的数
|
|
orderNumber: 1 //订单总数
|
|
}
|
|
// 委托数据查询接口
|
|
function searchGoods(data) {
|
|
let postList = new AJAX_OBJ(AgencyAddress + "order/searchGoods", successGood, onUrlError);
|
|
postList.postRequestData(JSON.stringify(data));
|
|
|
|
function successGood(xmlHttp) {
|
|
let res = eval('(' + xmlHttp.responseText + ')');
|
|
if (res.resultCode === "00000000") {
|
|
Client_date.entrustingPartyName = res.data.data[0].username; //委托方名称
|
|
Client_date.identityCode = res.data.data[0].user_islicode; //身份认证编码
|
|
type_status = res.data.data[0].goods_status;
|
|
title_Name = res.data.data[0].goods_name;
|
|
newOrderisli = res.data.data[0].goods_islicode;
|
|
if (cookieHandler.get("normal_login_token")) {
|
|
if (cookieHandler.get("isliCode") == "undefined" || cookieHandler.get("isliCode") == undefined ||
|
|
cookieHandler.get("isliCode") == "" || cookieHandler.get("isliCode") == null) {
|
|
$(".pingCart").hide(); //隐藏div
|
|
} else {
|
|
searchOrder();
|
|
$(".pingCart").show(); //显示div
|
|
if (res.data.data[0].username != "北京玖扬博文文化发展有限公司") {
|
|
$("#addCart").show(); //显示div
|
|
$("#employ").show(); //显示div
|
|
} else {
|
|
$("#employ").hide(); //显示div
|
|
$("#addCart").css("margin-right", "168px");
|
|
$("#addCart").show(); //显示div
|
|
}
|
|
}
|
|
}
|
|
$(".center_left").html(res.data.data[0].goods_image ? good_img(res.data.data[0].goods_image) :
|
|
'<img class="img_url" src=' + query.img + ' alt="暂无图片">')
|
|
$(".content")[0].innerText = res.data.data[0].goods_name
|
|
$(".content")[1].innerText = res.data.data[0].goods_islicode
|
|
$(".content")[2].innerText = goodsType(res.data.data[0].goods_type)
|
|
$(".content")[3].innerText = entrust(res.data.data[0].goods_entrust)
|
|
$(".content")[4].innerText = res.data.data[0].goods_ownership_str
|
|
// $(".content")[5].innerText = res.data.data[0].goods_exceptions
|
|
$(".content")[6].innerText = period(res.data.data[0].contractual_period)
|
|
$(".content")[7].innerText = chargesType(res.data.data[0].charges_type)
|
|
// $(".content")[8].innerText = "¥" + res.data.data[0].earnest_money
|
|
$(".content")[8].innerText = "¥" + res.data.data[0].price
|
|
$(".content_two")[0].innerText = res.data.data[0].user.name
|
|
$(".content_two").attr("title", res.data.data[0].user.name);
|
|
// $(".content_two")[1].innerText = res.data.data[0].user.registerTime
|
|
$(".content_two")[1].innerText = res.data.data[0].user.userType
|
|
$(".content_two")[2].innerText = new_total
|
|
$(".content1_two")[0].innerText = res.data.data[0].user.islicode
|
|
// $(".content1_two")[1].innerText = res.data.data[0].user.authTime
|
|
$(".content1_two")[1].innerText = attestStatus(res.data.data[0].user.state)
|
|
$(".content1_two")[2].innerText = '进入店铺';
|
|
searchGoodsdel(res.data.data[0].source, res.data.data[0].user_islicode)
|
|
} else {
|
|
Dreamer.error(res.resultMsg);
|
|
}
|
|
};
|
|
};
|
|
|
|
//进入店铺详情
|
|
function store_Detil() {
|
|
setTimeout(function() {
|
|
$(location).prop('href', './Store_details.html?username=' + query.username + '&time=' + new Date()
|
|
.getTime());
|
|
}, 1000)
|
|
}
|
|
|
|
// 委托数据查询资源
|
|
function searchGoodsdel(data, user_islicode) {
|
|
data.myForEach(function(item, index, arr) {
|
|
if (item.target_data) {
|
|
if (source_data2.indexOf(JSON.parse(item.source_data).isliCode) == -1) {
|
|
source_data2.push(JSON.parse(item.source_data).isliCode);
|
|
source_data.push([]);
|
|
}
|
|
source_data[source_data2.indexOf(JSON.parse(item.source_data).isliCode)].push(item);
|
|
} else {
|
|
target_data.push(JSON.parse(item.source_data))
|
|
}
|
|
});
|
|
if (source_data.length > 0) {
|
|
let str2 = "";
|
|
source_data.myForEach(function(item, index, arr) {
|
|
str2 += '<tr><td class="text-center1"><span>' + JSON.parse(item[0].source_data).titleName +
|
|
'</span></td><td class="text-center1"><span>' + JSON.parse(item[0].source_data).classification +
|
|
'</span></td><td class="text-center1"><span>' + JSON.parse(item[0].source_data).releaseTime
|
|
.split(" ")[0] +
|
|
'</span></td><td class="text-center1"><span>' + JSON.parse(item[0].source_data).isliCode +
|
|
'</span></td><td class="text-center1"><span>' + item.length +
|
|
'</span></td><td class="text-center1"><span class="details ' + index +
|
|
'">详情</span></td></tr>'
|
|
$("#text-body").html(str2);
|
|
});
|
|
} else {
|
|
$("#three1").hide()
|
|
}
|
|
$(".details").bind("click", function(data) {
|
|
localStorage.setItem("data", JSON.stringify(source_data[data.currentTarget.className.split(" ")[1]]));
|
|
$(location).prop('href', './collectionDetails.html?islicode=' + query.list_isli + '&goods_type=' + query
|
|
.goods_type + '&user_islicode=' + user_islicode + '&title_Name=' + title_Name +
|
|
'&type_status=' + type_status + '&entrustingPartyName=' + Client_date.entrustingPartyName +
|
|
'&identityCode=' + Client_date.identityCode + '&time=' + new Date().getTime())
|
|
});
|
|
if (target_data.length > 0) {
|
|
let str = "";
|
|
target_data.myForEach(function(item, index, arr) {
|
|
str += '<tr><td class="text-center1"><span>' + item.titleName +
|
|
'</span></td><td class="text-center1"><span>' + item.isliCode +
|
|
'</span></td><td class="text-center1"><span>' + FileSize(item.metadataFileSize) +
|
|
'</span></td><td class="text-center1"><span>' + item.metadataFileFormat +
|
|
'</span></td><td class="text-center1"><span>' + item.releaseTime.split(" ")[0] +
|
|
'</span></td></tr>'
|
|
$("#text-bodys").html(str);
|
|
});
|
|
} else {
|
|
$("#three2").hide()
|
|
}
|
|
};
|
|
// 函数节流
|
|
function debounce(fn) {
|
|
var timerId = null
|
|
return function() {
|
|
var arg = arguments[0] //获取事件
|
|
if (timerId) {
|
|
return
|
|
}
|
|
timerId = setTimeout(function() {
|
|
fn(arg) //事件传入函数
|
|
timerId = null
|
|
}, 1000)
|
|
}
|
|
}
|
|
|
|
function addCart() {
|
|
if (cookieHandler.get("normal_login_token")) {
|
|
if (cookieHandler.get("isliCode")) {
|
|
if (cookieHandler.get("userType") === "0") {
|
|
Dreamer.error("个人认证账号不能加入购物车!");
|
|
} else {
|
|
let postList = new AJAX_OBJ(AgencyAddress + "order/addShoppingCa?goods_isli=" + listQuerys.goods_isli +
|
|
"&user_isli=" + listQuerys.user_isli + "&use_years=" + listQuerys.use_years, successGood,
|
|
onUrlError);
|
|
postList.postRequestData();
|
|
|
|
function successGood(xmlHttp) {
|
|
let res = eval('(' + xmlHttp.responseText + ')');
|
|
if (res.resultCode === "00000000") {
|
|
Dreamer.success("添加购物车成功");
|
|
$("#addCart").text("已加入购物车")
|
|
} else {
|
|
Dreamer.error(res.resultMsg);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
Dreamer.error("账号未认证,请进行认证!");
|
|
setTimeout(function() {
|
|
window.location.href = 'MyCetification.html?time=' + new Date().getTime();
|
|
}, 1000);
|
|
}
|
|
} else {
|
|
Dreamer.error("请先登录");
|
|
setTimeout(function() {
|
|
window.location.href = 'login.html?time=' + new Date().getTime();
|
|
}, 1000);
|
|
}
|
|
}
|
|
|
|
function employ() {
|
|
if (cookieHandler.get("normal_login_token")) {
|
|
if (cookieHandler.get("isliCode")) {
|
|
if (cookieHandler.get("userType") === "0") {
|
|
Dreamer.error("个人认证账号不能申请使用!");
|
|
} else {
|
|
if (type_status == 1 || type_status == 5) {
|
|
if (disable) {
|
|
disable = false
|
|
$(".pingCart > div:nth-child(2)").css("background-color", "#5a1d1d")
|
|
var closeMsg = Dreamer.loading("正在申请使用,请稍等!");
|
|
let postList = new AJAX_OBJ(AgencyAddress + "order/createOrder?goods_isli=" + listQuerys
|
|
.goods_isli + "&is_car=2&user_isli=" + listQuerys.user_isli + "&use_years=" + listQuerys
|
|
.use_years, successGood, onUrlError);
|
|
postList.postRequestData();
|
|
|
|
function successGood(xmlHttp) {
|
|
let res = eval('(' + xmlHttp.responseText + ')');
|
|
if (res.resultCode === "00000000") {
|
|
addClient(Client_date);
|
|
setTimeout(function() {
|
|
$(location).prop('href', './BuyOrder.html?url=' + new Date().getTime());
|
|
}, 3000)
|
|
} else {
|
|
disable = true
|
|
closeMsg();
|
|
Dreamer.error(res.resultMsg);
|
|
$(".pingCart > div:nth-child(2)").css("background-color", "#842911")
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (type_status == 5) {
|
|
Dreamer.warning(title_Name + "正在委托中,无法购买");
|
|
} else {
|
|
Dreamer.warning(title_Name + "无法购买");
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
Dreamer.error("账号未认证,请进行认证!");
|
|
setTimeout(function() {
|
|
window.location.href = 'MyCetification.html?time=' + new Date().getTime();
|
|
}, 1000);
|
|
}
|
|
} else {
|
|
Dreamer.error("请先登录");
|
|
setTimeout(function() {
|
|
window.location.href = 'login.html?time=' + new Date().getTime();
|
|
}, 1000);
|
|
}
|
|
}
|
|
// 初始化
|
|
$(document).ready(function() {
|
|
// $("#addCart").hide(); //隐藏div
|
|
// $("#employ").hide(); //隐藏div
|
|
$(".pingCart").hide(); //隐藏div
|
|
$("#resourceSet").text(query.goods_type == "1" ? "文化资源数据集" : "文化数字内容集")
|
|
$("#resourceName").text(query.goods_type == "1" ? "文化资源数据集名称" : "文化数字内容集名称")
|
|
$("#singleResource").text(query.goods_type == "1" ? "文化资源数据" : "文化数字内容")
|
|
getUserName(query.username);
|
|
//点击量
|
|
addClickPageView(query.list_isli);
|
|
$("#addCart").click(debounce(addCart))
|
|
$("#employ").click(debounce(employ))
|
|
})
|
|
|
|
function searchOrder() {
|
|
let data = {
|
|
user_isli: cookieHandler.get("isliCode"),
|
|
user_role: '1',
|
|
order_status: ""
|
|
}
|
|
let OrderList = new AJAX_OBJ(AgencyAddress + 'order/queryRrder?user_isli=' + data.user_isli + '&user_role=' + data
|
|
.user_role + '&order_status=' + data.order_status, succesOrder, onUrlError);
|
|
OrderList.postRequestData();
|
|
}
|
|
|
|
function succesOrder(xmlHttp) {
|
|
let res = eval('(' + xmlHttp.responseText + ')');
|
|
if (res.resultCode === "00000000") {
|
|
for (i = 0; i < res.data.length; i++) {
|
|
for (j = 0; j < res.data[i].order_detail.length; j++) {
|
|
if (res.data[i].order_detail[j].goods_islicode == query.list_isli) {
|
|
if (cookieHandler.get("userType") === "1" || cookieHandler.get("userType") === "2") {
|
|
$("#addCart").hide(); //隐藏div
|
|
$('#employ').css({
|
|
"pointer-events": "none",
|
|
"background-color": "#AAAAAA"
|
|
});
|
|
$("#employ").text("已申请");
|
|
} else {
|
|
$(".pingCart").hide(); //隐藏div
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|