Няма описание

personal.js 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. mui.init();
  2. var token = localStorage.getItem("token"); //获取本地存储
  3. mui.plusReady(function() {
  4. ajaxRefresh();
  5. setTimeout(function() {
  6. clienGet();
  7. upData(); //监测版本号更新APP indexOutTime
  8. },huayi.config.indexOutTime);
  9. setInterval(function() {ajaxRefresh()},60*1000);
  10. setInterval(function() {clienGet()},huayi.config.indextime);
  11. })
  12. window.addEventListener('refreshPer', function(e) { //点返回按钮时执行刷新
  13. ajaxRefresh();
  14. });
  15. //权限判断
  16. $.ajax({
  17. data: {
  18. token: token,
  19. // pageindex: 1,
  20. // pagesize: 10,
  21. },
  22. dataType: 'json', //服务器返回json格式数据
  23. url: huayi.config.callcenter_url + '/UserAccount/GetNowUser',
  24. type: 'get', //HTTP请求类型
  25. success: function(data) {
  26. if(data.data.display == "1") {
  27. $(".addDisplay").show()
  28. } else {
  29. $(".addDisplay").hide()
  30. }
  31. var RoleCode = data.data.user.F_See;
  32. $(".F_UserName").text(data.data.user.F_UserName);
  33. localStorage.setItem("F_UserName", data.data.user.F_UserName);
  34. localStorage.setItem("F_RoleId", data.data.user.F_RoleId);
  35. localStorage.setItem("RoleCode", RoleCode);
  36. localStorage.setItem("F_See", data.data.user.F_See);
  37. $(".rolname").text(data.data.user.rolname);
  38. if(RoleCode == "0") { //调度
  39. $(".RoleCode_0").css('display', 'block')
  40. } else if(RoleCode == "1") {
  41. $(".RoleCode_1").css('display', 'block')
  42. } else if(RoleCode == "2") {
  43. $(".RoleCode_2").css('display', 'block')
  44. } else if(RoleCode == "3") {
  45. $(".RoleCode_3").css('display', 'block')
  46. } else if(RoleCode == "4") {
  47. $(".RoleCode_4").css('display', 'block')
  48. }
  49. },
  50. error: function(xhr, type, errorThrown) {
  51. //异常处理;
  52. }
  53. });
  54. //权限判断
  55. $.ajax({
  56. data: {
  57. token: token,
  58. pageindex: 1,
  59. pagesize: 10,
  60. },
  61. dataType: 'json', //服务器返回json格式数据
  62. url: huayi.config.callcenter_url + '/Rotation/Getlist',
  63. type: 'get', //HTTP请求类型
  64. success: function(data) {
  65. if(data.state="success"){
  66. // alert(JSON.stringify(data.data.modelList.length))
  67. // alert(data.data.modelList.length)
  68. $('<div class="mui-slider-item">'+
  69. '<a href="#">'+
  70. '<img src="'+data.data.modelList[0].romath+'">'+
  71. '</a>'+
  72. '</div>').appendTo('#baneSlider');
  73. $(data.data.modelList).each(function(i,n){
  74. if(n.isEnable==0){
  75. $('<div class="mui-slider-item">'+
  76. '<a href="#">'+
  77. '<img src="'+n.romath+'">'+
  78. '</a>'+
  79. '</div>').appendTo('#baneSlider');
  80. if(i==0){
  81. $('<div class="mui-indicator mui-active"></div>').appendTo('#baneQuan');
  82. }else{
  83. $('<div class="mui-indicator"></div>').appendTo('#baneQuan');
  84. }
  85. }
  86. })
  87. $('<div class="mui-slider-item">'+
  88. '<a href="#">'+
  89. '<img src="'+data.data.modelList[data.data.modelList.length-1].romath+'">'+
  90. '</a>'+
  91. '</div>').appendTo('#baneSlider');
  92. var slider = mui("#slider");
  93. slider.slider({interval: 5000});
  94. }
  95. },
  96. error: function(xhr, type, errorThrown) {
  97. //异常处理;
  98. }
  99. });
  100. function ajaxRefresh() {
  101. //权限判断
  102. $.ajax({
  103. data: {
  104. token: token,
  105. },
  106. url: huayi.config.callcenter_url + '/WorkorderApp/GetCount',
  107. dataType: 'json', //服务器返回json格式数据
  108. type: 'get', //HTTP请求类型
  109. timeout: 10000, //超时时间设置为10秒;
  110. headers: {
  111. 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
  112. },
  113. success: function(data) {
  114. if(data.DTJ == 0) {
  115. $(".DTJ").hide(); //待提交
  116. } else {
  117. $(".DTJ").text(data.DTJ); //待提交
  118. }
  119. if(data.DFP == 0) {
  120. $(".DFP").hide(); //待提交
  121. } else {
  122. $(".DFP").text(data.DFP); //待提交
  123. }
  124. if(data.DCL == 0) {
  125. $(".DCL").hide(); //待提交
  126. } else {
  127. $(".DCL").text(data.DCL); //待处理
  128. }
  129. if(data.CLZ == 0) {
  130. $(".CLZ").hide(); //待提交
  131. } else {
  132. $(".CLZ").text(data.CLZ); //处理中
  133. }
  134. if(data.YWJ == 0) {
  135. $(".YWJ").hide(); //待提交
  136. } else {
  137. $(".YWJ").text(data.YWJ); //已完结
  138. }
  139. if(data.CJSL == 0) {
  140. $(".CJSL").hide(); //待提交
  141. } else {
  142. $(".CJSL").text(data.CJSL); //抽检工单
  143. }
  144. if(data.THDTJ == 0) {
  145. $(".THDTJ").hide(); //待提交
  146. } else {
  147. $(".THDTJ").text(data.THDTJ); //退回待提交
  148. }
  149. if(data.THDFP == 0) {
  150. $(".THDFP").hide(); //待提交
  151. } else {
  152. $(".THDFP").text(data.THDFP); //退回待分配
  153. }
  154. if(data.YJGD == 0) {
  155. $(".YJGD").hide(); //待提交
  156. } else {
  157. $(".YJGD").text(data.YJGD); //一级工单
  158. }
  159. if(data.EJGD == 0) {
  160. $(".EJGD").hide(); //待提交
  161. } else {
  162. $(".EJGD").text(data.EJGD); //二级工单
  163. }
  164. if(data.SJGD == 0) {
  165. $(".SJGD").hide(); //待提交
  166. } else {
  167. $(".SJGD").text(data.SJGD); //三级工单
  168. }
  169. },
  170. error: function(xhr, type, errorThrown) {
  171. //异常处理;
  172. }
  173. });
  174. }
  175. //一级查看-待处理列表
  176. $(".work-list").on('tap', function() {
  177. var index = $(this).attr('index');
  178. mui.openWindow({
  179. id: 'Work-list',
  180. url: 'workOrder/Work-list.html',
  181. createNew: true,
  182. show: {
  183. autoShow: false
  184. },
  185. waiting: {
  186. autoShow: true //自动显示等待框,默认为true
  187. },
  188. extras: {
  189. index: index,
  190. }
  191. });
  192. })
  193. //工单等级列表
  194. $(".work-class").on('tap', function() {
  195. var importClass = $(this).attr('index');
  196. mui.openWindow({
  197. id: 'Work-listClass',
  198. url: 'workOrder/Work-listClass.html',
  199. createNew: true,
  200. show: {
  201. autoShow: false
  202. },
  203. waiting: {
  204. autoShow: true //自动显示等待框,默认为true
  205. },
  206. extras: {
  207. importClass: importClass
  208. }
  209. });
  210. })
  211. //工单等级列表
  212. $(".work-CJ").on('tap', function() {
  213. var importClass = $(this).attr('index');
  214. var choujian=$(this).attr('choujian');
  215. mui.openWindow({
  216. id: 'Work-listCJ',
  217. url: 'workOrder/Work-listCJ.html',
  218. createNew: true,
  219. show: {
  220. autoShow: false
  221. },
  222. waiting: {
  223. autoShow: true //自动显示等待框,默认为true
  224. },
  225. extras: {
  226. importClass: importClass,
  227. choujian: choujian
  228. }
  229. });
  230. })
  231. function clienGet() {
  232. var pinf = plus.push.getClientInfo();
  233. var cid = pinf.clientid;//客户端标识
  234. if (plus.device.model.indexOf('iPhone') > -1) {
  235. var apptype=2;
  236. }else{
  237. var apptype=1;
  238. }
  239. $.ajax({
  240. type: "get",
  241. url: huayi.config.callcenter_url + 'PushMessage/PutAppClientIdAsync',
  242. async: false,
  243. data: {
  244. apptype:apptype,
  245. clientid: cid,
  246. token:localStorage.getItem("token")
  247. },
  248. dataType: 'json',
  249. success: function(res) {
  250. if(res.state.toLowerCase() === "success") {
  251. }
  252. }
  253. });
  254. }
  255. function upData() {
  256. // 版本更新
  257. var Code_;
  258. var NewCode_;
  259. plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
  260. console.log("当前应用版本:" + wgtinfo.version + "---" + plus.runtime.version);
  261. localStorage.setItem("Code", wgtinfo.version) //缓存保存版本号;
  262. Code_ = localStorage.getItem("Code");
  263. $('.update').text(Code_);
  264. });
  265. if (plus.device.model.indexOf('iPhone') > -1) {
  266. typeUp=1;
  267. }else{
  268. typeUp=0;
  269. }
  270. //检查更新
  271. var server = huayi.config.callcenter_url + "ApplicationsVersion/GetAndroid"; //获取升级描述文件服务器地址
  272. mui.ajax(server, {
  273. data: {
  274. type:typeUp,
  275. isNew: true,
  276. token: token
  277. },
  278. dataType: 'json', //服务器返回json格式数据
  279. type: 'post', //HTTP请求类型
  280. timeout: 10000, //超时时间设置为10秒;
  281. headers: {
  282. 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
  283. },
  284. success: function(data) {
  285. if (data.state == "success") {
  286. NewCode_ = data.data.F_VersionCode;
  287. localStorage.setItem("Code", NewCode_);//缓存保存版本号;
  288. if(NewCode_&&Code_){
  289. if (Code_ != NewCode_) {
  290. var Codes = localStorage.setItem("Code", NewCode_);
  291. console.log(Codes);
  292. plus.nativeUI.confirm("发现新版本", function(event) {
  293. var tapIndex = event.index;
  294. if (tapIndex == 0) {
  295. if (typeUp==1) {
  296. plus.runtime.openURL(data.data.F_Url);
  297. }else{
  298. plus.runtime.openURL(data.data.FileUrl[0].F_Url);
  299. }
  300. } else {
  301. mui.toast("取消更新");
  302. }
  303. }, "提示", ["立即更新", "取消"])
  304. }
  305. }
  306. } else {
  307. mui.toast(data.message);
  308. }
  309. },
  310. error: function(data) {
  311. //异常处理;
  312. console.log(data.message);
  313. }
  314. })
  315. }