ali-1688->data-feature-json store.listData.list[0].goodsID:195177802523 store.listData.list[0].goodsName:"【牛肚|10斤】(全熟牛肚丝/牛肚块)4斤半成品牛肚块火锅牛肚丝牛肚1斤熟牛肚" store.initDataObj.goods.goodsID:98305814196 store.initDataObj.goods.goodsName:"金钱肚新鲜金钱肚蜂窝肚新鲜牛肚子批发清真半成品熟金钱肚包邮" store.initDataObj.goods.skus[0].thumbUrl store.initDataObj.goods.topGallery store.initDataObj.goods.detailGallery.0.url store.initDataObj.goods.goodsProperty store.initDataObj.goods.skus store.initDataObj.goods.skus[0].specs[0].spec_key "颜色分类" store.initDataObj.goods.skus[0].specs[0].spec_value "藏青色 套装 送背心" store.initDataObj.goods.skus[0].specs[1].spec_key "尺码" store.initDataObj.goods.skus[0].specs[1].spec_value "S 建议85-100以内" store.initDataObj.goods.skus[2].defaultQuantity 0 store.initDataObj.goods.skus[0].groupPrice store.initDataObj.goods.skus[0].thumbUrl store.initDataObj.goods.skus[0].weight INSERT INTO oc_product_source_image SET product_id='79', image='http', status='trans' INSERT INTO oc_product_source_image (product_id, image) SELECT product_id, image FROM oc_product_image WHERE product_id='78' stdClass Object ( [num_rows] => 1 [row] => Array ( [product_source_id] => 2 [source_id] => pdd98305814196 [product_id] => 79 [source_from] => pdd [collect_id] => pdd2103080436373210 ) [rows] => Array ( [0] => Array ( [product_source_id] => 2 [source_id] => pdd98305814196 [product_id] => 79 [source_from] => pdd [collect_id] => pdd2103080436373210 ) ) ) update `oc_product_option_ext` set image='catalog/cn/pdd161535231081/210312002.jpg' WHERE `option_list` like '453%'; update `oc_product_option_ext` set image='catalog/cn/pdd161535231081/210312003.jpg' WHERE `option_list` like '454%'; update `oc_product_option_ext` set image='catalog/cn/pdd161535231081/210312004.jpg' WHERE `option_list` like '455%'; update `oc_product_option_ext` set image='catalog/cn/pdd161535231081/210312005.jpg' WHERE `option_list` like '456%'; https://mobile.yangkeduo.com/goods.html?goods_id=204691077436&page_from=23&pxq_secret_key=52E7QF663BIFXIHTTSNRFPAHYBZNVWE4VMOVRBW6IOSPD4XS45DQ&share_uin=XF7PSVJD6RNGN62V7F4TOQUYSU_GEXDA&refer_share_id=96cb4b7f7e3e4002b73bdafd706e4323&refer_share_uid=5366106146&refer_share_channel=message&refer_share_form=card#pushState ========================================================================================================================= 新增所有 option 組合對應重量價格 1.) db->oc_product_option_ext 2.) joe /var/www/html/catalog/model/catalog/product.php 3.) joe /var/www/html/catalog/controller/product/product.php (/var/www/storage/modification/catalog/controller/product/product.php) --- 20210313 opencart-3.0.3.6 新增所有 option 組合對應重量價格 ========================================================================================================================= chrome extension 采集拼多多產品資料 0.) manifest.json //設置可訪問 https 權限 + 要注入的 js + 注入時機 "permissions": [ ... "https://*/*" ], "web_accessible_resources": ["js/inject.js","js/jquery-1.8.3.js"], "content_scripts": [ { "matches": [""], "js": ["js/jquery-1.8.3.js", "js/content-script.js"], "run_at": "document_start" }, 1.) inject.js //新增要注入采集產品頁的 rawData 轉為 string 最前面加上取出的 source_id 後傳給 conten-cript var sid=a.store.initDataObj.goods.goodsID; ... a=JSON.stringify(a); ... window.postMessage(a, '*'); 2.) content-script.js //設置調用注入函數 document.addEventListener('DOMContentLoaded', function(){ injectCustomJs(); } //設置注入函數 function injectCustomJs(jsPath) { ... document.body.appendChild(temp); //新增函數監聽 inject.js 回傳資料 window.addEventListener("message", function(e){ ... //從回傳資料取出 source_id 並分割為每個大小為 128KB 的分割塊數組等待命令使用,在最後多加上一個完成信號的 string sid=a.substr(0,tmpi); ... tosend[i]=a.substr(tmpsz*i,tmpsz); ... tosend[i]=sid + "-completed"; //新增函數監聽 popup 或 background 命令 chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){ ... //必需先回傳空資料以關閉 port, 否則出現 timeout error, 並且堵塞下次通信 sendResponse(''); //根據收到 popup 或 background 的命令,內容和已傳數量判斷是否調用 sendMessage 傳下一個分割塊給 background 跨域上傳資料給 aws if(request.cmd=="collect-pdd-item"){ ... if(request.msg.indexOf('ok')==0){ ... if(tmpidx<=tmpcnt){ chrome.runtime.sendMessage(tosend[tmpidx], function(response) { }); 3.) background.js //新增函數監聽 content-script 回傳資料 chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){ ... //必需先回傳空資料以關閉 port, 否則出現 timeout error, 並且堵塞下次通信 sendResponse(''); //修改 ajax contentType 為 urlencoded 以避免自動轉換解碼已編好的各種怪符號 7B { %7D } + & sign contentType: 'application/x-www-form-urlencoded', //調用 ajax 上傳分割塊 string 給 aws dv-3.php $.ajax({ url: 'https://oc.wg-1.com/dv/dv-3.php', //從 aws dv-3.php 收到回覆的信息後調用 sendMessageToContentScript 傳送給 content-script sendMessageToContentScript({cmd:'collect-pdd-item',msg:html}, function(response){ }); //新增函數 sendMessageToContentScript 將資料傳送給 content-script function sendMessageToContentScript(message, callback){ ... 4.) joe /var/www/html/dv/dv-3.php //直接讀取 file_get_contents('php://input'), 不可用 $_POST 會被 & sign 自動轉碼等問題干擾讀取不到正確資料 $raw=file_get_contents('php://input'); //取出帶頭的 source_id 後判斷是否未完成 -> 將分割塊 string append ../tmp/ 暫存文件 $sid=substr($raw,0,strpos($raw,"-")); ... $f1 = fopen($PF,"a"); fwrite($f1,$raw); //判斷是否完成 -> 將暫存文件移到 ../upf/ -> 取出文件轉為數組 -> 判斷是否為拼多多產品頁 -> 取出 source_id 新增 db->oc_product_source 資料 $tmpj=json_decode($f1[0],true); if(isset($tmpj['store']['initDataObj']['goods']['goodsID'])){ ... $db->query($tmpsql="INSERT INTO " . DB_PREFIX . "product_source SET source_id = '" . $sid . "', source_from = '" . $source_from . "', collect_id = '" . $cid . "', date_upload = NOW()"; 5.) popup.html //新增采集拼多多商品入口 采集此页商品 6.) popup.js //新增傳送命令給 content-script 開始采集拼多多商品 $('#pdd_get_item').click(e => { sendMessageToContentScript({cmd:'collect-pdd-item',msg:'ok-start'}, function(response){}); }); --- 20210312 chrome extension 采集拼多多產品資料 ========================================================================================================================= array, json, object 的區別 1.) a['xx']='yy'; 宣告為 new Object() 才能以 json 使用 2.) array key 只可以是數字, a['xx']不是 array 3.) json key 可以有文字 4.) object 包含 json 不是 array --- 20210311 javascript array, json, object 的區別 ========================================================================================================================= 修改全部連結為 https joe /var/www/html/system/library/url.php -> // public function link($route, $args = '', $secure = false) { public function link($route, $args = '', $secure = true) { --- 20210310 opencart-3.0.3.6 修改全部連結為 https ========================================================================================================================= 產品頁新增預估運費折疊區 1.) joe /var/www/html/catalog/controller/product/product.php -> //新增調用 country model + 預設 country_id $this->load->model('localisation/country'); $data['countries'] = $this->model_localisation_country->getCountries(); ... $data['country_id'] = $this->config->get('config_country_id'); 2.) joe /var/www/html/catalog/view/theme/default/template/product/popupop.twig -> //複制 checkout/tabcart.twig 下拉折疊區預估運費整個 panel
...
//複制 checkout/tabcart.twig->function depotship() 修改為 function productship(weight) //修改函數 recalculate() 調用 productship(weight) 時傳參當前產品頁已選規格數量的總重量 //修改函數 productship(weight) 調用 ajax 上傳當前總重量至 checkout/tabestship/getEstShip 取回所有報價 json 並產生下拉區 html 3.) joe /var/www/html/catalog/controller/checkout/tabestship.php -> //修改函數 getEstShip (原為 depotship 改名)產生 session productweight 供 library/cart/cart 使用 $this->session->data['productweight']=round($this->weight->convert($_POST['weight'], $this->config->get('config_weight_class_id'), 2),0); // 5 lb -> 2 g 4.) joe /var/www/html/system/library/cart/cart.php -> //修改函數 getAllWeights 增加產生產品重量 productweight $weights['productweight']=$this->session->data['productweight']; --- 20210309 opencart-3.0.3.6 產品頁新增預估運費折疊區 ========================================================================================================================= 修改所有 session selectcart, selectdepot 的判斷和預設 1.) joe /var/www/html/catalog/controller/checkout/cart.php-> 2.) joe /var/www/html/catalog/controller/checkout/checkout.php-> 3.) joe /var/www/html/catalog/controller/checkout/tabsetship.php-> if(isset($this->request->post['selected'])){ $this->session->data['cartselect']=$this->request->post['selected']; } elseif(!isset($this->session->data['cartselect'])){ $this->session->data['cartselect']=array(); } 4.) joe /var/www/html/catalog/controller/checkout/depotcheckout.php-> elseif(!isset($this->session->data['depotselect'])){ 5.) joe /var/www/html/catalog/controller/checkout/tabsetship.php-> public function depotship() (20210309 depotship->getEstShip) { ... elseif(!isset($this->session->data['depotselect'])){ --- 20210308 opencart-3.0.3.6 修改所有 session selectcart, selectdepot 的判斷和預設 ========================================================================================================================= 修改產品頁小屏格式 + 使用標準共用語言包 1.) joe /var/www/html/catalog/view/theme/default/stylesheet/stylesheet.css //面包屑產品名太長超出屏幕 .breadcrumb > li { // 改可換行 .breadcrumb > li:after { //改箭頭大小位置 2.) joe /var/www/html/catalog/view/theme/default/template/product/product.twig //小屏縮略圖太多放不下直接不顯示 @media (max-width: 518px) { .image-additional-row { display: none; //刪除廠牌, 型號, 積分, 庫存狀態