route.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <style>
  4. .table-tab .layui-tab-title{margin-bottom: 20px;}
  5. .layui-table-box{overflow: inherit;}
  6. .layui-table-body{overflow: inherit;}
  7. .layui-table-view td>div{overflow: inherit;}
  8. .route-wrap{display: flex;align-items: center;}
  9. .route-wrap a{margin: 0 10px;}
  10. .route-wrap .iconfont{font-size: 24px;vertical-align:bottom;cursor: pointer;}
  11. .promote-wrap{position: relative;}
  12. .qrcode-wrap {display: none;font-size: 14px;line-height: 20px;background-color: #fff;box-shadow: 0 2px 8px 0 rgba(200, 201, 204, .5);position: absolute;z-index: 2000;border-radius: 2px;top: 40px;right: 5px;transform: translateX(10px);width: 200px;margin-bottom: 20px;}
  13. .qrcode-wrap:before {right: 7px;top: -14px;border: solid transparent;content: "";height: 0;width: 0;position: absolute;pointer-events: none;border-color: transparent;border-bottom-color: #fff;border-width: 8px;}
  14. .qrcode-wrap h4{text-align: center;border-bottom: 2px solid;line-height: 40px;}
  15. .qrcode-wrap img{display: block;width: 130px;height: 130px;max-width: 100%;margin: 10px auto;}
  16. .qrcode-wrap span{display: block;text-align: center;margin-bottom: 10px;cursor: pointer;}
  17. </style>
  18. {/block}
  19. {block name="main"}
  20. <!-- 搜索框 -->
  21. <div class="single-filter-box">
  22. <div class="layui-form">
  23. <div class="layui-input-inline">
  24. <input type="text" name="search_text" placeholder="请输入页面名称" autocomplete="off" class="layui-input">
  25. <button type="button" class="layui-btn layui-btn-primary" lay-filter="search" lay-submit>
  26. <i class="layui-icon">&#xe615;</i>
  27. </button>
  28. </div>
  29. </div>
  30. </div>
  31. <table id="route_list" lay-filter="route_list"></table>
  32. <script type="text/html" id="h5_route">
  33. <div class="route-wrap">
  34. <span>{$h5_domain}{{d.wap_url}}</span>
  35. <a class="text-color" href="javascript:ns.copy('h5_route_{{d.id}}');">复制</a>
  36. <div class="promote-wrap">
  37. <span class="text-color iconfont iconerweima" data-event="qrcode" data-name="{{d.name}}" data-path="{{d.wap_url}}" onclick="showQrcode(this,'h5')"></span>
  38. <div class="qrcode-wrap" data-event="qrcode">
  39. <h4 class="border-color" data-event="qrcode">二维码</h4>
  40. <img src="" data-event="qrcode">
  41. <span class="text-color" onclick="ns.copy('h5_route_{{d.id}}')" data-event="qrcode">复制链接</span>
  42. </div>
  43. </div>
  44. <input type="hidden" id="h5_route_{{d.id}}" value="{$h5_domain}{{d.wap_url}}">
  45. </div>
  46. </script>
  47. <script type="text/html" id="weapp_route">
  48. <div class="route-wrap">
  49. <span>{{d.wap_url}}</span>
  50. <a class="text-color" href="javascript:ns.copy('weapp_route_{{d.id}}');">复制</a>
  51. <div class="promote-wrap">
  52. <span class="text-color iconfont iconerweima" data-event="qrcode" data-name="{{d.name}}" data-path="{{d.wap_url}}" onclick="showQrcode(this,'weapp')"></span>
  53. <div class="qrcode-wrap" data-event="qrcode">
  54. <h4 class="border-color" data-event="qrcode">二维码</h4>
  55. <img src="" data-event="qrcode">
  56. <span class="text-color" onclick="ns.copy('weapp_route_{{d.id}}')" data-event="qrcode">复制链接</span>
  57. </div>
  58. </div>
  59. <input type="hidden" id="weapp_route_{{d.id}}" value="{{d.wap_url}}">
  60. </div>
  61. </script>
  62. {/block}
  63. {block name="script"}
  64. <script>
  65. var form,laytpl,table,element;
  66. layui.use([ 'laytpl', 'form','element'], function () {
  67. laytpl = layui.laytpl;
  68. element = layui.element;
  69. form = layui.form;
  70. table = new Table({
  71. elem: '#route_list',
  72. url: ns.url("shop/diy/route"),
  73. cols: [[{
  74. type: 'checkbox',
  75. width: '3%'
  76. }, {
  77. width: '10%',
  78. title: '页面名称',
  79. templet: function (res) {
  80. var html = '';
  81. html += `<span>${res.title}</span>`;
  82. return html;
  83. }
  84. }, {
  85. width: '45%',
  86. title: 'H5链接',
  87. templet: '#h5_route',
  88. }, {
  89. width: '30%',
  90. title: '小程序链接',
  91. templet: '#weapp_route',
  92. }]],
  93. });
  94. /**
  95. * 搜索功能
  96. */
  97. form.on('submit(search)', function(data){
  98. table.reload({
  99. page: {
  100. curr: 1
  101. },
  102. where: data.field
  103. });
  104. });
  105. });
  106. function showQrcode(event,type) {
  107. $('.qrcode-wrap').hide();
  108. promote({name: $(event).attr('data-name'), path: $(event).attr('data-path'), app_type: type}, function (data) {
  109. if(data[type].status == 1) {
  110. var qrcode = $(event).next();
  111. qrcode.find('img').attr('src', ns.img(data[type].img));
  112. qrcode.show();
  113. }else{
  114. layer.msg(data[type].message);
  115. }
  116. });
  117. }
  118. $(document).click(function(event) {
  119. if ($(event.target).attr('data-event') !='qrcode' && $('.qrcode-wrap').not(':hidden').length) {
  120. $('.qrcode-wrap').css('display', 'none');
  121. }
  122. });
  123. // 推广链接
  124. function promote(data,callback) {
  125. $.ajax({
  126. type: "POST",
  127. url: ns.url("shop/diy/promoteRoute"),
  128. data: data,
  129. dataType: 'JSON',
  130. success: function (res) {
  131. if (res.code == 0) {
  132. if(callback) callback(res.data.path);
  133. }
  134. }
  135. });
  136. }
  137. </script>
  138. {/block}