ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 第二课常用语句解读 获取成为分销商商品信息 ``` <pre class="calibre14">``` <span class="token5">function</span> <span class="token1">get_goods</span><span class="token2">(</span><span class="token2">)</span><span class="token2">{</span> global $_W<span class="token2">;</span> $data <span class="token">=</span> <span class="token1">m</span><span class="token2">(</span><span class="token4">'common'</span><span class="token2">)</span><span class="token">-</span><span class="token">></span><span class="token1">getPluginset</span><span class="token2">(</span><span class="token4">'commission'</span><span class="token2">)</span><span class="token2">;</span> $goods <span class="token">=</span> <span class="token3">false</span><span class="token2">;</span> <span class="token5">if</span> <span class="token2">(</span><span class="token">!</span><span class="token1">empty</span><span class="token2">(</span>$data<span class="token2">[</span><span class="token4">'become_goodsid'</span><span class="token2">]</span><span class="token2">)</span><span class="token2">)</span> <span class="token2">{</span> foreach <span class="token2">(</span>$data<span class="token2">[</span><span class="token4">'become_goodsid'</span><span class="token2">]</span> as $item_good_id<span class="token2">)</span><span class="token2">{</span> $gooditem <span class="token">=</span> <span class="token1">pdo_fetch</span><span class="token2">(</span><span class="token4">'select id,title,thumb from '</span> <span class="token2">.</span> <span class="token1">tablename</span><span class="token2">(</span><span class="token4">'ewei_shop_goods'</span><span class="token2">)</span> <span class="token2">.</span> <span class="token4">' where id=:id and uniacid=:uniacid limit 1 '</span><span class="token2">,</span> <span class="token1">array</span><span class="token2">(</span><span class="token4">':id'</span> <span class="token">=</span><span class="token">></span> $item_good_id<span class="token2">,</span> <span class="token4">':uniacid'</span> <span class="token">=</span><span class="token">></span> $_W<span class="token2">[</span><span class="token4">'uniacid'</span><span class="token2">]</span><span class="token2">)</span><span class="token2">)</span><span class="token2">;</span> <span class="token5">if</span> <span class="token2">(</span>$gooditem<span class="token2">)</span><span class="token2">{</span> $goods<span class="token2">[</span><span class="token2">]</span> <span class="token">=</span> $gooditem<span class="token2">;</span> <span class="token2">}</span> <span class="token2">}</span> <span class="token2">}</span> <span class="token5">return</span> $goods<span class="token2">;</span> <span class="token2">}</span> ``` ``` 写入日志 ``` <pre class="calibre14">``` <span class="token1">load</span><span class="token2">(</span><span class="token2">)</span><span class="token">-</span><span class="token">></span><span class="token1">func</span><span class="token2">(</span><span class="token4">'logging'</span><span class="token2">)</span><span class="token2">;</span> <span class="token1">logging_run</span><span class="token2">(</span><span class="token4">'时间戳:'</span><span class="token2">.</span><span class="token1">time</span><span class="token2">(</span><span class="token2">)</span><span class="token2">)</span><span class="token2">;</span> ``` ``` 跳转 ``` <pre class="calibre14">``` <span class="token1">mobileUrl</span><span class="token2">(</span>$<span class="token5">do</span> <span class="token">=</span> <span class="token4">''</span><span class="token2">,</span> $query <span class="token">=</span> NULL<span class="token2">,</span> $full <span class="token">=</span> <span class="token3">false</span><span class="token2">)</span><span class="token2">;</span> <span class="token1">webUrl</span><span class="token2">(</span>$<span class="token5">do</span> <span class="token">=</span> <span class="token4">''</span><span class="token2">,</span> $query <span class="token">=</span> <span class="token1">array</span><span class="token2">(</span><span class="token2">)</span><span class="token2">,</span> $full <span class="token">=</span> <span class="token3">true</span><span class="token2">)</span><span class="token2">;</span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"{php echo webUrl('pc/product',array('tid'=>$row['tid']))}"</span><span class="token">></span><span class="token2">{</span>php echo <span class="token1">put_type</span><span class="token2">(</span>$row<span class="token2">[</span><span class="token4">'tid'</span><span class="token2">]</span><span class="token2">)</span><span class="token2">}</span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"/app{php echo mobileUrl('goods.detail',array('id'=>$row['goodsid']))}"</span> target<span class="token">=</span><span class="token4">"_blank"</span><span class="token">></span><span class="token2">{</span>$row<span class="token2">[</span><span class="token4">'goodsid_text'</span><span class="token2">]</span><span class="token2">}</span><span class="token"><</span><span class="token">/</span>a<span class="token">></span> ``` ``` 设备判断 ``` <pre class="calibre14">``` <span class="token1">is_weixin</span><span class="token2">(</span><span class="token2">)</span> 是否微信 <span class="token1">is_h5app</span><span class="token2">(</span><span class="token2">)</span> 是否h5应用 <span class="token1">is_ios</span><span class="token2">(</span><span class="token2">)</span> 是否苹果手机或ipad <span class="token1">is_mobile</span><span class="token2">(</span><span class="token2">)</span> 是否移动设备 ``` ``` 商品搜索选择器,输出 goodsid\_text标题和goodsid商品编号 true, 'readonly'=>true, 'multi'=>0, 'value'=>$item['goodsid_text'], 'url'=>webUrl('goods/query'), 'items'=>$goods, 'nokeywords'=>1, 'autosearch'=>1, 'buttontext'=>'选择产品', 'placeholder'=>'请选择产品') )?> ``` <pre class="calibre16">``` </div> ``` ```