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%'; ok-completed 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 UPDATE oc_product_source SET product_id = '55', date_collect = NOW() WHERE product_source_id = '181' crontab -e * * * * * /usr/bin/php /var/www/html/dv/dv-1-1.php * * * * * sleep 30; /usr/bin/php /var/www/html/dv/dv-1-1.php pclose(popen('php dv-1.php 60 &', 'r')); 必需關閉 echo 否則停止 /var/spool/cron/crontabs/root service cron restart service cron status echo $PATH -> /usr/bin/php -> ln /etc/alternatives/php -> /usr/bin/php8.0 mysqli_result Object ( [current_field] => 0 [field_count] => 11 [lengths] => [num_rows] => 0 [type] => 0 ) https://mobile.yangkeduo.com/mall_quality_assurance.html?_t_timestamp=comm_share_landing&goods_id=56972644840&_oak_share_type=6&_oak_share_url=https%3A%2F%2Ft00img.yangkeduo.com%2Fgoods%2Fimages%2F2019-10-23%2F67509b0a-e274-403d-8c8e-424b90418999.jpg&refer_share_id=0b792476fa464bc6ab879dd994fecad0&refer_share_uid=5366106146&refer_share_channel=copy_link&refer_share_form=text php error log /var/log/apache2/error.log chrome-extension://id/xx.html pdd197744894766 181->20210315 ========================================================================================================================= joe /var/www/html/catalog/language/zh-cn/zh-cn.php $_['code'] = 'zh-cn'; // 'cn'; --- 20210316 opencart-3.0.3.6 修改中文簡體語言包無法被 chrome 翻譯識別 ========================================================================================================================= 錯誤用法 timer 不生效 setTimeout(getnext(),2*1000); 正確用法 setTimeout(function(){ getnext(); },2*1000); --- 20210316 javascript timer 用法 ========================================================================================================================= popup->bg bg->ajax array 3.) bg->tab get ptt page cs->inject inject collect->cs cs ready->bg bg->ajax sent bg ret->cs cs next array->bg bg ret complete-> 3.)get next ptt page --- 20210315 chrome extension 連續自動采集拼多多產品資料 ========================================================================================================================= 新增所有 option 組合對應不同重量價格圖片 1.) db->oc_product_option_ext -> product_option_ext_id, product_id, option_list, price, weight, image //新增數據庫表用以存放所有 option 組合的資料 2.) joe /var/www/html/catalog/model/catalog/product.php //新增讀取表 product_option_ext 的單品所有 option 組合的資料數組 3.) joe /var/www/html/catalog/controller/product/product.php (/var/www/storage/modification/catalog/controller/product/product.php) //新增傳參單品所有 option 組合的資料數組給 tamplate $data['option_list_price'], $data['option_list_weight'], $data['option_list_image'] 4.) joe /var/www/html/catalog/view/theme/default/template/product/popupop.twig //新增3個 json 變量保存下載 option 組合的資料數組 var basepri={{ price }}; var basewgt={{ weight }}; var baseimg="{{ thumb }}"; //新增函數取得目前已選 option 組合 string function getoplist(){ //新增函數遍歷 option 組合的數組比對取得對應圖片,最大,最小重量單價 function getopdetail(){ //修改原以 mainselect 為主的計算重量單價方式為 -> 直接以已選 option 組合查找對應的資料 $("#puo-mainimg").attr("src",tmpimg); $("#puo-price").html((tmpminp*tmpv).toFixed(2) + (tmpminp string 用以上傳新增 json 變數 data['option_weight'] function ajaxeditdata (){ $.ajax({ ... data: JSON.stringify(data), 6.) joe /var/www/html/dv/dv-5.php //修改處理 ajax 上傳資料的方式 $_POST -> file_get_contents('php://input'); $raw=file_get_contents('php://input'); $tmpj=json_decode($raw,true); //新增處理 ajax 上傳資料的 option_weight 數組更新對應的數據庫表 oc_product_option_ext 包括 option (value=0)可代表全部 option $db->query("UPDATE " . DB_PREFIX . "product_option_ext SET weight='$tmpw' WHERE product_id='$product_id' AND option_list LIKE '$tmpl'"); --- 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; //刪除廠牌, 型號, 積分, 庫存狀態