xiaoxituisongshezhil.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. mui.init();
  2. var params = {};
  3. var first = true, docInfo, teamInfo,thisTeamsId , leader;
  4. mui.plusReady(function() {
  5. getStatus();
  6. bindEvents();
  7. })
  8. //var main = plus.android.runtimeMainActivity(); //获取activity
  9. //var Intent = plus.android.importClass('android.content.Intent');
  10. //var Settings = plus.android.importClass('android.provider.Settings');
  11. //var intent = new Intent(Settings.ACTION_SOUND_SETTINGS);//显示设置,以允许配置声音和音量
  12. //var intent = new Intent(Settings.ACTION_SETTINGS);//显示系统设置
  13. //main.startActivity(intent);
  14. //页面初始请求开关状态
  15. function getStatus(){
  16. plus.nativeUI.showWaiting();
  17. sendPost('doctor/message/getMessageNoticeSetting',{}, null,function(res) {
  18. if(res.status == 200){
  19. params = res.data;
  20. var html = template("setting-tmp", res.data);
  21. document.getElementById('settingPanel').innerHTML = html;
  22. mui('.mui-switch').switch();
  23. docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  24. if(docInfo.level == 2){
  25. $("#jgs_button").show()
  26. $('.jbs_ts').show()
  27. }else{
  28. $("#jgs_button").hide()
  29. $('.jbs_ts').hide()
  30. }
  31. }else{
  32. mui.toast(res.msg);
  33. }
  34. plus.nativeUI.closeWaiting();
  35. },'GET');
  36. }
  37. //更改状态发起的请求
  38. function updateStatus(){
  39. sendPost('doctor/message/saveMessageNoticeSetting', {json: JSON.stringify(params)},
  40. null,function(res) {
  41. if(res.status == 200){
  42. }else{
  43. mui.toast(res.msg);
  44. }
  45. plus.nativeUI.closeWaiting();
  46. },'POST');
  47. }
  48. //更改状态后处理的事件
  49. function bindEvents(){
  50. $("body").on("toggle", ".mui-switch", function(e){
  51. var $this = $(this),
  52. name = $this.attr("data-name");
  53. if(e.originalEvent.detail.isActive){
  54. params[name] = 1;
  55. }else{
  56. params[name] = 0;
  57. }
  58. updateStatus();
  59. })
  60. }