123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- mui.ready(function() {
- mui.plusReady(function() {
- var userid = plus.storage.getItem('userid');
- var ws = plus.webview.currentWebview();
- var str = JSON.stringify(ws);
- var oDt = document.getElementsByClassName("frmtype");
- var dataProvince = document.getElementById("data-province");
- var dataAddress = document.getElementById("data-address");
- var oAddress = document.getElementById("addressa")
- var telePhone = document.getElementById("telePhone");
- var mail = document.getElementById("mail");
- var authu = document.getElementsByClassName("authu");
- var authStatus;
- var name;
- var org;
- function personalMessage() {
- mui.ajax(baseUrl + "/ajax/professor/info/" + userid, {
- dataType: 'json',
- type: 'GET',
- timeout: 10000,
- success: function(data) {
- plus.nativeUI.closeWaiting();;
- ws.show("slide-in-right", 150);
- var $data = data.data;
- if($data.authStatus == 0) {
- authu[0].innerText = "未认证"
- } else if($data.authStatus == 1) {
- authu[0].innerText = "已认证"
- }
- authStatus = $data.authStatus;
- name = $data.name;
- org = $data.orgName;
-
- oDt[0].value = $data.name
- oDt[1].value = $data.orgName;
- if($data.department) {
- oDt[2].value = $data.department;
- }
- if($data.office) {
- oDt[3].value = $data.office;
- }
- if($data.title) {
- oDt[4].value = $data.title;
- }
- oAddress.innerText = $data.province + " " + $data.address;
- dataProvince.value = $data.province;
- dataAddress.value = $data.address;
- if($data.email) {
- mail.value = $data.email
- }
- if($data.phone) {
- telePhone.value = $data.phone
- }
- },
- error: function() {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- return;
- }
- });
- }
- function trim(str) {
-
- return str.replace(/(^\s*)|(\s*$)/g, "");
- }
- oDt[0].addEventListener("focus", function() {
- if(authStatus == 1) {
- plus.nativeUI.toast("修改姓名后,身份认证失效,需重新认证");
- } else {
- var length = trim(oDt[0].value);
- if(!length)
- plus.nativeUI.toast("姓名不能为空");
- }
- });
- oDt[1].addEventListener("focus", function() {
- if(authStatus == 1) {
- plus.nativeUI.toast("修改所在企业后,身份认证失效,需重新认证");
- } else {
- var length = trim(oDt[1].value);
- if(!length)
- plus.nativeUI.toast("所在企业不能为空");
- }
- });
-
- var cityPicker = new mui.PopPicker({
- layer: 2
- });
- cityPicker.setData(cityData);
- var showCityPickerButton = document.getElementById('showCityPicker');
- showCityPickerButton.addEventListener('tap', function(event) {
- cityPicker.show(function(items) {
- oAddress.innerText = items[0].text + " " + items[1].text;
- dataProvince.value = items[0].text;
- dataAddress.value = items[1].text;
-
-
- });
- }, false);
-
- var upStatus = function() {
- mui.ajax(baseUrl + "/ajax/professor/authStatus", {
- dataType: 'json',
- type: 'post',
- data: {
- authStatus: 0,
- id: userid
- },
- timeout: 10000,
- success: function(data) {
- if(data.success) {
- }else{
-
- }
- }
- })
- }
- function savePro() {
- var mess = {};
- mess.name = oDt[0].value;
- mess.orgName = oDt[1].value;
- mess.department = oDt[2].value;
- mess.office =oDt[4].value ;
- mess.title = oDt[3].value;
- mess.province = dataProvince.value;
- mess.address = dataAddress.value;
- mess.email = trim(mail.value);
- mess.phone = trim(telePhone.value);
- mess.id = userid;
- var mess1 = JSON.stringify(mess);
- $.ajax({
- "url": baseUrl + '/ajax/professor',
- "type": "PUT",
- "async": true,
- "data": mess1,
- "contentType": "application/json",
- "success": function(data) {
- if(data.success) {
- plus.nativeUI.showWaiting();
- var web = plus.webview.getWebviewById('html/companyUpdata.html');
- mui.fire(web, "newId");
- mui.back();
- var web3 = plus.webview.getWebviewById("html/myaccount.html");
- mui.fire(web3, "photoUser");
- } else {
- plus.nativeUI.toast("服务器链接超时", toastStyle);
- return;
- }
- }
- });
- }
-
- function phoneVal() {
- var hunPhone = /^1[3|4|5|7|8]\d{9}$/;
- if(!hunPhone.test(trim(telePhone.value))) {
- plus.nativeUI.toast("请输入正确的手机号码", toastStyle);
- return 0;
- }
- }
- telePhone.addEventListener("blur", function() {
- phoneVal()
- })
-
- function userEmail() {
- var gunf = /^\w+@\w+\.((cn)|(com)|(com\.cn))$/;
- if(!gunf.test(trim(mail.value))) {
- plus.nativeUI.toast("请输入正确的邮箱", toastStyle);
- return 0;
- }
- }
- mail.addEventListener("blur", function() {
- userEmail();
- })
- var save = function() {
- if(trim(telePhone.value)) {
- var t = phoneVal();
- if(t == 0) {
- return;
- }
- }
- if(trim(mail.value)) {
- var mt = userEmail();
- if(mt == 0) {
- return;
- }
- }
- var length1 = trim(oDt[0].value);
- var length2 = trim(oDt[1].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("姓名不能为空&&所在企业不能为空");
- }
- }
- document.getElementsByClassName("topsave")[0].addEventListener("click", function() {
- if(authStatus == 1 && (name != oDt[0].value || org != oDt[1].value)) {
- plus.nativeUI.confirm("确认修改?", function(e) {
- if(e.index == 0) {
- upStatus();
- save();
- }
- }, "修改姓名或所在企业后,身份认证失效,需重新认证", ["确认", "取消"]);
- } else {
- save();
- }
- });
- personalMessage();
- });
- })
|