123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- mui.ready(function() {
- mui.plusReady(function() {
- var userid = plus.storage.getItem('userid');
- var ws = plus.webview.currentWebview();
- console.log(ws.reFlag)
- var oDt = document.getElementsByClassName("frmtype");
- var service = document.getElementsByClassName("textareabox");
- function personalMessage() {
- mui.ajax(baseUrl + "/ajax/resource/" + ws.rsId, {
- dataType: 'json',
- type: 'GET',
- timeout: 10000,
- success: function(data) {
- plus.nativeUI.closeWaiting();
- ws.show("slide-in-right", 150);
- var $data = data.data;
-
- oDt[0].value = $data.resourceName;
- service[0].innerText = $data.supportedServices
- },
- error: function() {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- return;
- }
- });
- }
- function trim(str) {
- return str.replace(/(^\s*)|(\s*$)/g, "");
- }
- oDt[0].addEventListener("blur", function() {
- var length = trim(oDt[0].value);
- if(!length)
- plus.nativeUI.toast("资源名称不能为空");
- });
- service[0].addEventListener("blur", function() {
- var length = trim(service[0].value);
- if(!length)
- plus.nativeUI.toast("应用用途不能为空");
- });
- function savePro() {
- var $data = {};
- $data.resourceName = oDt[0].value;
- $data.supportedServices = service[0].value;
- if(ws.rsId) {
- $data.resourceId = ws.rsId;
- mui.ajax(baseUrl + "/ajax/resource/nameAndSupport", {
- "type": "post",
- "async": true,
- "data": $data,
- "error": function(type, xhr, errorThrown) {
- console.log(JSON.stringify(type));
- console.log(JSON.stringify(xhr));
- console.log(JSON.stringify(errorThrown));
- },
- "success": function(data) {
- var y = JSON.stringify(data)
- if(data.success) {
- plus.nativeUI.showWaiting();
- var web = plus.webview.getWebviewById("resinforupdate.html");
- mui.fire(web, "resourceMess");
- mui.back();
- if(ws.reFlag == 0) {
- var web1 = plus.webview.getWebviewById("html/proinforupdate.html");
- mui.fire(web1, "newId", {
- rd: 1
- });
- } else if(ws.reFlag == 1) {
- var web2 = plus.webview.getWebviewById("html/companyUpdata.html");
- mui.fire(web2, "newId", {
- rd: 1
- });
- } else if(ws.reFlag == 2) {
- var web2 = plus.webview.getWebviewById("html/studentUpdata.html");
- mui.fire(web2, "newId", {
- rd: 1
- });
- }
- } else {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- return;
- }
- }
- });
- } else {
- $data.professorId = userid;
- mui.ajax(baseUrl + "/ajax/resource", {
- "type": "post",
- "async": true,
- "data": $data,
- "success": function(data) {
- var y = JSON.stringify(data)
- if(data.success) {
- var id = data.data;
- plus.nativeUI.showWaiting();
- if(ws.reFlag == 0) {
- var web2 = plus.webview.getWebviewById("html/proinforupdate.html");
- mui.fire(web2, "newId", {
- rd: 1
- });
- } else if(ws.reFlag == 1) {
- var web2 = plus.webview.getWebviewById("html/companyUpdata.html");
- mui.fire(web2, "newId", {
- rd: 1
- });
- } else if(ws.reFlag == 2) {
- var web2 = plus.webview.getWebviewById("html/studentUpdata.html");
- mui.fire(web2, "newId", {
- rd: 1
- });
- }
- var web = plus.webview.create("../html/resinforupdate.html", "resinforupdate.html", {}, {
- resourceId: id,
- reFlag: ws.reFlag
- });
- web.addEventListener("loaded", function() {}, false);
- } else {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- return;
- }
- }
- });
- }
- }
- if(ws.rsId) {
- personalMessage()
- }
- document.getElementsByClassName("topsave")[0].addEventListener("click", function() {
- var length1 = trim(oDt[0].value);
- var length2 = trim(service[0].value);
- if(length1 && length2) {
- savePro();
- } else if(!length1 && length2) {
- plus.nativeUI.toast("资源名称不能为空");
- } else if(length1 && !length2) {
- plus.nativeUI.toast("应用用途不能为空");
- } else if(!length1 && !length2) {
- plus.nativeUI.toast("资源名称不能为空&&应用用途不能为空");
- }
- });
- });
- })
|