query_card.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <div style='max-height:500px;overflow:auto;min-width:850px;'>
  2. <div class="input-group layui-row" style="margin:10px;">
  3. <input type="text" placeholder="请输入会员卡名称" id="select-url-kw" value="" class="form-control">
  4. <span class="input-group-addon btn btn-default select-btn" data-type="url">搜索</span>
  5. </div>
  6. <table class="table supplyquery table-hover supplyquery" style="min-width:850px;">
  7. <tbody>
  8. <tr>
  9. <th>会员卡名称</th>
  10. <th>原价</th>
  11. <th>现价</th>
  12. <th>有效天数</th>
  13. <th>操作</th>
  14. </tr>
  15. <?php foreach( $list as $row ){ ?>
  16. <tr>
  17. <td>{$row['cardname']}</td>
  18. <td>{$row['orignprice']}</td>
  19. <td>{$row['price']}</td>
  20. <td>{$row['expire_day']}天</td>
  21. <td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json='{:json_encode($row);}'>选择</a></td>
  22. </tr>
  23. <?php } ?>
  24. <?php if( count($list)<=0){ ?>
  25. <tr>
  26. <td colspan='5' align='center'>未找到会员卡</td>
  27. </tr>
  28. <?php } ?>
  29. </tbody>
  30. <?php if( count($list) > 0){ ?>
  31. <tfoot>
  32. <tr>
  33. <td colspan='5' align='center' id="pager_ajax">{$pager}</td>
  34. </tr>
  35. </tfoot>
  36. <?php } ?>
  37. </table>
  38. </div>
  39. <script>
  40. var query_kwd = "{$kwd}";
  41. var query_url = "{:U('user/query_card')}";
  42. var can_next = true;
  43. var member_id = "{$member['member_id']}";
  44. $(document).delegate(".choose_dan_link","click",function(){
  45. var json_obj = JSON.parse($(this).attr('data-json'));
  46. var card_id = json_obj.id;
  47. $.ajax({
  48. url:"{:U('user/open_ucard')}",
  49. type:'post',
  50. dataType:'json',
  51. data:{card_id:card_id,member_id:member_id},
  52. success:function(info){
  53. if(info.status == 0)
  54. {
  55. layer.msg(info.result.message,{icon: 1,time: 2000});
  56. }else if(info.status == 1){
  57. var go_url = location.href;
  58. if( info.result.hasOwnProperty("url") )
  59. {
  60. go_url = info.result.url;
  61. }
  62. layer.msg('操作成功',{time: 1000,
  63. end:function(){
  64. location.href = info.result.url;
  65. }
  66. });
  67. }
  68. }
  69. })
  70. layer.close(layer.index);
  71. });
  72. $(".select-btn").click(function(){
  73. query_kwd = $.trim($("#select-url-kw").val());
  74. var s_page = $(this).attr('page');
  75. if(!can_next)
  76. {
  77. return false;
  78. }
  79. can_next = false;
  80. $.ajax({
  81. url:query_url,
  82. type:'post',
  83. dataType:'json',
  84. data:{keyword:query_kwd, page:1,is_ajax:1},
  85. success:function(ret){
  86. if(ret.code == 0)
  87. {
  88. $('.supplyquery tbody').html(ret.html);
  89. $('#pager_ajax').html(ret.pager);
  90. }
  91. can_next = true;
  92. }
  93. })
  94. });
  95. $("body").delegate(".pagination a","click",function(){
  96. var s_page = $(this).attr('page');
  97. if(!can_next)
  98. {
  99. return false;
  100. }
  101. can_next = false;
  102. $.ajax({
  103. url:query_url,
  104. type:'post',
  105. dataType:'json',
  106. data:{keyword:query_kwd, page:s_page,is_ajax:1},
  107. success:function(ret){
  108. if(ret.code == 0)
  109. {
  110. $('.supplyquery tbody').html(ret.html);
  111. $('#pager_ajax').html(ret.pager);
  112. }
  113. can_next = true;
  114. }
  115. })
  116. })
  117. </script>