index.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <style>
  4. *{margin: 0;padding: 0;}
  5. li{list-style: none;}
  6. .template-list{
  7. display: flex;
  8. flex-wrap: wrap;
  9. padding: 20px;
  10. }
  11. .template-list .template-item{
  12. overflow: hidden;
  13. position: relative;
  14. padding: 12px;
  15. margin-left: 32px;
  16. margin-bottom: 32px;
  17. width: 270px;
  18. height: 440px;
  19. border: 1px solid #e9e9e9;
  20. border-radius: 4px;
  21. box-sizing: border-box;
  22. }
  23. .template-list .template-item .item-img{
  24. overflow: hidden;
  25. width: 244px;
  26. height: 355px;
  27. }
  28. .template-list .template-item .item-img img{
  29. max-width: 100%;
  30. }
  31. .template-list .template-item .item-hide{
  32. display: none;
  33. position: absolute;
  34. left: 0;
  35. right: 0;
  36. top: 0;
  37. bottom: 0;
  38. background-color: rgba(0,0,0,.6);
  39. text-align: center;
  40. }
  41. .template-list .template-item .item-name{
  42. display: block;
  43. padding-top: 7px;
  44. line-height: 22px;
  45. font-size: 14px;
  46. overflow: hidden;
  47. text-overflow: ellipsis;
  48. display: -webkit-box;
  49. -webkit-line-clamp: 2;
  50. -webkit-box-orient: vertical;
  51. }
  52. .template-list .item-hide button{
  53. position: absolute;
  54. top: 50%;
  55. left: 50%;
  56. border: 1px solid #fff;
  57. display: flex;
  58. justify-content: center;
  59. align-items: center;
  60. height: 33px;
  61. width: 100px;
  62. color: #fff;
  63. background: none;
  64. border-radius: 4px;
  65. transform: translate(-50%, -50%);
  66. cursor: pointer;
  67. }
  68. .template-list .template-item:hover .item-hide{
  69. display: block;
  70. }
  71. .template-box{
  72. position: relative;
  73. height: 100%;
  74. }
  75. .template-box .template-content{
  76. display: flex;
  77. justify-content: space-between;
  78. width: 530px;
  79. margin: auto;
  80. }
  81. .template-box .template-right{
  82. position: relative;
  83. height: 500px;
  84. width: 180px;
  85. }
  86. .template-box .template-right .right-list li {
  87. width: 82px;
  88. padding: 8px 0px;
  89. text-align: center;
  90. cursor: pointer;
  91. white-space: nowrap;
  92. overflow: hidden;
  93. text-overflow: ellipsis;
  94. }
  95. .template-box .template-right .right-list li.active{
  96. color: #fff;
  97. }
  98. .template-box .template-right .right-code{
  99. position: absolute;
  100. bottom: 0;
  101. display: flex;
  102. flex-wrap: wrap;
  103. justify-content: center;
  104. }
  105. .template-box .template-right .right-code .img{
  106. display: flex;
  107. justify-content: center;
  108. align-items: center;
  109. width: 150px;
  110. height: 150px;
  111. }
  112. .template-box .template-right .right-code .img img{
  113. max-width: 100%;
  114. max-height: 100%;
  115. }
  116. .template-box .template-right .right-code span{
  117. display: block;
  118. margin-top: 20px;
  119. line-height: 12px;
  120. font-size: 12px;
  121. text-align: center;
  122. color: #666;
  123. margin-bottom: 20px;
  124. }
  125. .template-box .template-img{
  126. padding: 37px 13px 13px;
  127. width: 250px;
  128. height: 500px;
  129. background: url('HOME_IMG/iphone_shell.png') no-repeat center / cover;
  130. overflow: hidden;
  131. box-sizing: border-box;
  132. }
  133. .template-box .template-img img{
  134. max-width: 100%;
  135. }
  136. .template-box .template-operation{
  137. position: absolute;
  138. bottom: -12px;
  139. height: 50px;
  140. text-align: center;
  141. line-height: 50px;
  142. border-top: 1px solid #e9e9e9;
  143. right: 0;
  144. left: 0;
  145. cursor: pointer;
  146. }
  147. </style>
  148. {/block}
  149. {block name="main"}
  150. <ul class="template-list">
  151. {foreach $template as $template_val}
  152. <li class="template-item">
  153. <div class="item-img">
  154. <img src="{:img($template_val.templateValue.homePage.global.previewImg)}" alt="">
  155. </div>
  156. <span class="item-name">{$template_val.templateInfo.name}</span>
  157. <div class="item-hide">
  158. <button class="finsh">装修</button>
  159. </div>
  160. <input type="hidden" name="templeCotent" value='{:json_encode($template_val.templateValue)}'>
  161. </li>
  162. {/foreach}
  163. </ul>
  164. {/block}
  165. {block name="script"}
  166. <script type="text/html" id="templateShow">
  167. <div class="template-box">
  168. <div class="template-content">
  169. <div class="template-img">
  170. <img src={{ns.img(d.global.previewImg)}} alt="">
  171. </div>
  172. <div class="template-right">
  173. <ul class="right-list">
  174. <li class="ns-bg-color active">首页</li>
  175. <li>个人中心</li>
  176. <li>商品详情</li>
  177. </ul>
  178. <div class="right-code">
  179. <div class="img">
  180. <img src="http://localhost/niushop_b2c_saas/upload/qrcode/diy/diy_qrcode_DIYVIEW_INDEX_1_h5.png" alt="">
  181. </div>
  182. <span>微信扫一扫,查看手机端效果</span>
  183. </div>
  184. </div>
  185. </div>
  186. <div class="template-operation ns-text-color">操作</div>
  187. <input type="hidden" name="showTitle" value={{JSON.stringify(d.global.title)}}>
  188. <input type="hidden" name="showValue" value={{JSON.stringify(d)}}>
  189. </div>
  190. </script>
  191. <script>
  192. var name = "{$template_val.templateInfo.name}";
  193. $("body").on('click','.template-item .finsh',function () {
  194. var data = JSON.parse($(this).parents('.template-item').find('input[name="templeCotent"]').val());
  195. layui.use('laytpl', function(){
  196. var laytpl = layui.laytpl;
  197. laytpl($("#templateShow").html()).render(data.homePage,function (html) {
  198. layer.open({
  199. type:1,
  200. title:name,
  201. area:['800px','653px'],
  202. content:html,
  203. })
  204. })
  205. });
  206. });
  207. $("body").on('click','.template-operation',function () {
  208. var value = $(this).parents(".template-box").find("input[name='showValue']").val();
  209. var title = $(this).parents(".template-box").find("input[name='showTitle']").val();
  210. $.ajax({
  211. type: 'post',
  212. url: ns.url("shop/diy/edit"),
  213. data:{
  214. name: '{$data.name}',
  215. title: title,
  216. value: value
  217. },
  218. dataType: 'JSON',
  219. success: function(res) {
  220. if (res.code >= 0){
  221. location.href = ns.url("shop/diy/index");
  222. }
  223. }
  224. });
  225. });
  226. $("body").on('click','.template-box .template-right .right-list li',function () {
  227. $(this).addClass("ns-bg-color active").siblings().removeClass("ns-bg-color active");
  228. })
  229. document.getElementById('iframe').contentWindow.location.reload(true);
  230. </script>
  231. {/block}