作者 徐治堂

首页、商品列表页,细节优化,商品列表页上拉加载未测试

@@ -88,6 +88,14 @@ class ZjGoodsController extends AdminBaseController @@ -88,6 +88,14 @@ class ZjGoodsController extends AdminBaseController
88 public function state(){ 88 public function state(){
89 if ($this->request->isAjax()){ 89 if ($this->request->isAjax()){
90 $param=input('param.'); 90 $param=input('param.');
  91 + if (empty($param['is_shove'])){
  92 + if ($param['is_shove']==2){
  93 + $num=Db::name('zj_goods')->where(['delete_time'=>0,'is_shove'=>2])->count();
  94 + if ($num>=6){
  95 + $this->error('推荐商品最多为6个');
  96 + }
  97 + }
  98 + }
91 $edit=Db::name('zj_goods')->update($param); 99 $edit=Db::name('zj_goods')->update($param);
92 if (empty($edit)){ 100 if (empty($edit)){
93 $this->error('商品状态修改失败'); 101 $this->error('商品状态修改失败');
@@ -39,8 +39,8 @@ class ZjNewsController extends AdminBaseController @@ -39,8 +39,8 @@ class ZjNewsController extends AdminBaseController
39 $arr['create_time']=time(); 39 $arr['create_time']=time();
40 if($arr['is_sta']==1){ 40 if($arr['is_sta']==1){
41 $num=Db::name('zj_news')->where(['is_sta'=>1,'delete_time'=>0])->count(); 41 $num=Db::name('zj_news')->where(['is_sta'=>1,'delete_time'=>0])->count();
42 - if ($num>=3){  
43 - $this->error('最多同时发布三条系统消息'); 42 + if ($num>=1){
  43 + $this->error('最多同时发布一条系统消息');
44 } 44 }
45 } 45 }
46 $add=Db::name('zj_news')->insert($arr); 46 $add=Db::name('zj_news')->insert($arr);
@@ -71,8 +71,8 @@ class ZjNewsController extends AdminBaseController @@ -71,8 +71,8 @@ class ZjNewsController extends AdminBaseController
71 $arr=input('param.'); 71 $arr=input('param.');
72 if($arr['is_sta']==1){ 72 if($arr['is_sta']==1){
73 $num=Db::name('zj_news')->where(['is_sta'=>1,'delete_time'=>0])->count(); 73 $num=Db::name('zj_news')->where(['is_sta'=>1,'delete_time'=>0])->count();
74 - if ($num>=3){  
75 - $this->error('最多同时发布三条系统消息'); 74 + if ($num>=1){
  75 + $this->error('最多同时发布一条系统消息');
76 } 76 }
77 } 77 }
78 $edit=Db::name('zj_news')->update($arr); 78 $edit=Db::name('zj_news')->update($arr);
@@ -92,8 +92,8 @@ class ZjNewsController extends AdminBaseController @@ -92,8 +92,8 @@ class ZjNewsController extends AdminBaseController
92 $arr=input('param.'); 92 $arr=input('param.');
93 if($arr['is_sta']==1){ 93 if($arr['is_sta']==1){
94 $num=Db::name('zj_news')->where(['is_sta'=>1,'delete_time'=>0])->count(); 94 $num=Db::name('zj_news')->where(['is_sta'=>1,'delete_time'=>0])->count();
95 - if ($num>=3){  
96 - $this->error('最多同时发布三条系统消息'); 95 + if ($num>=1){
  96 + $this->error('最多同时发布一条系统消息');
97 } 97 }
98 } 98 }
99 $edit=Db::name('zj_news')->update($arr); 99 $edit=Db::name('zj_news')->update($arr);
@@ -22,6 +22,11 @@ class GoodsController extends HomeBaseController @@ -22,6 +22,11 @@ class GoodsController extends HomeBaseController
22 $html = ''; 22 $html = '';
23 if (!empty($goodsList)) { 23 if (!empty($goodsList)) {
24 foreach ($goodsList as $item) { 24 foreach ($goodsList as $item) {
  25 + if ($item['caid']==1){
  26 + $integral='购买可获得'.$item['price']*2 .'积分';
  27 + }else{
  28 + $integral='该商品无积分奖励';
  29 + }
25 $html .= ' 30 $html .= '
26 <a href="' . url('goods/Goods/detail', ['id' => $item['id']]) . '"> 31 <a href="' . url('goods/Goods/detail', ['id' => $item['id']]) . '">
27 <div class="container_list"> 32 <div class="container_list">
@@ -37,7 +42,7 @@ class GoodsController extends HomeBaseController @@ -37,7 +42,7 @@ class GoodsController extends HomeBaseController
37 </p> 42 </p>
38 <div class="people"> 43 <div class="people">
39 <p class="people_weight"> 44 <p class="people_weight">
40 - 购买可获得40积分 45 + '. $integral .'
41 </p> 46 </p>
42 <p class="people_money">¥<span class="money">' . $item['price'] . '</span></p> 47 <p class="people_money">¥<span class="money">' . $item['price'] . '</span></p>
43 </div> 48 </div>
@@ -8,16 +8,16 @@ class GoodsModel extends Model @@ -8,16 +8,16 @@ class GoodsModel extends Model
8 8
9 public function getGoods($is_shove = null, $cid = null) 9 public function getGoods($is_shove = null, $cid = null)
10 { 10 {
11 - $map['is_sta'] = ['eq', 1];  
12 - $map['delete_time'] = ['eq', 0]; 11 + $map['g.is_sta'] = ['eq', 1];
  12 + $map['g.delete_time'] = ['eq', 0];
13 if ($cid != null) { 13 if ($cid != null) {
14 - $map['cid'] = ['eq', $cid]; 14 + $map['g.cid'] = ['eq', $cid];
15 } 15 }
16 if($is_shove != null) { 16 if($is_shove != null) {
17 - $map['is_shove'] = ['eq', $is_shove]; 17 + $map['g.is_shove'] = ['eq', $is_shove];
18 } 18 }
19 - $res = Db::name('zj_goods')->field('id,name,intro,price,thumb')  
20 - ->where($map) 19 + $res = Db::name('zj_goods')->alias('g')->join('zj_category c','g.cid=c.id')
  20 + ->field('g.id,g.name,g.intro,g.price,g.thumb,c.cid as caid')->where($map)
21 ->select()->toArray(); 21 ->select()->toArray();
22 foreach ($res as $k => $v) { 22 foreach ($res as $k => $v) {
23 $res[$k]['thumb'] = cmf_get_image_url($v['thumb']); 23 $res[$k]['thumb'] = cmf_get_image_url($v['thumb']);
@@ -17,7 +17,27 @@ class IndexController extends HomeBaseController @@ -17,7 +17,27 @@ class IndexController extends HomeBaseController
17 { 17 {
18 $goods = new GoodsModel; 18 $goods = new GoodsModel;
19 $goodsList = $goods->getGoods(2); 19 $goodsList = $goods->getGoods(2);
  20 + $id=[];
  21 + foreach ($goodsList as $k=>$v){
  22 + $id[$k]=$v['id'];
  23 + }
  24 + $num=Db::name('zj_evaluate')->where(['delete_time'=>'0','is_sta'=>'2','gid'=>['in',$id]])->group('gid')
  25 + ->field("count('gid') as num,gid")->select();
  26 + foreach ($goodsList as $k=>$v){
  27 + foreach ($num as $val){
  28 + if ($v['id']==$val['gid']){
  29 + $goodsList[$k]['eva']=$val['num'];
  30 + break;
  31 + }else{
  32 + $goodsList[$k]['eva']=0;
  33 + }
  34 + }
  35 + }
  36 +
  37 + $notice=Db::name('zj_news')->where(['delete_time'=>0,'is_sta'=>1])->find();
  38 +
20 $return = [ 39 $return = [
  40 + 'notice' => $notice,
21 'banner' => getBanner(), 41 'banner' => getBanner(),
22 'goodsList' => $goodsList 42 'goodsList' => $goodsList
23 ]; 43 ];
@@ -72,7 +72,8 @@ body,html{ @@ -72,7 +72,8 @@ body,html{
72 padding:0.23rem 0; 72 padding:0.23rem 0;
73 } 73 }
74 .text_img img{ 74 .text_img img{
75 - width:100%; 75 + width:1.2rem;
  76 + height:1.2rem;
76 border-radius: 0.1rem; 77 border-radius: 0.1rem;
77 } 78 }
78 .container_info{ 79 .container_info{
@@ -113,7 +113,8 @@ body,html{ @@ -113,7 +113,8 @@ body,html{
113 height:3.71rem; 113 height:3.71rem;
114 } 114 }
115 .good_img img{ 115 .good_img img{
116 - width:100%; 116 + width: 3.71rem;
  117 + height: 3.71rem;
117 } 118 }
118 .good_name{ 119 .good_name{
119 width:3rem; 120 width:3rem;
@@ -91,6 +91,8 @@ @@ -91,6 +91,8 @@
91 </p> 91 </p>
92 <if condition="$vo.caid eq 1"> 92 <if condition="$vo.caid eq 1">
93 <p class="inter">购买可获得{$vo.price*2}积分</p> 93 <p class="inter">购买可获得{$vo.price*2}积分</p>
  94 + <else>
  95 + <p class="inter">该商品无积分奖励</p>
94 </if> 96 </if>
95 <div class="addcart"> 97 <div class="addcart">
96 <p class="price"> 98 <p class="price">
@@ -288,7 +290,7 @@ @@ -288,7 +290,7 @@
288 window.location.href="{:url('index/index/index')}" 290 window.location.href="{:url('index/index/index')}"
289 }) 291 })
290 $(".membercenter").click(function(){ 292 $(".membercenter").click(function(){
291 - window.location.href="{:url('index/index/index')}" 293 + window.location.href="{:url('user/Center/index')}"
292 }) 294 })
293 </script> 295 </script>
294 </html> 296 </html>
@@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
41 </p> 41 </p>
42 <div class="people"> 42 <div class="people">
43 <p class="people_weight"> 43 <p class="people_weight">
44 - 购买可获得40积分 44 + <if condition="$vo.caid eq 1">购买可获得{$vo.price*2}积分<else>该商品无积分奖励</if>
45 </p> 45 </p>
46 <p class="people_money"><span class="money">{$vo.price}</span></p> 46 <p class="people_money"><span class="money">{$vo.price}</span></p>
47 </div> 47 </div>
@@ -9,6 +9,25 @@ @@ -9,6 +9,25 @@
9 <link rel="stylesheet" href="__INDEX__/css/swiper.min.css"> 9 <link rel="stylesheet" href="__INDEX__/css/swiper.min.css">
10 <script type="text/javascript" src="__INDEX__/js/base.js"></script> 10 <script type="text/javascript" src="__INDEX__/js/base.js"></script>
11 <title>天生红积分商城</title> 11 <title>天生红积分商城</title>
  12 + <style>
  13 + .notice_text{
  14 + width:6rem;
  15 + height:18px;
  16 + overflow: hidden;
  17 + margin-top: 0.15rem;
  18 + position:relative;
  19 + }
  20 + .companynotice{
  21 + height:max-content;
  22 + font-size: 0.26rem;
  23 + color:#1A1A1A;
  24 + margin-left: 0.17rem;
  25 + position:absolute;
  26 + left:0;
  27 + top:0
  28 +
  29 + }
  30 + </style>
12 </head> 31 </head>
13 <body> 32 <body>
14 <!--绑定手机号--> 33 <!--绑定手机号-->
@@ -31,7 +50,7 @@ @@ -31,7 +50,7 @@
31 <div class="swiper-wrapper"> 50 <div class="swiper-wrapper">
32 <volist name="data.banner" id="vo"> 51 <volist name="data.banner" id="vo">
33 <div class="swiper-slide"> 52 <div class="swiper-slide">
34 - <a href="{$vo.url}"><img src="{$vo.image}" alt="" ></a> 53 + <a href="{$vo.url}"><img src="{$vo.image}"></a>
35 </div> 54 </div>
36 </volist> 55 </volist>
37 </div> 56 </div>
@@ -40,17 +59,19 @@ @@ -40,17 +59,19 @@
40 </div> 59 </div>
41 <div class="notice"> 60 <div class="notice">
42 <p class="iconfont icon-laba"></p> 61 <p class="iconfont icon-laba"></p>
43 - <p class="companynotice">公司公告</p> 62 + <div class="notice_text">
  63 + <p class="companynotice">{$data.notice.title}:{$data.notice.content}</p>
  64 + </div>
44 </div> 65 </div>
45 <div class="special"> 66 <div class="special">
46 <p class="memberarea"> 67 <p class="memberarea">
47 - <a href="{:url('goods/Goods/goodsList',['cid'=>1])}"><img src="__INDEX__/img/aicon01@2x.png" alt=""></a> 68 + <a href="{:url('goods/Goods/goodsList',['cid'=>1])}"><img src="__INDEX__/img/aicon01@2x.png"></a>
48 </p> 69 </p>
49 <p class="cashzone"> 70 <p class="cashzone">
50 - <a href="{:url('goods/Goods/goodsList',['cid'=>2])}"><img src="__INDEX__/img/aicon02@2x.png" alt=""></a> 71 + <a href="{:url('goods/Goods/goodsList',['cid'=>2])}"><img src="__INDEX__/img/aicon02@2x.png"></a>
51 </p> 72 </p>
52 <p class="intergralarea"> 73 <p class="intergralarea">
53 - <a href="{:url('goods/Goods/goodsList',['cid'=>3])}"><img src="__INDEX__/img/money.png" alt=""></a> 74 + <a href="{:url('goods/Goods/goodsList',['cid'=>3])}"><img src="__INDEX__/img/money.png"></a>
54 </p> 75 </p>
55 </div> 76 </div>
56 <div class="specialword"> 77 <div class="specialword">
@@ -78,11 +99,11 @@ @@ -78,11 +99,11 @@
78 {$vo.intro} 99 {$vo.intro}
79 </p> 100 </p>
80 <p class="good_points"> 101 <p class="good_points">
81 - 购买可获得40积分 102 + <if condition="$vo.caid eq 1">购买可获得{$vo.price*2}积分<else>该商品无积分奖励</if>
82 </p> 103 </p>
83 <div class="people"> 104 <div class="people">
84 <p class="people_price"><span class="money">{$vo.price}</span></p> 105 <p class="people_price"><span class="money">{$vo.price}</span></p>
85 - <p class="people_comment">40人好评</p> 106 + <p class="people_comment">{$vo.eva}人好评</p>
86 </div> 107 </div>
87 </div> 108 </div>
88 </volist> 109 </volist>
@@ -139,11 +160,39 @@ @@ -139,11 +160,39 @@
139 }) 160 })
140 161
141 $(".shopcart").click(function(){ 162 $(".shopcart").click(function(){
142 - window.location.href='shopcar/cart.html' 163 + window.location.href="{:url('cart/zj_cart/cart')}"
143 }) 164 })
144 $(".membercenter").click(function(){ 165 $(".membercenter").click(function(){
145 window.location.href="{:url('user/Center/index')}"; 166 window.location.href="{:url('user/Center/index')}";
146 }) 167 })
  168 +
  169 + //系统消息
  170 + var otoutiaoCt=document.querySelectorAll('.companynotice')[0];
  171 + var otoutiaoC=document.querySelectorAll('.notice_text')[0];
  172 + // console.log($('.companynotice').css('height'));
  173 + // console.log(otoutiaoCt.offsetHeight);
  174 + var timer0=null;
  175 + otoutiaoCt.style.top=otoutiaoC.offsetHeight+'px';
  176 + var tt=otoutiaoC.offsetHeight;
  177 + console.log(tt)
  178 + console.log(otoutiaoCt.offsetTop);
  179 + console.log(otoutiaoCt.offsetHeight);
  180 + console.log(otoutiaoCt.style.top);
  181 + // // console.log( otoutiaoCt.style.top)
  182 + // console.log(otoutiaoCt.offsetTop)
  183 +
  184 + timer0=setInterval(function(){
  185 + if(otoutiaoCt.offsetTop<=-otoutiaoCt.offsetHeight-2){
  186 + tt=otoutiaoC.offsetHeight;
  187 + otoutiaoCt.style.top=tt +'px';
  188 + // console.log( otoutiaoCt.style.Top)
  189 + }else{
  190 + tt=tt-1;
  191 + otoutiaoCt.style.top=tt+'px';
  192 + // console.log(otoutiaoCt.offsetTop)
  193 + var ll=-otoutiaoCt.offsetHeight-2+"px";
  194 + }
  195 + },4000/60)
147 </script> 196 </script>
148 </body> 197 </body>
149 </html> 198 </html>
@@ -137,7 +137,7 @@ @@ -137,7 +137,7 @@
137 window.location.href="{:url('index/Index/index')}"; 137 window.location.href="{:url('index/Index/index')}";
138 }) 138 })
139 $(".shopcart").click(function(){ 139 $(".shopcart").click(function(){
140 - window.location.href='__INDEX__/shopcar/cart.html' 140 + window.location.href="{:url('cart/zj_cart/cart')}"
141 }) 141 })
142 </script> 142 </script>
143 </html> 143 </html>