| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609 |
- window.cccField = '';
- window.apisMoveDivButton2Timer = '';
- window.apisMoveDivButton2Timer4Custorm = [];
- window.actualFlag = false;
- window.stopFlag = false;
- $(function () {
- initOther();
- });
- /*var dragJob=false;
- $(document).on("mousedown", '.watchlistpreview-top', function (e) {
- dragJob = true;
- });
- document.onmousemove = function (e) {
- if (dragJob) {
- var e = e || window.event;
- var height = $(document.body).height();
- var width = $(window).width();
- var widthJob = $("#watchlistpreview").width();
- var heightJob = $("#watchlistpreview").height();
- var left = e.clientX - widthJob / 2;
- var top = e.clientY - 18 + $(document).scrollTop();
- if (top >= 0 && top < height - heightJob) {
- $("#watchlistpreview").css("top", top);
- }
- if (left >= 0 && left < width - widthJob) {
- $("#watchlistpreview").css("left", left);
- }
- return false;
- }
- };
- $(document).mouseup(function (e) {
- dragJob = false;
- });*/
- /**
- * 初始化其他操作
- */
- function initOther() {
- initOther4Select();
- handleSelectChange($("select#apis-move-select,select#apis-quiet-select"));
- $(".apis-move-div-button1,.apis-quiet-div-button1").click(function () {
- var aa = $(this).attr("slideDiv");
- var display = $('#' + aa);
- if (display.css('display') == 'block') {
- display.slideUp("slow");
- //display.css("display", "none");
- $(this).html('展开');
- } else {
- display.slideDown("slow");
- //display.css("display", "block");
- $(this).html('收起');
- }
- });
- $(".apis-move-div-button2").click(function () {
- var this_ = $(this);
- stopFlag = false;
- if (!actualFlag) {
- var selectedOption = $("select#apis-move-select").find("option:selected");
- var nameEn = selectedOption.attr("nameEn");
- if (nameEn === 'needCustom') {
- $.each($(".needCustomInput"), function (index, obj) {
- var url = $(obj).attr("url");
- var typetype = $(obj).attr("typetype");
- var nameEn2 = $(obj).attr("nameEn");
- var slideDiv = $(this_).attr("slideDiv") + '-' + $(obj).attr("id");
- apisMoveDivButton2Timer4Custorm[index] = setInterval(mainSearch, 3000, url, nameEn2, slideDiv, typetype, "1");
- });
- actualFlag = true;
- } else {
- var url = selectedOption.attr("url");
- var typetype = selectedOption.attr("typetype");
- var slideDiv = $(this).attr("slideDiv");
- apisMoveDivButton2Timer = setInterval(mainSearch, 3000, url, nameEn, slideDiv, typetype, "2");
- actualFlag = true;
- }
- }
- });
- $(".apis-quiet-div-button2").click(function () {
- stopFlag = false;
- var selectedOption = $("select#apis-quiet-select").find("option:selected");
- var url = selectedOption.attr("url");
- var typetype = selectedOption.attr("typetype");
- var nameEn = selectedOption.attr("nameEn");
- var slideDiv = $(this).attr("slideDiv");
- mainSearch(url, nameEn, slideDiv, typetype,"2");
- });
- $(".apis-move-div-button3").click(function () {
- ownClearInterval();
- });
- }
- function ownClearInterval() {
- if (actualFlag) {
- if (apisMoveDivButton2Timer != undefined && apisMoveDivButton2Timer != null) {
- clearInterval(apisMoveDivButton2Timer);
- }
- if (apisMoveDivButton2Timer4Custorm != undefined && apisMoveDivButton2Timer != null) {
- $.each(apisMoveDivButton2Timer4Custorm, function (index, obj) {
- clearInterval(obj);
- });
- }
- //$("#apis-move-content").find("tbody.contentTD").html('');
- //$("#apis-move-content").find("span.contentSPAN").html('');
- actualFlag = false;
- }
- }
- function initOther4Select() {
- $.ajax({
- url: "coin/findApiConfig", //请求的url地址
- dataType: "json", //返回格式为json
- type: "post", //请求方式
- contentType: "application/json;charset=utf-8",
- async: false, //请求是否异步,默认为异步,这也是ajax重要特性
- success: function (data) {
- //请求成功时处理
- if (data != null && $.trim(data) != "" && data.success) {
- data = data.data;
- var quietStr = '';
- var moveStr = '';
- var move2Str = '';
- $.each(data, function (index, obj) {
- if (obj.type2 === 1) {
- if (obj.type === 0) {
- var nameEn = $('#' + obj.nameEn);
- nameEn.attr('nameEn', obj.nameEn);
- nameEn.attr('url', obj.url);
- nameEn.attr('typetype', obj.type);
- nameEn.attr('returnEn', obj.returnEn);
- nameEn.attr('returnCn', obj.returnCn);
- move2Str += obj.nameCn + '|';
- } else {
- moveStr += '<option type="9999" nameEn="' + obj.nameEn + '" url="' + obj.url + '" returnEn="' + obj.returnEn + '" returnCn="' + obj.returnCn + '" value="' + obj.nameEn + '-option">' + obj.nameCn + '</option>';
- }
- } else if (obj.type2 === 2) {
- quietStr += '<option typetype="' + obj.type + '" nameEn="' + obj.nameEn + '" url="' + obj.url + '" returnEn="' + obj.returnEn + '" returnCn="' + obj.returnCn + '" value="' + obj.nameEn + '-option">' + obj.nameCn + '</option>';
- }
- // watchlist
- if (obj.nameEn === 'watchlist'){
- var watchlistTrackCategoryStr = '';
- $.each(obj.trackCategoryList, function (index2, obj2) {
- watchlistTrackCategoryStr += '<option value="' + obj2 + '">' + obj2 + '</option>';
- });
- $("#apis-quiet-div-watchlist-trackCategoryField").append(watchlistTrackCategoryStr);
- }else if (obj.nameEn === 'image'){
- var uploadImageCategoryStr = '';
- $.each(obj.otherAttrList, function (index2, obj2) {
- uploadImageCategoryStr += '<option value="' + obj2.id + '">' + obj2.categoryName + '</option>';
- });
- $("#apis-quiet-div-uploadImgs-categoryField").append(uploadImageCategoryStr);
- $("#apis-quiet-div-image-categoryField").append(uploadImageCategoryStr);
- }
- });
- move2Str = '<option nameEn="needCustom" type="9999">' + move2Str.substring(0, move2Str.length - 1) + '</option>';
- $("select#apis-move-select").html(move2Str + moveStr);
- $("select#apis-quiet-select").html(quietStr);
- $("select#apis-move-select,select#apis-quiet-select").change(function () {
- handleSelectChange($(this));
- stopFlag = true;
- });
- } else {
- //alert(data.message);
- }
- },
- beforeSend: function () {
- },
- complete: function () {
- },
- error: function (data) {
- //请求出错处理
- //alert('error:' + data);
- }
- });
- }
- function handleSelectChange(objj) {
- $.each(objj, function (index, obj) {
- var selectedOption = $(obj).find("option:selected");
- var type = selectedOption.attr("type");
- var nameEn = selectedOption.attr("nameEn");
- if ($(obj).attr("id") === 'apis-move-select') {
- ownClearInterval();
- }
- if (type === '9999') {
- $("#apis-move-content").find("div").slideUp("slow");
- if (nameEn === 'needCustom') {
- $.each($(".needCustomInput"), function (index, ob) {
- var returnEn = $(ob).attr("returnen").split(",");
- var returnCn = $(ob).attr("returncn").split(",");
- var theadStr = '';
- $.each(returnEn, function (index, o) {
- theadStr += '<th returnEn="' + o + '">' + returnCn[index] + '</th>';
- });
- $("#apis-move-content-" + $(ob).attr("id")).find("span.contentSPAN").html('0');
- $("#apis-move-content-" + $(ob).attr("id")).find("tr.contentTH").html(theadStr);
- $("#apis-move-content-" + $(ob).attr("id")).find("tbody.contentTD").html('');
- $("#apis-move-content-" + $(ob).attr("id")).slideDown("slow");
- });
- } else {
- var returnEn = selectedOption.attr("returnen").split(",");
- var returnCn = selectedOption.attr("returncn").split(",");
- var theadStr = '';
- $.each(returnEn, function (index, ob) {
- theadStr += '<th returnEn="' + obj + '">' + returnCn[index] + '</th>';
- });
- $("#apis-move-content-other").find("span.contentSPAN").html('0');
- $("#apis-move-content-other").find("tr.contentTH").html(theadStr);
- $("#apis-move-content-other").find("tbody.contentTD").html('');
- $("#apis-move-content-other").slideDown("slow");
- }
- } else {
- var returnEn = selectedOption.attr("returnen").split(",");
- var returnCn = selectedOption.attr("returncn").split(",");
- var theadStr = '';
- $.each(returnEn, function (index, obj) {
- theadStr += '<th returnEn="' + obj + '">' + returnCn[index] + '</th>';
- });
- if (nameEn === 'watchlist' || nameEn === 'image') {
- theadStr += '<th>操作</th>';
- }
- $(obj).parent("div").next("div").find("span.contentSPAN").html('0');
- $(obj).parent("div").next("div").find("tr.contentTH").html(theadStr);
- $(obj).parent("div").next("div").find("tbody.contentTD").html('');
- $("div[id^=apis-quiet-div-]").css("display", "none");
- $("#apis-quiet-div-" + nameEn).css("display", "block");
- $("#apis-quiet-div-" + nameEn).find("input[id$=pageNo]").val(1);
- $("div[id^=apis-quiet-div-]").find($("button.apis-quiet-div-button3")).unbind("click");
- $("div[id^=apis-quiet-div-]").find($("button.apis-quiet-div-button3")).click(function () {
- stopFlag = false;
- var url = selectedOption.attr("url");
- var typetype = selectedOption.attr("typetype");
- var slideDiv = $(this).attr("slideDiv");
- var pageNoVar = $("#" + $(this).parent().attr("id") + "-pageNo");
- var pageO = $(this).attr("pageO");
- var beforePageNo = $(pageNoVar).val();
- if (pageO === 'prev') {
- if (beforePageNo > 1) {
- $(pageNoVar).val(Number(beforePageNo) - 1);
- }
- } else if (pageO === 'next') {
- if (beforePageNo < Number($("#apis-quiet-div-" + nameEn).find("input[id$=pages]").val())) {
- $(pageNoVar).val(Number(beforePageNo) + 1);
- }
- }
- mainSearch(url, nameEn, slideDiv, typetype, "2");
- });
- // 对输入框、选择框加入对应事件,方便及时筛选查询操作
- $("div[id^=apis-quiet-div-]").find("input[id$=keyword]").unbind("keydown");
- $("#apis-quiet-div-" + nameEn).find("input[id$=keyword]").keydown(function (e) {
- if (e.keyCode == 13) {
- $(".apis-quiet-div-button2").click();
- }
- });
- $("div[id^=apis-quiet-div-]").find("select").unbind("change");
- $("#apis-quiet-div-" + nameEn).find("select").change(function (e) {
- $(".apis-quiet-div-button2").click();
- });
- }
- });
- $(objj).parent("div").next("div").find(".contentTH").find("th").dblclick(function () {
- cccField = $(this).attr("returnEn");
- });
- }
- /**
- * 多条件搜索
- * @param pageNo
- */
- function mainSearch(url, nameEn, slideDiv, typetype, needCustomFlag) {
- var jsonData = {};
- jsonData.url = url;
- jsonData.nameEn = nameEn;
- if (nameEn === 'currentPlan' || nameEn === 'orderMarginCoinCurrent') {
- jsonData.chaRateSort = $("#chaRateSort").val();
- } else if (nameEn === 'monitorCurrency') {
- jsonData.changeUtcSort = $("#changeUtcSort").val();
- } else if (nameEn === 'allPositionv2') {
- jsonData.unrealizedPLSort = $("#unrealizedPLSort").val();
- } else if (nameEn === 'orderHistoryProductType') {
- jsonData.pageNo = $("#apis-quiet-div-orderHistoryProductType-pageNo").val();
- jsonData.pageSize = $("#apis-quiet-div-orderHistoryProductType-pageSize").val();
- jsonData.keyword = $("#apis-quiet-div-orderHistoryProductType-keyword").val();
- jsonData.sortField = $("#apis-quiet-div-orderHistoryProductType-sortField").val();
- jsonData.sort = $("#apis-quiet-div-orderHistoryProductType-sort").val();
- jsonData.side = $("#apis-quiet-div-orderHistoryProductType-side").val();
- } else if (nameEn === 'traderList') {
- jsonData.pageNo = $("#apis-quiet-div-traderList-pageNo").val();
- jsonData.pageSize = $("#apis-quiet-div-traderList-pageSize").val();
- jsonData.keyword = $("#apis-quiet-div-traderList-keyword").val();
- jsonData.sortField = $("#apis-quiet-div-traderList-sortField").val();
- jsonData.sort = $("#apis-quiet-div-traderList-sort").val();
- jsonData.canTrace = $("#apis-quiet-div-traderList-canTrace").val();
- } else if (nameEn === 'watchlist') {
- jsonData.pageNo = $("#apis-quiet-div-watchlist-pageNo").val();
- jsonData.pageSize = $("#apis-quiet-div-watchlist-pageSize").val();
- jsonData.keyword = $("#apis-quiet-div-watchlist-keyword").val();
- jsonData.sortField = $("#apis-quiet-div-watchlist-sortField").val();
- jsonData.sort = $("#apis-quiet-div-watchlist-sort").val();
- jsonData.filterField = $("#apis-quiet-div-watchlist-filterField").val();
- jsonData.trackCategoryField = $("#apis-quiet-div-watchlist-trackCategoryField").val();
- } else if (nameEn === 'image') {
- jsonData.pageNo = $("#apis-quiet-div-image-pageNo").val();
- jsonData.pageSize = $("#apis-quiet-div-image-pageSize").val();
- jsonData.keyword = $("#apis-quiet-div-image-keyword").val();
- jsonData.sortField = $("#apis-quiet-div-image-sortField").val();
- jsonData.sort = $("#apis-quiet-div-image-sort").val();
- jsonData.categoryField = $("#apis-quiet-div-image-categoryField").val();
- } else if (nameEn === 'cmcmap') {
- jsonData.pageNo = $("#apis-quiet-div-cmcmap-pageNo").val();
- jsonData.pageSize = $("#apis-quiet-div-cmcmap-pageSize").val();
- jsonData.keyword = $("#apis-quiet-div-cmcmap-keyword").val();
- jsonData.sortField = $("#apis-quiet-div-cmcmap-sortField").val();
- jsonData.sort = $("#apis-quiet-div-cmcmap-sort").val();
- jsonData.filterField = $("#apis-quiet-div-cmcmap-filterField").val();
- }
- $.ajax({
- url: "coin/mainSearch", //请求的url地址
- dataType: "json", //返回格式为json
- data: JSON.stringify(jsonData), //参数值
- type: "post", //请求方式
- contentType: "application/json;charset=utf-8",
- async: true, //请求是否异步,默认为异步,这也是ajax重要特性
- success: function (data) {
- //请求成功时处理
- if (data != null && $.trim(data) != "" && data.success) {
- if (stopFlag) {
- return;
- }
- if (nameEn === 'orderHistoryProductType' || nameEn === 'traderList' || nameEn === 'watchlist' || nameEn === 'image' || nameEn === 'cmcmap') {
- $("#apis-quiet-div-" + nameEn).find("input[id$=pages]").val(data.data.pages);
- $('#' + slideDiv).find("span.contentSPAN").html(data.data.total);
- data = data.data.list;
- } else {
- data = data.data;
- $('#' + slideDiv).find("span.contentSPAN").html(data.length);
- }
- var returnEn = '';
- if (needCustomFlag === '1') {
- returnEn = $("#" + nameEn).attr("returnen").split(",");
- } else {
- var selectedOption = $('option[nameen="' + nameEn + '"]');
- returnEn = selectedOption.attr("returnen").split(",");
- }
- var str = '';
- var title = 'Coin主页|';
- for (var i = 0; i < data.length; i++) {
- var dataDetail = data[i];
- if (nameEn === 'allPositionv2') {
- var bbbField = $(".apis-move-div-input1").val();
- var symbol = dataDetail.symbol;
- if (cccField.length > 0 && bbbField.length > 0 && symbol.indexOf(bbbField) != -1) {
- title += bbbField + '|' + dataDetail[cccField];
- $("title").html(title);
- }
- }
- str += '<tr>';
- $.each(returnEn, function (index, obj) {
- var objStyle = dataDetail.hasOwnProperty(obj + 'Style') ? dataDetail[obj + 'Style'] : '';
- var objContent = dataDetail.hasOwnProperty(obj) ? dataDetail[obj] : '--';
- str += '<td' + objStyle + '>' + objContent + '</td>';
- });
- if (nameEn === 'watchlist') {
- str += '<td style="padding: 0px 10px 0px 10px;">';
- str += '<button class="apis-quiet-div-watchlist-detail" operationType="detail" symbolName="' + dataDetail.symbol + '">详情</button>';
- str += '<button class="apis-quiet-div-watchlist-update" operationType="update" symbolName="' + dataDetail.symbol + '">编辑</button>';
- str += '</td>';
- } else if (nameEn === 'image') {
- str += '<td style="padding: 0px 10px 0px 10px;">';
- str += '<button class="apis-quiet-div-image-delete" operationType="delete" symbolName="' + dataDetail.id + '">删除</button>';
- str += '</td>';
- }
- str += '</tr>';
- }
- if (nameEn === 'watchlist') {
- $(".apis-quiet-div-watchlist-detail").unbind("click");
- $(".apis-quiet-div-watchlist-update").unbind("click");
- $(".watchlistpreview-top-close").unbind("click");
- } else if (nameEn === 'image') {
- $(".apis-quiet-div-image-delete").unbind("click");
- }
- $('#' + slideDiv).find(".contentTD").html(str);
- initContentEvent(nameEn);
- } else {
- //alert(data.message);
- }
- },
- beforeSend: function () {
- if (typetype === '2') {
- $(".quiet-loading").css("display", "block");
- }
- },
- complete: function () {
- if (typetype === '2') {
- $(".quiet-loading").css("display", "none");
- }
- },
- error: function (data) {
- //请求出错处理
- //alert('error:' + data);
- }
- });
- }
- /**
- * 初始化主内容事件
- */
- function initContentEvent(nameEn) {
- if ($(".apis-move-div-input1").val().length === 0) {
- $("title").html('Coin主页');
- }
- if (nameEn === 'watchlist') {
- $(".apis-quiet-div-watchlist-detail,.apis-quiet-div-watchlist-update").click(function () {
- if ($("#watchlistpreview").css("display") === 'none') {
- $("#watchlistpreview").css("display", "block");
- } else if ($("#watchlistpreview").css("display") === 'block') {
- $("#watchlistpreview").css("display", "none");
- }
- $(".watchlistpreview-top-close").click(function () {
- if ($("#watchlistpreview").css("display") === 'none') {
- $("#watchlistpreview").css("display", "block");
- } else if ($("#watchlistpreview").css("display") === 'block') {
- $("#watchlistpreview").css("display", "none");
- }
- $(this).unbind("click");
- $(".watchlistpreview-top-submit").unbind("click");
- });
- $(".watchlistpreview-top-submit").click(function () {
- $.ajax({
- url: "coin/watchlistUpdate", //请求的url地址
- dataType: "json", //返回格式为json
- data: {"symbol": $(".watchlistpreview-content").find(".watchlistpreview-symbol").val(), "remark": $(".watchlistpreview-content").find("textarea").val()}, //参数值
- type: "post", //请求方式
- async: false, //请求是否异步,默认为异步,这也是ajax重要特性
- success: function (data) {
- //请求成功时处理
- if (data != null && $.trim(data) != "" && data.success) {
- $(".watchlistpreview-top-close").click();
- } else {
- console.log("watchlistpreview-top-submit success error," + data);
- }
- },
- beforeSend: function () {
- },
- complete: function () {
- },
- error: function (data) {
- //请求出错处理
- console.log("watchlistpreview-top-submit error," + data);
- }
- });
- });
- var operationType = $(this).attr("operationType");
- if (operationType === 'detail') {
- $(".watchlistpreview-top-submit").css("display", "none");
- } else if (operationType === 'update') {
- $(".watchlistpreview-top-submit").css("display", "block");
- }
- var symbol = $(this).attr("symbolName");
- $.ajax({
- url: "coin/watchlistDetail/" + symbol + "/" + operationType, //请求的url地址
- type: "get", //请求方式
- async: true, //请求是否异步,默认为异步,这也是ajax重要特性
- success: function (data) {
- //请求成功时处理
- if (data != null && $.trim(data) != "" && data.success) {
- data = data.data;
- if (operationType === 'detail') {
- $(".watchlistpreview-content").html(data);
- } else if (operationType === 'update') {
- var update4Text = '<textarea rows="4" cols="50" style="background: antiquewhite;width: 100%;height: 100%;">' + data + '</textarea>';
- update4Text += '<input type="hidden" class="watchlistpreview-symbol" value="' + symbol + '"/>';
- $(".watchlistpreview-content").html(update4Text);
- }
- } else {
- //alert(data.message);
- }
- },
- beforeSend: function () {
- $(".watchlistpreview-content").html("");
- $(".watchlistpreview-loading").css("display", "block");
- },
- complete: function () {
- $(".watchlistpreview-loading").css("display", "none");
- },
- error: function (data) {
- //请求出错处理
- alert('error:' + data);
- }
- });
- });
- } else if (nameEn === 'image') {
- $(".apis-quiet-div-image-delete").click(function () {
- var symbol = $(this).attr("symbolName");
- $.ajax({
- url: "coin/deleteImgs/" + symbol, //请求的url地址
- type: "get", //请求方式
- async: true, //请求是否异步,默认为异步,这也是ajax重要特性
- success: function (data) {
- //请求成功时处理
- if (data != null && $.trim(data) != "" && data.success) {
- $(".apis-quiet-div-button2").click();
- } else {
- alert(data.message);
- }
- },
- beforeSend: function () {
- $(".quiet-loading").css("display", "block");
- },
- complete: function () {
- $(".quiet-loading").css("display", "none");
- },
- error: function (data) {
- //请求出错处理
- alert('error:' + data);
- }
- });
- });
- }
- }
- function uploadImgsSubmit(){
- var fromData = new FormData($("#uploadImgs")[0]);
- $.ajax({
- url: "coin/uploadImgs", //请求的url地址
- dataType: "json", //返回格式为json
- data: fromData, //参数值
- type: "post", //请求方式
- processData: false,// 告诉jQuery不要去处理发送的数据
- contentType: false,// 告诉jQuery不要去设置Content-Type请求头
- async: true, //请求是否异步,默认为异步,这也是ajax重要特性
- success: function (data) {
- $(".uploadImgs-loading").css("display", "none");
- //请求成功时处理
- if (data != null && $.trim(data) != "" && data.success) {
- $("#uploadImgsAlert").html(JSON.stringify(data.data));
- var quietSelectOption = $("#apis-quiet-select option:selected");
- if ($(quietSelectOption).attr("nameen") === 'image') {
- $(".apis-quiet-div-button2").click();
- }
- } else {
- $("#uploadImgsAlert").html(data.message);
- }
- },
- beforeSend: function () {
- $(".uploadImgs-loading").css("display", "block");
- },
- complete: function () {
- },
- error: function (data) {
- //请求出错处理
- console.log("uploadImgs-submit error," + data);
- }
- });
- }
|