$(document).ready(function () { let url = window.location.search; var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for (var i = 0; i < strs.length; i++) { theRequest[strs[i].split("=")[0]] = unescape( decodeURI(strs[i].split("=")[1]) ); } } let index = 0; let payType = 0; let payTypea = 0; let payTypeb = 0; let array = []; let htmlArray = ['#ZFBQX', '#ZFBZB', '#ZFBKS', '#ZFBYY']; $.ajax({ type: "post", url: "https://api.9169kkxstzsjkdd222.app/Admin/Adminbackoneeight/select_td_list", dataType: "json", data: {}, success: function (res) { console.log(res); console.log(res.data) array = [res.data[0].num, res.data[1].num, res.data[2].num]; for (let i = 0; i < array.length; i++) { console.log(array[i]) console.log(htmlArray[array[i]]); $(`#HoutaiContainerBottomAppleListHeader${(i + 1)}`).find(htmlArray[array[i] - 1] + (i + 1)).attr('checked', true); } } }); $('.HoutaiContainerBottomAppleListHeaderQR').on('click', function () { index = $(this).parent().index(); let arr = [payTypea, payTypeb, 4]; payType = arr[index]; console.log(index); console.log(payType); index += 1; payType += 1; $.ajax({ type: "post", url: "https://api.9169kkxstzsjkdd222.app/Admin/Adminbackoneeight/save_td", dataType: "json", data: { id: index, td_id: payType }, success: function (res) { console.log(res); alert('修改成功'); } }); }) $('.paySelectTypeContent').on('click', function () { index = $(this).parent().parent().index(); console.log(index); let arr = [0, 1, 2, 3]; if (index == 0) { payTypea = arr[$(this).index()]; } else if (index == 1) { payTypeb = arr[$(this).index()]; } else { payType = 4; } }) });