// //截取url中的参数 // function GetQueryString(name) { // var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); // var r = window.location.search.substr(1).match(reg); // if (r != null) return unescape(r[2]); // return null // } // // 传递userId // if (GetQueryString("list_isli") != null && GetQueryString("list_isli").toString().length > 1) { // var list_isli = GetQueryString("list_isli"); // } // if (GetQueryString("goods_type") != null && GetQueryString("goods_type").toString().length >= 1) { // var goods_type = GetQueryString("goods_type"); // } // //单价 // if (GetQueryString("pricets") != null && GetQueryString("pricets").toString().length > 1) { // var pricets = GetQueryString("pricets"); // } // //判断是否是转让还是授权 // if (GetQueryString("ears_of") != null && GetQueryString("ears_of").toString().length > 1) { // var ears_of = GetQueryString("ears_of"); // } 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.title_Name = decodeURI(query.title_Name); query.NewuserName = decodeURI(query.NewuserName); let purchase = {}; //加入购物车,立即购买的参数 let data = JSON.parse(localStorage.getItem("data")); let sourceData = JSON.parse(data[0].source_data); let targetData = [] let tableType = [] let new_linkcode = []; data.myForEach(function (item, index, arr) { if (tableType.indexOf(JSON.parse(item.target_data).entityName) == -1) { tableType.push(JSON.parse(item.target_data).entityName); targetData.push([]); new_linkcode.push([]); } targetData[tableType.indexOf(JSON.parse(item.target_data).entityName)].push(JSON.parse(item.target_data)); new_linkcode[tableType.indexOf(JSON.parse(item.target_data).entityName)].push(item.linkcode); }); let user_isli = null; //过滤 function collection(data) { if (data == "1") { return "完好"; } else if (data == "2") { return "残破"; } else if (data == "3") { return "残缺"; } else if (data == "4") { return "霉变"; } else if (data == "5") { return "皱褶"; } else if (data == "6") { return "污渍"; } else if (data == "7") { return "脱浆"; } else if (data == "8") { return "脱线"; } else if (data == "9") { return "生锈"; } else if (data == "10") { return "褪色"; } else if (data == "11") { return "焦脆"; } else { return data } }; function carrier(data) { if (data == "1") { return "纸张"; } else if (data == "2") { return "感光材料"; } else if (data == "3") { return "磁带"; } else if (data == "4") { return "光盘"; } else if (data == "5") { return "移动终端"; } else if (data == "6") { return "计算机"; } else if (data == "7") { return "数字化数据"; } else if (data == "8") { return "天然载体"; } else if (data == "9") { return "器具载体"; } else if (data == "10") { return "其它载体"; } else { return data } }; function edition(data) { if (data == "1") { return "真迹"; } else if (data == "2") { return "抄本"; } else if (data == "3") { return "拓本"; } else if (data == "4") { return "临摹"; } else if (data == "5") { return "复制"; } else if (data == "6") { return "复原"; } else if (data == "7") { return "重建"; } else if (data == "8") { return "原始录音"; } else if (data == "9") { return "原始视频"; } else if (data == "10") { return "刻录"; } else if (data == "11") { return "原创"; } else { return data } }; function isbaseId(data) { if (data) { let list = data.split(";"); let str = ""; list.myForEach(function (v, index, arr) { if (v == "1") { str += "标本库;"; } else if (v == "2") { str += "基因库;"; } else if (v == "3") { str += "素材库;"; } }); if (str) { return str.substr(0, str.length - 1); } else { return data; } } else { return ""; } }; function filter(data) { if (data) { return data; } 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]; }; // 初始化 $(document).ready(function () { user_isli = cookieHandler.get("isliCode"); $(".ipt").val(""); //输入年限 $("#addprice").html(0); //计算价格 $(".Shopcart").hide();//隐藏div $(".shopyear").hide();//隐藏div $(".talprice").hide();//隐藏div $(".purchase").hide();//隐藏div if (query.NewuserName != "中国数字文化集团有限公司" && query.NewuserName != "国家图书馆出版社有限公司" && query.NewuserName != "深圳国夏文化数字科技有限公司") { $(".Shopcart").show();//显示div $(".shopyear").show();//显示div $(".talprice").show();//显示div $(".purchase").show();//显示div } else { $(".Shopcart").css("margin-left", "1200px"); $(".Shopcart").show();//显示div } $(".coll-title").text("名称:" + filter(sourceData.titleName)) $(".coll-item")[0].innerText = "其他标识符:" + filter(sourceData.otherIdentifiers) $(".coll-item")[1].innerText = "标识符:" + filter(sourceData.isliCode) $(".coll-item")[2].innerText = "类型:" + filter(sourceData.collectionType) $(".coll-item")[3].innerText = "服务类型:" + filter(sourceData.serviceType) $(".coll-item")[4].innerText = "分类:" + filter(sourceData.classification) $(".coll-item")[5].innerText = "贡献者:" + filter(sourceData.contributors) $(".coll-item")[6].innerText = "著作权人:" + filter(sourceData.copyrightOwner) $(".coll-item")[7].innerText = "载体:" + filter(carrier(sourceData.carrier)) $(".coll-item")[8].innerText = "登记者:" + filter(sourceData.registrant) $(".coll-item")[9].innerText = "登记日期:" + filter(sourceData.registerDate) $(".coll-item")[10].innerText = "所属/收藏机构:" + filter(sourceData.repositoryName) $(".coll-item")[11].innerText = "尺寸:" + filter(sourceData.dimensions) $(".coll-item")[12].innerText = "组件数量:" + filter(sourceData.quantity) $(".coll-item")[13].innerText = "标签:" + filter(sourceData.label) $(".coll-item")[14].innerText = "描述:" + filter(sourceData.description) $(".coll-item")[15].innerText = "哈希值:" + filter(sourceData.md5Val) $(".coll-item")[16].innerText = "入库标识:" + filter(isbaseId(sourceData.databaseId)) $(".coll-item")[17].innerText = "版本:" + filter(edition(sourceData.edition)) $(".coll-item")[18].innerText = "现况:" + filter(collection(sourceData.collectionCondition)) $(".coll-item")[19].innerText = "封面:" + filter(sourceData.cover) $(".title").text(query.goods_type == "1" ? "文化资源数据" : "文化数字内容") $(".title2").text(query.goods_type == "1" ? "文化资源数据-关联资源" : "文化数字内容-关联资源") let str = ""; targetData.myForEach(function (item, id, arr) { str += '
' + tableType[id] + '
' item.myForEach(function (i, index, arr) { str += '' }) str += '
资源名称ISLI标志码ISLI关联编码大小格式时间
' + i.titleName + '' + i.isliCode + '' + new_linkcode[id][index] + // '' + query.user_islicode + '' + FileSize(i.metadataFileSize) + '' + i.metadataFileFormat + '' + i.registerDate.split(" ")[0].split("-").join("-") + '
' }); $("#resources").html(str); transfer(query.ears_of); }) //判断数据是否是转让的 function transfer(pass_Num) { if (pass_Num == "1") { $(".shopyear").hide() // let shopRice = Math.floor(parseFloat(query.pricets * 100 * 99)) / 100; $("#addprice").html(query.pricets); purchase = { goods_islicode: query.list_isli, use_years: 99, is_car: 2, //1:购物车商品;2:不是购物车商品 } } } let addprice = null; // //输入年限获取价格 $('.ipt').bind('input propertychange', function (e) { addprice = $(".ipt").val(); if (addprice == 0 || addprice == null) { Dreamer.warning("购买年限只能输入整数"); $(".ipt").val(""); } if (addprice) { let shopRice = Math.round(parseFloat(query.pricets * 100 * e.delegateTarget.value)) / 100; $("#addprice").html(shopRice); purchase = { goods_islicode: query.list_isli, use_years: addprice, is_car: 2, //1:购物车商品;2:不是购物车商品 } } else { $("#addprice").html(0); } }); function Shopp_Cart() { if (cookieHandler.get("normal_login_token")) { if (user_isli) { if (cookieHandler.get("userType") === "0") { Dreamer.error("个人认证账号不能加入购物车!"); } else { if (query.ears_of == "2") { if (addprice != null) { $(".Shopcart").attr("disabled", true); shop_goods(); } else { Dreamer.warning("购买年限只能输入整数"); } } if (query.ears_of == "1") { $(".Shopcart").attr("disabled", true); shop_goods(); } if (query.ears_of == "3") { $(".Shopcart").attr("disabled", true); shop_goods(); } } } 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 shop_goods() { if (query.ears_of == "3") { purchase.use_years = 1; purchase.goods_islicode = goods_islicode } var ajaxaddShop = new AJAX_OBJ(AgencyAddress + "order/addShoppingCa?goods_isli=" + purchase.goods_islicode + "&user_isli=" + user_isli + "&use_years=" + purchase.use_years, entrustaddShop, onUrlError); ajaxaddShop.postRequestData(); } function entrustaddShop(xmlHttp) { var res = eval('(' + xmlHttp.responseText + ')'); if (res.resultCode === "00000000") { Dreamer.success("加入购物车成功"); $(".Shopcart").val("已加入购物车"); } else { $(".Shopcart").attr("disabled", false); Dreamer.error(res.resultMsg); } } //点击购物车将数据传到购物车 $(".Shopcart").click(Shopp_Cart); function order() { if (cookieHandler.get("normal_login_token")) { if (user_isli) { if (cookieHandler.get("userType") === "0") { Dreamer.error("个人认证账号不能购买!"); } else { if (query.type_status == 1 || query.type_status == 5) { if (query.ears_of == "2") { if (addprice) { // if ($("#addprice").html() > 20000) { // Dreamer.warning("单次购买金额不能高于2万"); // } else { $(".purchase").attr("disabled", true); Buy_now(); // } } else { Dreamer.warning("请输入购买年限"); } } if (query.ears_of == "1") { // if (query.pricets > 20000) { // Dreamer.warning("单次购买金额不能高于2万"); // } else { $(".purchase").attr("disabled", true); Buy_now(); // } } } else { if (query.type_status == 5) { Dreamer.warning(query.title_Name + "正在委托中,无法购买"); } else { Dreamer.warning(query.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) } } //立即购买 function Buy_now() { var ajaxAddress = new AJAX_OBJ(AgencyAddress + "order/createOrder?goods_isli=" + purchase.goods_islicode + "&is_car=" + purchase.is_car + "&user_isli=" + user_isli + "&use_years=" + purchase.use_years, entrustAddress, onUrlError); ajaxAddress.postRequestData(); } function entrustAddress(xmlHttp) { var res = eval('(' + xmlHttp.responseText + ')'); if (res.resultCode === "00000000") { $(location).prop('href', './payment.html?batchcode=' + res.data.batchcode + '&img=' + img + '&time=' + new Date().getTime()); $(".ipt").val(""); $("#addprice").html(0); } else { $(".purchase").attr("disabled", false); Dreamer.error(res.resultMsg); $(".ipt").val(""); $("#addprice").html(0); } } //点击立即购买,调下单推送接收接口 $(".purchase").click(order);