{"id":199165,"date":"2025-05-03T12:37:55","date_gmt":"2025-05-03T04:37:55","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199165\/"},"modified":"2025-05-03T12:37:55","modified_gmt":"2025-05-03T04:37:55","slug":"ecshop%e8%b0%83%e7%94%a8%e6%8c%87%e5%ae%9a%e5%88%86%e7%b1%bb%e4%b8%8b%e7%b2%be%e5%93%81%e4%ba%a7%e5%93%81%e5%88%97%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199165\/","title":{"rendered":"ecshop\u8c03\u7528\u6307\u5b9a\u5206\u7c7b\u4e0b\u7cbe\u54c1\u4ea7\u54c1\u5217\u8868"},"content":{"rendered":"<p>&nbsp;ecshop\u8c03\u7528\u6307\u5b9a\u5206\u7c7b\u4e0b\u7cbe\u54c1\u4ea7\u54c1\u5217\u8868<\/p>\n<p><span style=\"font-family: \u5b8b\u4f53, Verdana, Arial;line-height: 25px\"> <\/span><\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\"><strong>\u9996\u5148\u58f0\u660e<\/strong><\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">&nbsp;<\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">\/**<br \/> * \u83b7\u5f97cat_id\u7cbe\u54c1\u5217\u8868\u3002<br \/> *<br \/> * @access&nbsp; private<br \/> * @param&nbsp;&nbsp; integer<br \/> * @return&nbsp; array<br \/> *\/<br \/> function index_get_cat_id_goods_best_list($cat_id, $num)<br \/> {<br \/> &nbsp;&nbsp;&nbsp; $sql = &#8216;Select g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price, g.promote_price, &#8216; .<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, &#8221; .<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;g.is_best, g.is_new, g.is_hot, g.is_promote &#8221; .<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8216;FROM &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;goods&#8217;) . &#8216; AS g &#8216; .<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.is_best = 1 AND g.cat_id = &#8216;$cat_id'&#8221;.<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8221; LIMIT $num&#8221;;<br \/> &nbsp;&nbsp;&nbsp; $res = $GLOBALS[&#8216;db&#8217;]-&gt;getAll($sql);<\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">&nbsp;&nbsp;&nbsp; $goods = array();<br \/> &nbsp;&nbsp;&nbsp; foreach ($res AS $idx =&gt; $row)<br \/> &nbsp;&nbsp;&nbsp; {<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;id&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $row[&#8216;article_id&#8217;];<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;id&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $row[&#8216;goods_id&#8217;];<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;name&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $row[&#8216;goods_name&#8217;];<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;brief&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $row[&#8216;goods_brief&#8217;];<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;brand_name&#8217;]&nbsp;&nbsp; = $row[&#8216;brand_name&#8217;];<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;goods_style_name&#8217;]&nbsp;&nbsp; = add_style($row[&#8216;goods_name&#8217;],$row[&#8216;goods_name_style&#8217;]);<\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;short_name&#8217;]&nbsp;&nbsp; = $GLOBALS[&#8216;_CFG&#8217;][&#8216;goods_name_length&#8217;] &gt; 0 ?<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sub_str($row[&#8216;goods_name&#8217;], $GLOBALS[&#8216;_CFG&#8217;][&#8216;goods_name_length&#8217;]) : $row[&#8216;goods_name&#8217;];<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;short_style_name&#8217;]&nbsp;&nbsp; = add_style($goods[$idx][&#8216;short_name&#8217;],$row[&#8216;goods_name_style&#8217;]);<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;market_price&#8217;] = price_format($row[&#8216;market_price&#8217;]);<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;shop_price&#8217;]&nbsp;&nbsp; = price_format($row[&#8216;shop_price&#8217;]);<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;thumb&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = empty($row[&#8216;goods_thumb&#8217;]) ? $GLOBALS[&#8216;_CFG&#8217;][&#8216;no_picture&#8217;] : $row[&#8216;goods_thumb&#8217;];<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;goods_img&#8217;]&nbsp;&nbsp;&nbsp; = empty($row[&#8216;goods_img&#8217;])&nbsp;&nbsp; ? $GLOBALS[&#8216;_CFG&#8217;][&#8216;no_picture&#8217;] : $row[&#8216;goods_img&#8217;];<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $goods[$idx][&#8216;url&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = build_uri(&#8216;goods&#8217;, array(&#8216;gid&#8217; =&gt; $row[&#8216;goods_id&#8217;]), $row[&#8216;goods_name&#8217;]);<br \/> &nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">&nbsp;&nbsp;&nbsp; return $goods;<br \/> }<\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\"><strong>&nbsp;\u58f0\u660e\u540e\u7528$smarty\u8c03\u7528<\/strong><\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">$smarty-&gt;assign(&#8216;cat_id2_best_goods&#8217;, index_get_cat_id_goods_best_list(2,4));<br \/> \/\/2\u6307\u5206\u7c7bid\uff0c4\u6307\u5faa\u73af\u6b21\u6570<\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">&nbsp;<\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\"><strong>\u7136\u540e\u5c31\u53ef\u4ee5\u5728dwt\u6a21\u677f\u6587\u4ef6\u91cc\u5f00\u59cb\u8c03\u7528\u4e86<br \/> \u5177\u4f53\u8c03\u7528\u65b9\u6cd5\u6709\u4e24\u79cd,\u56e0\u4e3a\u4ea7\u54c1\u8c03\u7528\u8981\u662f\u5148js\u8c03\u7528\u7684\u6548\u679c\u7684\u8bdd,\u5c31\u662f\u6709H\u548cV\u4e24\u79cd,\u56fe\u7247\u4ef7\u683c\u548c\u6587\u5b57\u6807\u9898\u4e24\u79cd.<br \/> \u5982\u679c\u662f\u6a2a\u5411\u8c03\u75284\u4e2a\u4ea7\u54c1,\u5e26\u56fe\u7247\u4ef7\u683c\u7b49.\u53ef\u4ee5\u8fd9\u6837\u5199<\/strong><\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">&nbsp;<\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">&lt;!&#8211;{foreach from=$cat_id2_best_goods item=goods}&#8211;&gt;<br \/> &nbsp;&nbsp;&nbsp;&nbsp; &lt;div class=&#8221;goodsItem&#8221; style=&#8221;float:left ; margin-left:10px;&#8221; &gt;<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;a href=&#8221;{$goods.url}&#8221;&gt;&lt;img src=&#8221;{$goods.thumb}&#8221; alt=&#8221;{$goods.name|escape:html}&#8221; class=&#8221;goodsimg&#8221; width=&#8221;100&#8243; height=&#8221;100&#8243; \/&gt;&lt;\/a&gt;&lt;br \/&gt;<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;p&gt;&lt;a href=&#8221;{$goods.url}&#8221; title=&#8221;{$goods.name|escape:html}&#8221;&gt;{$goods.short_name|truncate:7:true}&lt;\/a&gt;&lt;\/p&gt;<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div class=&#8221;shop_s&#8221; style=&#8221;text-align:center; color:#CC0000 &#8221; &gt;<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;strong&gt;<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {$goods.shop_price}<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/strong&gt;<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/div&gt;<br \/> &nbsp;&nbsp;&nbsp;&nbsp; &lt;\/div&gt;<br \/> &lt;!&#8211;{\/foreach}&#8211;&gt;<\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">&nbsp;<\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\"><strong>\u5982\u679c\u9700\u8981\u8c03\u7528\u7eb5\u5411\u6807\u9898\u5217\u8868\u7684\u8bdd\u53ea\u9700\u8981\u628aitem=goods\u4fee\u6539\u6210item=list,\u7136\u540e\u5220\u6389\u4e0d\u9700\u8981\u7684\u8c03\u7528\u4ee3\u7801\u5373\u53ef<\/strong><\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">&nbsp;<\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">&lt;!&#8211;{foreach from=$cat_id11_best_goods item=list}&#8211;&gt;<br \/> &nbsp;&nbsp;&nbsp; &lt;li&gt;<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;a href=&#8221;{$list.url}&#8221; title=&#8221;{$list.name|escape:html}&#8221;&gt;{$list.name|truncate:15:true}&lt;\/a&gt;<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/li&gt;<br \/> &lt;!&#8211;{\/foreach}&#8211;&gt;<\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">&nbsp;<\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\"><strong>\u5176\u5b9e\u6a2a\u5411\u7eb5\u5411\u7684\u6392\u5217\u65b9\u5f0f\u5728\u6a21\u677f\u6587\u4ef6\u91cc\u4fee\u6539\u4e5f\u53ef\u4ee5,\u4f46\u65b9\u6cd5\u90fd\u4e00\u6837,\u5c31\u662f\u5728css\u91cc\u4fee\u6539.\u52a0\u4e2afloat:left\u5373\u53ef.<\/strong><\/p>\n<p style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;border-top-style: none;border-right-style: none;border-bottom-style: none;border-left-style: none;border-width: initial;border-color: initial;list-style-type: none;font-size: 14px;line-height: 25px\">\u597d\u6a21\u677f\u63d0\u4f9b\uff0c\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u7f51\u5740\uff01<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;ecshop\u8c03\u7528\u6307\u5b9a&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-199165","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=199165"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199165\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}