list-xueyaji.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var category_code = null;
  3. var prescriptionCode;
  4. $(function() {
  5. Request = GetRequest();
  6. var openid = Request["openid"];
  7. prescriptionCode = Request["prescriptionCode"];
  8. category_code = Request["category_code"];
  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-xueyaji.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. }