133 lines
3.6 KiB
JavaScript
133 lines
3.6 KiB
JavaScript
|
|
$(document).ready(function () {
|
|
|
|
loadKolMakeupCheckboxItem();
|
|
loadKolStyleCheckboxItem();
|
|
loadKolFansTypeCheckboxItem();
|
|
|
|
$('#kolNewModal').on('click', function () {
|
|
$('#method').val('add');
|
|
|
|
$('#clientNewModal').modal('toggle');
|
|
});
|
|
});
|
|
|
|
function loadKolFansTypeCheckboxItem() {
|
|
var formData = {
|
|
option_uid: 'fansType'
|
|
}
|
|
|
|
$.ajax({
|
|
url: "/Api/optionItemList",
|
|
type: "post",
|
|
data: formData,
|
|
success: function (data, textStatus, jqXHR) {
|
|
if (data.ret == "yes") {
|
|
var obj = data.optionItems;
|
|
var items = "";
|
|
$.each(obj, function (index, item) {
|
|
items += optionItemHtml(item);
|
|
});
|
|
|
|
items = "<label class=\"d-block\">粉絲輪廓</label>" + items;
|
|
|
|
|
|
$('#kolFansType_div').children().first().html(items);
|
|
|
|
} else {
|
|
alert(data.message);
|
|
|
|
if (data.err_code == "99999") {
|
|
location.href = "/Root/Login";
|
|
}
|
|
}
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
|
}
|
|
});
|
|
}
|
|
|
|
function loadKolStyleCheckboxItem() {
|
|
var formData = {
|
|
option_uid: 'kolStyle'
|
|
}
|
|
|
|
$.ajax({
|
|
url: "/Api/optionItemList",
|
|
type: "post",
|
|
data: formData,
|
|
success: function (data, textStatus, jqXHR) {
|
|
if (data.ret == "yes") {
|
|
var obj = data.optionItems;
|
|
var items = "";
|
|
$.each(obj, function (index, item) {
|
|
items += optionItemHtml(item);
|
|
});
|
|
|
|
items = "<label class=\"d-block\">KOL 類型</label>" + items;
|
|
|
|
|
|
$('#kolStyle_div').children().html(items);
|
|
|
|
} else {
|
|
alert(data.message);
|
|
|
|
if (data.err_code == "99999") {
|
|
location.href = "/Root/Login";
|
|
}
|
|
}
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
|
}
|
|
});
|
|
}
|
|
|
|
function loadKolMakeupCheckboxItem() {
|
|
var formData = {
|
|
option_uid: 'kolMakeup'
|
|
}
|
|
|
|
$.ajax({
|
|
url: "/Api/optionItemList",
|
|
type: "post",
|
|
data: formData,
|
|
success: function (data, textStatus, jqXHR) {
|
|
if (data.ret == "yes") {
|
|
var obj = data.optionItems;
|
|
var items = "";
|
|
$.each(obj, function (index, item) {
|
|
items += optionItemHtml(item);
|
|
});
|
|
|
|
items = "<label class=\"d-block\">成員</label>" + items;
|
|
|
|
|
|
$('#kolMakeup_div').children().html(items);
|
|
|
|
} else {
|
|
alert(data.message);
|
|
|
|
if (data.err_code == "99999") {
|
|
location.href = "/Root/Login";
|
|
}
|
|
}
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
alert('網路或伺服器發生錯誤,請稍後重試!');
|
|
}
|
|
});
|
|
}
|
|
|
|
function optionItemHtml(item) {
|
|
var html = "";
|
|
|
|
html += "<div class=\"custom-control custom-control-inline custom-checkbox\">";
|
|
html += " <input type=\"checkbox\" class=\"custom-control-input\" name=\"kolMakeup[]\" value=\"" + item.optionItem_uid + "\" id=\"" + item.optionItem_uid + "\"> <label class=\"custom-control-label\" for=\"" + item.optionItem_uid + "\">" + item.optionItem_name + "</label>";
|
|
html += "</div>";
|
|
|
|
return html;
|
|
}
|
|
|