index.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. use common\components\stringUtil;
  3. ?>
  4. <script type="text/javascript" src="/js/idangerous.swiper.min.js?version=<?= $this->context->version ?>"></script>
  5. <div class="lay-body lay-body1" id="J_MainBody">
  6. <div class="home">
  7. <div class="banner-container" style="cursor: -webkit-grab;">
  8. <div class="swiper-wrapper" style="width: 5328px; height: 500px;">
  9. <?php
  10. if(!empty($imgList)){
  11. foreach($imgList as $key => $val){
  12. if(!empty($val['img'])){
  13. ?>
  14. <div class="swiper-slide" style="width: 1332px; height: 500px;">
  15. <a href="<?php if(!empty($val['link'])){ echo $val['link']; }else{ echo 'javascript:void(0)'; } ?>"><img name="slideImg" src="<?= Yii::$app->params['imgUrl'].$val['img'] ?>" alt=""></a>
  16. </div>
  17. <?php
  18. }
  19. }}
  20. ?>
  21. </div>
  22. <div class="pagination" style="margin-left: -37px;"><span class="swiper-pagination-switch swiper-visible-switch swiper-active-switch"></span><span class="swiper-pagination-switch"></span><span class="swiper-pagination-switch"></span><span class="swiper-pagination-switch"></span></div>
  23. </div>
  24. <div class="lay-body" id="J_MainBody" style="padding-top:0px;">
  25. <div class="list">
  26. <?php
  27. if(!empty($list)){
  28. foreach($list as $val){
  29. ?>
  30. <div class="home-group">
  31. <div class="container news">
  32. <div class="pic" style="padding-top:4px;padding-left:6px;padding-right:6px;">
  33. <a href="/mobile/goods-detail?id=<?= $val['id'] ?>&account=<?php echo $_GET['account'] ?>">
  34. <img src="/images/newGrey.gif" data-original="<?= Yii::$app->params['imgUrl'].$val['cover'] ?>" alt="<?= $val['goodsName'] ?>" class="lazy">
  35. </a>
  36. </div>
  37. <div style="font-size:14px;">
  38. <div style="color:#8C8F90;"><a style="color:#8C8F90;text-decoration:none;" href="/mobile/goods-detail?id=<?= $val['id'] ?>&account=<?php echo $_GET['account'] ?>"><?= $val['goodsName'] ?></a></div>
  39. <div style="margin-top:6px;"><span style="color:red;">¥<?= $val['price'] ?></span><span style="float:right;color:#8C8F90;">销量 <?= stringUtil::calcAdd($val['sold'], $val['actualSold']) ?></span></div>
  40. </div>
  41. </div>
  42. </div>
  43. <?php
  44. }
  45. }
  46. ?>
  47. <div style="margin:0 auto;display:none;" name="loadingMore"><img style="display:block; margin:0 auto;" src="/images/loading3.gif" /></div>
  48. <script>
  49. /*banner轮播*/
  50. var mySwiper = new Swiper('.banner-container',{
  51. pagination: '.pagination',
  52. loop:true,
  53. autoplay: 6000,//可选选项,自动滑动
  54. speed: 2000,
  55. grabCursor: true,
  56. lazyLoading : true,
  57. paginationClickable: true
  58. });
  59. $('.pagination').eq(0).css({marginLeft:-$('.pagination').width()/2+'px'});
  60. $('.banner-container').on('swipeLeft', function(e){ e.stopPropagation(); });
  61. $('.banner-container').on('swipeRight', function(e){ e.stopPropagation(); });
  62. //幻灯片图片外框自适应图片大小
  63. $(window).load(function() {
  64. var thisSwiperHeight = $("img[name=slideImg]").eq(0).css('height');
  65. $('.swiper-container').css('height',thisSwiperHeight);
  66. $('.banner-container').css('height',thisSwiperHeight);
  67. });
  68. /*脚部切换产品*/
  69. (function(){
  70. function Switch(ele){
  71. this.ele = ele;
  72. this.init();
  73. }
  74. Switch.prototype = {
  75. init: function(){
  76. var that = this,
  77. ul = this.ele.find('ul').eq(0),
  78. li = this.ele.find('li'),
  79. screenWidth = $('body').width()-20;
  80. li.width( screenWidth/3 );
  81. ul.width( screenWidth/3 * li.length);
  82. this.ele.on('swipeLeft', function(e){
  83. e.stopPropagation();
  84. var ul = that.ele.find('ul').eq(0), li = that.ele.find('li');
  85. that.left(li, ul, screenWidth);
  86. });
  87. this.ele.on('swipeRight', function(e){
  88. e.stopPropagation();
  89. var ul = that.ele.find('ul').eq(0), li = that.ele.find('li');
  90. that.right(li, ul, screenWidth);
  91. });
  92. },
  93. left : function(li, ul, screenWidth){
  94. li.eq(0).animate({marginLeft: -screenWidth/3+'px'},400, '', function(){
  95. ul.append(li.eq(0)), li.eq(0).css({marginLeft:0});
  96. });
  97. },
  98. right : function(li, ul, screenWidth){
  99. li.eq(li.length-1).css({marginLeft: -screenWidth/3+'px'}), ul.prepend(li.eq(li.length-1));
  100. li.eq(li.length-1).animate({marginLeft: 0 },400);
  101. }
  102. };
  103. $.fn.switch = function(opt){
  104. opt = $.extend({}, opt);
  105. this.each(function(){
  106. return new Switch($(this));
  107. });
  108. }
  109. })();
  110. $('.J_Switch').switch();
  111. </script>
  112. <script>
  113. <?php if($this->context->isWeixin){ ?>
  114. //微信分享
  115. var shareTitle = '<?= $this->context->webTitle ?>';
  116. var descContent = '<?php echo stringUtil::subStringUtf8($this->context->webDescription,26,'…'); ?>';
  117. var lineLink = '<?= Yii::$app->request->hostInfo ?>/mobile/index?account=<?= $_GET['account'] ?>&weixinShare=yes';
  118. var imgUrl = '<?php if(!empty($this->context->merchant['logo'])){ echo Yii::$app->params['imgUrl'].$this->context->merchant['logo']; }else{ echo Yii::$app->request->hostInfo.'/images/weixinSharelogo.jpg'; } ?>'
  119. wx.config({
  120. //debug:true,
  121. appId: '<?= $this->context->signPackage['appId'] ?>',
  122. timestamp: <?= $this->context->signPackage['timestamp'] ?>,
  123. nonceStr: '<?= $this->context->signPackage['nonceStr'] ?>',
  124. signature: '<?= $this->context->signPackage['signature'] ?>',
  125. jsApiList: [
  126. 'checkJsApi',
  127. 'onMenuShareTimeline',
  128. 'onMenuShareAppMessage',
  129. 'onMenuShareQQ',
  130. 'onMenuShareWeibo',
  131. ]
  132. });
  133. wx.ready(function () {
  134. var shareData = {
  135. title: shareTitle,
  136. link: lineLink,
  137. imgUrl: imgUrl,
  138. desc:descContent,
  139. };
  140. wx.onMenuShareAppMessage(shareData);
  141. wx.onMenuShareTimeline({
  142. title: shareTitle,
  143. link: lineLink,
  144. imgUrl: imgUrl,
  145. desc:descContent,
  146. success: function () {
  147. //分享成功后的操作
  148. },
  149. cancel: function () {
  150. // 用户取消分享后执行的回调函数
  151. }
  152. });
  153. wx.onMenuShareQQ({
  154. title: shareTitle,
  155. link: lineLink,
  156. imgUrl: imgUrl,
  157. desc:descContent,
  158. success: function () {
  159. //分享成功后的操作
  160. },
  161. cancel: function () {
  162. // 用户取消分享后执行的回调函数
  163. }
  164. });
  165. wx.onMenuShareWeibo(shareData);
  166. });
  167. <?php } ?>
  168. /*幻灯片/触摸屏向下滑动隐藏/向上滑动显示*/
  169. (function(){
  170. var startX, startY, endX, endY, mainbody = $('#J_MainBody').get(0);
  171. mainbody.addEventListener('touchstart',function(event){
  172. startX = event.changedTouches[0].pageX;
  173. startY = event.changedTouches[0].pageY;
  174. });
  175. mainbody.addEventListener('touchend', function(event){
  176. endX = event.changedTouches[0].pageX;
  177. endY = event.changedTouches[0].pageY;
  178. if( (startY-endY) > 50 ){
  179. $('#J_SubHead').css({top:0});
  180. }else if( (startY-endY) < -50 ){
  181. $('#J_SubHead').css({top:'45px'});
  182. }
  183. });
  184. })();
  185. //滚动到底部请求更多商品
  186. $(document).ready(function() {
  187. $(window).scroll(function() {
  188. if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
  189. /*
  190. $("div[name=loadingMore]").css("display",'block');
  191. $.ajax({
  192. type:"GET",
  193. url:'/mobile/get-index-more?account=<?= $_GET['account'] ?>',
  194. dataType:'json',
  195. async:false,
  196. success:function(data){
  197. if(data.code == 'A0001'){
  198. }
  199. }
  200. });
  201. */
  202. }
  203. });
  204. });
  205. </script>