common.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. var mobile = {};
  2. var dictMap = {};
  3. var paramMap = {};
  4. var user={};
  5. var company="";
  6. var shareUser="";
  7. var share={"title":"上饶生活服务平台",
  8. "link":"http://www.3water.cn/buying/mobile/index.jsp",
  9. "imgUrl":"http://www.3water.cn/buying/static/mobile/image/shangraowang.jpg",
  10. "desc":"为上饶人民一站式生活服务"};
  11. $(function() {
  12. pushHistory();
  13. });
  14. function pushHistory() {
  15. window.addEventListener("popstate", function(e) {
  16. self.location.reload();
  17. }, false);
  18. var state = {
  19. title : "",
  20. url : "#"
  21. };
  22. window.history.replaceState(state, "", "#");
  23. };
  24. (function() {
  25. if (typeof WeixinJSBridge == "object" && typeof WeixinJSBridge.invoke == "function") {
  26. handleFontSize();
  27. } else {
  28. if (document.addEventListener) {
  29. document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
  30. } else if (document.attachEvent) {
  31. //IE浏览器,非W3C规范
  32. document.attachEvent("onWeixinJSBridgeReady", handleFontSize);
  33. }
  34. }
  35. function handleFontSize() {
  36. // 设置网页字体为默认大小
  37. WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
  38. // 重写设置网页字体大小的事件
  39. WeixinJSBridge.on('menu:setfont', function() {
  40. WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
  41. });
  42. }
  43. })();
  44. $(document).ready(function () {
  45. if(window.history.length<2){
  46. //$(".mui-action-back").hide();
  47. }
  48. addLog();
  49. getTicket();
  50. $(".home-btn").on("tap",function(){
  51. location.href=base+"/mobile/index.jsp";
  52. });
  53. });
  54. function addLog(){
  55. if(mobile.getUrlVars("company")){
  56. company = mobile.getUrlVars("company");
  57. sessionStorage.setItem("company",mobile.getUrlVars("company"));
  58. }else if(sessionStorage.getItem("company")){
  59. company = sessionStorage.getItem("company");
  60. }
  61. if(mobile.getUrlVars("shareUser")){
  62. shareUser = mobile.getUrlVars("shareUser");
  63. sessionStorage.setItem("shareUser",mobile.getUrlVars("shareUser"));
  64. }else if(sessionStorage.getItem("shareUser")){
  65. shareUser = sessionStorage.getItem("shareUser");
  66. }
  67. var url = location.href.replace('#','');
  68. if (user){
  69. if(url.indexOf("?")!=-1){
  70. if(url.indexOf("shareUser")!=-1){
  71. url = mobile.changeUrlParam(url,"shareUser",user.openid);
  72. }else{
  73. url+="&shareUser="+user.openid;
  74. }
  75. }else{
  76. url+="?shareUser="+user.openid;
  77. }
  78. }
  79. if(company){
  80. if(url.indexOf("?")!=-1){
  81. url+="&company="+company;
  82. }else{
  83. url+="?company="+company;
  84. }
  85. }
  86. share.link = url;
  87. var page = window.location.pathname;
  88. var id = mobile.getUrlVars("id");
  89. mobile.ajaxPost(base+"/userViewLog/save",{id:id,page:page,company:company,shareUser:shareUser},function(json){},"");
  90. }
  91. //获取微信js参数
  92. function getTicket(){
  93. mobile.ajaxPost(base+"/wechat/getTicket",{url:window.location.href},function(data){
  94. wx.config({
  95. debug: false,
  96. appId:data.appId,
  97. timestamp: data.timestamp,
  98. nonceStr: data.nonceStr,
  99. signature: data.signature,
  100. jsApiList: [
  101. 'onMenuShareTimeline',
  102. 'onMenuShareAppMessage',
  103. 'getLocation',
  104. 'openLocation'
  105. ]
  106. });
  107. },"");
  108. }
  109. //分享
  110. wx.ready(function(){
  111. wx.onMenuShareTimeline({
  112. title: share.title, // 分享标题
  113. link: share.link, // 分享链接
  114. imgUrl: share.imgUrl, // 分享图标
  115. success: function () {
  116. if(typeof share.callback=='function'){
  117. share.callback('1');
  118. }
  119. saveShareLog("10");
  120. },
  121. cancel: function () {
  122. alert('取消分享');
  123. }
  124. });
  125. wx.onMenuShareAppMessage({
  126. title: share.title, // 分享标题
  127. desc: share.desc, // 分享描述
  128. link: share.link, // 分享链接
  129. imgUrl: share.imgUrl, // 分享图标
  130. type: 'link', // 分享类型,music、video或link,不填默认为link
  131. success: function () {
  132. if(typeof share.callback=='function'){
  133. share.callback('2');
  134. }
  135. saveShareLog("20");
  136. },
  137. cancel: function () {
  138. alert('取消分享');
  139. }
  140. });
  141. });
  142. function saveShareLog(type) {
  143. var page = window.location.pathname;
  144. var id = mobile.getUrlVars("id");
  145. mobile.ajaxPost(base+"/userShareLog/save",{id:id,page:page,type:type},function(json){},"");
  146. }
  147. /**
  148. * 获取购物车数量
  149. */
  150. mobile.getCartNum = function () {
  151. mobile.ajaxPost(base+'/userCart/getNum',{},function(json){
  152. if(json.data!=0){
  153. $('.mui-bar-tab .icon-gouwuche .mui-badge').html(json.data);
  154. $('.mui-bar-tab .icon-gouwuche .mui-badge').removeClass('mui-hidden');
  155. }else{
  156. $('.mui-bar-tab .icon-gouwuche .mui-badge').addClass('mui-hidden');
  157. }
  158. });
  159. };
  160. /**
  161. * flag 当子窗口取不到是否不取父窗口的值,默认取父窗口
  162. */
  163. mobile.getUrlVars = function (name, flag) {
  164. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  165. var r = window.location.search.substr(1).match(reg);
  166. //modify by zhengwei
  167. if (flag) {
  168. if (r == null) {
  169. r = window.parent.location.search.substr(1).match(reg);
  170. }
  171. }
  172. if (r != null) return decodeURI(r[2]);
  173. return null;
  174. };
  175. /**
  176. * form赋值
  177. */
  178. mobile.toForm = function (data) {
  179. if(data){
  180. $.each(data,function(key,value){
  181. if($('#'+key)){
  182. $('#'+key).val(mobile.nullToSpace(value));
  183. }
  184. });
  185. }
  186. }
  187. //把null转为空
  188. mobile.nullToSpace = function (param) {
  189. if (param == null || typeof param == 'undefined') {
  190. param = '';
  191. }
  192. return param;
  193. }
  194. //把null转为0
  195. mobile.nullToZore = function (param) {
  196. if (param == null || typeof param == 'undefined') {
  197. param = 0;
  198. }
  199. return param;
  200. }
  201. /**
  202. * 增加天数
  203. */
  204. mobile.addDate = function(date,days){
  205. var a = new Date(date)
  206. a = a.valueOf();
  207. a = a + days * 24 * 60 * 60 * 1000
  208. a = new Date(a)
  209. return a;
  210. }
  211. /**
  212. * 获取星期
  213. */
  214. mobile.getWeek = function(date){
  215. var str = "星期";
  216. var week = date.getDay();
  217. switch (week) {
  218. case 0 :
  219. str += "日";
  220. break;
  221. case 1 :
  222. str += "一";
  223. break;
  224. case 2 :
  225. str += "二";
  226. break;
  227. case 3 :
  228. str += "三";
  229. break;
  230. case 4 :
  231. str += "四";
  232. break;
  233. case 5 :
  234. str += "五";
  235. break;
  236. case 6 :
  237. str += "六";
  238. break;
  239. }
  240. return str;
  241. }
  242. /**
  243. * 检查手机号码
  244. */
  245. mobile.checkMobile = function (phone){
  246. var reg= /(^1[3|4|5|7|8|9][0-9]{9}$)/;
  247. return reg.test(phone);
  248. }
  249. //ajax post
  250. mobile.ajaxPost = function (url, params, callback,msg) {
  251. var index=null;
  252. $.ajax({
  253. type:"POST",
  254. url:url,
  255. data:params,
  256. dataType:"json",
  257. timeout:60000,
  258. beforeSend:function(){
  259. if(msg!=""){
  260. if(msg){
  261. index=layer.open({type: 3,shadeClose:false,content: msg});
  262. }else{
  263. index=layer.open({type: 3,shadeClose:false,content: '加载中...'});
  264. }
  265. }
  266. },
  267. success:function(data){
  268. if(msg!=""){
  269. layer.close(index);
  270. }
  271. if(typeof callback=='function'){
  272. callback(data);
  273. }
  274. },
  275. error:function(XMLHttpRequest, textStatus, errorThrown){
  276. if(msg!=""){
  277. layer.close(index);
  278. }
  279. switch (XMLHttpRequest.status){
  280. case(500):
  281. layer.open({content: "服务异常",time: 3});
  282. break;
  283. case(408):
  284. layer.open({content: "请求超时",time: 3});
  285. break;
  286. case(0):
  287. layer.open({content: "网络连接异常",time: 3});
  288. break;
  289. default:
  290. layer.open({content: "请求错误,请稍后再试",time: 3});
  291. }
  292. },
  293. complete: function (XHR, TS) { XHR = null; }
  294. });
  295. };
  296. //保留两位小数
  297. mobile.toDecimal = function (x) {
  298. var f = parseFloat(x);
  299. if (isNaN(f)) {
  300. return;
  301. }
  302. f = Math.round(x * 100) / 100;
  303. return f;
  304. }
  305. mobile.getWeekDay = function (){
  306. var str = "";
  307. var week = new Date().getDay();
  308. if (week == 0) {
  309. str = "星期日";
  310. } else if (week == 1) {
  311. str = "星期一";
  312. } else if (week == 2) {
  313. str = "星期二";
  314. } else if (week == 3) {
  315. str = "星期三";
  316. } else if (week == 4) {
  317. str = "星期四";
  318. } else if (week == 5) {
  319. str = "星期五";
  320. } else if (week == 6) {
  321. str = "星期六";
  322. }
  323. return str;
  324. }
  325. //日期格式化
  326. Date.prototype.format = function (fmt) {
  327. var o = {
  328. "M+": this.getMonth() + 1, //月份
  329. "d+": this.getDate(), //日
  330. "h+": this.getHours(), //小时
  331. "m+": this.getMinutes(), //分
  332. "s+": this.getSeconds(), //秒
  333. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  334. "S": this.getMilliseconds() //毫秒
  335. };
  336. if (/(y+)/.test(fmt))
  337. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  338. for (var k in o)
  339. if (new RegExp("(" + k + ")").test(fmt))
  340. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  341. return fmt;
  342. }
  343. //数组移除
  344. Array.prototype.removeAt = function (Index) {
  345. if (isNaN(Index) || Index > this.length) {
  346. return false;
  347. }
  348. for (var i = 0, n = 0; i < this.length; i++) {
  349. if (this[i] != this[Index]) {
  350. this[n++] = this[i]
  351. }
  352. }
  353. this.length -= 1
  354. }
  355. //数组是否包含某项
  356. Array.prototype.contains = function (needle) {
  357. for (i in this) {
  358. if (this[i] == needle)
  359. return true;
  360. }
  361. return false;
  362. }
  363. /**
  364. * 根据字典类型获取items
  365. * @param d_key
  366. * @returns
  367. */
  368. mobile.getDictMap = function (d_key) {
  369. if (dictMap[d_key]) {
  370. return dictMap[d_key];
  371. }
  372. };
  373. /**
  374. * 根据系统参数
  375. * @param code
  376. * @returns
  377. */
  378. mobile.getParam = function (code) {
  379. if (paramMap[code]) {
  380. return paramMap[code];
  381. } else {
  382. return "";
  383. }
  384. };
  385. /**
  386. * 根据代码和字典类型获取下拉选项的名称item{value:'1',label:'测试'}
  387. * @param d_key
  388. * @param code
  389. * @returns
  390. */
  391. mobile.getDictVal = function (key, code) {
  392. var items = dictMap[key];
  393. if (items && items.length > 0) {
  394. for (var i = 0; i < items.length; i++) {
  395. var item = items[i];
  396. if (item.dict_code == code) {
  397. return item.dict_name;
  398. break;
  399. }
  400. }
  401. }
  402. return "";
  403. }
  404. mobile.fileUploader = function(filePicker,callback,params){
  405. //添加删除事件结束
  406. var imgUploadUrl = base+'/common/upload';
  407. if(typeof params!='undefined'){
  408. imgUploadUrl = imgUploadUrl+"?"+params;
  409. }
  410. var opt={
  411. auto: true,
  412. // swf文件路径
  413. swf: base+'/static/frame/webuploader/Uploader.swf',
  414. // 文件接收服务端。
  415. server : imgUploadUrl,
  416. // 内部根据当前运行是创建,可能是input元素,也可能是flash.
  417. pick : {
  418. id : '#'+filePicker,
  419. multiple : false
  420. },
  421. //fileSingleSizeLimit: 5*1024*1024, //最大5M
  422. // 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
  423. resize : false,
  424. multiple : false,
  425. duplicate :true
  426. };
  427. if(typeof options!='undefined'){
  428. opt = $.extend(opt,options);
  429. }
  430. var uploader = WebUploader.create(opt);
  431. // 文件上传过程中提示。
  432. uploader.on( 'uploadProgress', function( file, percentage ) {
  433. //layer.msg
  434. });
  435. uploader.on( 'uploadError', function( file ) {
  436. layer.msg("上传失败");
  437. uploader.reset();
  438. });
  439. uploader.onError = function( code ) {
  440. switch(code){
  441. case 'F_EXCEED_SIZE':
  442. layer.msg('文件大小超出最大值');
  443. break;
  444. case 'Q_EXCEED_NUM_LIMIT':
  445. layer.msg('超过最大上传数量');
  446. break;
  447. case 'Q_EXCEED_SIZE_LIMIT':
  448. layer.msg('文件大小超出最大值');
  449. break;
  450. case 'Q_TYPE_DENIED':
  451. layer.msg('文件类型不允许');
  452. break;
  453. default:
  454. layer.msg('未知错误:'+code);
  455. break;
  456. }
  457. };
  458. //如果服务器端返回的code不为0,那么也是没有成功,会触发uploadError事件
  459. uploader.on("uploadAccept", function(file,data){
  460. if(!data.success){
  461. return false;
  462. }
  463. });
  464. // 文件上传成功,给item添加成功class, 用样式标记上传成功。
  465. uploader.on( 'uploadSuccess', function(file,data) {
  466. if(typeof callback=='function'){
  467. callback(data);
  468. }
  469. uploader.reset();
  470. });
  471. // 完成上传完了,成功或者失败,先删除进度条。
  472. uploader.on( 'uploadComplete', function(file,data) {
  473. });
  474. }
  475. /**
  476. * 加载图片
  477. * @param fileList 容器ID
  478. * @param data 数组类型或者字符串
  479. * @param width 图片宽度
  480. * @param height 图片高度
  481. */
  482. mobile.loadImage = function(fileList,data,width,height,editFlag){
  483. if(!width){//如果没有设置,默认为100px
  484. width=100;
  485. }
  486. if(!height){
  487. height=100;
  488. }
  489. var $list = $('#'+fileList);
  490. var arr=[];
  491. if(typeof(data) == "string"){
  492. var $li = $(
  493. '<div class="file-item thumbnail">' +
  494. '<img src="'+data+'" style="width:'+width+'px;height:'+height+'px;">' +
  495. '</div>'
  496. );
  497. if(editFlag){
  498. var $btns = $('<div class="file-panel" style="height:0px;">' +
  499. '<span class="cancel">删除</span>' +
  500. '</div>').appendTo( $li );
  501. }
  502. if(data.indexOf("flag=true")==-1){
  503. data +="&flag=true";
  504. }
  505. arr.push(data);
  506. $list.append( $li );
  507. }else{
  508. $.each(data,function(id,item){
  509. if(typeof(item) == "string"){
  510. var $li = $(
  511. '<div class="file-item thumbnail">' +
  512. '<img src="'+item+'" style="width:'+width+'px;height:'+height+'px;">' +
  513. '</div>'
  514. );
  515. if(item.indexOf("flag=true")==-1){
  516. item +="&flag=true";
  517. }
  518. arr.push(item);
  519. }else{
  520. var $li = $(
  521. '<div class="file-item thumbnail">' +
  522. '<img src="'+item.imgUrl+'" style="width:'+width+'px;height:'+height+'px;">' +
  523. '<div class="info">"'+item.imgName+'"</div>' +
  524. '</div>'
  525. );
  526. if(item.imgUrl.indexOf("flag=true")==-1){
  527. item.imgUrl +="&flag=true";
  528. }
  529. arr.push(item.imgUrl);
  530. }
  531. if(editFlag){
  532. var $btns = $('<div class="file-panel" style="height:0px;">' +
  533. '<span class="cancel">删除</span>' +
  534. '</div>').appendTo( $li );
  535. }
  536. $list.append( $li );
  537. });
  538. }
  539. $list.find("img").on('click',function(){
  540. web.showImage(arr,$(this).parent().index());
  541. });
  542. }
  543. /**
  544. * 上传图片
  545. * @param fileList 容器ID
  546. * @param filePicker 上传按钮ID
  547. * @param callback 返回方法
  548. * @param options 自定义上传
  549. * @param params 参数
  550. */
  551. mobile.imageUploader = function(fileList,filePicker,callback,options,params){
  552. $('#'+fileList).on('mouseover','.file-item',function(){
  553. $(this).find('.file-panel').css('height','30px');
  554. });
  555. $('#'+fileList).on('mouseout','.file-item',function(){
  556. $(this).find('.file-panel').css('height','0');
  557. });
  558. $('#'+fileList).on('click','.cancel',function(){
  559. $(this).parents('.file-item').remove();
  560. });
  561. //添加删除事件结束
  562. var imgUploadUrl = base+'/common/upload';
  563. if(typeof params!='undefined'){
  564. imgUploadUrl = imgUploadUrl+"?"+params;
  565. }
  566. var opt={
  567. auto: true,
  568. // swf文件路径
  569. swf: base+'/static/frame/webuploader/Uploader.swf',
  570. // 文件接收服务端。
  571. server : imgUploadUrl,
  572. // 内部根据当前运行是创建,可能是input元素,也可能是flash.
  573. pick : {
  574. id : '#'+filePicker,
  575. multiple : true
  576. },
  577. fileSingleSizeLimit: 5*1024*1024, //最大5M
  578. // 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
  579. resize : false,
  580. duplicate :true,
  581. fileNumLimit:10,
  582. accept : {
  583. title : 'Images',
  584. extensions : 'jpg,jpeg,png',
  585. mimeTypes : 'image/jpg,image/jpeg,image/png'
  586. }
  587. };
  588. if(typeof options!='undefined'){
  589. opt = $.extend(opt,options);
  590. }
  591. if(!opt.thumbnailWidth){//如果没有设置,默认为100px
  592. opt.thumbnailWidth=100;
  593. }
  594. if(!opt.thumbnailHeight){
  595. opt.thumbnailHeight=100;
  596. }
  597. var $list = $('#'+fileList);
  598. var uploader = WebUploader.create(opt);
  599. uploader.on( 'fileQueued', function( file ) {
  600. if($list.find('.image-item').length>=opt.maxLength){
  601. layer.open({content:'最多上传'+opt.maxLength+'张图片',time:3});
  602. uploader.cancelFile( file );
  603. return;
  604. }
  605. var $li = $(
  606. '<div class="image-item">'+
  607. '<div class="image-close">X</div>'+
  608. '</div>'
  609. );
  610. $list.append( $li );
  611. // 创建缩略图
  612. // 如果为非图片文件,可以不用调用此方法。
  613. // thumbnailWidth x thumbnailHeight 为 100 x 100
  614. uploader.makeThumb( file, function( error, src ) {
  615. if ( error ) {
  616. $img.replaceWith('<span>不能预览</span>');
  617. return;
  618. }
  619. $li.css("background-image","url("+src+")");
  620. }, opt.thumbnailWidth, opt.thumbnailHeight);
  621. });
  622. // 文件上传过程中创建进度条实时显示。
  623. uploader.on( 'uploadProgress', function( file, percentage ) {
  624. var $li = $( '#'+file.id );
  625. var $percent = $li.find('.progress span');
  626. // 避免重复创建
  627. if ( !$percent.length ) {
  628. $percent = $('<p class="progress"><span></span></p>')
  629. .appendTo( $li )
  630. .find('span');
  631. }
  632. $percent.css( 'width', percentage * 100 + '%' );
  633. });
  634. uploader.on( 'uploadError', function( file ,reason) {
  635. var $li = $( '#'+file.id );
  636. var $error = $li.find('div.error');
  637. // 避免重复创建
  638. if ( !$error.length ) {
  639. $error = $('<div class="error"></div>').appendTo( $li );
  640. }
  641. $error.text('上传失败');
  642. });
  643. uploader.onError = function( code ) {
  644. switch(code){
  645. case 'F_EXCEED_SIZE':
  646. layer.msg('文件大小超出最大值');
  647. break;
  648. case 'Q_EXCEED_NUM_LIMIT':
  649. layer.msg('超过最大上传数量');
  650. break;
  651. case 'Q_EXCEED_SIZE_LIMIT':
  652. layer.msg('文件大小超出最大值');
  653. break;
  654. case 'Q_TYPE_DENIED':
  655. layer.msg('文件类型不允许');
  656. break;
  657. default:
  658. layer.msg('未知错误:'+code);
  659. break;
  660. }
  661. };
  662. //如果服务器端返回的code不为0,那么也是没有成功,会触发uploadError事件
  663. uploader.on("uploadAccept", function(file,data){
  664. if(!data.success){
  665. return false;
  666. }
  667. });
  668. // 文件上传成功,给item添加成功class, 用样式标记上传成功。
  669. uploader.on( 'uploadSuccess', function(file,data) {
  670. if(typeof callback=='function'){
  671. callback(data);
  672. }
  673. });
  674. // 完成上传完了,成功或者失败,先删除进度条。
  675. uploader.on( 'uploadComplete', function(file,data) {
  676. $( '#'+file.id ).find('.progress').remove();
  677. });
  678. }
  679. /**
  680. * 上传图片
  681. * @param fileList 容器ID
  682. * @param filePicker 上传按钮ID
  683. * @param callback 返回方法
  684. * @param options 自定义上传
  685. * @param params 参数
  686. */
  687. mobile.tip=function(obj,msg,icon,top){
  688. if(!top){
  689. top="50%"
  690. }
  691. if(!icon){
  692. icon="icon-zanwushuju"
  693. }
  694. $(""+obj+"").append('<div class="center" style="top:'+top+'">'+
  695. '<div class="mui-icon iconfont '+icon+' fs44 mb10"></div><div class="fs14">'+msg+'</div></div>');
  696. }
  697. mobile.changeUrlParam=function (url, param, val){
  698. var pattern = param+'=([^&]*)';
  699. var replaceText = param+'='+val;
  700. return url.match(pattern) ? url.replace(eval('/('+ param+'=)([^&]*)/gi'), replaceText) : (url.match('[\?]') ? url+'&'+replaceText : url+'?'+replaceText);
  701. }