这里把jg的伪代码贴出来,方便测试function jg(jf) {var jI = jW.call(this, jf) || this;jI.doms = {};jI.count = 0;jI.globalTimer = 0;jI.timeoutCount = 0;jI.firstTimeStamp = 0;jI.moveingBarX = 0;jI.moveingBarY = 0;jI.maxLeft = 0;jI._x = 0;jI._y = 0;jI.actualMove = 0;jI.initTimeStamp = Date.now();jI.isDrag = false;jI.data = {trajectory: [],env: {Type: 0,Return: 0,zone: [],client: [],Timestamp: [],count: 0,timeout: 0}};jI.customStyle = {};jI.ids = {help: "yodaHelp",boxWrapper: "yodaBoxWrapper",box: "yodaBox",moveingbar: "yodaMoveingBar",tip: "yodaSliderTip"};jI.whiteDuration = 0;jI.sliderMaxLenth = 100;jI.sliderType = 0;jI.sliderReturn = 0;jI.oceanPoint = [];jI.init = function () {var jM = jI.config;var jK = jM.action;var jF = jM.type;var jP = jM.style;var jN = jM.requestCode;var jJ = jM.root;var jO = jM.t;var jo = jM.display;jI.customStyle = jP || {};if (aV(jI.customStyle.slider) === "object") {jI.customStyle = jI.customStyle.slider;}try {var jQ = new aY(jI.config);var jS = jQ.template(jI.ids, jI.customStyle || {}, vX(jI.config));vx(jJ, jS, jo);} catch (jp) {vE(jp, jK, jF);return;}jI.whiteDuration = Date.now() - jI.config.yodaInitTime;jI.doms = vC(jI.ids);if (typeof jO === "number") {jI.sliderType = jO;}var jA = function jU(jD, jX) {return Math.round(Math.random() * (jX - jD)) + jD;};if (jO === 2) {var jk = jI.doms.boxWrapper;var jY = jk.getBoundingClientRect().width;var js = Math.ceil(jY / 100 * 70);var jZ = Math.floor(jY / 100) * 100;var jB = jA(js, jZ);jk.style.width = jB + "px";}if (jO === 3) {var je = jA(50, 70);jI.sliderMaxLenth = je;}jI.initSlider(jI.doms.box, jI.doms.boxWrapper);var jn = {duration: jI.whiteDuration,method: bT.SLIDER,mtaction: "loading",action: jK,requestCode: jN};vK(jn);if (jI.config.mounted) {vz(jI.config.mounted);}// change// jI.createbgImage("https://s3plus.meituan.net/v1/mss_f231eb419c414559a1837748d11d4312/yoda-resources/slider/m_loading.png", jK).then(function () {});// TOLOOKsetTimeout(function () {try {RQ("slider", jN);} catch (jX) {var jD = jX;window.Yoda.CAT.sendLog(location.href, "jsError", jD.message, jD.stack || "", "info");}}, 0);};jI.initSlider = function (jM, jK) {jI.drag = jM;jI.moveingBar = jI.doms.moveingbar;jI.maxContainer = jK;H8(jI.doms.box, "mousedown", jI.startDrag);H8(jI.doms.box, "touchstart", jI.startDrag);H8(jI.doms.box, "touchstart", function () {window.Yoda.CAT.sendLog(location.href, "jsError", "PC上显示了i版的滑动", "使用了touchstart事件触发了滑块", "info");});var jF = {action: jI.config.action,type: jI.config.type,yodaInitTime: jI.config.yodaInitTime,whiteDuration: jI.whiteDuration};Hy(jF);if (typeof jI.config.mounted === "function") {jI.config.mounted();}};jI.help = function () {var jM = "https://verify.inf.test.meituan.com/feedback/manmachine/#/?requestCode=" + jI.config.requestCode;window.open(jM);};jI.startDrag = function (jM) {jI.count++;clearTimeout(jI.globalTimer);jI.timeoutListen();if (!jI.firstTimeStamp) {jI.firstTimeStamp = Date.now();}jI.moveingBarX = jI.moveingBar.clientWidth;jI.maxLeft = jI.maxContainer.clientWidth - jI.drag.offsetWidth;if (jM.clientX) {jI._x = jM.clientX;jI._y = jM.clientY;} else {jI._x = jM.targetTouches[0].clientX;jI._y = jM.targetTouches[0].clientY;}H8(document, "mousemove", jI.moveDrag);H8(document, "mouseup", jI.stopDrag);H8(document, "touchmove", jI.moveDrag);H8(document, "touchend", jI.stopDrag);H8(document, "mousemove", jI.sliderMoveDrag);H8(document, "mouseup", jI.sliderStopDrag);H8(document, "touchmove", jI.sliderMoveDrag);H8(document, "touchend", jI.sliderStopDrag);H9(jI.doms.box, "mousedown", jI.startDrag);H9(jI.doms.box, "touchstart", jI.startDrag);var jK = jI.maxContainer;var jF = {startX: vM(jI._x),startY: vM(jI._y),w: vM(jK.clientWidth),h: vM(jK.clientHeight),clientX: vM(jK.getBoundingClientRect().left),clientY: vM(jK.getBoundingClientRect().top)};jI.onStart(jF);Hm(jM);};jI.timeoutListen = function () {jI.globalTimer = window.setTimeout(function () {clearTimeout(jI.globalTimer);if (!jI.isDrag) {jI.stopDrag();if (jI.data) {jI.delLastItem(jI.data.trajectory);}jI.timeoutCount++;}}, 3000);};jI.move = function (jM) {var jK = 0;var jF = 0;if (jM.clientX) {jK = jM.clientX;jF = jM.clientY;} else if (jM.targetTouches) {jK = jM.targetTouches[0].clientX;jF = jM.targetTouches[0].clientY;}var jP = {clientX: jK,clientY: jF};return jP;};jI.sliderMoveDrag = function (jM) {var jK = jI.move(jM);var jF = jK.clientX;var jP = jK.clientY;jI.oceanPoint.push([0, jF, jP, Date.now() - jI.initTimeStamp]);};jI.sliderStopDrag = function (jM) {var jK = jI.move(jM);var jF = jK.clientX;var jP = jK.clientY;jI.oceanPoint.push([0, jF, jP, Date.now() - jI.initTimeStamp]);H9(document, "touchmove", jI.sliderMoveDrag);H9(document, "touchend", jI.sliderStopDrag);H9(document, "mousemove", jI.sliderMoveDrag);H9(document, "mouseup", jI.sliderStopDrag);jI.sliderPCPoint(JSON.stringify(jI.oceanPoint));jI.oceanPoint.splice(0);};jI.moveDrag = function (jM) {var jK = jI.move(jM);var jF = jK.clientX;var jP = jK.clientY;var jN = jF - jI._x;var jJ = jP - jI._y;if (Math.abs(jN) < 6 && Math.abs(jJ) < 6) {return false;}if (jN < 0) {jN = 0;}if (jN > jI.maxLeft) {jN = jI.maxLeft;}if (jI.sliderMaxLenth !== 100 && jN / jI.maxContainer.clientWidth * 100 > jI.sliderMaxLenth) {jI.sliderReturn = jN;jI.sliderMaxLenth = 100;jN = 0;Hm(jM);jI.stopDrag();}jI.setBoxPosition(jN);jI.onMove(vM(jF), vM(jP));if (jN === jI.maxLeft) {jI.stopDrag();}Hm(jM);};jI.stopDrag = function () {H9(document, "mousemove", jI.moveDrag);H9(document, "mouseup", jI.stopDrag);H9(document, "touchmove", jI.moveDrag);H9(document, "touchend", jI.stopDrag);jI.dealMove();};jI.setBoxPosition = function (jM) {jI.drag.style.left = jM + "px";jI.moveingBar.style.width = jI.moveingBarX + jM + "px";jI.actualMove = jM;};jI.dealMove = function () {if (jI.actualMove === jI.maxLeft) {jI.isDrag = true;H9(jI.drag, "mousedown", jI.startDrag);H9(jI.drag, "touchstart", jI.startDrag);jI.actualMove = 0;jI.drag.className = "boxLoading " + (jI.customStyle.boxLoading || "");jI.onStop();return false;}jI.backToStart();};jI.boxOk = function () {jI.drag.className = "boxOk " + (jI.customStyle.boxOk || "");};jI.boxStatic = function () {jI.drag.innerHTML = "";jI.drag.className = "boxStatic " + (jI.customStyle.boxStatic || "");jI.moveingBar.className = "moveingBar " + (jI.customStyle.moveingBar || "");};jI.boxError = function () {jI.drag.className = "boxError " + (jI.customStyle.boxError || "");jI.moveingBar.className = "moveingBarError " + (jI.customStyle.moveingBarError || "");};jI.backToStart = function () {var jM = 0;var jK = // TOLOOKsetInterval(function () {var jF = vw.easeOutCubic(jM * 17, 0, jI.actualMove, 500);var jP = jI.actualMove - jF;jI.drag.style.left = jP + "px";jI.drag.style.left = jP + "px";jI.moveingBar.style.width = jI.moveingBarX + jP + "px";if (jP <= 0) {jI.drag.style.left = "0px";jI.drag.style.left = "0px";jI.moveingBar.style.width = jI.moveingBarX + "px";jI.actualMove = 0;clearInterval(jK);H8(jI.drag, "mousedown", jI.startDrag);H8(jI.drag, "touchstart", jI.startDrag);}jM++;jI.boxStatic();}, 17);};jI.onStart = function (jM) {var jK = jM.startX;var jF = jM.startY;var jP = jM.w;var jN = jM.h;var jJ = jM.clientX;var jO = jM.clientY;jI.data.env.zone = [jP, jN];jI.data.env.client = [jJ, jO];jI.data.trajectory.push({point: [[0, jK, jF, Date.now() - jI.initTimeStamp]],vector: {orientation: "h"}});jI.oceanPoint.push([0, jK, jF, Date.now() - jI.initTimeStamp]);var jQ = {action: jI.config.action,method: "71",requestCode: jI.config.requestCode};vN(jQ);};jI.onMove = function (jM, jK) {var jF = jI.data.trajectory;if (Array.isArray(jF) && jF.length) {jF[jF.length - 1].point.push([0, jM, jK, Date.now() - jI.initTimeStamp]);}};jI.showMessage = function (jM) {jI.doms.tip.textContent = jM;Ha(jI.doms.tip);var jK = window.setTimeout(function () {clearTimeout(jK);Hh(jI.doms.tip);}, 3000);};jI.config = jf;var jd = jf.theme || "meituan";if (typeof window.yodaTheme === "function") {window.yodaTheme(jd);}jI.init();return jI;
}
jg.prototype.onStop = function () {var jf = this;var jI = this.data.trajectory.length - 3;this.data.trajectory = this.data.trajectory.slice(jI > 0 ? jI : 0);this.data.env.Timestamp = [this.initTimeStamp, this.firstTimeStamp];this.data.env.count = this.count;this.data.env.timeout = this.timeoutCount;this.data.env.Type = this.sliderType;this.data.env.Return = Number(this.sliderReturn.toFixed(0));var jc = this.config.requestCode;var jz = {id: bT.SLIDER,request_code: jc,behavior: Rx(this.data, jc, this.config.isDegrade),fingerprint: "",action: this.config.action};this.verify(jc, jz).then(function (jE) {if (jE) {var jd = jE.message;var jM = jE.code;var jK = vn.isNeedSwap(jM);jf.boxError();if (!jK) {jf.showMessage(jd);}if (jM !== "jump" && jM !== 121056 && !jK) {// TOLOOKsetTimeout(function () {jf.backToStart();}, 1000);}} else {jf.boxOk();}});
};
jg.prototype.delLastItem = function (jf) {if (Array.isArray(jf) && jf.length) {jf.length = jf.length - 1;}
};