🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 商品详情 商品详情 文件路径:shop/controllers/Goods/GoodsCtl.php; ##### 后台数据: 商品信息(商品活动信息,评论数,销售数,咨询数): ``` <pre class="calibre14">``` $goods_detail <span class="token">=</span> $Goods_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getGoodsDetailInfoByGoodId</span><span class="token1">(</span>$goods_id<span class="token1">)</span><span class="token1">;</span> ``` ``` 计算商品的销售数量: 1.直接显示本件商品的销售数量,2.显示本类common商品的销售数量 ``` <pre class="calibre14">``` $common_goods <span class="token">=</span> $Goods_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getByWhere</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span><span class="token4">'common_id'</span> <span class="token">=</span><span class="token">></span> $goods_detail<span class="token1">[</span><span class="token4">'goods_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'common_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span> $count_sale <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span> foreach <span class="token1">(</span>$common_goods as $comkey <span class="token">=</span><span class="token">></span> $comval<span class="token1">)</span> <span class="token1">{</span> $count_sale <span class="token">+</span><span class="token">=</span> $comval<span class="token1">[</span><span class="token4">'goods_salenum'</span><span class="token1">]</span><span class="token1">;</span> <span class="token1">}</span> $goods_detail<span class="token1">[</span><span class="token4">'goods_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'count_sale'</span><span class="token1">]</span> <span class="token">=</span> $count_sale<span class="token1">;</span> ``` ``` 获取商品所在地: ``` <pre class="calibre14">``` $goods_location_row <span class="token">=</span> $Base_DistrictModel<span class="token">-</span><span class="token">></span><span class="token3">getByWhere</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span><span class="token4">'district_id:IN'</span> <span class="token">=</span><span class="token">></span> $goods_detail<span class="token1">[</span><span class="token4">'common_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'common_location'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span> ``` ``` 店铺信息: ``` <pre class="calibre14">``` $shop_detail <span class="token">=</span> $Shop_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getShopDetail</span><span class="token1">(</span>$goods_detail<span class="token1">[</span><span class="token4">'goods_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'shop_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> ``` ``` 查找店铺下的实体店铺 ``` <pre class="calibre14">``` $entity_shop <span class="token">=</span> $Shop_EntityModel<span class="token">-</span><span class="token">></span><span class="token3">getByWhere</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span><span class="token4">"shop_id"</span> <span class="token">=</span><span class="token">></span> $goods_detail<span class="token1">[</span><span class="token4">'goods_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'shop_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span> ``` ``` 推荐商品 ``` <pre class="calibre14">``` $data_foot_recommon <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">listByWhere</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span> <span class="token4">'shop_id'</span> <span class="token">=</span><span class="token">></span> $shop_id <span class="token1">)</span><span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token4">'common_is_recommend'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'DESC'</span><span class="token1">)</span><span class="token1">,</span> <span class="token6">0</span><span class="token1">,</span> <span class="token6">5</span><span class="token1">)</span><span class="token1">;</span> $data_foot_recommon_goods <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">getRecommonRow</span><span class="token1">(</span>$data_foot_recommon<span class="token1">)</span><span class="token1">;</span> ``` ``` 热门销售 ``` <pre class="calibre14">``` $data_hot_salle <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">getHotSalle</span><span class="token1">(</span>$shop_id<span class="token1">,</span> $is_wap<span class="token1">)</span><span class="token1">;</span> $data_salle <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">getRecommonRow</span><span class="token1">(</span>$data_hot_salle<span class="token1">)</span><span class="token1">;</span> ``` ``` 热门收藏 ``` <pre class="calibre14">``` $data_hot_collect <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">getHotCollect</span><span class="token1">(</span>$shop_id<span class="token1">)</span><span class="token1">;</span> $data_collect <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">getRecommonRow</span><span class="token1">(</span>$data_hot_collect<span class="token1">)</span><span class="token1">;</span> ``` ``` 商品咨询数量 ``` <pre class="calibre14">``` $Consult_BaseModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Consult_BaseModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $data_consult <span class="token">=</span> $Consult_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getByWhere</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span> <span class="token4">'goods_id'</span> <span class="token">=</span><span class="token">></span> $goods_id<span class="token1">,</span> <span class="token4">'shop_id'</span> <span class="token">=</span><span class="token">></span> $shop_id <span class="token1">)</span><span class="token1">)</span><span class="token1">;</span> $consult_num <span class="token">=</span> <span class="token3">count</span><span class="token1">(</span>$data_consult<span class="token1">)</span><span class="token1">;</span> ``` ``` 首页名 ``` <pre class="calibre14">``` $title <span class="token">=</span> Web_ConfigModel<span class="token1">:</span><span class="token1">:</span><span class="token3">value</span><span class="token1">(</span><span class="token4">"product_title"</span><span class="token1">)</span><span class="token1">;</span> ``` ``` 关键字 ``` <pre class="calibre14">``` $this<span class="token">-</span><span class="token">></span>keyword <span class="token">=</span> Web_ConfigModel<span class="token1">:</span><span class="token1">:</span><span class="token3">value</span><span class="token1">(</span><span class="token4">"product_keyword"</span><span class="token1">)</span><span class="token1">;</span> ``` ``` 描述 ``` <pre class="calibre14">``` $this<span class="token">-</span><span class="token">></span>description <span class="token">=</span> Web_ConfigModel<span class="token1">:</span><span class="token1">:</span><span class="token3">value</span><span class="token1">(</span><span class="token4">"product_description"</span><span class="token1">)</span><span class="token1">;</span> ``` ``` QQ: ``` <pre class="calibre14">``` $service<span class="token1">[</span>$key<span class="token1">]</span><span class="token1">[</span><span class="token4">"tool"</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">"<a target='_blank' href='http://wpa.qq.com/msgrd?v=3&uin="</span><span class="token1">.</span>$val<span class="token1">[</span><span class="token4">'number'</span><span class="token1">]</span><span class="token1">.</span><span class="token4">"&site=qq&menu=yes'><img border='0' src='http://wpa.qq.com/pa?p=2:"</span><span class="token1">.</span>$val<span class="token1">[</span><span class="token4">'number'</span><span class="token1">]</span><span class="token1">.</span><span class="token4">":41 &amp;r=0.22914223582483828' alt='点击这里'></a>"</span><span class="token1">;</span> ``` ``` 旺旺: ``` <pre class="calibre14">``` $service<span class="token1">[</span>$key<span class="token1">]</span><span class="token1">[</span><span class="token4">"tool"</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">"<a target='_blank' href='http://www.taobao.com/webww/ww.php?ver=3&amp;touid="</span><span class="token1">.</span>$val<span class="token1">[</span><span class="token4">'number'</span><span class="token1">]</span><span class="token1">.</span><span class="token4">"&amp;siteid=cntaobao&amp;status=1&amp;charset=utf-8' ><img border='0' src='http://amos.alicdn.com/online.aw?v=2&amp;uid="</span><span class="token1">.</span>$val<span class="token1">[</span><span class="token4">'number'</span><span class="token1">]</span><span class="token1">.</span><span class="token4">"&amp;site=cntaobao&s=1&amp;charset=utf-8' alt='点击这里' /></a>"</span><span class="token1">;</span> ``` ``` IM: ``` <pre class="calibre14">``` $service<span class="token1">[</span>$key<span class="token1">]</span><span class="token1">[</span><span class="token4">"tool"</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'<a href="javascript:;" class="chat-enter" onclick="return chat(\''</span><span class="token1">.</span>$val<span class="token1">[</span><span class="token4">'number'</span><span class="token1">]</span><span class="token1">.</span><span class="token4">'\');"><img src="'</span><span class="token1">.</span>$this<span class="token">-</span><span class="token">></span>view<span class="token">-</span><span class="token">></span>img<span class="token1">.</span><span class="token4">'/icon-im.gif" alt=""></a>'</span><span class="token1">;</span> ``` ``` 物流和运费信息: ``` <pre class="calibre14">``` $cookie_area <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">getCookieArea</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> <span class="token2">if</span><span class="token1">(</span>$cookie_area<span class="token1">[</span><span class="token4">'city'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">{</span> $transportInfo <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">getTramsportData</span><span class="token1">(</span>$cookie_area<span class="token1">[</span><span class="token4">'city'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'id'</span><span class="token1">]</span><span class="token1">,</span> $goods_detail<span class="token1">[</span><span class="token4">'goods_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'common_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> $transportInfo<span class="token1">[</span><span class="token4">'area'</span><span class="token1">]</span> <span class="token">=</span> $cookie_area<span class="token1">[</span><span class="token4">'area'</span><span class="token1">]</span><span class="token1">;</span> $transportInfo<span class="token1">[</span><span class="token4">'area_id'</span><span class="token1">]</span> <span class="token">=</span> $cookie_area<span class="token1">[</span><span class="token4">'city'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'id'</span><span class="token1">]</span><span class="token1">;</span> <span class="token1">}</span><span class="token2">else</span><span class="token1">{</span> $transportInfo <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> $goods_detail<span class="token1">[</span><span class="token4">'transport'</span><span class="token1">]</span> <span class="token">=</span> $transportInfo<span class="token1">;</span> ``` ``` wap端: ``` <pre class="calibre14">``` <span class="token5">//商品规格描述</span> $show_goods_spec_value <span class="token">=</span> <span class="token3">array_values</span><span class="token1">(</span>$goods_detail<span class="token1">[</span><span class="token4">'goods_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'goods_spec'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//商品详情</span> $goods_info <span class="token">=</span> <span class="token3">array_merge</span><span class="token1">(</span>$goods_detail<span class="token1">[</span><span class="token4">'common_base'</span><span class="token1">]</span><span class="token1">,</span> $goods_detail<span class="token1">[</span><span class="token4">'goods_base'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//好评率</span> $all_count <span class="token">=</span> $Goods_EvaluationModel<span class="token">-</span><span class="token">></span><span class="token3">countEvaluation</span><span class="token1">(</span>$common_id<span class="token1">,</span> <span class="token4">'all'</span><span class="token1">)</span><span class="token1">;</span> $good_count <span class="token">=</span> $Goods_EvaluationModel<span class="token">-</span><span class="token">></span><span class="token3">countEvaluation</span><span class="token1">(</span>$goods_detail<span class="token1">[</span><span class="token4">'common_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'common_id'</span><span class="token1">]</span><span class="token1">,</span> <span class="token4">'good'</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//配送信息</span> $goods_hair_info<span class="token1">[</span><span class="token4">'content'</span><span class="token1">]</span> <span class="token">=</span> $goods_detail<span class="token1">[</span><span class="token4">'shop_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'shipping'</span><span class="token1">]</span><span class="token1">;</span> $goods_hair_info<span class="token1">[</span><span class="token4">'store'</span><span class="token1">]</span> <span class="token">=</span> $goods_detail<span class="token1">[</span><span class="token4">'goods_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'goods_stock'</span><span class="token1">]</span><span class="token1">;</span> <span class="token5">//定位</span> $user_lbs_geo <span class="token">=</span> $subSiteModel<span class="token">-</span><span class="token">></span><span class="token3">getLbsGeo</span><span class="token1">(</span>$lbs_geo<span class="token1">,</span>$level<span class="token1">)</span><span class="token1">;</span> <span class="token5">//获取默认配送区域运费</span> $transportInfo <span class="token">=</span> $Goods_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getTransportInfo</span><span class="token1">(</span>$user_lbs_geo<span class="token1">[</span><span class="token4">'district_id'</span><span class="token1">]</span><span class="token1">,</span> $goods_detail<span class="token1">[</span><span class="token4">'common_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'common_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//图片信息</span> <span class="token2">if</span> <span class="token1">(</span> <span class="token3">isset</span><span class="token1">(</span>$goods_detail<span class="token1">[</span><span class="token4">'goods_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'image_row'</span><span class="token1">]</span><span class="token1">)</span> <span class="token">&&</span> <span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$goods_detail<span class="token1">[</span><span class="token4">'goods_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'image_row'</span><span class="token1">]</span><span class="token1">)</span> <span class="token1">)</span> <span class="token1">{</span> $images_list <span class="token">=</span> <span class="token3">array_column</span><span class="token1">(</span>$goods_detail<span class="token1">[</span><span class="token4">'goods_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'image_row'</span><span class="token1">]</span><span class="token1">,</span> <span class="token4">'images_image'</span><span class="token1">)</span><span class="token1">;</span> $images_list <span class="token">=</span> <span class="token3">array_map</span><span class="token1">(</span><span class="token2">function</span> <span class="token1">(</span>$img<span class="token1">)</span> <span class="token1">{</span> <span class="token2">return</span> <span class="token3">image_thumb</span><span class="token1">(</span>$img<span class="token1">,</span> <span class="token6">360</span><span class="token1">,</span> <span class="token6">360</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span><span class="token1">,</span> $images_list<span class="token1">)</span><span class="token1">;</span> $goods_image <span class="token">=</span> <span class="token3">implode</span><span class="token1">(</span><span class="token4">','</span><span class="token1">,</span> $images_list<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> $goods_image <span class="token">=</span> $goods_detail<span class="token1">[</span><span class="token4">'goods_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'goods_image'</span><span class="token1">]</span><span class="token1">;</span> <span class="token1">}</span> <span class="token5">//满送</span> $mansong_info <span class="token">=</span> $goods_detail<span class="token1">[</span><span class="token4">'mansong_info'</span><span class="token1">]</span><span class="token1">;</span> <span class="token5">//商品规格</span> $spec_list <span class="token">=</span> $Goods_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">createSGIdByWap</span><span class="token1">(</span>$goods_detail<span class="token1">[</span><span class="token4">'common_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'common_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//商品规格颜色图</span> <span class="token2">if</span> <span class="token1">(</span> <span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$goods_detail<span class="token1">[</span><span class="token4">'common_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'common_spec_value_color'</span><span class="token1">]</span><span class="token1">)</span> <span class="token1">)</span> <span class="token1">{</span> $spec_image <span class="token">=</span> $goods_detail<span class="token1">[</span><span class="token4">'common_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'common_spec_value_color'</span><span class="token1">]</span><span class="token1">;</span> <span class="token1">}</span> $data<span class="token1">[</span><span class="token4">'goods_id'</span><span class="token1">]</span> <span class="token">=</span> $goods_id<span class="token1">;</span> $data<span class="token1">[</span><span class="token4">'goods_info'</span><span class="token1">]</span> <span class="token">=</span> $goods_info<span class="token1">;</span> <span class="token5">//商品详情</span> $data<span class="token1">[</span><span class="token4">'goods_commend_list'</span><span class="token1">]</span> <span class="token">=</span> $data_salle<span class="token1">;</span> <span class="token5">//推荐商品(销量)</span> $data<span class="token1">[</span><span class="token4">'goods_eval_list'</span><span class="token1">]</span> <span class="token">=</span> $goods_eval_list<span class="token1">;</span> <span class="token5">//商品评论</span> $data<span class="token1">[</span><span class="token4">'goods_evaluate_info'</span><span class="token1">]</span> <span class="token">=</span> $goods_evaluate_info<span class="token1">;</span> <span class="token5">//商品评论</span> $data<span class="token1">[</span><span class="token4">'goods_hair_info'</span><span class="token1">]</span> <span class="token">=</span> $goods_hair_info<span class="token1">;</span> <span class="token5">//售卖区域</span> $data<span class="token1">[</span><span class="token4">'goods_image'</span><span class="token1">]</span> <span class="token">=</span> $goods_image<span class="token1">;</span> <span class="token5">//商品图片</span> $data<span class="token1">[</span><span class="token4">'mansong_info'</span><span class="token1">]</span> <span class="token">=</span> $mansong_info<span class="token1">;</span> <span class="token5">//商品满送</span> $data<span class="token1">[</span><span class="token4">'spec_list'</span><span class="token1">]</span> <span class="token">=</span> $spec_list<span class="token1">;</span> <span class="token5">//商品规格</span> $data<span class="token1">[</span><span class="token4">'stock_list'</span><span class="token1">]</span> <span class="token">=</span> $stock_list<span class="token1">;</span> <span class="token5">//规格库存</span> $data<span class="token1">[</span><span class="token4">'spec_image'</span><span class="token1">]</span> <span class="token">=</span> $spec_image<span class="token1">;</span> <span class="token5">//商品颜色</span> $data<span class="token1">[</span><span class="token4">'store_info'</span><span class="token1">]</span> <span class="token">=</span> $store_info<span class="token1">;</span> <span class="token5">//店铺信息</span> $data<span class="token1">[</span><span class="token4">'buyer_limit'</span><span class="token1">]</span> <span class="token">=</span> $goods_detail<span class="token1">[</span><span class="token4">'buy_limit'</span><span class="token1">]</span><span class="token1">;</span> <span class="token5">//限购数量</span> $data<span class="token1">[</span><span class="token4">'is_favorate'</span><span class="token1">]</span> <span class="token">=</span> $isFavoritesGoods<span class="token1">;</span> <span class="token5">//是否收藏过商品</span> $data<span class="token1">[</span><span class="token4">'shop_owner'</span><span class="token1">]</span> <span class="token">=</span> $shop_owner<span class="token1">;</span> <span class="token5">//是否为店主</span> $data<span class="token1">[</span><span class="token4">'isBuyHave'</span><span class="token1">]</span> <span class="token">=</span> $IsHaveBuy<span class="token1">;</span> <span class="token5">//是否已达限购数量</span> $data<span class="token1">[</span><span class="token4">'good_pre'</span><span class="token1">]</span> <span class="token">=</span> $good_pre<span class="token1">;</span> <span class="token5">//好评率</span> <span class="token2">if</span><span class="token1">(</span>Web_ConfigModel<span class="token1">:</span><span class="token1">:</span><span class="token3">value</span><span class="token1">(</span><span class="token4">'Plugin_Directseller'</span><span class="token1">)</span><span class="token1">)</span> <span class="token1">{</span> $data<span class="token1">[</span><span class="token4">'rec_images'</span><span class="token1">]</span> <span class="token">=</span> $goods_detail<span class="token1">[</span><span class="token4">'recImages'</span><span class="token1">]</span><span class="token1">;</span><span class="token5">//推荐者上传图片</span> <span class="token1">}</span> <span class="token5">//获取商品的促销信息</span> $promotion_info <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">getPromotionInfo</span><span class="token1">(</span>$goods_id<span class="token1">)</span><span class="token1">;</span> $data<span class="token1">[</span><span class="token4">'promotion_info'</span><span class="token1">]</span> <span class="token">=</span> $promotion_info<span class="token1">;</span> ``` ``` ##### 前台显示: 面包屑导航: ``` <pre class="calibre14">``` <span class="token"><</span><span class="token">?</span>php <span class="token2">if</span><span class="token1">(</span>$parent_cat<span class="token1">)</span><span class="token1">{</span><span class="token">?</span><span class="token">></span> <span class="token"><</span><span class="token">?</span>php <span class="token3">foreach</span><span class="token1">(</span>$parent_cat as $catkey <span class="token">=</span><span class="token">></span> $catval<span class="token1">)</span><span class="token1">:</span><span class="token">?</span><span class="token">></span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"<?= Yf_Registry::get('url') ?>?ctl=Goods_Goods&met=goodslist&cat_id=<?=($catval['cat_id'])?>"</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token1">(</span>$catval<span class="token1">[</span><span class="token4">'cat_name'</span><span class="token1">]</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>a<span class="token">></span><span class="token"><</span><span class="token">?</span>php <span class="token2">if</span><span class="token1">(</span><span class="token">!</span><span class="token3">isset</span><span class="token1">(</span>$catval<span class="token1">[</span><span class="token4">'ext'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">)</span><span class="token1">{</span> <span class="token">?</span><span class="token">></span><span class="token"><</span>i class<span class="token">=</span><span class="token4">"iconfont icon-iconjiantouyou"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<span class="token">></span><span class="token"><</span><span class="token">?</span>php <span class="token1">}</span><span class="token">?</span><span class="token">></span> <span class="token"><</span><span class="token">?</span>php endforeach<span class="token1">;</span><span class="token">?</span><span class="token">></span> <span class="token"><</span><span class="token">?</span>php <span class="token1">}</span><span class="token">?</span><span class="token">></span> ``` ``` 二维码: ``` <pre class="calibre14">``` <span class="token2">function</span> <span class="token3">lazyload</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span> $<span class="token1">(</span><span class="token4">"img.lazy"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">lazyload</span><span class="token1">(</span><span class="token1">{</span> effect<span class="token1">:</span> <span class="token4">"fadeIn"</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">'img.lazy'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">on</span><span class="token1">(</span><span class="token4">'load'</span><span class="token1">,</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span> $<span class="token1">(</span>window<span class="token1">)</span><span class="token1">.</span><span class="token3">trigger</span><span class="token1">(</span><span class="token4">'scroll'</span><span class="token1">)</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> ``` ``` 商品数量加减: ``` <pre class="calibre14">``` g<span class="token1">.</span><span class="token3">bind</span><span class="token1">(</span><span class="token4">"click"</span><span class="token1">,</span><span class="token2">function</span><span class="token1">(</span>l<span class="token1">)</span><span class="token1">{</span> <span class="token2">if</span><span class="token1">(</span><span class="token">!</span>$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">hasClass</span><span class="token1">(</span><span class="token4">"no_reduce"</span><span class="token1">)</span><span class="token1">)</span><span class="token1">{</span> var j<span class="token">=</span><span class="token3">parseInt</span><span class="token1">(</span>h<span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span><span class="token6">10</span><span class="token1">)</span><span class="token">||</span><span class="token6">1</span><span class="token1">;</span> <span class="token2">if</span><span class="token1">(</span>$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">hasClass</span><span class="token1">(</span><span class="token4">"add"</span><span class="token1">)</span><span class="token">&&</span><span class="token">!</span>$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">hasClass</span><span class="token1">(</span><span class="token4">"no_add"</span><span class="token1">)</span><span class="token1">)</span><span class="token1">{</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">prev</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">prev</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">"class"</span><span class="token1">,</span><span class="token4">"reduce"</span><span class="token1">)</span><span class="token1">;</span> <span class="token2">if</span><span class="token1">(</span>f<span class="token">>=</span>i<span class="token">&&</span>j<span class="token">>=</span>f<span class="token1">)</span><span class="token1">{</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">"class"</span><span class="token1">,</span><span class="token4">"no_add"</span><span class="token1">)</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> j<span class="token">++</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span><span class="token2">else</span><span class="token1">{</span> <span class="token2">if</span><span class="token1">(</span>$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">hasClass</span><span class="token1">(</span><span class="token4">"reduce"</span><span class="token1">)</span><span class="token">&&</span><span class="token">!</span>$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">hasClass</span><span class="token1">(</span><span class="token4">"no_reduce"</span><span class="token1">)</span><span class="token1">)</span><span class="token1">{</span> j<span class="token">--</span><span class="token1">;</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">next</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">next</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">"class"</span><span class="token1">,</span><span class="token4">"add"</span><span class="token1">)</span><span class="token1">;</span> j<span class="token"><=</span>i<span class="token">&&</span>$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">"class"</span><span class="token1">,</span><span class="token4">"no_reduce"</span><span class="token1">)</span> <span class="token1">}</span> <span class="token1">}</span> h<span class="token1">.</span><span class="token3">val</span><span class="token1">(</span>j<span class="token1">)</span><span class="token1">.</span><span class="token3">trigger</span><span class="token1">(</span><span class="token4">"propertychange"</span><span class="token1">)</span> <span class="token1">}</span> <span class="token1">}</span><span class="token1">)</span> ``` ``` 加入购物车: ``` <pre class="calibre14">``` $<span class="token1">.</span><span class="token3">ajax</span><span class="token1">(</span><span class="token1">{</span> url<span class="token1">:</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Buyer_Cart&met=addCart&typ=json'</span><span class="token1">,</span> data<span class="token1">:</span> <span class="token1">{</span>goods_id<span class="token1">:</span>goods_id<span class="token1">,</span> goods_num<span class="token1">:</span> goods_num<span class="token1">}</span><span class="token1">,</span> dataType<span class="token1">:</span> <span class="token4">"json"</span><span class="token1">,</span> contentType<span class="token1">:</span> <span class="token4">"application/json;charset=utf-8"</span><span class="token1">,</span> async<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span> success<span class="token1">:</span> <span class="token2">function</span> <span class="token1">(</span>a<span class="token1">)</span> <span class="token1">{</span> <span class="token2">if</span> <span class="token1">(</span>a<span class="token1">.</span>status <span class="token">==</span> <span class="token6">250</span><span class="token1">)</span> <span class="token1">{</span> Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">error</span><span class="token1">(</span>a<span class="token1">.</span>msg<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> <span class="token5">//加入购物车成功后,修改购物车数量</span> $<span class="token1">.</span><span class="token3">ajax</span><span class="token1">(</span><span class="token1">{</span> type<span class="token1">:</span> <span class="token4">"GET"</span><span class="token1">,</span> url<span class="token1">:</span> SITE_URL <span class="token">+</span> <span class="token4">"?ctl=Buyer_Cart&met=getCartGoodsNum&typ=json"</span><span class="token1">,</span> data<span class="token1">:</span> <span class="token1">{</span><span class="token1">}</span><span class="token1">,</span> dataType<span class="token1">:</span> <span class="token4">"json"</span><span class="token1">,</span> success<span class="token1">:</span> <span class="token2">function</span><span class="token1">(</span>data<span class="token1">)</span><span class="token1">{</span> <span class="token3">getCartList</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">'#cart_num'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">html</span><span class="token1">(</span>data<span class="token1">.</span>data<span class="token1">.</span>cart_count<span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">'.cart_num_toolbar'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">html</span><span class="token1">(</span>data<span class="token1">.</span>data<span class="token1">.</span>cart_count<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> $<span class="token1">.</span><span class="token3">dialog</span><span class="token1">(</span><span class="token1">{</span> title<span class="token1">:</span> <span class="token4">"<?=__('加入购物车')?>"</span><span class="token1">,</span> height<span class="token1">:</span> <span class="token6">100</span><span class="token1">,</span> width<span class="token1">:</span> <span class="token6">250</span><span class="token1">,</span> lock<span class="token1">:</span> <span class="token6">true</span><span class="token1">,</span> drag<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span> content<span class="token1">:</span> <span class="token4">'url: '</span><span class="token">+</span>SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Buyer_Cart&met=add&typ=e'</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span><span class="token1">,</span> failure<span class="token1">:</span> <span class="token2">function</span> <span class="token1">(</span>a<span class="token1">)</span> <span class="token1">{</span> Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">error</span><span class="token1">(</span><span class="token4">'<?=__('</span>操作失败!<span class="token4">')?>'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//判断商品是否满足限购条件,如果限时折扣设置最低购买数量大于商品本身限购数,按照限时折扣最低数量计算</span> <span class="token2">if</span><span class="token1">(</span>$goods_xianshi <span class="token">&&</span> $goods_num <span class="token"><</span> $goods_xianshi<span class="token1">[</span><span class="token4">'goods_lower_limit'</span><span class="token1">]</span> <span class="token">&&</span> <span class="token3">strtotime</span><span class="token1">(</span>$goods_xianshi<span class="token1">[</span><span class="token4">'goods_start_time'</span><span class="token1">]</span><span class="token1">)</span> <span class="token"><=</span> <span class="token3">time</span><span class="token1">(</span><span class="token1">)</span> <span class="token">&&</span> <span class="token3">strtotime</span><span class="token1">(</span>$goods_xianshi<span class="token1">[</span><span class="token4">'goods_end_time'</span><span class="token1">]</span><span class="token1">)</span> <span class="token">>=</span> <span class="token3">time</span><span class="token1">(</span><span class="token1">)</span><span class="token1">)</span> <span class="token1">{</span> <span class="token2">return</span> $this<span class="token">-</span><span class="token">></span>data<span class="token">-</span><span class="token">></span><span class="token3">setError</span><span class="token1">(</span><span class="token4">"添加失败,低于最低购买数量"</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token5">//如果该商品限购,查出用户之前购买过的商品数量,当前添加购物车数量与之前购买数量相加不能超过限购数</span> <span class="token2">if</span><span class="token1">(</span>$goods_num_sum <span class="token">+</span> $goods_num<span class="token">></span> $goods_limit_num<span class="token1">)</span> <span class="token1">{</span> <span class="token2">return</span> $this<span class="token">-</span><span class="token">></span>data<span class="token">-</span><span class="token">></span><span class="token3">setError</span><span class="token1">(</span><span class="token4">"添加失败,超出限购数量"</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token5">//如果是供货商的商品</span> <span class="token5">//分销商申请是否通过</span> <span class="token2">if</span><span class="token1">(</span><span class="token">!</span>$shopDistributorBase<span class="token1">[</span><span class="token4">'distributor_enable'</span><span class="token1">]</span><span class="token1">)</span> <span class="token1">{</span> <span class="token2">return</span> $this<span class="token">-</span><span class="token">></span>data<span class="token">-</span><span class="token">></span><span class="token3">setError</span><span class="token1">(</span><span class="token4">"分销申请未通过!"</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">if</span><span class="token1">(</span><span class="token">!</span><span class="token3">array_intersect</span><span class="token1">(</span>$common_shopcat_id<span class="token1">,</span> $allow_shop_cat<span class="token1">)</span> <span class="token1">)</span> <span class="token1">{</span> <span class="token2">return</span> $this<span class="token">-</span><span class="token">></span>data<span class="token">-</span><span class="token">></span><span class="token3">setError</span><span class="token1">(</span><span class="token4">"该分类未授权"</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token5">//判断购物车中是否存在该商品</span> <span class="token2">if</span><span class="token1">(</span><span class="token3">is_array</span><span class="token1">(</span>$cart_row<span class="token1">)</span> <span class="token">&&</span> $cart_row<span class="token1">)</span><span class="token1">{</span> $cart_row <span class="token">=</span> <span class="token3">array_shift</span><span class="token1">(</span>$cart_row<span class="token1">)</span><span class="token1">;</span> <span class="token5">//如果购物车中存在该商品</span> <span class="token5">//购物车内的商品与立即购买的商品数不累加所以如果购物车存在此商品就将购物车商品数量修改为现在购买的数量</span> $flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>cartModel<span class="token">-</span><span class="token">></span><span class="token3">editCart</span><span class="token1">(</span>$cart_row<span class="token1">[</span><span class="token4">'cart_id'</span><span class="token1">]</span><span class="token1">,</span> $edit_cond_rows<span class="token1">,</span> <span class="token6">false</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//如果不存在</span> $flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>cartModel<span class="token">-</span><span class="token">></span><span class="token3">addCart</span><span class="token1">(</span>$add_row<span class="token1">,</span> <span class="token6">true</span><span class="token1">)</span><span class="token1">;</span> ``` ``` 立即购买虚拟商品: ``` <pre class="calibre14">``` $<span class="token1">.</span><span class="token3">ajax</span><span class="token1">(</span><span class="token1">{</span> type <span class="token1">:</span> <span class="token4">'POST'</span><span class="token1">,</span> url <span class="token1">:</span> SITE_URL <span class="token">+</span> <span class="token4">"?ctl=Goods_Goods&met=checkVirtual&typ=json"</span><span class="token1">,</span> data <span class="token1">:</span> <span class="token1">{</span>goods_id<span class="token1">:</span>goods_id<span class="token1">,</span>goods_num<span class="token1">:</span>$<span class="token1">(</span><span class="token4">'#nums'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token1">)</span><span class="token1">}</span><span class="token1">,</span> dataType <span class="token1">:</span> <span class="token4">'JSON'</span><span class="token1">,</span> success <span class="token1">:</span> <span class="token2">function</span><span class="token1">(</span>a<span class="token1">)</span> <span class="token1">{</span> <span class="token2">if</span><span class="token1">(</span>a<span class="token1">.</span>status <span class="token">==</span> <span class="token6">250</span><span class="token1">)</span> <span class="token1">{</span> Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">warning</span><span class="token1">(</span><span class="token4">'<?=__('</span>您已达购买上限!<span class="token4">')?>'</span><span class="token1">)</span><span class="token1">;</span> <span class="token2">return</span> <span class="token6">false</span><span class="token1">;</span> <span class="token1">}</span><span class="token2">else</span><span class="token1">{</span> window<span class="token1">.</span>location<span class="token1">.</span>href <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Buyer_Cart&met=buyVirtual&goods_id='</span> <span class="token">+</span> goods_id <span class="token">+</span><span class="token4">'&goods_num='</span><span class="token">+</span>$<span class="token1">(</span><span class="token4">"#nums"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//检测当前商品是否参加团购活动</span> $info <span class="token">=</span> $Groupbuy_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getByWhere</span><span class="token1">(</span>$con_row<span class="token1">)</span><span class="token1">;</span> <span class="token2">if</span><span class="token1">(</span>$info<span class="token1">)</span><span class="token1">{</span> $limit <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span> <span class="token3">foreach</span><span class="token1">(</span>$info as $k<span class="token">=</span><span class="token">></span>$v<span class="token1">)</span><span class="token1">{</span> $limit <span class="token">=</span> $v<span class="token1">[</span><span class="token4">'groupbuy_upper_limit'</span><span class="token1">]</span><span class="token1">;</span> <span class="token1">}</span> $goods_max_sale <span class="token">=</span> $limit<span class="token1">;</span> <span class="token1">}</span><span class="token2">else</span><span class="token1">{</span> $goods_max_sale <span class="token">=</span> $goods_detail<span class="token1">[</span><span class="token4">'goods_max_sale'</span><span class="token1">]</span><span class="token1">;</span> <span class="token1">}</span> ``` ``` 立即购买实物商品: ``` <pre class="calibre14">``` $<span class="token1">.</span><span class="token3">ajax</span><span class="token1">(</span><span class="token1">{</span> url<span class="token1">:</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Buyer_Cart&met=addCart&typ=json'</span><span class="token1">,</span> data<span class="token1">:</span> <span class="token1">{</span>goods_id<span class="token1">:</span>goods_id<span class="token1">,</span> goods_num<span class="token1">:</span>$<span class="token1">(</span><span class="token4">"#nums"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token1">)</span><span class="token1">}</span><span class="token1">,</span> dataType<span class="token1">:</span> <span class="token4">"json"</span><span class="token1">,</span> contentType<span class="token1">:</span> <span class="token4">"application/json;charset=utf-8"</span><span class="token1">,</span> async<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span> success<span class="token1">:</span> <span class="token2">function</span> <span class="token1">(</span>a<span class="token1">)</span> <span class="token1">{</span> <span class="token2">if</span> <span class="token1">(</span>a<span class="token1">.</span>status <span class="token">==</span> <span class="token6">250</span><span class="token1">)</span> <span class="token1">{</span> Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">error</span><span class="token1">(</span>a<span class="token1">.</span>msg<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> <span class="token2">if</span><span class="token1">(</span>a<span class="token1">.</span>data<span class="token1">.</span>cart_id<span class="token1">)</span> <span class="token1">{</span> window<span class="token1">.</span>location<span class="token1">.</span>href <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Buyer_Cart&met=confirm&product_id='</span> <span class="token">+</span> a<span class="token1">.</span>data<span class="token1">.</span>cart_id<span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span> <span class="token1">}</span><span class="token1">,</span> failure<span class="token1">:</span> <span class="token2">function</span> <span class="token1">(</span>a<span class="token1">)</span> <span class="token1">{</span> Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">error</span><span class="token1">(</span><span class="token4">'<?=__('</span>操作失败!<span class="token4">')?>'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> ``` ``` 收藏商品: ``` <pre class="calibre14">``` $<span class="token1">.</span><span class="token3">post</span><span class="token1">(</span>SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Goods_Goods&met=collectGoods&typ=json'</span><span class="token1">,</span><span class="token1">{</span>goods_id<span class="token1">:</span>e<span class="token1">}</span><span class="token1">,</span><span class="token2">function</span><span class="token1">(</span>data<span class="token1">)</span> <span class="token1">{</span> <span class="token2">if</span><span class="token1">(</span>data<span class="token1">.</span>status <span class="token">==</span> <span class="token6">200</span><span class="token1">)</span> <span class="token1">{</span> Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">success</span><span class="token1">(</span>data<span class="token1">.</span>data<span class="token1">.</span>msg<span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">".icon-icoheart"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">addClass</span><span class="token1">(</span><span class="token4">"icon-taoxinshi"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">removeClass</span><span class="token1">(</span><span class="token4">'icon-icoheart'</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//toolbar显示收藏效果</span> $<span class="token1">(</span><span class="token4">"#collect_lable"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">removeClass</span><span class="token1">(</span><span class="token4">'icon-icoheart'</span><span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">"#collect_lable"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">addClass</span><span class="token1">(</span><span class="token4">'icon-taoxinshi'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">addClass</span><span class="token1">(</span><span class="token4">'bbc_color'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">error</span><span class="token1">(</span>data<span class="token1">.</span>data<span class="token1">.</span>msg<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//插入用户收藏商品表</span> <span class="token5">//如果用户未收藏过</span> <span class="token5">//商品详情中收藏数量增加</span> $edit_row<span class="token1">[</span><span class="token4">'goods_collect'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'1'</span><span class="token1">;</span> $flag <span class="token">=</span> $Goods_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$goods_id<span class="token1">,</span> $edit_row<span class="token1">,</span> <span class="token6">true</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//商品common中</span> $edit_common_row<span class="token1">[</span><span class="token4">'common_collect'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'1'</span><span class="token1">;</span> $Goods_CommonModel <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">editCommonTrue</span><span class="token1">(</span>$goods_base<span class="token1">[</span><span class="token4">'common_id'</span><span class="token1">]</span><span class="token1">,</span>$edit_common_row<span class="token1">)</span><span class="token1">;</span> ``` ``` 收藏店铺: ``` <pre class="calibre15">``` $<span class="token1">.</span><span class="token3">post</span><span class="token1">(</span>SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Shop&met=addCollectShop&typ=json'</span><span class="token1">,</span><span class="token1">{</span>shop_id<span class="token1">:</span>e<span class="token1">}</span><span class="token1">,</span><span class="token2">function</span><span class="token1">(</span>data<span class="token1">)</span> <span class="token1">{</span> <span class="token2">if</span><span class="token1">(</span>data<span class="token1">.</span>status <span class="token">==</span> <span class="token6">200</span><span class="token1">)</span> <span class="token1">{</span> Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">success</span><span class="token1">(</span>data<span class="token1">.</span>data<span class="token1">.</span>msg<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">error</span><span class="token1">(</span>data<span class="token1">.</span>data<span class="token1">.</span>msg<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//插入用户收藏店铺表</span> <span class="token5">//如果用户未收藏过</span> $User_FavoritesShopModel<span class="token">-</span><span class="token">></span><span class="token3">addShop</span><span class="token1">(</span>$add_row<span class="token1">)</span><span class="token1">;</span> <span class="token5">//店铺详情中收藏数量增加</span> $edit_row<span class="token1">[</span><span class="token4">'shop_collect'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'1'</span><span class="token1">;</span> $flag <span class="token">=</span> $Shop_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBaseCollectNum</span><span class="token1">(</span>$shop_id<span class="token1">,</span> $edit_row<span class="token1">,</span> <span class="token6">true</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//店铺收藏成功添加数据到统计中心</span> $analytics_data <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span> <span class="token4">'shop_id'</span><span class="token">=</span><span class="token">></span>$shop_id<span class="token1">,</span> <span class="token4">'date'</span><span class="token">=</span><span class="token">></span><span class="token3">date</span><span class="token1">(</span><span class="token4">'Y-m-d'</span><span class="token1">)</span><span class="token1">,</span> <span class="token1">)</span><span class="token1">;</span> Yf_Plugin_Manager<span class="token1">:</span><span class="token1">:</span><span class="token3">getInstance</span><span class="token1">(</span><span class="token1">)</span><span class="token">-</span><span class="token">></span><span class="token3">trigger</span><span class="token1">(</span><span class="token4">'analyticsShopCollect'</span><span class="token1">,</span>$analytics_data<span class="token1">)</span><span class="token1">;</span> ``` ```