<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ### 通過商品ID的查詢商品主圖 **位置:** Common\Common\function.php jig 2018-06-26 **參數:** * @param int $goods_id spu_id/skc_id/sku_id/item_id * @param int $goods_type 屬性類型 1:唯一碼 4:SPU 3:SKU 2:SKC * @param string $img_size 圖片尺寸 默認為空顯示原圖800,其他尺寸分為:'_300.jpg', '_60.jpg' ,**1標識尺寸300.jpg,2標識尺寸60.jpg** **調用:** > PHP 調用: print_img ($goods_id, 4, '_300.jpg') > View 模版調用: {$vo['goods_id'], 4, '1'|print_img} 通過SKC ID獲取主圖 **完整代碼:** ~~~ /** * 通過商品ID的查詢商品主圖 * jig 2018-06-26 * * @param int $goods_id spu_id/skc_id/sku_id/item_id * @param int $goods_type 屬性類型 1:唯一碼 4:SPU 3:SKU 2:SKC * @param string $img_size 圖片尺寸 默認為空顯示原圖800,其他尺寸分為:'_300.jpg', '_60.jpg' * * @return string */ function print_img ($goods_id, $goods_type, $img_size = '') { if ($goods_type == 1) { // 通過唯一碼ID查詢出 SKC ID $no_res = M('goods_item')->where('id = ' . $goods_id)->find(); $where['skc_id'] = $no_res['skc_id']; // SKC $map['id'] = $no_res['skc_id']; } else if ($goods_type == 3) { // 通過SKU ID 查詢出 SKC ID $sku_res = M('goods_sku')->where('id = ' . $goods_id)->find(); $where['skc_id'] = $sku_res['skc_id']; // SKC $map['id'] = $sku_res['skc_id']; } else if ($goods_type == 4) { $where['spu_id'] = $goods_id; // SPU $map['spu_id'] = $goods_id; } else if ($goods_type == 2) { $where['skc_id'] = $goods_id; // SKC $map['id'] = $goods_id; } else { return 'error'; } $where['is_delete'] = array('eq', 0); // 查詢 SKC 圖片 $skc_img = M('goods_skc_image')->where($where)->order('img_sort asc')->find(); // 解決模版調用報錯 2018-9-30 if ($img_size == 1) { $img_size = '_300.jpg'; } else if ($img_size == 2) { $img_size = '_60.jpg'; } else { $img_size = $img_size; } // 返回 SKC 圖片 if (!empty($skc_img['img_url'])) { $url = C('IMAGE_OSS_URL') . $skc_img['img_url'] . $img_size; // 域名 + 圖片路徑 + 圖片尺寸 } // 如果圖片不存在查詢 SPU 表歷史老圖片 if (empty($skc_img['img_url'])) { // 查詢 SKC 表數據 $map['is_delete'] = array('eq', 0); $skc_result = M('goods_skc')->where($map)->find(); // 查詢款號圖片 $spu_img = M('goods_spu')->where(array('id' => $skc_result['spu_id']))->find(); if (!empty($spu_img['image'])) { $url = C('IMAGE_OSS_URL') . $spu_img['image']; } } // 如果skc和spu圖片都不存在 查詢 item 表歷史老圖片 if (empty($skc_result['img_url']) && empty($spu_img['image'])) { // 查詢唯一碼圖片 $item_img = M('goods_item')->where(array('skc_id' => $skc_result['id']))->find(); $no_image = json_decode($item_img['image'], true); if (!empty($no_image[0]['image_src'])) { // $url = 'http://' . $_SERVER['HTTP_HOST'] . $no_image[0]['image_src']; $url = 'http://work.coscia.com.cn' . $no_image[0]['image_src']; } } // 如果圖片為空返回默認圖片 if (empty($url)) { $img_url = 'coscia/coscia.jpg'; // 默認圖片 return C('IMAGE_OSS_URL') . $img_url . $img_size; // 域名 + 圖片路徑 + 圖片尺寸 } else { return $url; } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看