选品添加主品

专用的

  1. // ==UserScript==
  2. // @name 选品添加主品
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-06-02
  5. // @description 专用的
  6. // @author You
  7. // @match https://shopee.co.th/*
  8. // @match https://detail.1688.com/offer/*
  9. // @require https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.7.1.min.js
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=mabangerp.com
  11. // @grant GM_xmlhttpRequest
  12.  
  13. // ==/UserScript==
  14.  
  15. (function () {
  16. 'use strict';
  17. function jisuan_roi(that_click){
  18. $(that_click).closest('.thisMsg').find('.jisuan_roi').each(function(index, value) {
  19. if(index>0){
  20. var saleprice = parseFloat($(value).find('.mx1').val().replace(/[^0-9.]/g, ''));
  21. var yongjin = parseFloat($(value).find('.cg0').val()/100);
  22. var chengben = parseFloat($(value).find('.cg1').val());
  23. var wuliu = parseFloat($(value).find('.cg2').val());
  24. var baocai = parseFloat($(value).find('.cg3').val());
  25. var zongchengben=yongjin*saleprice+chengben+wuliu+baocai;
  26. var maolilv=1-zongchengben/saleprice;
  27. $(this).find('.cg4').val((maolilv.toFixed(3)*100).toFixed(3)+"%");
  28. $(this).find('.cg5').val((1/maolilv).toFixed(3));
  29. }
  30. });
  31. }
  32. function update_input(father_id,that_click){//更新输入数据
  33. var this_class="";
  34. var typea="";
  35. if ($(that_click).hasClass('caigoua') || $(that_click).hasClass('xiaoshou') || $(that_click).hasClass('fuzhia') || $(that_click).hasClass('fuzhib')) {
  36. // 如果当前对象包含class 'caigoua',执行这里的代码
  37. this_class=".caigoua";
  38. typea="xp_xuanpin";
  39. } else if ($(that_click).hasClass('caigoua1') || $(that_click).hasClass('xiaoshou1') || $(that_click).hasClass('fuzhia1') || $(that_click).hasClass('fuzhib1')){
  40. // 如果当前对象不包含class 'caigoua',执行这里的代码
  41. this_class=".caigoua1";
  42. typea="xp_jp";
  43. }
  44. var values = '';
  45. $(that_click).closest('.thisMsg').find(this_class).each(function(index, element) {
  46. if (index > 0 && index % 6 == 0) {
  47. values += '分行';
  48. }
  49. if (index > 0 && index % 6 != 0) {
  50. values += '分隔';
  51. }
  52. values += $(element).val();
  53.  
  54. });
  55. console.log("触发采购成本计算")
  56. console.log("father_id="+ father_id.slice(2)+"&update_cg=" + values+"&type=" + typea)
  57. GM_xmlhttpRequest({
  58. method: "post",
  59. url: 'https://www.taobaimei.com/thailand/inser_xp.php',
  60. data: "father_id="+ father_id.slice(2)+"&update_cg=" + values+"&type=" + typea,
  61. headers: {"Content-Type": "application/x-www-form-urlencoded"},
  62. onload: function (r) {
  63. // code
  64. console.log(r)
  65. }
  66. });
  67. }
  68.  
  69. function update_xiaoshou(father_id,that_click){//更新输入数据
  70. var this_class="";
  71. var typea="";
  72. if ($(that_click).hasClass('xiaoshou') || $(that_click).hasClass('fuzhib') || $(that_click).hasClass('fuzhia')) {
  73. // 如果当前对象包含class 'caigoua',执行这里的代码
  74. this_class=".xiaoshou";
  75. typea="xp_xuanpin";
  76. } else if ($(that_click).hasClass('xiaoshou1') || $(that_click).hasClass('fuzhib1') || $(that_click).hasClass('fuzhia1')){
  77. // 如果当前对象不包含class 'caigoua',执行这里的代码
  78. this_class=".xiaoshou1";
  79. typea="xp_jp";
  80. }
  81. var values = '';
  82. $(that_click).closest('.thisMsg').find(this_class).each(function(index, element) {
  83. if (index > 0 && index % 4 == 0) {
  84. values += '分行';
  85. }
  86. if (index > 0 && index % 4 != 0) {
  87. values += '分隔';
  88. }
  89. if ($(this).is('span')) {
  90. values += $(element).text();
  91. } else if ($(this).is('input')) {
  92. values += $(element).val();
  93. }
  94.  
  95.  
  96. });
  97. console.log("father_id="+ father_id.slice(2)+"&update_xs=" + values+"&type=" + typea)
  98. GM_xmlhttpRequest({
  99. method: "post",
  100. url: 'https://www.taobaimei.com/thailand/inser_xp.php',
  101. data: "father_id="+ father_id.slice(2)+"&update_xs=" + values+"&type=" + typea,
  102. headers: {"Content-Type": "application/x-www-form-urlencoded"},
  103. onload: function (r) {
  104. // code
  105. console.log(r)
  106. }
  107. });
  108. }
  109. function postdata_jp(dataa,father_id) {
  110. // console.log(dataa)
  111. GM_xmlhttpRequest({
  112. method: "post",
  113. url: 'https://www.taobaimei.com/thailand/inser_xp.php',
  114. data: "father_id="+ father_id+"&dataa_jp=" + dataa+"&jpurl=" + encodeURIComponent(window.location.href),
  115. headers: {"Content-Type": "application/x-www-form-urlencoded"},
  116. onload: function (r) {
  117. // code
  118. // console.log(r)
  119. getxpdata()
  120. }
  121. });
  122. }
  123. function postdata(dataa) {
  124. GM_xmlhttpRequest({
  125. method: "post",
  126. url: 'https://www.taobaimei.com/thailand/inser_xp.php',
  127. data: "caozuo=" + $("#caozuo").val()+"&dataa=" + dataa+"&xpurl="+encodeURIComponent(window.location.href),
  128. headers: {"Content-Type": "application/x-www-form-urlencoded"},
  129. onload: function (r) {
  130. // code
  131. getxpdata()
  132. console.log(r)
  133. }
  134. });
  135. }
  136. function getxpdata_sj(weiyi_id,typea) {
  137. var leixingxs="xiaoshou1";
  138. var leixingcg="caigoua1";
  139. if(typea=="xp_xuanpin"){leixingxs="xiaoshou";leixingcg="caigoua";}
  140. console.log("调用获取竞品数据详细中间")
  141. var xphtml = "";
  142. GM_xmlhttpRequest({
  143. method: "post",
  144. url: 'https://www.taobaimei.com/thailand/inser_xp.php',
  145. data: "weiyi_id="+ weiyi_id+"&xuanpinGET_sj=" + "yes"+"&type=" + typea,
  146. headers: {"Content-Type": "application/x-www-form-urlencoded"},
  147. onload: function (r) {
  148. console.log(r)
  149. var value = $.parseJSON(r.response)[0];
  150. console.log(value)
  151. var arr = value.neirong.split('哦个');
  152. $.each(arr, function(index1, value1) {
  153. if (value1.indexOf("分行") !== -1) {
  154. var arr1 = value1.split('分行');
  155. var arrcg1 = value.caigou.split('分行');
  156. $.each(arr1, function(index2, value2) {
  157. xphtml=xphtml+"<div class='jisuan_roi' style='width:100%;border-bottom: 2px solid #808080;margin-top:5px;'>";
  158. var arr2 = value2.split('分隔');
  159. var arrcg2 = arrcg1[index2].split('分隔');
  160. var kuandu=10;
  161. $.each(arr2, function(index3, value3) {
  162. if(index2>0 && index3==1){
  163. xphtml=xphtml+"<span style='width:"+kuandu+"%;display: inline-block;'><input data-custom='"+index3+"_"+value.weiyi_ID+"' index-data='"+index2+","+index3+"' class='"+leixingxs+" xs"+index3+"_"+value.weiyi_ID+" mx"+index3+"' type='text' value='"+value3.replace(/¥/g, '')+"' style='color: black;text-align: center;width: 70%;'><button style='width: 20%; color: black; text-align: center; padding: 0px;' class='fuzhib1' data-custom='"+index3+"_"+value.weiyi_ID+"'>↑↓</button></span>";
  164.  
  165. }
  166. else{
  167. xphtml=xphtml+"<span class='"+leixingxs+" mx"+index3+"' style='width:"+kuandu+"%;display: inline-block;font-size: 12px;'>"+value3+"</span>";
  168. }
  169. });
  170. $.each(arrcg2, function(index4, value4) {
  171. if(index2==0){
  172. xphtml=xphtml+"<span style='width:"+kuandu+"%;display: inline-block;font-size: 12px;'>"+value4+"</span>";
  173. }else{
  174. xphtml=xphtml+"<span style='width:"+kuandu+"%;display: inline-block;'><input data-custom='"+index4+"_"+value.weiyi_ID+"' index-data='"+index2+","+index4+"' class='"+leixingcg+" cg"+index4+"_"+value.weiyi_ID+" cg"+index4+"' type='text' value='"+value4+"' style='color: black;text-align: center;width: 70%;'><button style='width: 20%; color: black; text-align: center; padding: 0px;' class='fuzhia1' data-custom='"+index4+"_"+value.weiyi_ID+"'>↑↓</button></span>";
  175. }
  176. });
  177. xphtml=xphtml+"</div>";
  178.  
  179. });
  180. } else {
  181. if(index1==0){
  182. xphtml=xphtml+"<div style='width:60%;height:140px;float:left;'>";
  183. }
  184. xphtml=xphtml+"<div style='width:100%;padding:10px;height: 35px;'>"+value1+"</div>";
  185. if(index1==3){
  186. xphtml=xphtml+"</div>";
  187. xphtml=xphtml+"<div style='width:40%;height:140px;float:left;'><div id='add_cgp' data-father-id='"+value.father_weiyi_id+"' style='width:80px;height:80px;padding:10px;float:left;justify-content: center;align-items: center;display: flex;background-color:black;border: 1px solid white;color: aliceblue;margin-top: 10px;'>添加当前</br>连接到采品</div><div id='content_cg"+value.father_weiyi_id+"'></div></div>";
  188. }
  189.  
  190. }
  191.  
  192.  
  193. });
  194. $('#content_sj'+value.father_weiyi_id).html(xphtml);
  195.  
  196. }
  197. });
  198. }
  199. function getxpdata_cg(father_id) {
  200. console.log("调用采购品"+father_id)
  201. $('#content_cg'+father_id).html("");
  202. var xphtml = "";
  203. GM_xmlhttpRequest({
  204. method: "post",
  205. url: 'https://www.taobaimei.com/thailand/inser_xp.php',
  206. data: "father_id="+ father_id+"&xuanpinGET_cg=" + "yes",
  207. headers: {"Content-Type": "application/x-www-form-urlencoded"},
  208. onload: function (r) {
  209. //console.log(r.response)
  210. var jsonObj = $.parseJSON(r.response);
  211.  
  212. $.each(jsonObj, function (key, value) {
  213. //下面是采购图片
  214. xphtml=xphtml+"<div style='width:100px;height:100px;padding:10px;float:left;position: relative;' class='jingpin_cg'><div style='position: absolute;color: red; font-weight: bold;width:80px;'><span style='background-color: blanchedalmond; padding: 0px 1px;'>采品"+key+"</span><span style='background-color: blanchedalmond; padding: 0px 1px;float: right;' id='delete_cp' data-father-id='"+value.father_id+"' data-weiyi-ID='"+value.ID+"'>×</span></div><div style='position: absolute;color: red;font-weight: bold;width:80px;bottom: 10px;'><span style='background-color: blanchedalmond; padding: 0px 1px;float: right;'><a href='"+value.url_lj+"' target='_blank'>🔗</a></span></div><img src='"+value.url+"' style='width:100%;height:100%;'></div>";
  215. });
  216. $('#content_cg'+father_id).append(xphtml);
  217. }
  218. });
  219. }
  220. function getxpdata_jp(father_id) {
  221. var xphtml = "";
  222. GM_xmlhttpRequest({
  223. method: "post",
  224. url: 'https://www.taobaimei.com/thailand/inser_xp.php',
  225. data: "father_id="+ father_id+"&xuanpinGET_jp=" + "yes",
  226. headers: {"Content-Type": "application/x-www-form-urlencoded"},
  227. onload: function (r) {
  228. // console.log(r.response)
  229. var jsonObj = $.parseJSON(r.response);
  230.  
  231. $.each(jsonObj, function (key, value) {
  232. //下面是左侧图片
  233. xphtml=xphtml+"<div style='width:100px;height:100px;padding:10px;float:left;position: relative;' class='jingpin_xz' data-weiyi-ID='"+value.weiyi_ID+"' data-father-id='"+value.father_id+"'><div style='position: absolute;color: red; font-weight: bold;width:80px;'><span style='background-color: blanchedalmond; padding: 0px 1px;'>竞品"+key+"</span><span style='background-color: blanchedalmond; padding: 0px 1px;float: right;' id='delete_jp' data-father-id='"+value.weiyi_ID+"' data-weiyi-ID='"+value.ID+"'>×</span></div><div style='position: absolute;color: red;font-weight: bold;width:80px;bottom: 10px;'><span style='background-color: blanchedalmond; padding: 0px 1px;float: right;'><a href='"+value.url_lj+"' target='_blank'>🔗</a></span></div><img src='"+value.url+"' style='width:100%;height:100%;'></div>";
  234. });
  235. $('#content_jp'+father_id).append(xphtml);
  236. }
  237. });
  238. }
  239. function getxpdata() {
  240. var xphtml = "";
  241. $('#xuanpin').html(xphtml)
  242. GM_xmlhttpRequest({
  243. method: "post",
  244. url: 'https://www.taobaimei.com/thailand/inser_xp.php',
  245. data: "xuanpinGET=" + "yes",
  246. headers: {"Content-Type": "application/x-www-form-urlencoded"},
  247. onload: function (r) {
  248. // code
  249. //console.log(r.response)
  250. // 使用jQuery进行JSON格式化
  251. var jsonObj = $.parseJSON(r.response);
  252.  
  253. $.each(jsonObj, function (key, value) {
  254. var beijingse="";
  255. if((key+1)%2==1){beijingse="background-color: rgba(128, 128, 128, 0.8);";}
  256. xphtml=xphtml+"<div style='display: flex;width:100%;"+beijingse+"' class='thisMsg xpall"+value.weiyi_ID+"'>";
  257. //下面是左侧图片
  258. xphtml=xphtml+"<div id='content_jp"+value.weiyi_ID+"' style='width:20%;float:left;'><div class='jingpin_xp' style='width:100px;height:100px;padding:10px;float:left;position: relative;' data-weiyi-ID='"+value.weiyi_ID+"' data-father-id='"+value.weiyi_ID+"'><div style='position: absolute;color: red; font-weight: bold;width:80px;'><span style='background-color: blanchedalmond; padding: 0px 1px;'>选品"+key+"</span><span style='background-color: blanchedalmond; padding: 0px 1px;float: right;' id='delete_xp' data-father-id='"+value.weiyi_ID+"'>×</span></div><div style='position: absolute;color: red;font-weight: bold;width:80px;bottom: 10px;'><span style='background-color: blanchedalmond; padding: 0px 1px;float: right;'><a href='"+value.url_lj+"' target='_blank'>🔗</a></span></div><img src='"+value.url+"' style='width:100%;height:100%;'></div><div id='add_jp' data-father-id='"+value.weiyi_ID+"' style='width:80px;height:80px;padding:10px;float:left;justify-content: center;align-items: center;display: flex;background-color: black;border: 1px solid white;color: aliceblue;margin-top: 10px;'>添加当前</br>连接到竞品"+value.caozuo+"</div></div>";
  259. xphtml=xphtml+"<div id='content_sj"+value.weiyi_ID+"' style='width:80%;float:left;max-height: 300px;overflow: auto;'>";
  260. var arr = value.neirong.split('哦个');
  261. $.each(arr, function(index1, value1) {
  262. if (value1.indexOf("分行") !== -1) {
  263. var arr1 = value1.split('分行');
  264. var arrcg1 = value.caigou.split('分行');
  265. $.each(arr1, function(index2, value2) {
  266. xphtml=xphtml+"<div class='jisuan_roi' style='width:100%;border-bottom: 2px solid #808080;margin-top:5px;'>";
  267. var arr2 = value2.split('分隔');
  268. var arrcg2 = arrcg1[index2].split('分隔');
  269. var kuandu=10;
  270. $.each(arr2, function(index3, value3) {
  271. if(index2>0 && index3==1){
  272. xphtml=xphtml+"<span style='width:"+kuandu+"%;display: inline-block;'><input data-custom='"+index3+"_"+value.weiyi_ID+"' index-data='"+index2+","+index3+"' class='xiaoshou xs"+index3+"_"+value.weiyi_ID+" mx"+index3+"' type='text' value='"+value3.replace(/¥/g, '')+"' style='color: black;text-align: center;width: 70%;'><button style='width: 20%; color: black; text-align: center; padding: 0px;' class='fuzhib' data-custom='"+index3+"_"+value.weiyi_ID+"'>↑↓</button></span>";
  273.  
  274. }
  275. else{
  276. xphtml=xphtml+"<span class='xiaoshou mx"+index3+"' style='width:"+kuandu+"%;display: inline-block;font-size: 12px;'>"+value3+"</span>";
  277. }
  278. });
  279. $.each(arrcg2, function(index4, value4) {
  280. if(index2==0){
  281. xphtml=xphtml+"<span style='width:"+kuandu+"%;display: inline-block;font-size: 12px;'>"+value4+"</span>";
  282. }else{
  283. xphtml=xphtml+"<span style='width:"+kuandu+"%;display: inline-block;'><input data-custom='"+index4+"_"+value.weiyi_ID+"' index-data='"+index2+","+index4+"' class='caigoua cg"+index4+"_"+value.weiyi_ID+" cg"+index4+"' type='text' value='"+value4+"' style='color: black;text-align: center;width: 70%;'><button style='width: 20%; color: black; text-align: center; padding: 0px;' class='fuzhia' data-custom='"+index4+"_"+value.weiyi_ID+"'>↑↓</button></span>";
  284. }
  285. });
  286. xphtml=xphtml+"</div>";
  287.  
  288. });
  289. } else {
  290. if(index1==0){
  291. xphtml=xphtml+"<div style='width:60%;height:140px;float:left;'>";
  292. }
  293. xphtml=xphtml+"<div style='width:100%;padding:10px;height: 35px;'>"+value1+"</div>";
  294. if(index1==3){
  295. xphtml=xphtml+"</div>";
  296. xphtml=xphtml+"<div style='width:40%;height:140px;float:left;'><div id='add_cgp' data-father-id='"+value.weiyi_ID+"' style='width:80px;height:80px;padding:10px;float:left;justify-content: center;align-items: center;display: flex;background-color:black;border: 1px solid white;color: aliceblue;margin-top: 10px;'>添加当前</br>连接到采品</div><div id='content_cg"+value.weiyi_ID+"'></div></div>";
  297. }
  298.  
  299. }
  300.  
  301.  
  302. });
  303. xphtml=xphtml+"</div>";
  304.  
  305. xphtml=xphtml+"</div>";
  306. xphtml=xphtml+"<div style='clear: both;border-bottom: 1px solid black; padding-bottom: 5px;'></div>";
  307. xphtml=xphtml+"</div>";
  308. $('#xuanpin').append(xphtml)
  309. xphtml = "";
  310. getxpdata_jp(value.weiyi_ID)
  311. getxpdata_cg(value.weiyi_ID)
  312. });
  313.  
  314.  
  315.  
  316. }
  317. });
  318. }
  319.  
  320. $(document).ready(function () {
  321. if (window.location.href.includes('https://detail.1688.com/')) {
  322. $('body').append('<div id="modal"></div>')
  323. }
  324. if ($("#modal").length > 0) {
  325. $("#modal").append('<div id="toggle" style="z-index: 2147483644;position: fixed;top: 40%;line-height: 100px;display: flex;align-items: center;margin-top: -25px;width: auto;height: 50px;border: 1px solid black;background: crimson;padding: 5px;color: white;" >打开选品</div><div id="sidebar" style="z-index: 2147483646; width: 0;height: 100vh;background-color: rgba(128, 128, 128, 0.7);color: white;position: fixed;top: 0;left: 0;overflow-x: hidden;transition: 0.5s;"></div>');
  326. }
  327.  
  328. $(document).on("click", "#toggle", function () {
  329.  
  330. if ($('#sidebar').html() === '') {
  331. var divhtml = '';
  332. divhtml = divhtml + '<div style="width:100%;height: 150px;background-color:black; display: flex;justify-content: center;align-items: center;"><div id="close_sidebar" style="position: absolute;top: 8px; right: 8px;width: 24px; height: 24px; background-color: #ccc; border: 1px solid #aaa;cursor: pointer;text-align: center;line-height: 24px;">X</div>';
  333. divhtml = divhtml + '<button style="padding:20px;margin:10px;color:black;" id="add_product">添加此品到品库</button>';
  334. divhtml = divhtml + '<div style="padding:20px;margin:10px;color:black;"><input id="caozuo" value="" placeholder="输入你的编号"></div>';
  335. // divhtml = divhtml + '<button style="padding:20px;margin:10px;color:black;">按钮3</button>';
  336. divhtml = divhtml + '</div>';
  337.  
  338. divhtml = divhtml + '<div id="xuanpin" style="width:100%;">';
  339. divhtml = divhtml + '</div>';
  340.  
  341. divhtml = divhtml + '</div>';
  342.  
  343. $('#toggle').text('点击隐藏');
  344. $('#sidebar').html(divhtml);
  345. getxpdata();
  346. $("#sidebar").animate({
  347. width: "1080px" // 设置侧边栏的宽度
  348. });
  349.  
  350. if (localStorage.getItem('caozuo') != null && localStorage.getItem('caozuo') != "undefined") {
  351. // 如果没有 'caozuo',则创建
  352. $("#caozuo").val(localStorage.getItem('caozuo'));
  353. }
  354. } else {
  355. $(this).text('打开选品');
  356. }
  357. });
  358.  
  359. });
  360.  
  361. //触发通过js动态添加的主品a
  362. $(document).on("click", "#add_product", function () {
  363. if (!window.location.href.includes('shopee.co.th')) {
  364. alert("只能在虾皮详情页加入选品");
  365. return;
  366. }
  367. if ($("#caozuo").val()=="") {
  368. alert("输入代表你的编号或名字");
  369. $("#caozuo").focus();
  370. return;
  371. }else{
  372. localStorage.setItem('caozuo',$("#caozuo").val());
  373. }
  374. var heji = [];
  375. heji.push($('.UBG7wZ:eq(1) picture img').first().attr('src'));
  376. $('div').filter('.detail-info-list').each(function () {
  377. // 在这里处理每个匹配的div元素
  378. heji.push($(this).text());
  379. });
  380. var bodytr = "";
  381. $('.t-table__header tr').each(function () {
  382. $(this).find('th').each(function () {
  383. // 在这里处理每个<td>元素
  384. bodytr = bodytr + $(this).text() + "分隔";
  385. });
  386. bodytr = bodytr.replace(/分隔$/, '');
  387. bodytr = bodytr + "分行";
  388. });
  389. //bodytr = bodytr.replace(/分行$/, '');
  390. $('.t-table__body tr').each(function () {
  391. $(this).find('td').each(function () {
  392. // 在这里处理每个<td>元素
  393. bodytr = bodytr + $(this).text() + "分隔";
  394. });
  395. bodytr = bodytr.replace(/分隔$/, '');
  396. bodytr = bodytr + "分行";
  397. });
  398. bodytr = bodytr.replace(/分行$/, '');
  399.  
  400. heji.push(bodytr);
  401. postdata(encodeURIComponent(JSON.stringify(heji)))
  402. });
  403. //触发通过js动态添加的竞品
  404. $(document).on("click", "#add_cgp", function () {
  405. // 检查当前窗口的URL是否包含特定字符串
  406. if (!window.location.href.includes('detail.1688.com')) {
  407. alert("只能在阿里巴巴加入采购品");
  408. return;
  409. }
  410. var src = $('.img-list-wrapper [ind="2"]').attr('src');
  411. var fatherid=$(this).data('father-id');
  412. GM_xmlhttpRequest({
  413. method: "post",
  414. url: 'https://www.taobaimei.com/thailand/inser_xp.php',
  415. data: "father_id="+ $(this).data('father-id')+"&urlcg=" + encodeURIComponent(window.location.href)+"&picurl=" +src,
  416. headers: {"Content-Type": "application/x-www-form-urlencoded"},
  417. onload: function (r) {
  418. // code
  419. console.log("父亲ID"+fatherid);
  420. getxpdata_cg(fatherid)
  421. console.log(r)
  422. }
  423. });
  424. });
  425. //触发删除竞品
  426. $(document).on("click", "#delete_jp", function () {
  427. if(!confirm("你确定要删除"+$(this).prev().text()+"吗?")){
  428. return;
  429. }
  430. var father_id = $(this).data('weiyi-id');
  431. var father_id1 = $(this).data('father-id');
  432. GM_xmlhttpRequest({
  433. method: "post",
  434. url: 'https://www.taobaimei.com/thailand/inser_xp.php',
  435. data: "delete_jp="+ father_id,
  436. headers: {"Content-Type": "application/x-www-form-urlencoded"},
  437. onload: function (r) {
  438. // code
  439. console.log(r)
  440. if (r.response != "竞品删除成功") {
  441. alert("出错了"+r.response);
  442. } else {
  443. getxpdata_jp(father_id1);
  444. }
  445. }
  446. });
  447. });
  448. //触发删除选品
  449. $(document).on("click", "#delete_xp", function () {
  450. if(!confirm("你确定要删除"+$(this).prev().text()+"吗?")){
  451. return;
  452. }
  453. var father_id = $(this).data('father-id');
  454. GM_xmlhttpRequest({
  455. method: "post",
  456. url: 'https://www.taobaimei.com/thailand/inser_xp.php',
  457. data: "delete_xp="+ father_id,
  458. headers: {"Content-Type": "application/x-www-form-urlencoded"},
  459. onload: function (r) {
  460. // code
  461. console.log(r)
  462. if (r.response === "删除成功") {
  463. $(".xpall"+father_id).remove();
  464. } else {
  465. alert("出错了"+r.response);
  466. }
  467.  
  468.  
  469. }
  470. });
  471. });
  472. //触发通过js动态添加的竞品
  473. $(document).on("click", "#delete_cp", function () {
  474. if(!confirm("你确定要删除"+$(this).prev().text()+"吗?")){
  475. return;
  476. }
  477. var father_id = $(this).data('father-id');
  478. var weiyi_ID = $(this).data('weiyi-id');
  479. GM_xmlhttpRequest({
  480. method: "post",
  481. url: 'https://www.taobaimei.com/thailand/inser_xp.php',
  482. data: "delete_cp="+ weiyi_ID,
  483. headers: {"Content-Type": "application/x-www-form-urlencoded"},
  484. onload: function (r) {
  485. // code
  486. getxpdata_cg(father_id)
  487.  
  488. console.log(r)
  489. }
  490. });
  491. });
  492. //触发通过js动态添加的竞品
  493. $(document).on("click", "#add_jp", function () {
  494. // 检查当前窗口的URL是否包含特定字符串
  495. if (!window.location.href.includes('shopee.co.th')) {
  496. alert("只能在虾皮详情页加入竞品");
  497. return;
  498. }
  499. var heji = [];
  500. heji.push($('.UBG7wZ picture img').first().attr('src'));
  501. $('div').filter('.detail-info-list').each(function () {
  502. // 在这里处理每个匹配的div元素
  503. heji.push($(this).text());
  504. });
  505. var bodytr = "";
  506. $('.t-table__header tr').each(function () {
  507. $(this).find('th').each(function () {
  508. // 在这里处理每个<td>元素
  509. bodytr = bodytr + $(this).text() + "分隔";
  510. });
  511. bodytr = bodytr.replace(/分隔$/, '');
  512. bodytr = bodytr + "分行";
  513. });
  514. //bodytr = bodytr.replace(/分行$/, '');
  515. $('.t-table__body tr').each(function () {
  516. $(this).find('td').each(function () {
  517. // 在这里处理每个<td>元素
  518. bodytr = bodytr + $(this).text() + "分隔";
  519. });
  520. bodytr = bodytr.replace(/分隔$/, '');
  521. bodytr = bodytr + "分行";
  522. });
  523. bodytr = bodytr.replace(/分行$/, '');
  524.  
  525. heji.push(bodytr);
  526. //console.log(heji)
  527. postdata_jp(encodeURIComponent(JSON.stringify(heji)),$(this).data('father-id'))
  528. });
  529.  
  530. //触发通过js动态改变数据列表页
  531. $(document).on("click", ".fuzhia", function () {
  532. $('.cg'+$(this).data('custom')).val($(this).prev('input').val());
  533. jisuan_roi($(this));
  534. update_input($(this).data('custom'),$(this))
  535. });
  536. //触发批量修改价格
  537. $(document).on("click", ".fuzhib", function () {
  538. $('.xs'+$(this).data('custom')).val($(this).prev('input').val());
  539. jisuan_roi($(this));
  540. update_xiaoshou($(this).data('custom'),$(this))
  541. update_input($(this).data('custom'),$(this))
  542. });
  543. //触发修改单个采购输入款值
  544. $(document).on("change", ".caigoua", function () {
  545. jisuan_roi($(this));
  546. update_input($(this).data('custom'),$(this))
  547.  
  548. });
  549. //触发单个数改变保存
  550. $(document).on("change", ".xiaoshou", function () {
  551. console.log("触发单个数改变")
  552. jisuan_roi($(this));
  553. update_xiaoshou($(this).data('custom'),$(this))
  554. update_input($(this).data('custom'),$(this))
  555. });
  556.  
  557.  
  558. //触发竞品点击改变数据列表页
  559. $(document).on("click", ".fuzhia1", function () {
  560. $('.cg'+$(this).data('custom')).val($(this).prev('input').val());
  561. jisuan_roi($(this));
  562. update_input($(this).data('custom'),$(this))
  563. });
  564. //触发竞品点击批量修改价格
  565. $(document).on("click", ".fuzhib1", function () {
  566. $('.xs'+$(this).data('custom')).val($(this).prev('input').val());
  567. jisuan_roi($(this));
  568. update_xiaoshou($(this).data('custom'),$(this))
  569. update_input($(this).data('custom'),$(this))
  570. });
  571. //触发竞品点击修改单个采购输入款值
  572. $(document).on("change", ".caigoua1", function () {
  573. jisuan_roi($(this));
  574. update_input($(this).data('custom'),$(this))
  575.  
  576. });
  577. //触发竞品点击单个数改变保存
  578. $(document).on("change", ".xiaoshou1", function () {
  579. console.log("触发竞品单个数改变")
  580. jisuan_roi($(this));
  581. update_xiaoshou($(this).data('custom'),$(this))
  582. update_input($(this).data('custom'),$(this))
  583. });
  584.  
  585. //触发通过js动态改变数据列表页
  586. $(document).on("click", ".jingpin_xz", function () {
  587. console.log($(this).data('father-id'))
  588. var fatherid=$(this).data('father-id')
  589. getxpdata_sj($(this).data('weiyi-id'),"xp_jp")
  590. setTimeout(function() {
  591. // 这里是你想要延迟执行的代码
  592. getxpdata_cg(fatherid)
  593. }, 3000);
  594. });
  595.  
  596. //触发选品改变数据列表页
  597. $(document).on("click", ".jingpin_xp", function () {
  598. console.log($(this).data('father-id'))
  599. var fatherid=$(this).data('father-id')
  600. getxpdata_sj($(this).data('weiyi-id'),"xp_xuanpin")
  601. setTimeout(function() {
  602. // 这里是你想要延迟执行的代码
  603. getxpdata_cg(fatherid)
  604. }, 3000);
  605. });
  606.  
  607. $(document).on("click", "#close_sidebar", function () {
  608. $('#sidebar').empty();
  609. $("#sidebar").animate({
  610. width: "0" // 设置侧边栏的宽度
  611. });
  612. $("#toggle").text('打开选品');
  613. });
  614.  
  615. $(document).click(function () {
  616. if($("#sidebar").width()=="1080"){
  617. event.stopPropagation(); // 阻止点击事件冒泡到document
  618. }
  619. //console.log("清空")
  620. //$('#sidebar').empty();
  621. //$("#sidebar").animate({
  622. // width: "0" // 设置侧边栏的宽度
  623. // });
  624. // $("#toggle").text('打开选品');
  625. });
  626. // Your code here...
  627. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址