list-xuetangyi.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var category_code = null;
  3. var prescriptionCode;
  4. $(function() {
  5. Request = GetRequest();
  6. prescriptionCode = Request["prescriptionCode"];
  7. category_code = Request["category_code"];
  8. var openid = Request["openid"];
  9. var userAgent = window.localStorage.getItem(agentName);
  10. if(!userAgent){
  11. window.localStorage.setItem(pageName,"{\"pageurl\":\""+window.location.href+"\"}");
  12. window.location.href = "../../home/html/zhmm-login.html?type=0&openid=" + openid;
  13. }
  14. getDevices();
  15. bindEvents();
  16. });
  17. function getDevices(){
  18. var params = {};
  19. params.category_code = category_code;
  20. d.show();
  21. sendPost("/common/device/DeviceList",params,"JSON","GET",queryListFailed,queryListSuccess);
  22. }
  23. function queryListSuccess(res){
  24. d.close();
  25. if(res.status==200){
  26. if(res.data&&res.data.length>0){
  27. var html = template('list-tmp', {list: res.data});
  28. $("#list").empty().append(html);
  29. }else{
  30. $("#list").hide();
  31. $(".div-no-info").show();
  32. // dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'无更多设备!'}).show();
  33. }
  34. }else{
  35. queryListFailed(res);
  36. }
  37. }
  38. function bindEvents(){
  39. template.helper("getPhoto", function(str){
  40. return getImgUrl(str);
  41. });
  42. $("#list").on('click', 'li', function(){
  43. var $this = $(this),
  44. id = $this.attr("data-id");
  45. location.href="edit-xuetangyi.html?deviceId="+id+"&prescriptionCode="+prescriptionCode;
  46. })
  47. }
  48. function queryListFailed(res) {
  49. d.close();
  50. if (res && res.msg) {
  51. dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true, content:res.msg}).show();
  52. } else {
  53. dialog({contentType:'tipsbox', skin:'bk-popup' ,bottom:true, content:'加载设备型号列表失败'}).show();
  54. }
  55. }