select.html 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <style>
  4. html,body {width: 100%;height: 100%}
  5. .store-empty {display: flex;height: 100%; align-items: center;justify-content: center}
  6. .store-wrap {display: flex;height: 100%;flex-wrap: wrap;overflow-y: auto;padding: 15px;box-sizing: border-box}
  7. .store-wrap .store-item {box-sizing: border-box;margin: 0 15px 15px 0;border: 1px solid #f5f5f5;width: calc((100% - 30px) / 3);padding: 10px;cursor: pointer;height: fit-content;}
  8. .store-wrap .store-item.active {border-color: var(--base-color);}
  9. .store-wrap .store-item .name {font-weight: bold;}
  10. .store-wrap .store-item .status {margin: 5px 0;line-height: 1;font-size: 12px}
  11. .store-wrap .store-item .address {color: #999;font-size: 12px}
  12. .store-wrap .store-item:nth-child(3n+3) {margin-right: 0}
  13. .open {color: #00A717}
  14. .close {color: #ff0000}
  15. </style>
  16. {/block}
  17. {block name="body"}
  18. {notempty name="store_list"}
  19. <div class="store-wrap">
  20. {foreach name="store_list" item="vo"}
  21. <div class="store-item {if in_array($vo.store_id, $store_id)}active{/if}" data-store="{$vo.store_id}">
  22. <div class="name">{$vo.store_name}</div>
  23. <div class="status">
  24. {if $vo.is_frozen == 1 || $vo.status == 0}
  25. <span class="close">已停业</span>
  26. {else/}
  27. <span class="open">营业中</span>
  28. {/if}
  29. </div>
  30. <div class="address">{$vo.full_address}{$vo.address}</div>
  31. </div>
  32. {/foreach}
  33. </div>
  34. {else/}
  35. <div class="store-empty">暂无可用门店</div>
  36. {/notempty}
  37. {/block}
  38. {block name="script"}
  39. <script>
  40. var storeList = {:json_encode($store_list)};
  41. $('.store-item').click(function () {
  42. if ($(this).hasClass('active')) $(this).removeClass('active');
  43. else $(this).addClass('active');
  44. })
  45. function selectStore(callback) {
  46. var store = [];
  47. $('.store-item.active').each(function () {
  48. var index = $(this).index();
  49. store.push(storeList[index])
  50. })
  51. if (typeof callback == "function") callback(store);
  52. }
  53. </script>
  54. {/block}