Ei kuvausta

personal.js 8.5KB

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