123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- var s_home2 = "home2.html",
- s_home1 = "home1.html",
- s_admin = "admin.html",
- s_mine = "mine.html";
- /**
- * 返回消息页面
- */
- function back2Xiaoxi(){
- baseBack("xiaoxi.html");
- }
- /**
- * 返回消息并刷新
- */
- function backxiaoxi(){
- var old_back = mui.back;
- mui.back = function() {
- var wobj = plus.webview.getWebviewById("xiaoxi.html");//获取全科、健康医生页面的讨论组 ID
- //html/home/html/xiaoxi.html
- if(wobj!=null){
- mui.fire(wobj, "refresh");
- // wobj.reload(true);//刷新
- }
-
- if(self.opener && self.opener()){
- mui.fire(self.opener(), "xiaoxiUpdate");
- }
-
- old_back();
- }
- }
- /**
- * 返回消息并刷新
- */
- function backzhidingzixun(){
- var old_back = mui.back;
- mui.back = function() {
- var wobj = plus.webview.getWebviewById("zhidingzixun");//获取全科、健康医生页面的讨论组 ID
- if(wobj){
- mui.fire(wobj, "refresh");
- // wobj.reload(true);
- }
- old_back();
- }
- }
- /**
- * 返回全科与建管首页
- */
- function back2home(){
- baseBack("home2.html");
- }
- function back2OneByOneGongzuozu(){
- baseBack("dlz");
- }
- function baseBack(htmlId){
- var oldback = mui.back;
- mui.back = function() {
- var ww = plus.webview.getWebviewById(htmlId);
- if(ww){
- mui.fire(plus.webview.getWebviewById(htmlId), "refresh");
- }
- oldback();
- }
- }
- /**
- * 判断是否多角色
- */
- function isMultiRole(){
- if(!plus.storage.getItem("docInfo")){
- exit2Login();
- plus.storage.removeItem("isLoginOut");
- }
-
- var userRole = JSON.parse(plus.storage.getItem("userRole"));
- var docInfo = JSON.parse(plus.storage.getItem("docInfo"));
-
-
- var doctorType = docInfo.level;
-
- //alert(JSON.stringify(userRole));
- //plus.storage.getItem('docType')!='10' &&
- //doctorType!='10' &&
-
- return doctorType!=10 && userRole && userRole.length>0;
- }
- /**
- * 初始化切换页面
- */
- function initQiehuanDom(){
- // if(true){//v1.1.3暂不发布
- // $('#qiehuan').hide();
- // return true;
- // }
- var flag = isMultiRole();
- if(flag)
- $('#qiehuan').show();
- else
- $('#qiehuan').hide();
- $('#qiehuan').on('tap', function(){
- mui.fire(plus.webview.getWebviewById("main"), "showQiehuan");
- })
- }
- /**
- * 设置医生头像
- * @param {Object} sex
- * @param {Object} docType
- */
- function setDocPhoto(sex, docType){
- docType = docType || plus.storage.getItem("docType");
- if(docType=="10"){
- return sex==2? "../../../images/s-female.png" : "../../../images/s-male.png";
- }
- return sex==2? "../../../images/d-female.png" : "../../../images/d-male.png";
- }
- /**
- * 设置医生头像
- * @param {Object} p
- * @param {Object} sex
- * @param {Object} docType
- */
- function setTemDocPhoto(p, sex, docType){
- if (!p || p.length == 0) {
- return setDocPhoto(sex, docType);
- }
- return getImgUrl(p);
- }
- /**
- * 初始化医生头像
- * @param {Object} domId
- * @param {Object} p
- * @param {Object} sex
- * @param {Object} docType
- */
- function initDocPhoto(domId, p, sex, docType){
- document.getElementById(domId).onerror = function(){
- this.src = setDocPhoto(sex, docType);
- }
- $('#'+ domId).attr("src", setTemDocPhoto(p, sex, docType));
- }
- /**
- * 刷新医生头像
- */
- function flushDocPhoto(photo){
- var docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- docInfo.photo = photo;
- plus.storage.setItem("docInfo", JSON.stringify(docInfo));
- var wv = plus.webview.getWebviewById(s_admin);
- if(wv)
- mui.fire(wv, "flushDocPhoto");
-
- wv = plus.webview.getWebviewById(s_home1);
- if(wv)
- mui.fire(wv, "flushDocPhoto");
-
- wv = plus.webview.getWebviewById(s_home2);
- if(wv)
- mui.fire(wv, "flushDocPhoto");
-
- wv = plus.webview.getWebviewById(s_mine);
- if(wv)
- mui.fire(wv, "flushDocPhoto");
- }
- /**
- * 自定义刷新头像事件
- */
- window.addEventListener("flushDocPhoto", function(e){
- var docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- $('#doc_photo').attr("src", docInfo.photo);
- })
- /**
- * 开启主从页面
- * @param {Object} id 主页面id
- * @param {Object} subPage 子页面路径, 基于header1
- * @param {Object} title 主题
- * @param {Object} extras 参数(带到子页面)
- * @param {Object} subId 子页面id
- * openWindowWithSub("health-record", "health-record.html", "居民详情")
- */
- function openWindowWithSub(id, subPage, title, extras, subId){
- extras = extras || {};
- mui.openWindow({
- url: '../../header1.html',
- id: id,
- extras: {
- title: title,
- subPage: subPage,
- subId: subId,
- extras: extras
- }
- });
- }
- /*
- * 查看协议书
- */
- function toXieYiShu(index) {
- mui.openWindow("../../qygl/html/xieyishu.html", "xieyishu");
- }
- /**
- * 设置疾病类型
- * @param {Object} d
- */
- function setDiseases(d, t) {
- if(!d || d.length == 0)
- return t==1? "" : "无";
- var v = "";
- for(var k in d){
- v += "、" + d[k].diseaseName;
- }
- return v.substring(1);
- }
- /**
- * 跳转到个人单项修改页面
- * @param {Object} key
- * @param {Object} value
- */
- function gotoModify(key, value){
- mui.openWindow({
- url: "modify.html",
- id: "modify.html",
- extras:{
- key: key,
- value: value
- }
- })
- }
- function isPasswordPrompt(){
- plus.nativeUI.showWaiting();
- var docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- var isPasswordPrompt = plus.storage.getItem('isPasswordPrompt');
- plus.nativeUI.closeWaiting();
- if(docInfo.isPasswordPrompt == 0 && !isPasswordPrompt){
- plus.storage.setItem('isPasswordPrompt', "0");
- mui.confirm("为了给您提供更好的服务,我们上线了账号密码登录功能,为了您的账户安全,快来设置您的登录密码~", "提示", ["立即设置"], function(e){
- mui.openWindow({
- url: "../../mine/html/shezhimima.html",
- id: "shezhimima.html",
- extras:{
- mobile: docInfo.mobile
- }
- })
- })
- return true;
- }
- return false;
- }
- function checkIdcard(idcard){
-
- var userAgent = plus.navigator.getUserAgent(),
- index = userAgent.indexOf("}"),
- s = userAgent.substr(0, index+1),
- item = JSON.parse(s);
- if(!isPasswordPrompt() && !idcard && !item.observer){
- mui.confirm("如果医生未绑定身份证号,可能影响被关注量和咨询效率,是否前往绑定?", "提示", ["立即绑定", "以后再说"], function(e) {
- if(e.index==0){
- mui.openWindow({
- url: "../../mine/html/modify.html",
- id: "modify.html",
- extras:{
- key: "idcard",
- value: ""
- }
- })
- return ;
- }
- });
- }
- }
- function getUid(){
- return JSON.parse(plus.storage.getItem("docInfo")).code;
- }
- function validMobile(){
- var mobile = $.trim($('.reg-mobile').val());
- if(!isphone(mobile)){
- mui.toast("请输入有效的手机号码");
- return;
- }
- return mobile;
- }
- /*判断输入是否为合法的手机号码*/
- function isphone(inputString)
- {
- var partten = /^0?(13[0-9]|15[0-9]|18[0-9]|14[57]|17[0-9]|16[0-9]|19[0-9])[0-9]{8}$/;
- if(partten.test(inputString))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- var chineseReg = /.*[\u4e00-\u9fa5]+.*$/;
- function validPsd(){
- var psd = $.trim($('.reg-psd').val());
- if(chineseReg.test(psd)){
- mui.toast("密码不可包含中文!");
- return;
- }
- if(psd.length<6){
- mui.toast("密码不得少于6位!");
- return;
- }
- return psd;
- }
|