123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968 |
- /** ***** BEGIN LICENSE BLOCK *****
- * |------------------------------------------------------------------------------|
- * | O2OA 活力办公 创意无限 o2m.api.js |
- * |------------------------------------------------------------------------------|
- * | Distributed under the AGPL license: |
- * |------------------------------------------------------------------------------|
- * | Copyright © 2018, o2oa.net, o2server.io O2 Team |
- * | All rights reserved. |
- * |------------------------------------------------------------------------------|
- *
- * This file is part of O2OA.
- *
- * O2OA is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * O2OA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <https://www.gnu.org/licenses/>.
- *
- * ***** END LICENSE BLOCK ******/
- /**
- * @summary
- * <b>o2m</b> 是O2OA移动端APP提供的调用原生控件的能力,帮助开发者高效使用拍照、定位等手机系统的能力,同时可以直接使用扫一扫、打开原生应用、选择时间,人员,组织等业务的能力,带给门户接近原生代码的体验
- * <br/>
- * <b>o2m</b> 只有在O2OA移动端APP中才能提供能力
- * @namespace o2m
- * @o2cn 平台移动APP API
- * @o2category mobile
- * @o2ordernumber 13
- * @o2range {流程表单|门户}
- * @o2syntax
- * // 可以在移动端 流程表单、门户 上使用
- * window.o2m
- *
- */
- (function () {
- this.o2m = {
- version: {
- v: "1.1.0",
- build: "2021.01.20",
- info: "O2OA 活力办公 创意无限. Copyright © 2021, o2oa.net O2 Team All rights reserved."
- },
- log: function (message) {
- window.o2android && window.o2android.o2mLog ? window.o2android.o2mLog(message) : window.webkit.messageHandlers.o2mLog.postMessage(message);
- }
- };
- /** ***** BEGIN NOTIFICATION BLOCK *****
- @ignore
- @summary notification 模块
- alert
- confirm
- prompt
- vibrate
- toast
- actionSheet
- showLoading
- hideLoading
- * ***** END NOTIFICATION BLOCK ******/
- this.o2m.notification = {};
- var _notification_post = function (body, onFail) {
- if (body == null) {
- if (onFail && typeof onFail === "function") {
- onFail("参数异常!");
- return
- }
- }
- var message = JSON.stringify(body);
- if (window.flutter_inappwebview && window.flutter_inappwebview.callHandler) {
- window.flutter_inappwebview.callHandler('o2mNotification', message);
- } else if (window.o2mNotification && window.o2mNotification.postMessage) {
- window.o2mNotification.postMessage(message);
- } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mNotification) {
- window.webkit.messageHandlers.o2mNotification.postMessage(message);
- } else {
- if (onFail && typeof onFail === "function") {
- onFail("请在O2OA移动端使用!");
- return
- }
- }
- };
- this.o2m.notification.alertSuccess = function () {
- console.log("notification alert back");
- };
- var _o2m_n_alert = function (alert) {
- var message = alert && alert.message ? alert.message : "";
- var title = alert && alert.title ? alert.title : "";
- var buttonName = alert && alert.buttonName ? alert.buttonName : "";
- var onSuccess = alert && alert.onSuccess ? alert.onSuccess : null;
- var onFail = alert && alert.onFail ? alert.onFail : null;
- if (message === "") {
- if (typeof onFail === "function") { onFail("消息内容不能为空!"); }
- return;
- }
- if (onSuccess && typeof onSuccess === "function") {
- o2m.notification.alertSuccess = onSuccess;
- }
- var body = {
- type: "alert",
- callback: "o2m.notification.alertSuccess",
- data: {
- message: message,
- title: title,
- buttonName: buttonName,
- }
- };
- _notification_post(body, onFail);
- };
- /**
- * 原生Alert提示弹出窗
- * @method alert
- * @memberOf o2m
- * @o2membercategory notification
- * @static
- * @param {Object} obj 提示窗传入对象
- * <pre><code class='language-js'>{
- * "title": "提示", //消息标题,可为空
- * "message": "这里是消息内容", //消息内容
- * "buttonName": "确定", //确定按钮名称
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/notification_alert.jpeg">
- * </caption>
- * o2m.notification.alert({
- * message: "亲爱的",
- * title: "提示",//可传空
- * buttonName: "收到",
- * onSuccess : function() {//onSuccess将在点击button之后回调},
- * onFail : function(err) {}
- * });
- *
- */
- this.o2m.notification.alert = _o2m_n_alert;
- //notification.confirm
- this.o2m.notification.confirmSuccess = function (index) {
- console.log("notification confirm back, click button index: " + index);
- };
- var _o2m_n_confirm = function (c) {
- var buttonLabels = c && c.buttonLabels ? c.buttonLabels : ["确定", "取消"];
- var message = c && c.message ? c.message : "";
- var title = c && c.title ? c.title : "";
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (message === "") {
- if (typeof onFail === "function") { onFail("消息内容message不能为空!"); }
- return;
- }
- if (buttonLabels.length != 2) {
- if (typeof onFail === "function") { onFail("按钮名称数组长度只能是2!"); }
- return;
- }
- if (onSuccess && typeof onSuccess === "function") {
- o2m.notification.confirmSuccess = onSuccess;
- }
- var body = {
- type: "confirm",
- callback: "o2m.notification.confirmSuccess",
- data: {
- message: message,
- title: title,
- buttonLabels: buttonLabels,
- }
- };
- _notification_post(body, onFail);
- }
- /**
- * 原生confirm提示弹出窗
- * @method confirm
- * @memberOf o2m
- * @o2membercategory notification
- * @static
- * @param {Object} obj 提示窗传入对象
- * <pre><code class='language-js'>{
- * "title": "提示", //消息标题,可为空
- * "message": "这里是消息内容", //消息内容
- * "buttonLabels": ["确定", "取消"], //按钮名称 Array[String]
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/notification_confirm.jpeg">
- * </caption>
- * o2m.notification.confirm({
- * message: "你爱我吗",
- * title: "提示",//可传空
- * buttonLabels: ['爱', '不爱'],
- * onSuccess : function(buttonIndex) {
- * //onSuccess将在点击button之后回调
- * //buttonIndex: 0 被点击按钮的索引值,Number类型,从0开始
- * },
- * onFail : function(err) {}
- * });
- *
- */
- this.o2m.notification.confirm = _o2m_n_confirm;
- //notification.prompt
- this.o2m.notification.promptSuccess = function (result) {
- console.log("notification prompt back, click button result: " + result);
- };
- var _o2m_n_prompt = function (c) {
- var buttonLabels = c && c.buttonLabels ? c.buttonLabels : ["确定", "取消"];
- var message = c && c.message ? c.message : "";
- var title = c && c.title ? c.title : "";
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (message === "") {
- if (typeof onFail === "function") { onFail("消息内容message不能为空!"); }
- return;
- }
- if (buttonLabels.length != 2) {
- if (typeof onFail === "function") { onFail("按钮名称数组长度只能是2!"); }
- return;
- }
- if (onSuccess && typeof onSuccess === "function") {
- o2m.notification.promptSuccess = onSuccess;
- }
- var body = {
- type: "prompt",
- callback: "o2m.notification.promptSuccess",
- data: {
- message: message,
- title: title,
- buttonLabels: buttonLabels,
- }
- };
- _notification_post(body, onFail);
- }
- /**
- * 原生prompt提示弹出窗
- * @method prompt
- * @memberOf o2m
- * @o2membercategory notification
- * @static
- * @param {Object} obj prompt需要传入对象
- * <pre><code class='language-js'>{
- * "title": "提示", //消息标题,可为空
- * "message": "这里是消息内容", //消息内容
- * "buttonLabels": ['继续', '不玩了'], //按钮名称 Array[String]
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/notification_prompt.jpeg">
- * </caption>
- * o2m.notification.prompt({
- * message: "再说一遍?",
- * title: "提示",//可传空
- * buttonLabels: ['继续', '不玩了'],
- * onSuccess : function(result) {
- * //result是一个字符串,格式是json格式,内容如下:
- * //{
- * // buttonIndex: 0, //被点击按钮的索引值,Number类型,从0开始
- * // value: '' //输入的值
- * //}
- * },
- * onFail : function(err) {}
- * });
- *
- */
- this.o2m.notification.prompt = _o2m_n_prompt;
- //notification.vibrate
- this.o2m.notification.vibrateSuccess = function () {
- console.log("notification vibrate back, click button");
- };
- var _o2m_n_vibrate = function (c) {
- var duration = c && c.duration ? c.duration : 300;
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.notification.vibrateSuccess = onSuccess;
- }
- var body = {
- type: "vibrate",
- callback: "o2m.notification.vibrateSuccess",
- data: {
- duration: duration
- }
- };
- _notification_post(body, onFail);
- };
- /**
- * 手机震动
- * @method vibrate
- * @memberOf o2m
- * @o2membercategory notification
- * @static
- * @param {Object} obj 震动需要传入对象
- * <pre><code class='language-js'>{
- * "duration": 300, //震动时间,android可配置 iOS忽略
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * o2m.notification.vibrate({
- * duration: 300,
- * onSuccess : function() {
- * },
- * onFail : function(err) {}
- * });
- *
- */
- this.o2m.notification.vibrate = _o2m_n_vibrate;
- //notification.toast
- this.o2m.notification.toastSuccess = function () {
- console.log("notification toast back, click button");
- };
- var _o2m_n_toast = function (c) {
- var duration = c && c.duration ? c.duration : 300;
- var message = c && c.message ? c.message : "";
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (message === "") {
- if (typeof onFail === "function") { onFail("消息内容message不能为空!"); }
- return;
- }
- if (onSuccess && typeof onSuccess === "function") {
- o2m.notification.toastSuccess = onSuccess;
- }
- var body = {
- type: "toast",
- callback: "o2m.notification.toastSuccess",
- data: {
- duration: duration,
- message: message
- }
- };
- _notification_post(body, onFail);
- };
- /**
- * toast提示
- * @method toast
- * @memberOf o2m
- * @o2membercategory notification
- * @static
- * @param {Object} obj toast需要传入对象
- * <pre><code class='language-js'>{
- * "message": "这里是提示信息",
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * o2m.notification.toast({
- * message: "提示消息内容",
- * onSuccess : function() {
- * },
- * onFail : function(err) {}
- * });
- *
- */
- this.o2m.notification.toast = _o2m_n_toast;
- //notification.actionSheet
- this.o2m.notification.actionSheetSuccess = function (buttonIndex) {
- console.log("notification actionSheet back, click button:" + buttonIndex);
- };
- var _o2m_n_actionSheet = function (c) {
- var title = c && c.title ? c.title : "";
- var cancelButton = c && c.cancelButton ? c.cancelButton : "取消";
- var otherButtons = c && c.otherButtons ? c.otherButtons : [];
- var tooManyButtons = c && c.tooManyButtons ? c.tooManyButtons : false;
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (otherButtons.length < 1) {
- if (typeof onFail === "function") { onFail("其他按钮列表不能为空!"); }
- return;
- }
- if (onSuccess && typeof onSuccess === "function") {
- o2m.notification.actionSheetSuccess = onSuccess;
- }
- var body = {
- type: "actionSheet",
- callback: "o2m.notification.actionSheetSuccess",
- data: {
- title: title,
- cancelButton: cancelButton,
- otherButtons: otherButtons,
- tooManyButtons: tooManyButtons
- }
- };
- _notification_post(body, onFail);
- };
- /**
- * 底部弹出菜单
- * @method actionSheet
- * @memberOf o2m
- * @o2membercategory notification
- * @static
- * @param {Object} obj actionSheet需要传入对象
- * <pre><code class='language-js'>{
- * "title": "谁是最棒哒?",//标题
- * "cancelButton": '取消', //取消按钮文本
- * "otherButtons": ["孙悟空","猪八戒","唐僧","沙和尚"], //其他选项按钮名称
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/notification_action_sheet.jpeg">
- * </caption>
- * o2m.notification.actionSheet({
- * title: "谁是最棒哒?", //标题
- * cancelButton: '取消', //取消按钮文本
- * otherButtons: ["孙悟空","猪八戒","唐僧","沙和尚"],
- * onSuccess : function(buttonIndex) {
- * //buttonIndex: 0 被点击按钮的索引值,Number,从0开始, 取消按钮为-1
- * },
- * onFail : function(err) {}
- * });
- *
- */
- this.o2m.notification.actionSheet = _o2m_n_actionSheet;
- //notification.showLoading
- this.o2m.notification.showLoadingSuccess = function () {
- console.log("notification showLoading back");
- };
- var _o2m_n_showLoading = function (c) {
- var text = c && c.text ? c.text : "";
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.notification.showLoadingSuccess = onSuccess;
- }
- var body = {
- type: "showLoading",
- callback: "o2m.notification.showLoadingSuccess",
- data: {
- text: text
- }
- };
- _notification_post(body, onFail);
- };
- /**
- * 显示Loading浮层,请和hideLoading配合使用
- * @method showLoading
- * @memberOf o2m
- * @o2membercategory notification
- * @static
- * @param {Object} obj showLoading需要传入对象
- * <pre><code class='language-js'>{
- * text: "使劲加载中..", //loading显示的字符,空表示不显示文字
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/notification_showLoading.jpeg">
- * </caption>
- * o2m.notification.showLoading({
- * text: "使劲加载中..", //loading显示的字符,空表示不显示文字
- * onSuccess : function() {
- * },
- * onFail : function(err) {}
- * });
- *
- */
- this.o2m.notification.showLoading = _o2m_n_showLoading;
- //notification.hideLoading
- this.o2m.notification.hideLoadingSuccess = function () {
- console.log("notification hideLoading back");
- };
- var _o2m_n_hideLoading = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.notification.hideLoadingSuccess = onSuccess;
- }
- var body = {
- type: "hideLoading",
- callback: "o2m.notification.hideLoadingSuccess",
- data: {
- }
- };
- _notification_post(body, onFail);
- }
- /**
- * 隐藏Loading浮层
- * @method hideLoading
- * @memberOf o2m
- * @o2membercategory notification
- * @static
- * @param {Object} obj hideLoading需要传入对象
- * <pre><code class='language-js'>{
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * o2m.notification.hideLoading({
- * onSuccess : function() {
- * },
- * onFail : function(err) {}
- * });
- *
- */
- this.o2m.notification.hideLoading = _o2m_n_hideLoading;
- /** ***** BEGIN UTIL BLOCK *****
- * @ignore
- * @summary
- util 模块
- date
- o2m.util.date.datePicker
- o2m.util.date.timePicker
- o2m.util.date.dateTimePicker
- calendar
- o2m.util.calendar.chooseOneDay
- o2m.util.calendar.chooseDateTime
- o2m.util.calendar.chooseInterval
- device
- o2m.util.device.getPhoneInfo
- o2m.util.device.scan
- o2m.util.deveice.location
- navigation
- o2m.util.navigation.setTitle
- o2m.util.navigation.close
- o2m.util.navigation.goBack
- o2m.util.navigation.openInnerApp
- o2m.util.navigation.openOtherApp
- o2m.util.navigation.openWindow
- o2m.util.navigation.share
-
- * ***** END UTIL BLOCK ******/
- this.o2m.util = {
- date: {},
- calendar: {},
- device: {},
- navigation: {}
- };
- var _util_post = function (body, onFail) {
- if (body == null) {
- if (onFail && typeof onFail === "function") {
- onFail("参数异常!");
- return;
- }
- }
- var message = JSON.stringify(body);
- if (window.flutter_inappwebview && window.flutter_inappwebview.callHandler) {
- window.flutter_inappwebview.callHandler('o2mUtil', message);
- } else if (window.o2mUtil && window.o2mUtil.postMessage) {
- window.o2mUtil.postMessage(message);
- } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mUtil) {
- window.webkit.messageHandlers.o2mUtil.postMessage(message);
- } else {
- if (onFail && typeof onFail === "function") {
- onFail("请在O2OA移动端使用!");
- }
- }
- };
- //o2m.util.date.datePicker
- this.o2m.util.date.datePickerSuccess = function (result) {
- console.log("util date datePicker back, result:" + result);
- };
- var _o2m_u_date_datePicker = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- var value = c && c.value ? c.value : "";
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.date.datePickerSuccess = onSuccess;
- }
- var body = {
- type: "date.datePicker",
- callback: "o2m.util.date.datePickerSuccess",
- data: {
- value: value
- }
- };
- _util_post(body, onFail);
- };
-
- /**
- * 日期选择器
- * @method datePicker
- * @memberOf o2m
- * @o2membercategory util.date
- * @static
- * @param {Object} obj datePicker需要传入对象
- * <pre><code class='language-js'>{
- * value: '2019-04-17', //默认显示日期
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/util_date_picker.jpeg">
- * </caption>
- * o2m.util.date.datePicker({
- * value: '2019-04-17', //默认显示日期
- * onSuccess : function(result) {
- * //onSuccess将在点击完成之后回调
- * {
- * value: "2019-02-10"
- * }
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.date.datePicker = _o2m_u_date_datePicker;
- //o2m.util.date.timePicker
- this.o2m.util.date.timePickerSuccess = function (result) {
- console.log("util date timePicker back, result:" + result);
- };
- var _o2m_u_date_timePicker = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- var value = c && c.value ? c.value : "";
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.date.timePickerSuccess = onSuccess;
- }
- var body = {
- type: "date.timePicker",
- callback: "o2m.util.date.timePickerSuccess",
- data: {
- value: value
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 时间选择器
- * @method timePicker
- * @memberOf o2m
- * @o2membercategory util.date
- * @static
- * @param {Object} obj timePicker需要传入对象
- * <pre><code class='language-js'>{
- * value: '14:00', //默认显示时间
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/util_time_picker.jpeg">
- * </caption>
- * o2m.util.date.timePicker({
- * value: '14:00', //默认显示时间
- * onSuccess : function(result) {
- * //onSuccess将在点击完成之后回调
- * {
- * value: "18:10"
- * }
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.date.timePicker = _o2m_u_date_timePicker;
- //o2m.util.date.dateTimePicker
- this.o2m.util.date.dateTimePickerSuccess = function (result) {
- console.log("util date dateTimePicker back, result:" + result);
- };
- var _o2m_u_date_dateTimePicker = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- var value = c && c.value ? c.value : "";
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.date.dateTimePickerSuccess = onSuccess;
- }
- var body = {
- type: "date.dateTimePicker",
- callback: "o2m.util.date.dateTimePickerSuccess",
- data: {
- value: value
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 日期时间选择器
- * @method dateTimePicker
- * @memberOf o2m
- * @o2membercategory util.date
- * @static
- * @param {Object} obj dateTimePicker需要传入对象
- * <pre><code class='language-js'>{
- * value: '2019-05-05 14:00', //默认显示时间
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/util_date_time_picker.jpeg">
- * </caption>
- * o2m.util.date.dateTimePicker({
- * value: '2019-05-05 14:00', //默认显示时间
- * onSuccess : function(result) {
- * //onSuccess将在点击完成之后回调
- * {
- * value: "2019-03-18 18:10"
- * }
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.date.dateTimePicker = _o2m_u_date_dateTimePicker;
- //o2m.util.calendar.chooseOneDay
- this.o2m.util.calendar.chooseOneDaySuccess = function (result) {
- console.log("util calendar chooseOneDay back, result:" + result);
- };
- var _o2m_u_calendar_chooseOneDay = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- var value = c && c.value ? c.value : "";
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.calendar.chooseOneDaySuccess = onSuccess;
- }
- var body = {
- type: "calendar.chooseOneDay",
- callback: "o2m.util.calendar.chooseOneDaySuccess",
- data: {
- value: value
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 月历日期选择器
- * @method chooseOneDay
- * @memberOf o2m
- * @o2membercategory util.calendar
- * @static
- * @param {Object} obj chooseOneDay需要传入对象
- * <pre><code class='language-js'>{
- * value: '2019-05-05', //默认显示日期
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/util_choose_one_day.jpeg">
- * </caption>
- * o2m.util.calendar.chooseOneDay({
- * value: '2019-05-05', //默认显示日期
- * onSuccess : function(result) {
- * //onSuccess将在点击完成之后回调
- * {
- * value: "2019-03-18"
- * }
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.calendar.chooseOneDay = _o2m_u_calendar_chooseOneDay;
- //o2m.util.calendar.chooseDateTime
- this.o2m.util.calendar.chooseDateTimeSuccess = function (result) {
- console.log("util calendar chooseDateTime back, result:" + result);
- };
- var _o2m_u_calendar_chooseDateTime = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- var value = c && c.value ? c.value : "";
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.calendar.chooseDateTimeSuccess = onSuccess;
- }
- var body = {
- type: "calendar.chooseDateTime",
- callback: "o2m.util.calendar.chooseDateTimeSuccess",
- data: {
- value: value
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 月历日期时间选择器
- * @method chooseDateTime
- * @memberOf o2m
- * @o2membercategory util.calendar
- * @static
- * @param {Object} obj chooseDateTime需要传入对象
- * <pre><code class='language-js'>{
- * value: '2019-05-05 11:00', //默认显示时间
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/util_choose_date_time.jpeg">
- * </caption>
- * o2m.util.calendar.chooseDateTime({
- * value: '2019-05-05 11:00', //默认显示时间
- * onSuccess : function(result) {
- * //onSuccess将在点击完成之后回调
- * {
- * value: "2019-03-18 18:45"
- * }
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.calendar.chooseDateTime = _o2m_u_calendar_chooseDateTime;
- //o2m.util.calendar.chooseInterval
- this.o2m.util.calendar.chooseIntervalSuccess = function (result) {
- console.log("util calendar chooseInterval back, result:" + result);
- };
- var _o2m_u_calendar_chooseInterval = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- var startDate = c && c.startDate ? c.startDate : "";
- var endDate = c && c.endDate ? c.endDate : "";
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.calendar.chooseIntervalSuccess = onSuccess;
- }
- var body = {
- type: "calendar.chooseInterval",
- callback: "o2m.util.calendar.chooseIntervalSuccess",
- data: {
- startDate: startDate,
- endDate: endDate
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 月历日期区间选择器
- * @method chooseInterval
- * @memberOf o2m
- * @o2membercategory util.calendar
- * @static
- * @param {Object} obj chooseInterval需要传入对象
- * <pre><code class='language-js'>{
- * startDate: '2019-05-05',
- * endDate: '2019-05-06',
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/util_choose_interval.jpeg">
- * </caption>
- * o2m.util.calendar.chooseInterval({
- * startDate: '2019-05-05',
- * endDate: '2019-05-06',
- * onSuccess : function(result) {
- * //onSuccess将在点击完成之后回调
- * {
- * startDate: "2019-05-05",
- endDate: "2019-05-06",
- * }
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.calendar.chooseInterval = _o2m_u_calendar_chooseInterval;
- //o2m.util.device.getPhoneInfo
- this.o2m.util.device.getPhoneInfoSuccess = function (result) {
- console.log("util calendar chooseInterval back, result:" + result);
- };
- var _o2m_u_device_getPhoneInfo = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.device.getPhoneInfoSuccess = onSuccess;
- }
- var body = {
- type: "device.getPhoneInfo",
- callback: "o2m.util.device.getPhoneInfoSuccess",
- data: {
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 获取手机基础信息
- * @method getPhoneInfo
- * @memberOf o2m
- * @o2membercategory util.device
- * @static
- * @param {Object} obj getPhoneInfo需要传入对象
- * <pre><code class='language-js'>{
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * o2m.util.device.getPhoneInfo({
- * onSuccess : function(result) {
- * {
- * screenWidth: 1080, // 手机屏幕宽度
- * screenHeight: 1920, // 手机屏幕高度
- * brand:'Mi', // 手机品牌
- * model:'Note4', // 手机型号
- * version:'7.0'. // 版本
- * netInfo:'wifi' , // 网络类型 wifi/4g/3g
- * operatorType :'xx' // 运营商信息
- * }
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.device.getPhoneInfo = _o2m_u_device_getPhoneInfo;
- //o2m.util.device.rotate
- this.o2m.util.device.rotateSuccess = function (result) {
- console.log("util device rotate back, result:" + result);
- };
- var _o2m_u_device_rotate = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.device.rotateSuccess = onSuccess;
- }
- var body = {
- type: "device.rotate",
- callback: "o2m.util.device.rotateSuccess",
- data: {
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 旋转屏幕
- * @method rotate
- * @memberOf o2m
- * @o2membercategory util.device
- * @static
- * @param {Object} obj rotate
- * <pre><code class='language-js'>{
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * o2m.util.device.rotate({
- * onSuccess : function(result) {
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.device.rotate = _o2m_u_device_rotate;
- //o2m.util.device.scan
- this.o2m.util.device.scanSuccess = function (result) {
- console.log("util device scan back, result:" + result);
- };
- var _o2m_u_device_scan = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.device.scanSuccess = onSuccess;
- }
- var body = {
- type: "device.scan",
- callback: "o2m.util.device.scanSuccess",
- data: {
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 扫二维码
- * @method scan
- * @memberOf o2m
- * @o2membercategory util.device
- * @static
- * @param {Object} obj scan需要传入对象
- * <pre><code class='language-js'>{
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * o2m.util.device.scan({
- * onSuccess : function(result) {
- * // result返回结果就是扫码的结果
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.device.scan = _o2m_u_device_scan;
- //o2m.util.device.location
- this.o2m.util.device.locationSuccess = function (result) {
- console.log("util device location back, result:" + result);
- };
- var _o2m_u_device_location = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.device.locationSuccess = onSuccess;
- }
- var body = {
- type: "device.location",
- callback: "o2m.util.device.locationSuccess",
- data: {
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 单次定位
- * @method location
- * @memberOf o2m
- * @o2membercategory util.device
- * @static
- * @param {Object} obj location需要传入对象
- * <pre><code class='language-js'>{
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * o2m.util.device.location({
- * onSuccess : function(result) {
- * //这里返回百度坐标系的定位信息
- * {
- * 'latitude': 39.903578, // 纬度
- * 'longitude': 116.473565, // 经度
- * 'address': '地址描述'
- * }
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.device.location = _o2m_u_device_location;
- //o2m.util.device.localAuth
- this.o2m.util.device.localAuthSuccess = function (result) {
- console.log("util device localAuth back, result:" + result);
- };
- /**
- * 移动端生物识别认证
- * @method localAuth
- * @memberOf o2m
- * @o2membercategory util.device
- * @static
- * @param {Object} obj localAuth 需要传入对象
- * <pre><code class='language-js'>{
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * o2m.util.device.localAuth({
- * onSuccess : function(result) {
- * // result 是一个 json 字符串
- * {
- * "value": false // 是否授权成功
- * }
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.device.localAuth = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.device.localAuthSuccess = onSuccess;
- }
- var body = {
- type: "device.localAuth",
- callback: "o2m.util.device.localAuthSuccess",
- data: {}
- };
- _util_post(body, onFail);
- };
- //o2m.util.navigation.setTitle
- this.o2m.util.navigation.setTitleSuccess = function (result) {
- console.log("util calendar chooseInterval back, result:" + result);
- };
- var _o2m_u_navigation_setTitle = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- var title = c && c.title ? c.title : "";
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.navigation.setTitleSuccess = onSuccess;
- }
- var body = {
- type: "navigation.setTitle",
- callback: "o2m.util.navigation.setTitleSuccess",
- data: {
- title: title
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 设置原生页面标题
- * @method setTitle
- * @memberOf o2m
- * @o2membercategory util.navigation
- * @static
- * @param {Object} obj setTitle需要传入对象
- * <pre><code class='language-js'>{
- * title : '导航标题',
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * o2m.util.navigation.setTitle({
- * title : '导航标题',
- * onSuccess : function() {
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.navigation.setTitle = _o2m_u_navigation_setTitle;
- //o2m.util.navigation.close
- this.o2m.util.navigation.closeSuccess = function (result) {
- console.log("util calendar chooseInterval back, result:" + result);
- };
- var _o2m_u_navigation_close = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.navigation.closeSuccess = onSuccess;
- }
- var body = {
- type: "navigation.close",
- callback: "o2m.util.navigation.closeSuccess",
- data: {
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 关闭当前原生页面
- * @method close
- * @memberOf o2m
- * @o2membercategory util.navigation
- * @static
- * @example
- * o2m.util.navigation.close();
- */
- this.o2m.util.navigation.close = _o2m_u_navigation_close;
- //o2m.util.navigation.goBack
- this.o2m.util.navigation.goBackSuccess = function (result) {
- console.log("util calendar chooseInterval back, result:" + result);
- };
- var _o2m_u_navigation_goBack = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.navigation.goBackSuccess = onSuccess;
- }
- var body = {
- type: "navigation.goBack",
- callback: "o2m.util.navigation.goBackSuccess",
- data: {
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 返回上级原生页面
- * @method goBack
- * @memberOf o2m
- * @o2membercategory util.navigation
- * @static
- * @example
- * o2m.util.navigation.goBack();
- */
- this.o2m.util.navigation.goBack = _o2m_u_navigation_goBack;
- //o2m.util.navigation.openInnerApp 内部应用打开 包含门户
- this.o2m.util.navigation.openInnerAppSuccess = function (result) {
- console.log("util navigation openInnerApp back, result:" + result);
- };
- var _o2m_u_navigation_openInnerApp = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.navigation.openInnerAppSuccess = onSuccess;
- }
- var appKey = c && c.appKey ? c.appKey : "";
- var portalFlag = c && c.portalFlag ? c.portalFlag : "";
- var portalTitle = c && c.portalTitle ? c.portalTitle : "";
- var portalPage = c && c.portalPage ? c.portalPage : "";
- var parameters = c && c.parameters ? c.parameters : {};
- var body = {
- type: "navigation.openInnerApp",
- callback: "o2m.util.navigation.openInnerAppSuccess",
- data: {
- appKey: appKey,
- portalFlag: portalFlag,
- portalTitle: portalTitle,
- portalPage: portalPage,
- parameters: parameters
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 打开内部应用
- * @method openInnerApp
- * @memberOf o2m
- * @o2membercategory util.navigation
- * @static
- * @param {Object} obj openInnerApp需要传入对象
- * <pre><code class='language-js'>{
- * appKey : 'attendance', // 对应用的 key: task(待办)、taskcompleted(已办)、read(待阅)、readcompleted(已阅)、meeting(会议管理)、clouddisk(网盘)、bbs(论坛)、cms(信息中心)、attendance(考勤)、calendar(日程)、mindMap(脑图)、portal(门户,门户需要传入portalFlag和portalTitle)
- * portalFlag : '门户标识',
- * portalTitle : '门户标题',
- * portalPage : '门户页面 id',
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * o2m.util.navigation.openInnerApp({
- * appKey : 'attendance',
- * onSuccess : function() {
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.navigation.openInnerApp = _o2m_u_navigation_openInnerApp;
- //o2m.util.navigation.openOtherApp 功能不完整,有很多限制。暂时不开放
- this.o2m.util.navigation.openOtherAppSuccess = function (result) {
- console.log("util navigation openOtherApp back, result:" + result);
- };
- var _o2m_u_navigation_openOtherApp = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.navigation.openOtherAppSuccess = onSuccess;
- }
- var schema = c && c.schema ? c.schema : "";
- var body = {
- type: "navigation.openOtherApp",
- callback: "o2m.util.navigation.openOtherAppSuccess",
- data: {
- schema: schema
- }
- };
- _util_post(body, onFail);
- };
- this.o2m.util.navigation.openOtherApp = _o2m_u_navigation_openOtherApp;
- //o2m.util.navigation.openWindow 新窗口打开网页 门户
- this.o2m.util.navigation.openWindowSuccess = function (result) {
- console.log("util navigation openWindow back, result:" + result);
- };
- var _o2m_u_navigation_openWindow = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.navigation.openWindowSuccess = onSuccess;
- }
- var url = c && c.url ? c.url : "";
- var body = {
- type: "navigation.openWindow",
- callback: "o2m.util.navigation.openWindowSuccess",
- data: {
- url: url
- }
- };
- _util_post(body, onFail);
- };
-
- /**
- * 新窗口打开网页
- * @method openWindow
- * @memberOf o2m
- * @o2membercategory util.navigation
- * @static
- * @param {Object} obj openWindow需要传入对象
- * <pre><code class='language-js'>{
- * url : 'https://www.o2oa.net', // 打开的网址
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * o2m.util.navigation.openWindow({
- * url : 'https://www.o2oa.net',
- * onSuccess : function() {
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.navigation.openWindow = _o2m_u_navigation_openWindow;
-
- //o2m.util.navigation.openInBrowser 手机默认浏览器打开当前页面
- this.o2m.util.navigation.openInBrowserSuccess = function (result) {
- console.log("util navigation openInBrowser back, result:" + result);
- };
- var _o2m_u_navigation_openInBrowser = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.navigation.openInBrowserSuccess = onSuccess;
- }
- var body = {
- type: "navigation.openInBrowser",
- callback: "o2m.util.navigation.openInBrowserSuccess",
- data: {}
- };
- _util_post(body, onFail);
- };
-
- /**
- * 手机默认浏览器打开当前页面
- * @method openInBrowser
- * @memberOf o2m
- * @o2membercategory util.navigation
- * @static
- * @example
- * o2m.util.navigation.openInBrowser({
- * onSuccess : function() {
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.navigation.openInBrowser = _o2m_u_navigation_openInBrowser;
- //o2m.util.navigation.clearCache 清理缓存并刷新页面
- this.o2m.util.navigation.clearCacheSuccess = function (result) {
- console.log("util navigation clearCache back, result:" + result);
- };
- var _o2m_u_navigation_clearCache = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.navigation.clearCacheSuccess = onSuccess;
- }
- var body = {
- type: "navigation.clearCache",
- callback: "o2m.util.navigation.clearCacheSuccess",
- data: {}
- };
- _util_post(body, onFail);
- };
-
- /**
- * 清理缓存并刷新页面
- * @method clearCache
- * @memberOf o2m
- * @o2membercategory util.navigation
- * @static
- * @example
- * o2m.util.navigation.clearCache({
- * onSuccess : function() {
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.navigation.clearCache = _o2m_u_navigation_clearCache;
- //o2m.util.navigation.share 分享图片
- this.o2m.util.navigation.shareSuccess = function (result) {
- console.log("util navigation share back, result:" + result);
- };
- var _o2m_u_navigation_share = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- var base64 = c && c.base64 ? c.base64 : "";
- if (onSuccess && typeof onSuccess === "function") {
- o2m.util.navigation.shareSuccess = onSuccess;
- }
- var body = {
- type: "navigation.share",
- callback: "o2m.util.navigation.shareSuccess",
- data: {
- base64: base64
- }
- };
- _util_post(body, onFail);
- };
- /**
- * 分享图片功能,目前只支持 base64 进行分享
- * @method share
- * @memberOf o2m
- * @o2membercategory util.navigation
- * @static
- * @example
- * o2m.util.navigation.share({
- * base64: '图片的 base64 编码';
- * onSuccess : function() {
- * },
- * onFail : function(err) {}
- *});
- */
- this.o2m.util.navigation.share = _o2m_u_navigation_share;
-
- /** ***** BEGIN BIZ BLOCK *****
- * @ignore
- * @summary
- biz 模块
- contact
- o2m.biz.contact.PersonPicker
- o2m.biz.contact.IdentityPicker
- o2m.biz.contact.departmentsPicker
- o2m.biz.contact.ComplexPicker
- o2m.biz.contact.GroupPicker
- o2m.biz.file.previewDoc
- * ***** END UTIL BLOCK ******/
- this.o2m.biz = {
- contact: {},
- file:{}
- };
- var _biz_post = function (body, onFail) {
- if (body == null) {
- if (onFail && typeof onFail === "function") {
- onFail("参数异常!");
- return;
- }
- }
- var message = JSON.stringify(body);
- if (window.flutter_inappwebview && window.flutter_inappwebview.callHandler) {
- window.flutter_inappwebview.callHandler('o2mBiz', message);
- } else if (window.o2mBiz && window.o2mBiz.postMessage) {
- window.o2mBiz.postMessage(message)
- } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.o2mBiz) {
- window.webkit.messageHandlers.o2mBiz.postMessage(message);
- } else {
- if (onFail && typeof onFail === "function") {
- onFail("请在O2OA移动端使用!");
- }
- }
- };
- //o2m.biz.workClose()
- var _o2m_b_work_close = function () {
- if (window.o2android && window.o2android.closeWork) {
- window.o2android.closeWork("");
- } else if (window.o2android && window.o2android.postMessage) {
- var body = {
- type: "closeWork"
- };
- window.o2android.postMessage(JSON.stringify(body));
- } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.closeWork) {
- window.webkit.messageHandlers.closeWork.postMessage("");
- } else {
- console.log("请在O2OA移动端使用, workClose");
- }
- }
- /**
- * 关闭当前工作页面,<b>只能在工作表单中可以使用</b>
- * @method workClose
- * @memberOf o2m
- * @o2membercategory biz
- * @static
- * @example
- * o2m.biz.workClose();
- */
- this.o2m.biz.workClose = _o2m_b_work_close;
- //o2m.biz.contact.departmentsPicker
- this.o2m.biz.contact.departmentsPickerSuccess = function (result) {
- console.log("biz contact departmentsPicker back, result:" + result);
- };
- var _o2m_b_contact_department_picker = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.biz.contact.departmentsPickerSuccess = onSuccess;
- }
- var topList = c && c.topList ? c.topList : [];
- var orgType = c && c.orgType ? c.orgType : "";
- var multiple = c && c.multiple ? c.multiple : false;
- var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
- var pickedDepartments = c && c.pickedDepartments ? c.pickedDepartments : [];
- var body = {
- type: "contact.departmentPicker",
- callback: "o2m.biz.contact.departmentsPickerSuccess",
- data: {
- topList: topList,
- orgType: orgType,
- multiple: multiple,
- maxNumber: maxNumber,
- pickedDepartments: pickedDepartments,
- }
- };
- _biz_post(body, onFail);
- };
- /**
- * 通讯录选部门
- * @method departmentsPicker
- * @memberOf o2m
- * @o2membercategory biz
- * @static
- * @param {Object} obj departmentsPicker需要传入对象
- * <pre><code class='language-js'>{
- * topList: [],//Array[String] 可选的顶级组织列表,不传或列表为空的时候,显示全部组织
- * orgType: "",//String 可选择的组织类别。为空就是全部组织类型都可以
- * multiple:true, //是否多选
- * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的部门数
- * pickedDepartments:[],//Array[String] 已经选择的部门distinguishedName列表
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/biz_dept_choose.png">
- * </caption>
- * o2m.biz.contact.departmentsPicker({
- * topList: [],//不传或者空列表,显示全部组织
- * orgType: "",//可传空 只显示某种类型的组织
- * multiple:true, //是否多选
- * maxNumber: 0, //最大选择数量
- * pickedDepartments:[],//已选部门
- * onSuccess : function(result) {
- * //返回结果样例
- * {
- * departments:[{
- * "id":"xxxx",
- * "name":"部门名称",
- * "unique":"xxxx",
- * "distinguishedName":"部门@xxxx@U",
- * "typeList":["xxxx"],
- * "shortName":"xxxx",
- * "level": 0,
- * "levelName":"xxxx",
- * }]
- * }
- *
- * },
- * onFail : function(err) {}
- * });
- */
- this.o2m.biz.contact.departmentsPicker = _o2m_b_contact_department_picker;
- //o2m.biz.contact.IdentityPicker
- this.o2m.biz.contact.IdentityPickerSuccess = function (result) {
- console.log("biz contact IdentityPicker back, result:" + result);
- };
- var _o2m_b_contact_identity_picker = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.biz.contact.IdentityPickerSuccess = onSuccess;
- }
- var topList = c && c.topList ? c.topList : [];
- var multiple = c && c.multiple ? c.multiple : false;
- var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
- var pickedIdentities = c && c.pickedIdentities ? c.pickedIdentities : [];
- var duty = c && c.duty ? c.duty : [];
- var body = {
- type: "contact.identityPicker",
- callback: "o2m.biz.contact.IdentityPickerSuccess",
- data: {
- topList: topList,
- multiple: multiple,
- maxNumber: maxNumber,
- pickedIdentities: pickedIdentities,
- duty: duty,
- }
- };
- _biz_post(body, onFail);
- };
- /**
- * 通讯录选身份
- * @method IdentityPicker
- * @memberOf o2m
- * @o2membercategory biz
- * @static
- * @param {Object} obj IdentityPicker需要传入对象
- * <pre><code class='language-js'>{
- * topList: [],//Array[String] 可选的顶级组织列表,不传或列表为空的时候,显示全部组织
- * multiple:true, //Boolean 是否多选
- * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
- * pickedIdentities:[],//Array[String] 已经选择的身份distinguishedName列表
- * duty: [],//Array[String] 可选择的人员职责
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/biz_identity_choose.png">
- * </caption>
- * o2m.biz.contact.IdentityPicker({
- * topList: [],//不传或者空列表,显示全部组织
- * multiple:true, //是否多选
- * maxNumber: 0, //最大选择数量
- * pickedIdentities:[],//已选身份列表
- * duty: [],//人员职责
- * onSuccess : function(result) {
- * //返回结果样例
- * {
- * identities:[{
- * "id":"xxxx",
- * "name":"姓名",
- * "distinguishedName":"姓名@xxxx@I",
- * "person":"xxx",
- * "unique":"xxxx",
- * "unit":"xxx",
- * "unitName":"xxxx",
- * "unitLevel": 0,
- * "unitLevelName":"xxxx",
- * "personName":"xxxx",
- * "personUnique":"xxx",
- * "personDn":"xxx"
- * }]
- * }
- *
- * },
- * onFail : function(err) {}
- * });
- */
- this.o2m.biz.contact.IdentityPicker = _o2m_b_contact_identity_picker;
- //o2m.biz.contact.GroupPicker
- this.o2m.biz.contact.GroupPickerSuccess = function (result) {
- console.log("biz contact GroupPicker back, result:" + result);
- };
- var _o2m_b_contact_group_picker = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.biz.contact.GroupPickerSuccess = onSuccess;
- }
- var multiple = c && c.multiple ? c.multiple : false;
- var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
- var pickedGroups = c && c.pickedGroups ? c.pickedGroups : [];
- var body = {
- type: "contact.groupPicker",
- callback: "o2m.biz.contact.GroupPickerSuccess",
- data: {
- multiple: multiple,
- maxNumber: maxNumber,
- pickedGroups: pickedGroups,
- }
- };
- _biz_post(body, onFail);
- };
- /**
- * 群组选择
- * @method GroupPicker
- * @memberOf o2m
- * @o2membercategory biz
- * @static
- * @param {Object} obj GroupPicker需要传入对象
- * <pre><code class='language-js'>{
- * multiple:true, //Boolean 是否多选
- * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
- * pickedGroups:[],//Array[String] 已经选择的群组distinguishedName列表
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/biz_group_choose.png">
- * </caption>
- * o2m.biz.contact.GroupPicker({
- * multiple:true, //是否多选
- * maxNumber: 0, //最大选择数量
- * pickedGroups:[],//已选群组列表
- * onSuccess : function(result) {
- * //返回结果样例
- * {
- * groups:[{
- * "id":"xxxx",
- * "name":"群组名称",
- * "distinguishedName":"群组名称@xxxx@G"
- * "unique":"xxxx",
- * }]
- * }
- *
- * },
- * onFail : function(err) {}
- * });
- */
- this.o2m.biz.contact.GroupPicker = _o2m_b_contact_group_picker;
- //o2m.biz.contact.PersonPicker
- this.o2m.biz.contact.PersonPickerSuccess = function (result) {
- console.log("biz contact PersonPicker back, result:" + result);
- };
- var _o2m_b_contact_person_picker = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.biz.contact.PersonPickerSuccess = onSuccess;
- }
- var multiple = c && c.multiple ? c.multiple : false;
- var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
- var pickedUsers = c && c.pickedUsers ? c.pickedUsers : [];
- var body = {
- type: "contact.personPicker",
- callback: "o2m.biz.contact.PersonPickerSuccess",
- data: {
- multiple: multiple,
- maxNumber: maxNumber,
- pickedUsers: pickedUsers,
- }
- };
- _biz_post(body, onFail);
- };
- /**
- * 人员选择
- * @method PersonPicker
- * @memberOf o2m
- * @o2membercategory biz
- * @static
- * @param {Object} obj PersonPicker需要传入对象
- * <pre><code class='language-js'>{
- * multiple:true, //Boolean 是否多选
- * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
- * pickedUsers:[],//Array[String] 已经选择的人员distinguishedName列表
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/biz_person_choose.png">
- * </caption>
- * o2m.biz.contact.PersonPicker({
- * multiple:true, //是否多选
- * maxNumber: 0, //最大选择数量
- * pickedUsers:[],//已选人员列表
- * onSuccess : function(result) {
- * //返回结果样例
- * {
- * users:[{
- * "id":"xxx",
- * "name":"姓名",
- * "unique":"xxx",
- * "distinguishedName":"姓名@xxxx@P"
- * "genderType":"xxx",
- * "employee":"xxx",
- * "mail":"xxx",
- * "weixin":"xxx",
- * "qq":"xxx",
- * "mobile":"xxx",
- * "officePhone":"xxx"
- * }]
- * }
- *
- * },
- * onFail : function(err) {}
- * });
- */
- this.o2m.biz.contact.PersonPicker = _o2m_b_contact_person_picker;
- //o2m.biz.contact.ComplexPicker
- this.o2m.biz.contact.ComplexPickerSuccess = function (result) {
- console.log("biz contact ComplexPicker back, result:" + result);
- };
- var _o2m_b_contact_complex_picker = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.biz.contact.ComplexPickerSuccess = onSuccess;
- }
- var pickMode = c && c.pickMode ? c.pickMode : [];
- var multiple = c && c.multiple ? c.multiple : false;
- var maxNumber = c && c.maxNumber ? c.maxNumber : 0;
- var topList = c && c.topList ? c.topList : [];
- var orgType = c && c.orgType ? c.orgType : "";
- var duty = c && c.duty ? c.duty : [];
- var pickedGroups = c && c.pickedGroups ? c.pickedGroups : [];
- var pickedUsers = c && c.pickedUsers ? c.pickedUsers : [];
- var pickedIdentities = c && c.pickedIdentities ? c.pickedIdentities : [];
- var pickedDepartments = c && c.pickedDepartments ? c.pickedDepartments : [];
- var body = {
- type: "contact.complexPicker",
- callback: "o2m.biz.contact.ComplexPickerSuccess",
- data: {
- pickMode: pickMode,
- multiple: multiple,
- maxNumber: maxNumber,
- topList: topList,
- orgType: orgType,
- duty: duty,
- pickedGroups: pickedGroups,
- pickedUsers: pickedUsers,
- pickedIdentities: pickedIdentities,
- pickedDepartments: pickedDepartments,
- }
- };
- _biz_post(body, onFail);
- };
- /**
- * 复合选择器,可配置选择多种数据
- * @method ComplexPicker
- * @memberOf o2m
- * @o2membercategory biz
- * @static
- * @param {Object} obj ComplexPicker需要传入对象
- * <pre><code class='language-js'>{
- * pickMode: ["departmentPicker", "identityPicker"], //Array[String] 选择器类型,可传入值:departmentPicker、identityPicker、groupPicker、personPicker
- * topList:Array[String] 可选的顶级组织列表,不传或列表为空的时候,显示全部组织
- * duty: Array[String] 可选择的人员职责
- * orgType:String 可选择的组织类别。为空就是全部组织类型都可以
- * multiple:true, //Boolean 是否多选
- * maxNumber: 0, //Int 当multiple为true的时候,最多可选择的身份数
- * pickedDepartments:Array[String] 已经选择的部门distinguishedName列表
- * pickedIdentities:Array[String] 已经选择的身份distinguishedName列表
- * pickedGroups: Array[String] 已经选择的群组distinguishedName列表
- * pickedUsers:[],//Array[String] 已经选择的人员distinguishedName列表
- * "onSuccess": function, //成功回调
- * "onFail": function, //失败回调
- * }</code></pre>
- * @example
- * <caption>
- * 样例效果:<br/>
- * <img src="img/module/o2m/biz_complex_choose.png">
- * </caption>
- * o2m.biz.contact.ComplexPicker({
- * pickMode: ["departmentPicker", "identityPicker"], //选择器类型
- * topList: [],//不传或者空列表,显示全部组织
- * orgType: "",//可传空 只显示某种类型的组织
- * duty: [],//人员职责
- * multiple:true, //是否多选
- * maxNumber: 0, //最大选择数量
- * pickedDepartments:[],//已选部门
- * pickedIdentities:[],//已选身份列表
- * pickedGroups:[],//已选群组列表
- * pickedUsers:[],//已选人员列表
- * onSuccess : function(result) {
- * //返回结果样例
- * {
- * departments:[{
- * "id":"xxxx",
- * "name":"部门名称",
- * "unique":"xxxx",
- * "distinguishedName":"部门@xxxx@U",
- * "typeList":["xxxx"],
- * "shortName":"xxxx",
- * "level": 0,
- * "levelName":"xxxx",
- * }],
- * identities:[{
- * "id":"xxxx",
- * "name":"姓名",
- * "distinguishedName":"姓名@xxxx@I",
- * "person":"xxx",
- * "unique":"xxxx",
- * "unit":"xxx",
- * "unitName":"xxxx",
- * "unitLevel": 0,
- * "unitLevelName":"xxxx",
- * "personName":"xxxx",
- * "personUnique":"xxx",
- * "personDn":"xxx"
- * }],
- * groups:[{
- * "id":"xxxx",
- * "name":"群组名称",
- * "distinguishedName":"群组名称@xxxx@G"
- * "unique":"xxxx",
- * }],
- * users:[{
- * "id":"xxx",
- * "name":"姓名",
- * "unique":"xxx",
- * "distinguishedName":"姓名@xxxx@P"
- * "genderType":"xxx",
- * "employee":"xxx",
- * "mail":"xxx",
- * "weixin":"xxx",
- * "qq":"xxx",
- * "mobile":"xxx",
- * "officePhone":"xxx"
- * }]
- * }
- * },
- * onFail : function(err) {}
- * });
- */
- this.o2m.biz.contact.ComplexPicker = _o2m_b_contact_complex_picker;
- this.o2m.biz.file.PreviewDocSuccess = function (result) {
- console.log("biz file preview doc back, result:" + result);
- };
- var _o2m_b_file_preview = function (c) {
- var onSuccess = c && c.onSuccess ? c.onSuccess : null;
- var onFail = c && c.onFail ? c.onFail : null;
- if (onSuccess && typeof onSuccess === "function") {
- o2m.biz.file.PreviewDocSuccess = onSuccess;
- }
- var fileUrl = c && c.url ? c.url : "";
- var fileName = c && c.fileName ? c.fileName : "";
-
- var body = {
- type: "file.previewDoc",
- callback: "o2m.biz.file.PreviewDocSuccess ",
- data: {
- url: fileUrl,
- fileName: fileName
- }
- };
- _biz_post(body, onFail);
- };
- // 文件预览 后续要删除
- this.o2m.biz.file.PreviewDoc = _o2m_b_file_preview;
- })();
|