mui.ready(function() {
mui.plusReady(function() {
var userid = plus.storage.getItem('userid');
var ws = plus.webview.currentWebview();
//查询应用行业
var industryShow = function(data) {
if(data != undefined && data.length != 0) {
var subs = new Array();
if(data.indexOf(',')) {
subs = data.split(',');
} else {
subs[0] = data;
}
if(subs.length > 0) {
var html = [];
for(var i = 0; i < subs.length; i++) {
html.push("
" + subs[i] + "");
};
document.getElementsByClassName("labelshow")[0].innerHTML = html.join('');
}
}
}
function personalMessage() {
mui.ajax(baseUrl + "/ajax/resource/" + ws.rsId, {
dataType: 'json', //数据格式类型
type: 'GET', //http请求类型
timeout: 10000, //超时设置
success: function(data) {
plus.nativeUI.closeWaiting();
ws.show("slide-in-right", 150);
var $data = data.data;
//应用行业
if($data.industry) {
industryShow($data.industry);
}
},
error: function() {
plus.nativeUI.toast("服务器链接超时", toastStyle);
return;
}
});
}
function trim(str) { //删除左右两端的空格
return str.replace(/(^\s*)|(\s*$)/g, "");
}
mui(".labelshow").on("tap", "em", function() {
var val = this.parentNode;
document.getElementsByClassName('labelshow')[0].removeChild(val);
});
document.getElementsByClassName("addlabelbtn")[0].addEventListener("tap", function() {
var addContent = document.getElementsByTagName('input')[0].value;
var content = trim(addContent);
if(content) {
var node = document.createElement("li");
node.innerHTML = content + '';
document.getElementsByClassName("labelshow")[0].appendChild(node);
} else {
plus.nativeUI.toast("添加内容不能为空", toastStyle);
}
});
document.getElementsByClassName("topsave")[0].addEventListener("tap", function() {
var subjects = document.getElementsByTagName("li");
var subjectAll = "";
if(subjects.length > 0) {
for(var i = 0; i < subjects.length; i++) {
subjectAll += subjects[i].innerText;
subjectAll += ',';
};
subjectAll = subjectAll.substring(0, subjectAll.length - 1);
}
console.log(subjectAll);
mui.ajax(baseUrl + '/ajax/resource/industry', {
data: {
"resourceId": ws.rsId,
"industry": subjectAll
},
dataType: 'json', //数据格式类型
async: false,
type: 'POST', //http请求类型
timeout: 10000, //超时设置
success: function(data) {
console.log(JSON.stringify(data));
if(data.success) {
plus.nativeUI.showWaiting();
var web = plus.webview.getWebviewById("resinforupdate.html");
mui.fire(web, "resourceMess");
mui.back();
}
},
error: function() {
plus.nativeUI.toast("服务器链接超时", toastStyle);
return;
}
});
});
personalMessage();
});
})