Best JavaScript code snippet using wpt
mutations.js
Source:mutations.js
1import {2 LoadAdvertList,3 LoadCateGrop,4 getQuery,5 GetSpecialActivity,6 GetReferenceProductList,7 getCheckTime,8 HandleImageData,9 HandleProductData,10 LoadProductByCate,11 Cookies,12 LoadActivityList,13 LoadGetTypeTree14} from '../server/getData.js'15import axios from "axios";16import Vue from 'vue';17var more = require('../assets/images/more.jpg')18var cateMore = require('../assets/images/catemore.png')19export default {20 changeFlag: function (state, id) {21 state.flag = id.state;22 },23 changeHeaderShow: function (state, id) {24 state.HeaderShow = id.state;25 },26 changeFlagRIght: function (state, id) {27 state.flagRight = id.state;28 },29 getHome: function (state, id) {30 var This = this;31 var CheckTime = ''32 LoadAdvertList("IMAGE", "HOME_BANNER", 1, 100, CheckTime).then(function (res) {33 This.state.home.swiperSlides = HandleImageData(res)34 This.state.home.loadingFlag++;35 })36 LoadAdvertList("IMAGE", "HOME_SPECIAL_AREA", 1, 100, CheckTime).then(function (res) {37 This.state.home.specialAreaContent = HandleImageData(res)38 This.state.home.loadingFlag++;39 })40 LoadAdvertList("PRODUCT", "HOME_HOT", 1, 26, CheckTime).then(function (res) {41 This.state.home.HotSaleProduct = HandleProductData(res)42 if (This.state.home.HotSaleProduct.length == 26) {43 var obj = {}44 obj.ImageUrl = more45 This.state.home.HotSaleProduct.push(obj)46 }47 // This.state.home.loadingFlag++;48 })49 LoadAdvertList("IMAGE", "HOMT_ADVERTISING_SPACE_1", 1, 100, CheckTime).then(function (res) {50 This.state.home.adversitingone = HandleImageData(res)51 This.state.home.loadingFlag++;52 })53 LoadAdvertList("IMAGE", "HOMT_ADVERTISING_SPACE_2", 1, 100, CheckTime).then(function (res) {54 This.state.home.adversitingtwo = [];55 This.state.home.adversitingtwo = HandleImageData(res)56 This.state.home.loadingFlag++;57 })58 LoadAdvertList("IMAGE", "HOMT_ADVERTISING_SPACE_3", 1, 100, CheckTime).then(function (res) {59 This.state.home.adversitingthree = [];60 This.state.home.adversitingthree = HandleImageData(res)61 This.state.home.loadingFlag++;62 })63 LoadAdvertList("PRODUCT", "HOME_NEW_PRODUCT", 1, 9, CheckTime).then(function (res) {64 This.state.home.NewProduct = HandleProductData(res)65 // This.state.home.loadingFlag++;66 })67 LoadAdvertList("IMAGE", "HOME_SPECIAL_SPACE", 1, 100, CheckTime).then(function (res) {68 This.state.home.specialArr = HandleImageData(res)69 This.state.home.loadingFlag++;70 })71 LoadAdvertList("PRODUCT", "HOME_RECOMMEND", 1, 10, CheckTime).then(function (res) {72 This.state.home.RecommendProduct = HandleProductData(res)73 // This.state.home.loadingFlag++;74 })75 LoadAdvertList("IMAGE", "HOME_ARTICLE", 1, 100, CheckTime).then(function (res) {76 This.state.home.HomeAritcal = HandleImageData(res)77 This.state.home.loadingFlag++;78 })79 // éæ¶ç¹æ 80 LoadAdvertList('PRODUCT', 'HOME_LIMITEDTIME', 1, 4, CheckTime).then(function (res) {81 This.state.home.specialTimeLimitArr = HandleProductData(res);82 })83 LoadAdvertList("IMAGE", "HOME_YUANWEI", 1, 100, CheckTime).then(function (res) {84 res.data.Data.forEach(v => {85 if (v.ImageUrl) {86 v.ImageUrl = JSON.parse(v.ImageUrl)[0].ServerUrl + JSON.parse(v.ImageUrl)[0].FilePath + ".thumb." + JSON.parse(v.ImageUrl)[0].FileExt87 }88 });89 This.state.home.originalCompilation = res.data.Data90 This.state.home.loadingFlag++;91 })92 },93 getMs: function () {94 var This = this;95 var CheckTime = '';96 // LoadCateGrop().then(function(res){97 // })98 LoadAdvertList("PRODUCT", "MS_NEW_PRODUCT", 1, 9, CheckTime).then(function (res) {99 This.state.ms.NewProduct = HandleProductData(res)100 })101 LoadAdvertList("IMAGE", "MS_BANNER", 1, 100, CheckTime).then(function (res) {102 This.state.ms.swiperSlides = HandleImageData(res)103 This.state.ms.loadingFlag++;104 })105 LoadAdvertList("IMAGE", "MS_ARTICLE", 1, 100, CheckTime).then(function (res) {106 This.state.ms.MsAritcal = HandleImageData(res)107 This.state.ms.loadingFlag++;108 })109 LoadAdvertList("IMAGE", "MS_CATEGORY", 1, 9, CheckTime).then(function (res) {110 This.state.ms.categoryArrBefore = HandleImageData(res)111 if (This.state.ms.categoryArrBefore.length > 0) {112 var aObj = {113 Title: "æ´å¤",114 ImageUrl: cateMore,115 URL: This.state.ms.categoryArrBefore[0].URL116 };117 This.state.ms.categoryArrBefore.push(aObj);118 }119 This.state.ms.loadingFlag++;120 })121 LoadAdvertList("IMAGE", "MS_AREA", 1, 100, CheckTime).then(function (res) {122 This.state.ms.categoryAreaArr = HandleImageData(res)123 This.state.ms.loadingFlag++;124 })125 LoadAdvertList("PRODUCT", "MS_HOTPRODUCT", 1, 100, CheckTime).then(function (res) {126 This.state.ms.hotRecommendLevel = HandleProductData(res)127 })128 LoadAdvertList("PRODUCT", "MS_HOTRECOMMEND_VERTICAL", 1, 10, CheckTime).then(function (res) {129 This.state.ms.hotRecommendVertical = HandleProductData(res)130 })131 },132 getJjjz: function () {133 var This = this;134 var CheckTime = ''135 LoadAdvertList("PRODUCT", "JJJZ_NEW_PRODUCT", 1, 9, CheckTime).then(function (res) {136 This.state.jjjz.NewProduct = HandleProductData(res)137 })138 LoadAdvertList("IMAGE", "jjjz_BANNER", 1, 100, CheckTime).then(function (res) {139 This.state.jjjz.swiperSlides = HandleImageData(res)140 This.state.jjjz.loadingFlag++;141 })142 LoadAdvertList("IMAGE", "JJJZ_ARTICLE", 1, 100, CheckTime).then(function (res) {143 This.state.jjjz.jjjzAritcal = HandleImageData(res)144 This.state.jjjz.loadingFlag++;145 })146 LoadAdvertList("IMAGE", "jjjz_CATEGORY", 1, 9, CheckTime).then(function (res) {147 This.state.jjjz.categoryArrBefore = HandleImageData(res)148 if (This.state.jjjz.categoryArrBefore.length > 0) {149 var aObj = {150 Title: "æ´å¤",151 ImageUrl: cateMore,152 URL: This.state.jjjz.categoryArrBefore[0].URL153 };154 This.state.jjjz.categoryArrBefore.push(aObj);155 }156 This.state.jjjz.loadingFlag++;157 })158 LoadAdvertList("IMAGE", "jjjz_AREA", 1, 100, CheckTime).then(function (res) {159 This.state.jjjz.categoryAreaArr = HandleImageData(res)160 This.state.jjjz.loadingFlag++;161 })162 LoadAdvertList("PRODUCT", "jjjz_HOTPRODUCT", 1, 100, CheckTime).then(function (res) {163 This.state.jjjz.hotRecommendLevel = HandleProductData(res)164 })165 LoadAdvertList("PRODUCT", "jjjz_HOTRECOMMEND_VERTICAL", 1, 10, CheckTime).then(function (res) {166 This.state.jjjz.hotRecommendVertical = HandleProductData(res)167 })168 },169 getJydq: function () {170 var This = this;171 var CheckTime = ''172 LoadAdvertList("PRODUCT", "JYDQ_NEW_PRODUCT", 1, 9, CheckTime).then(function (res) {173 This.state.jydq.NewProduct = HandleProductData(res)174 })175 LoadAdvertList("IMAGE", "JYDQ_BANNER", 1, 100, CheckTime).then(function (res) {176 This.state.jydq.swiperSlides = HandleImageData(res)177 This.state.jydq.loadingFlag++;178 })179 LoadAdvertList("IMAGE", "JYDQ_ARTICLE", 1, 100, CheckTime).then(function (res) {180 This.state.jydq.jydqAritcal = HandleImageData(res)181 This.state.jydq.loadingFlag++;182 })183 LoadAdvertList("IMAGE", "JYDQ_CATEGORY", 1, 9, CheckTime).then(function (res) {184 This.state.jydq.categoryArrBefore = HandleImageData(res)185 if (This.state.jydq.categoryArrBefore.length > 0) {186 var aObj = {187 Title: "æ´å¤",188 ImageUrl: cateMore,189 URL: This.state.jydq.categoryArrBefore[0].URL190 };191 This.state.jydq.categoryArrBefore.push(aObj);192 }193 This.state.jydq.loadingFlag++;194 })195 LoadAdvertList("IMAGE", "JYDQ_AREA", 1, 100, CheckTime).then(function (res) {196 This.state.jydq.categoryAreaArr = HandleImageData(res)197 This.state.jydq.loadingFlag++;198 })199 LoadAdvertList("PRODUCT", "JYDQ_HOTPRODUCT", 1, 100, CheckTime).then(function (res) {200 This.state.jydq.hotRecommendLevel = HandleProductData(res)201 })202 LoadAdvertList("PRODUCT", "JYDQ_HOTRECOMMEND_VERTICAL", 1, 10, CheckTime).then(function (res) {203 This.state.jydq.hotRecommendVertical = HandleProductData(res)204 })205 },206 getMyyp: function () {207 var This = this;208 var CheckTime = ''209 LoadAdvertList("PRODUCT", "MYYP_NEW_PRODUCT", 1, 9, CheckTime).then(function (res) {210 This.state.myyp.NewProduct = HandleProductData(res)211 })212 LoadAdvertList("IMAGE", "MYYP_BANNER", 1, 100, CheckTime).then(function (res) {213 This.state.myyp.swiperSlides = HandleImageData(res)214 This.state.myyp.loadingFlag++;215 })216 LoadAdvertList("IMAGE", "MYYP_ARTICLE", 1, 100, CheckTime).then(function (res) {217 This.state.myyp.myypAritcal = HandleImageData(res)218 This.state.myyp.loadingFlag++;219 })220 LoadAdvertList("IMAGE", "MYYP_CATEGORY", 1, 9, CheckTime).then(function (res) {221 This.state.myyp.categoryArrBefore = HandleImageData(res)222 if (This.state.myyp.categoryArrBefore.length > 0) {223 var aObj = {224 Title: "æ´å¤",225 ImageUrl: cateMore,226 URL: This.state.myyp.categoryArrBefore[0].URL227 };228 This.state.myyp.categoryArrBefore.push(aObj);229 }230 This.state.myyp.loadingFlag++;231 })232 LoadAdvertList("IMAGE", "MYYP_AREA", 1, 100, CheckTime).then(function (res) {233 This.state.myyp.categoryAreaArr = HandleImageData(res)234 This.state.myyp.loadingFlag++;235 })236 LoadAdvertList("PRODUCT", "MYYP_HOTPRODUCT", 1, 100, CheckTime).then(function (res) {237 This.state.myyp.hotRecommendLevel = HandleProductData(res)238 })239 LoadAdvertList("PRODUCT", "MYYP_HOTRECOMMEND_VERTICAL", 1, 10, CheckTime).then(function (res) {240 This.state.myyp.hotRecommendVertical = HandleProductData(res)241 })242 },243 getMzgh: function () {244 var This = this;245 var CheckTime = '';246 LoadAdvertList("PRODUCT", "MZGH_NEW_PRODUCT", 1, 9, CheckTime).then(function (res) {247 This.state.mzgh.NewProduct = HandleProductData(res)248 })249 LoadAdvertList("IMAGE", "MZGH_BANNER", 1, 100, CheckTime).then(function (res) {250 This.state.mzgh.swiperSlides = HandleImageData(res)251 This.state.mzgh.loadingFlag++;252 })253 LoadAdvertList("IMAGE", "MZGH_ARTICLE", 1, 100, CheckTime).then(function (res) {254 This.state.mzgh.mzghAritcal = HandleImageData(res)255 This.state.mzgh.loadingFlag++;256 })257 LoadAdvertList("IMAGE", "MZGH_CATEGORY", 1, 9, CheckTime).then(function (res) {258 This.state.mzgh.categoryArrBefore = HandleImageData(res)259 if (This.state.mzgh.categoryArrBefore.length > 0) {260 var aObj = {261 Title: "æ´å¤",262 ImageUrl: cateMore,263 URL: This.state.mzgh.categoryArrBefore[0].URL264 };265 This.state.mzgh.categoryArrBefore.push(aObj);266 }267 This.state.mzgh.loadingFlag++;268 })269 LoadAdvertList("IMAGE", "MZGH_AREA", 1, 100, CheckTime).then(function (res) {270 This.state.mzgh.categoryAreaArr = HandleImageData(res)271 This.state.mzgh.loadingFlag++;272 })273 LoadAdvertList("PRODUCT", "MZGH_HOTPRODUCT", 1, 100, CheckTime).then(function (res) {274 This.state.mzgh.hotRecommendLevel = HandleProductData(res)275 })276 LoadAdvertList("PRODUCT", "MZGH_HOTRECOMMEND_VERTICAL", 1, 10, CheckTime).then(function (res) {277 This.state.mzgh.hotRecommendVertical = HandleProductData(res)278 })279 },280 getQcbk: function () {281 var This = this;282 var CheckTime = ''283 LoadAdvertList("PRODUCT", "QCBK_NEW_PRODUCT", 1, 9, CheckTime).then(function (res) {284 This.state.qcbk.NewProduct = HandleProductData(res)285 })286 LoadAdvertList("IMAGE", "QCBK_BANNER", 1, 100, CheckTime).then(function (res) {287 This.state.qcbk.swiperSlides = HandleImageData(res)288 This.state.qcbk.loadingFlag++;289 })290 LoadAdvertList("IMAGE", "QCBK_ARTICLE", 1, 100, CheckTime).then(function (res) {291 This.state.qcbk.qcbkAritcal = HandleImageData(res)292 This.state.qcbk.loadingFlag++;293 })294 LoadAdvertList("IMAGE", "QCBK_CATEGORY", 1, 9, CheckTime).then(function (res) {295 This.state.qcbk.categoryArrBefore = HandleImageData(res)296 if (This.state.qcbk.categoryArrBefore.length > 0) {297 var aObj = {298 Title: "æ´å¤",299 ImageUrl: cateMore,300 URL: This.state.qcbk.categoryArrBefore[0].URL301 };302 This.state.qcbk.categoryArrBefore.push(aObj);303 }304 This.state.qcbk.loadingFlag++;305 })306 LoadAdvertList("IMAGE", "QCBK_AREA", 1, 100, CheckTime).then(function (res) {307 This.state.qcbk.categoryAreaArr = HandleImageData(res)308 This.state.qcbk.loadingFlag++;309 })310 LoadAdvertList("PRODUCT", "QCBK_HOTPRODUCT", 1, 100, CheckTime).then(function (res) {311 This.state.qcbk.hotRecommendLevel = HandleProductData(res)312 })313 LoadAdvertList("PRODUCT", "QCBK_HOTRECOMMEND_VERTICAL", 1, 10, CheckTime).then(function (res) {314 This.state.qcbk.hotRecommendVertical = HandleProductData(res)315 })316 },317 getWhjy: function () {318 var This = this;319 var CheckTime = ''320 LoadAdvertList("PRODUCT", "WHJY_NEW_PRODUCT", 1, 9, CheckTime).then(function (res) {321 This.state.whjy.NewProduct = HandleProductData(res)322 })323 LoadAdvertList("IMAGE", "WHJY_BANNER", 1, 100, CheckTime).then(function (res) {324 This.state.whjy.swiperSlides = HandleImageData(res)325 This.state.whjy.loadingFlag++;326 })327 LoadAdvertList("IMAGE", "WHJY_ARTICLE", 1, 100, CheckTime).then(function (res) {328 This.state.whjy.whjyAritcal = HandleImageData(res)329 This.state.whjy.loadingFlag++;330 })331 LoadAdvertList("IMAGE", "WHJY_CATEGORY", 1, 9, CheckTime).then(function (res) {332 This.state.whjy.categoryArrBefore = HandleImageData(res)333 if (This.state.whjy.categoryArrBefore.length > 0) {334 var aObj = {335 Title: "æ´å¤",336 ImageUrl: cateMore,337 URL: This.state.whjy.categoryArrBefore[0].URL338 };339 This.state.whjy.categoryArrBefore.push(aObj);340 }341 This.state.whjy.loadingFlag++;342 })343 LoadAdvertList("IMAGE", "WHJY_AREA", 1, 100, CheckTime).then(function (res) {344 This.state.whjy.categoryAreaArr = HandleImageData(res)345 This.state.whjy.loadingFlag++;346 })347 LoadAdvertList("PRODUCT", "WHJY_HOTPRODUCT", 1, 100, CheckTime).then(function (res) {348 This.state.whjy.hotRecommendLevel = HandleProductData(res)349 })350 LoadAdvertList("PRODUCT", "WHJY_HOTRECOMMEND_VERTICAL", 1, 10, CheckTime).then(function (res) {351 This.state.whjy.hotRecommendVertical = HandleProductData(res)352 })353 },354 getcatetoryData(state, arr) {355 for (var i = 0; i < state[arr.catetoraName].categroysKind.length; i++) {356 state[arr.catetoraName][357 state[arr.catetoraName].categroysKind[i] + "index"358 ] = 2;359 state[arr.catetoraName][360 state[arr.catetoraName].categroysKind[i] + "flag"361 ] = true;362 state[obj.catetory][363 state[obj.catetory].categroysKind[i] + "scrollTop"364 ] = 0;365 }366 axios367 .post("/api/Product/LoadProductByCate", {368 TypeId: obj.Id,369 PageIndex: 1,370 PageSize: 8371 })372 .then(function (res) {373 res.data.Data.map(function (item) {374 item.ProductImage =375 JSON.parse(item.ProductImage)[0].ServerUrl +376 JSON.parse(item.ProductImage)[0].FilePath +377 ".thumb." +378 JSON.parse(item.ProductImage)[0].FileExt;379 state[arr.catetoraName].categroyList[380 state[arr.catetoraName].categroysKind.indexOf(obj.Id)381 ].push(item);382 });383 if (state[arr.catetoraName].categroysKind.indexOf(obj.Id) >= 0) {384 if (385 state[arr.catetoraName].categroysKind.indexOf(obj.Id) - 1 >=386 0387 ) {388 axios389 .post("/api/Product/LoadProductByCate", {390 TypeId:391 state[arr.catetoraName].categroysKind[392 state[arr.catetoraName].categroysKind.indexOf(obj.Id) - 1393 ],394 PageIndex: 1,395 PageSize: 8396 })397 .then(function (res) {398 res.data.Data.map(function (item) {399 item.ProductImage =400 JSON.parse(item.ProductImage)[0].ServerUrl +401 JSON.parse(item.ProductImage)[0].FilePath +402 ".thumb." +403 JSON.parse(item.ProductImage)[0].FileExt;404 state[arr.catetoraName].categroyList[405 state[arr.catetoraName].categroysKind.indexOf(406 state[arr.catetoraName].categroysKind[407 state[arr.catetoraName].categroysKind.indexOf(408 obj.Id409 ) - 1410 ]411 )412 ].push(item);413 });414 });415 }416 }417 if (state[obj.catetory].categroysKind.indexOf(obj.Id) >= 0) {418 if (419 state[obj.catetory].categroysKind.indexOf(obj.Id) + 1 <=420 state[obj.catetory].categroysKind.length421 ) {422 axios423 .post("/api/Product/LoadProductByCate", {424 TypeId:425 state[obj.catetory].categroysKind[426 state[obj.catetory].categroysKind.indexOf(obj.Id) + 1427 ],428 PageIndex: 1,429 PageSize: 8430 })431 .then(function (res) {432 res.data.Data.map(function (item) {433 item.ProductImage =434 JSON.parse(item.ProductImage)[0].ServerUrl +435 JSON.parse(item.ProductImage)[0].FilePath +436 ".thumb." +437 JSON.parse(item.ProductImage)[0].FileExt;438 state[obj.catetory].categroyList[439 state[obj.catetory].categroysKind.indexOf(440 state[obj.catetory].categroysKind[441 state[obj.catetory].categroysKind.indexOf(obj.Id) + 1442 ]443 )444 ].push(item);445 });446 });447 }448 }449 });450 },451 getcatetoryOne(state, arr) {452 if (state[arr.name][arr.id + "flag"]) {453 state[arr.name][arr.id + "flag"] = false;454 LoadProductByCate(arr.id, state[arr.name][arr.id + "index"], 8).then(function (res) {455 state[arr.name][arr.id + "index"] =456 state[arr.name][arr.id + "index"] + 1;457 res.data.Data.map(function (data) {458 data.ProductImage =459 JSON.parse(data.ProductImage)[0].ServerUrl +460 JSON.parse(data.ProductImage)[0].FilePath +461 ".thumb." +462 JSON.parse(data.ProductImage)[0].FileExt;463 state[arr.name].categroyList[464 state[arr.name].categroysKind.indexOf(arr.id)465 ].push(data);466 });467 if (res.data.Data.length < 8) {468 state[arr.name][arr.id + "flag"] = false;469 } else {470 state[arr.name][arr.id + "flag"] = true;471 }472 })473 }474 },475 getcatetory(state, obj) {476 function getParam(paramName) {477 var paramValue = "";478 if (window.location.href.indexOf("?") != -1) {479 var paramArr = window.location.href.split("?")[1];480 if (paramArr.indexOf("&") != -1) {481 var Parr = paramArr.split("&");482 for (var i = 0; i < Parr.length; i++) {483 var result = Parr[i].split("=");484 if (result[0] == paramName) {485 paramValue = result[1];486 return paramValue;487 }488 }489 }490 }491 }492 var CheckTime = getParam("CheckTime");493 if (CheckTime) {494 var data = new Date(t)495 CheckTime = myDate.getFullYear() + '-' + myDate.getMonth() + '-' + myDate.getDate()496 } else {497 CheckTime = ''498 }499 axios500 .post("/api/Advert/LoadAdvertList", {501 Kind: "IMAGE",502 AdvertCode: obj.catetoraName,503 PageIndex: 1,504 PageSize: 100,505 CheckTime: CheckTime506 })507 .then(function (res) {508 for (var i = 0; i < res.data.Data.length; i++) {509 var NavigationCf = JSON.parse(res.data.Data[i].NavigationConfig)510 // console.log(JSON.parse(res.data.Data[i].NavigationConfig))511 for (var j = 0; j < NavigationCf.length; j++) {512 if (NavigationCf[j].hasOwnProperty('status') && !NavigationCf[j].status) {513 NavigationCf.splice(j, 1)514 j--515 }516 }517 res.data.Data[i].NavigationConfig = JSON.stringify(NavigationCf)518 }519 state[obj.catetory].categorys = [];520 state[obj.catetory].categroysKind = [];521 if (res.data.Data) {522 res.data.Data.map(function (data) {523 state[obj.catetory].categroyList.push([]);524 state[obj.catetory].categorys.push(data.Title);525 state[obj.catetory].categroysKind.push(data.Url);526 state[obj.catetory].catetoryAfter.push(data.Title);527 var bannerObj = {};528 bannerObj.Describe = data.Describe;529 bannerObj.Title = data.Title;530 bannerObj.URL = data.Url;531 if (data.ImageUrl) {532 bannerObj.IMAGE =533 JSON.parse(data.ImageUrl)[0].ServerUrl +534 JSON.parse(data.ImageUrl)[0].FilePath +535 ".thumb." +536 JSON.parse(data.ImageUrl)[0].FileExt;537 }538 var NavigationConfigArr = [];539 var NavigationArr = [];540 if (JSON.parse(data.NavigationConfig).length <= 10) {541 JSON.parse(data.NavigationConfig).map(function (res, index) {542 if (res.Image.ServerUrl) {543 res.ImageUrl = res.Image.ServerUrl +544 res.Image.FilePath +545 ".thumb." +546 res.Image.FileExt;547 }548 if ((index + 1) % 11 == 0) {549 NavigationConfigArr.push(NavigationArr)550 NavigationArr = []551 } else {552 NavigationArr.push(res)553 if (index == JSON.parse(data.NavigationConfig).length - 1) {554 NavigationConfigArr.push(NavigationArr)555 }556 }557 })558 if (NavigationConfigArr[0] && NavigationConfigArr[0].length == 7) {559 var aObj = {560 Title: "æ´å¤",561 ImageUrl: cateMore,562 Id: NavigationConfigArr[0][0].Id563 }564 NavigationConfigArr[0].push(aObj)565 } else if (NavigationConfigArr.length[0] && NavigationConfigArr.length[0] >= 9) {566 var aObj = {567 Title: "æ´å¤",568 ImageUrl: cateMore,569 Id: NavigationConfigArr[0][0].Id570 }571 NavigationConfigArr[0].push(aObj)572 }573 } else {574 JSON.parse(data.NavigationConfig).map(function (res, index) {575 if (res.Image.ServerUrl) {576 res.ImageUrl = res.Image.ServerUrl +577 res.Image.FilePath +578 ".thumb." +579 res.Image.FileExt;580 }581 NavigationArr.push(res)582 if (NavigationArr.length >= 9) {583 NavigationConfigArr.push(NavigationArr)584 NavigationArr = []585 }586 // console.log(index)587 if (index == JSON.parse(data.NavigationConfig).length - 1) {588 NavigationConfigArr.push(NavigationArr)589 }590 })591 for (var i = 0; i < NavigationConfigArr.length; i++) {592 if (NavigationConfigArr[i] && NavigationConfigArr[i].length >= 9 && i != NavigationConfigArr.length - 1) {593 var aObj = {594 Title: "æ»å¨æ´å¤",595 ImageUrl: cateMore,596 Id: NavigationConfigArr[0][0].Id597 }598 NavigationConfigArr[i].push(aObj)599 }600 }601 }602 bannerObj.NavigationConfig = NavigationConfigArr603 state[obj.catetory].categoryArr.push(bannerObj);604 });605 }606 for (var i = 0; i < state[obj.catetory].categroysKind.length; i++) {607 state[obj.catetory][608 state[obj.catetory].categroysKind[i] + "index"609 ] = 2;610 state[obj.catetory][611 state[obj.catetory].categroysKind[i] + "flag"612 ] = true;613 state[obj.catetory][614 state[obj.catetory].categroysKind[i] + "scrollTop"615 ] = 0;616 }617 axios618 .post("/api/Product/LoadProductByCate", {619 TypeId: obj.Id,620 PageIndex: 1,621 PageSize: 8622 })623 .then(function (res) {624 if (res.data.Data.length > 0) {625 res.data.Data.map(function (item) {626 try {627 item.ProductImage =628 JSON.parse(item.ProductImage)[0].ServerUrl +629 JSON.parse(item.ProductImage)[0].FilePath +630 ".thumb." +631 JSON.parse(item.ProductImage)[0].FileExt;632 } catch (e) {633 }634 if (state[obj.catetory].categroyList[635 state[obj.catetory].categroysKind.indexOf(obj.Id)636 ]) {637 state[obj.catetory].categroyList[638 state[obj.catetory].categroysKind.indexOf(obj.Id)639 ].push(item);640 }641 });642 }643 if (state[obj.catetory].categroysKind.indexOf(obj.Id) >= 0) {644 if (645 state[obj.catetory].categroysKind.indexOf(obj.Id) - 1 >=646 0647 ) {648 axios649 .post("/api/Product/LoadProductByCate", {650 TypeId:651 state[obj.catetory].categroysKind[652 state[obj.catetory].categroysKind.indexOf(obj.Id) - 1653 ],654 PageIndex: 1,655 PageSize: 8656 })657 .then(function (res) {658 res.data.Data.map(function (item) {659 item.ProductImage =660 JSON.parse(item.ProductImage)[0].ServerUrl +661 JSON.parse(item.ProductImage)[0].FilePath +662 ".thumb." +663 JSON.parse(item.ProductImage)[0].FileExt;664 state[obj.catetory].categroyList[665 state[obj.catetory].categroysKind.indexOf(666 state[obj.catetory].categroysKind[667 state[obj.catetory].categroysKind.indexOf(668 obj.Id669 ) - 1670 ]671 )672 ].push(item);673 });674 });675 }676 }677 if (state[obj.catetory].categroysKind.indexOf(obj.Id) >= 0) {678 if (679 state[obj.catetory].categroysKind.indexOf(obj.Id) + 1 <680 state[obj.catetory].categroysKind.length681 ) {682 axios683 .post("/api/Product/LoadProductByCate", {684 TypeId:685 state[obj.catetory].categroysKind[686 state[obj.catetory].categroysKind.indexOf(obj.Id) + 1687 ],688 PageIndex: 1,689 PageSize: 8690 })691 .then(function (res) {692 res.data.Data.map(function (item) {693 item.ProductImage =694 JSON.parse(item.ProductImage)[0].ServerUrl +695 JSON.parse(item.ProductImage)[0].FilePath +696 ".thumb." +697 JSON.parse(item.ProductImage)[0].FileExt;698 state[obj.catetory].categroyList[699 state[obj.catetory].categroysKind.indexOf(700 state[obj.catetory].categroysKind[701 state[obj.catetory].categroysKind.indexOf(702 obj.Id703 ) + 1704 ]705 )706 ].push(item);707 });708 });709 }710 }711 });712 });713 },714 getCatetoryOneDate(state, obj) {715 axios716 .post("/api/Product/LoadProductByCate", {717 TypeId: obj.Id,718 PageIndex: 1,719 PageSize: 8720 })721 .then(function (res) {722 res.data.Data.map(function (item) {723 item.ProductImage =724 JSON.parse(item.ProductImage)[0].ServerUrl +725 JSON.parse(item.ProductImage)[0].FilePath +726 ".thumb." +727 JSON.parse(item.ProductImage)[0].FileExt;728 state[obj.catetory].categroyList[729 state[obj.catetory].categroysKind.indexOf(obj.Id)730 ].push(item);731 });732 });733 },734 getMoredata(state, obj) {735 var CheckTime = ''736 var cateNAme = obj.name737 if (cateNAme == "home") {738 if (state.home.flag) {739 state.home.flag = false;740 axios741 .post("/api/Advert/LoadAdvertList", {742 Kind: "PRODUCT",743 AdvertCode: "HOME_RECOMMEND",744 PageIndex: obj.index,745 PageSize: 10,746 CheckTime: CheckTime747 })748 .then(function (res) {749 state.home.flag = true;750 state.home.index = state.home.index + 1;751 if (res.data.Data) {752 res.data.Data.map(function (data) {753 var PromotionTagTexts = {754 conditional_discount: '满å',755 conditional_gift: 'æ»¡èµ ',756 discount: 'ç´é',757 gift: 'ä¹°èµ ',758 shipfee: 'å
é®',759 coupon: 'ä¼æ å¸',760 limit: 'éå¶',761 };762 if (PromotionTagTexts[data.PromotionTag] && data.PromotionTag != "shipfee" && data.PromotionTag != "limit") {763 data.PromotionTag = PromotionTagTexts[data.PromotionTag]764 } else {765 data.PromotionTag = ''766 }767 data.ImageUrl =768 JSON.parse(data.ImageUrl)[0].ServerUrl +769 JSON.parse(data.ImageUrl)[0].FilePath +770 ".thumb." +771 JSON.parse(data.ImageUrl)[0].FileExt;772 });773 for (var i = 0; i < res.data.Data.length; i++) {774 state.home.RecommendProduct.push(res.data.Data[i]);775 }776 if (res.data.Data.length < 10) {777 state.home.flag = false;778 }779 }780 });781 }782 } else {783 if (state[cateNAme].flag) {784 state[cateNAme].flag = false;785 axios786 .post("/api/Advert/LoadAdvertList", {787 Kind: "PRODUCT",788 AdvertCode: cateNAme.toUpperCase() + "_HOTRECOMMEND_VERTICAL",789 PageIndex: obj.index,790 PageSize: 10,791 CheckTime: CheckTime792 })793 .then(function (res) {794 state[cateNAme].flag = true;795 state[cateNAme].index = state[cateNAme].index + 1;796 if (res.data.Data) {797 res.data.Data.map(function (data) {798 var PromotionTagTexts = {799 conditional_discount: '满å',800 conditional_gift: 'æ»¡èµ ',801 discount: 'ç´é',802 gift: 'ä¹°èµ ',803 shipfee: 'å
é®',804 coupon: 'ä¼æ å¸',805 limit: 'éå¶',806 };807 if (PromotionTagTexts[data.PromotionTag] && data.PromotionTag != "shipfee" && data.PromotionTag != "limit") {808 // return PromotionTagTexts[tag]809 data.PromotionTag = PromotionTagTexts[data.PromotionTag]810 } else {811 data.PromotionTag = ''812 }813 data.ImageUrl =814 JSON.parse(data.ImageUrl)[0].ServerUrl +815 JSON.parse(data.ImageUrl)[0].FilePath +816 ".thumb." +817 JSON.parse(data.ImageUrl)[0].FileExt;818 });819 }820 for (var i = 0; i < res.data.Data.length; i++) {821 state[cateNAme].hotRecommendVertical.push(res.data.Data[i]);822 }823 if (res.data.Data.length < 10) {824 state[cateNAme].flag = false;825 }826 });827 }828 }829 },830 LoadAdvertPoistion(state, obj) {831 axios832 .post("/api/Advert/LoadAdvertPoistion?PositionCode=" + obj.PositionCode)833 .then(function (response) {834 state[obj.catetory].cateTitle = response.data.Data.TITLE;835 })836 .catch(function (error) { });837 },838 CheckNewMember(state) {839 axios840 .post("/api/Member/CheckNewMember", {})841 .then(function (response) {842 state.Discount = response.data.Data;843 })844 .catch(function (error) { });845 },846 getMoreProduct(state, obj) {847 var CheckTime = '';848 var This = this;849 LoadAdvertList("PRODUCT", obj.id + "_NEW_PRODUCT", 2, 9, CheckTime).then(function (res) {850 state[obj.id.toLowerCase()].moreProduct = HandleProductData(res)851 })852 },853 getMorehotsale(state, obj) {854 var CheckTime = '';855 var This = this;856 LoadAdvertList("PRODUCT", obj.id + "_HOT", 2, 26, CheckTime).then(function (res) {857 state[obj.id.toLowerCase()].moreHotProduct = HandleProductData(res)858 })859 },860 moreProductImg(state, obj) {861 var CheckTime = ''862 var This = this;863 LoadAdvertList("IMAGE", obj.id + "_MORENEWPORDUCT", 1, 100, CheckTime).then(function (res) {864 This.state[obj.id.toLowerCase()].moreProductImg = HandleImageData(res)865 })866 },867 moreHotProductImg(state, obj) {868 var CheckTime = ''869 var This = this;870 LoadAdvertList("IMAGE", obj.id + "_MOREHOTPORDUCT", 1, 100, CheckTime).then(function (res) {871 This.state[obj.id.toLowerCase()].moreHotProductImg = HandleImageData(res)872 })873 },874 BUOY(state) {875 var CheckTime = ''876 var This = this;877 LoadAdvertList("IMAGE", "HOME_BUOY", 1, 100, CheckTime).then(function (res) {878 var arr = []879 if (res.data.Data.length) {880 for (var i = 0; i < JSON.parse(res.data.Data[0].ImageUrl).length; i++) {881 arr.push(JSON.parse(res.data.Data[0].ImageUrl)[i].ServerUrl +882 JSON.parse(res.data.Data[0].ImageUrl)[i].FilePath +883 ".thumb." +884 JSON.parse(res.data.Data[0].ImageUrl)[i].FileExt)885 }886 res.data.Data[0].ImageUrl = arr887 }888 This.state.home.BUOY = res.data.Data889 })890 },891 getHotMore(state, arr) {892 var CheckTime = ''893 if (state[arr.id.toLowerCase()].getMoreHotflag) {894 state[arr.id.toLowerCase()].getMoreHotflag = false;895 LoadAdvertList("PRODUCT", arr.id + "_HOT", state[arr.id.toLowerCase()].HotIndex + 1, 26, CheckTime).then(function (res) {896 state[arr.id.toLowerCase()].HotIndex = state[arr.id.toLowerCase()].HotIndex + 1;897 HandleProductData(res).map(function (data) {898 state[arr.id.toLowerCase()].moreHotProduct.push(data)899 })900 if (res.data.Data.length < 26) {901 state[arr.id.toLowerCase()].getMoreHotflag = false;902 } else {903 state[arr.id.toLowerCase()].getMoreHotflag = true;904 }905 })906 }907 },908 getMore(state, arr) {909 var CheckTime = ''910 if (state[arr.id.toLowerCase()].getMoreflag) {911 state[arr.id.toLowerCase()].getMoreflag = false;912 LoadAdvertList("PRODUCT", arr.id + "_NEW_PRODUCT", state[arr.id.toLowerCase()].NewIndex + 1, 6, CheckTime).then(function (res) {913 state[arr.id.toLowerCase()].NewIndex = state[arr.id.toLowerCase()].NewIndex + 1;914 HandleProductData(res).map(function (data) {915 state[arr.id.toLowerCase()].moreProduct.push(data)916 })917 if (res.data.Data.length < 6) {918 state[arr.id.toLowerCase()].getMoreflag = false;919 } else {920 state[arr.id.toLowerCase()].getMoreflag = true;921 }922 })923 }924 },925 getTopImage() {926 var This = this;927 var CheckTime = '';928 LoadAdvertList("IMAGE", "HOME_TOPTOAST", 1, 100, CheckTime).then(function (res) {929 This.state.topImg = [];930 This.state.topImg[0] = false931 This.state.TopImage = HandleImageData(res)932 })933 },934 getToast(state) {935 var CheckTime = ''936 var This = this;937 LoadAdvertList("IMAGE", "HOME_TOAST", 1, 100, CheckTime).then(function (res) {938 This.state.home.homeToast = HandleImageData(res)939 if (This.state.home.homeToast.length > 0) {940 if (!Cookies('toastTime')) {941 This.state.home.homeToast = []942 }943 }944 })945 },946 IsLogin(state) {947 },948 getNotice(state) {949 if (state.moticeFlag) {950 axios951 .post('/api/Member/LodUnReadNotice', {952 }).then(function (res) {953 if (res.data.Data) {954 state.LodUnReadNotice = true;955 state.moticeFlag = false956 }957 })958 }959 },960 // æç´¢ææ¬961 // getSearch(state) {962 // var CheckTime = ''963 // var This = this;964 // LoadAdvertList("IMAGE", "SEARCH_MESS", 1, 100, CheckTime).then(function (res) {965 // This.state.searchText=res.data.Data966 // })967 // },968 getHeadNavArr(state) {969 state.headNavArr = [];970 var CheckTime = "";971 var This = this;972 LoadAdvertList("IMAGE", "Navigation", 1, 100, CheckTime).then(function (res) {973 // state.headNavArr = res.data.Data;974 if (res.data.Data) {975 res.data.Data.map(function (res) {976 state.headNavArr.push(res)977 })978 // var obj = {979 // AdvertCode: "Navigation",980 // Describe: "ä¸ç§æ´»å¨",981 // Sort: 0,982 // Title: "年货大ä½æ",983 // Url: "ZQHD",984 // ImageUrl: '[{"FileId":0,"FilePath":"/res/gdtvimg/20190110/40307a98e6654e789d5b1baa630c849c.png","FileName":null,"FileExt":"png","SplitList":null,"ServerUrl":"http://gdtvimg.weixinmvp.com"}]'985 // }986 // state.headNavArr.unshift(obj);987 }988 })989 },990 getKind(state, obj) {991 // console.log992 var CheckTime = '';993 var This = this;994 state.kind.NavigateId = [];995 state.kind.NavigateTitle = [];996 state.kind.NavigateDescribe = [];997 state.kind.NavigateData = [];998 LoadAdvertList("IMAGE", obj.catetory, 1, 100, CheckTime).then(function (res) {999 for (var i = 0; i < res.data.Data.length; i++) {1000 var NavigationCf = JSON.parse(res.data.Data[i].NavigationConfig)1001 // console.log(JSON.parse(res.data.Data[i].NavigationConfig))1002 for (var j = 0; j < NavigationCf.length; j++) {1003 if (NavigationCf[j].hasOwnProperty('status') && !NavigationCf[j].status) {1004 NavigationCf.splice(j, 1)1005 j--1006 }1007 }1008 res.data.Data[i].NavigationConfig = JSON.stringify(NavigationCf)1009 }1010 res.data.Data.map(function (data, index) {1011 var titleobj = {1012 id: '',1013 title: ''1014 };1015 titleobj.id = data.Url;1016 titleobj.title = data.Title;1017 state.kind.headerTitle.push(titleobj)1018 if (data.Url == obj.id) {1019 JSON.parse(data.NavigationConfig).map(function (NavigateData, index) {1020 state.kind['NavigateId'].push(NavigateData.Id);1021 state.kind['NavigateTitle'].push(NavigateData.Title);1022 state.kind['NavigateDescribe'].push(NavigateData.Describe);1023 })1024 }1025 })1026 var snFunc = async function () {1027 for (let i = 0; i < state.kind['NavigateId'].length; i++) {1028 state['kindPageIndex' + state.kind['NavigateId'][i]] = 21029 state['kindPageFalg' + state.kind['NavigateId'][i]] = true;1030 state['kindPageScroll' + state.kind['NavigateId'][i]] = 0;1031 await axios.post('/api/Product/LoadCateGroup', { "TypeId": [state.kind['NavigateId'][i]], PageIndex: 1, PageSize: 10, }).then(function (res) {1032 var kindArr = [];1033 var data = res.data.Data[state.kind['NavigateId'][i]].map(function (data, index) {1034 data.ProductImage = JSON.parse(data.ProductImage)[0].ServerUrl + JSON.parse(data.ProductImage)[0].FilePath + '.thumb.' + JSON.parse(data.ProductImage)[0].FileExt1035 })1036 state.kind['NavigateData'].push(res.data.Data[state.kind['NavigateId'][i]])1037 })1038 }1039 }1040 snFunc();1041 })1042 },1043 getMoreKindProduct(state, obj) {1044 if (state["kindPageFalg" + obj.id]) {1045 state["kindPageFalg" + obj.id] = false;1046 var index = state["kindPageIndex" + obj.id]1047 var inDex = state.kind['NavigateId'].indexOf(obj.id);1048 axios.post('/api/Product/LoadCateGroup', { "TypeId": [obj.id], PageIndex: index, PageSize: 10, }).then(function (res) {1049 state["kindPageIndex" + obj.id]++;1050 var data = res.data.Data[obj.id].map(function (data, index) {1051 data.ProductImage = JSON.parse(data.ProductImage)[0].ServerUrl + JSON.parse(data.ProductImage)[0].FilePath + '.thumb.' + JSON.parse(data.ProductImage)[0].FileExt1052 state.kind['NavigateData'][inDex].push(data)1053 })1054 if (res.data.Data[obj.id].length >= 10) {1055 state["kindPageFalg" + obj.id] = true;1056 } else {1057 state["kindPageFalg" + obj.id] = false;1058 }1059 })1060 }1061 },1062 getFullToast(state) {1063 var CheckTime = ''1064 var This = this;1065 LoadAdvertList("IMAGE", "HOME_FULL_TOAST", 1, 100, CheckTime).then(function (res) {1066 var arr = []1067 if (res.data.Data.length) {1068 for (var i = 0; i < JSON.parse(res.data.Data[0].ImageUrl).length; i++) {1069 arr.push(JSON.parse(res.data.Data[0].ImageUrl)[i].ServerUrl +1070 JSON.parse(res.data.Data[0].ImageUrl)[i].FilePath +1071 ".thumb." +1072 JSON.parse(res.data.Data[0].ImageUrl)[i].FileExt)1073 }1074 res.data.Data[0].ImageUrl = arr1075 }1076 This.state.FullToastImage = res.data.Data1077 })1078 },1079 getZQHD: function (state, id) {1080 var This = this;1081 var CheckTime = '';1082 // banner1083 GetSpecialActivity(398).then(function (res) {1084 if (!res.data.Data) return1085 var data = res.data.Data;1086 var banner = [];1087 if (data.ADVERT_CONFIG) {1088 var advertConfigData = JSON.parse(data.ADVERT_CONFIG).Data;1089 advertConfigData.forEach(v => {1090 v.Image = v.Image.ServerUrl + v.Image.FilePath + '.thumb.' + v.Image.FileExt;1091 banner.push(v);1092 });1093 This.state.zqhd.banner = banner;1094 }1095 })1096 GetSpecialActivity(399).then(function (res) {1097 if (!res.data.Data) return1098 var data = res.data.Data;1099 var banner = [];1100 var foolrData = JSON.parse(data.NAVIGATION_CONFIG);1101 foolrData.forEach(v => {1102 v.Image = v.Image[0].ServerUrl + v.Image[0].FilePath + '.thumb.' + v.Image[0].FileExt;1103 GetReferenceProductList(1, 7, 0, 'specialactivity', v.Code).then(res => {1104 if (!res.data.Data) return1105 var productList = [];1106 res.data.Data.forEach(element => {1107 var img = JSON.parse(element.ProductImage);1108 element.ProductImage = img[0].ServerUrl + img[0].FilePath + '.thumb.' + img[0].FileExt;1109 productList.push(element)1110 });1111 if (v.Title == '买满é礼') {1112 This.state.zqhd.fullDelivery.Code = v.Code;1113 This.state.zqhd.fullDelivery.Image = v.Image;1114 This.state.zqhd.fullDelivery.Title = v.Title;1115 This.state.zqhd.fullDelivery.productList = productList;1116 } else if (v.Title == 'ç款ç´é') {1117 This.state.zqhd.descendingData.Code = v.Code;1118 This.state.zqhd.descendingData.Image = v.Image;1119 This.state.zqhd.descendingData.Title = v.Title;1120 This.state.zqhd.descendingData.productList = productList;1121 } else {1122 This.state.zqhd.GiftData.Code = v.Code;1123 This.state.zqhd.GiftData.Image = v.Image;1124 This.state.zqhd.GiftData.Title = v.Title;1125 This.state.zqhd.GiftData.productList = productList;1126 }1127 This.state.zqhd.loadingFlag++;1128 })1129 });1130 });1131 GetSpecialActivity(401).then(res=>{1132 if (!res.data.Data) return1133 var data = res.data.Data;1134 var code = JSON.parse(data.NAVIGATION_CONFIG)[0].Code;1135 GetReferenceProductList(1, 3, 0,'specialactivity',code).then(res=>{1136 var productList = [];1137 res.data.Data.forEach(element => {1138 var img = JSON.parse(element.ProductImage);1139 element.ProductImage = img[0].ServerUrl + img[0].FilePath + '.thumb.' + img[0].FileExt;1140 productList.push(element)1141 });1142 This.state.zqhd.GiftData.productList = productList;1143 })1144 })1145 // å¢è´å广åä½1146 GetSpecialActivity(358).then(function (res) {1147 if (!res.data.Data) return1148 var data = res.data.Data;1149 var advertConfig = [];1150 var advertConfigData = JSON.parse(data.ADVERT_CONFIG).Data;1151 advertConfigData.forEach(v => {1152 v.Image = v.Image.ServerUrl + v.Image.FilePath + '.thumb.' + v.Image.FileExt;1153 advertConfig.push(v);1154 });1155 This.state.zqhd.advertConfig = advertConfig;1156 This.state.zqhd.loadingFlag++;1157 var code = JSON.parse(data.NAVIGATION_CONFIG)[0].Code;1158 GetReferenceProductList(1, 6, 0, 'specialactivity', code).then(res => {1159 if (!res.data.Data) return1160 var productList = [];1161 res.data.Data.forEach(element => {1162 var img = JSON.parse(element.ProductImage);1163 element.ProductImage = img[0].ServerUrl + img[0].FilePath + '.thumb.' + img[0].FileExt;1164 productList.push(element)1165 });1166 This.state.zqhd.tuangouData = productList;1167 This.state.zqhd.loadingFlag++;1168 })1169 })1170 // ç§æ1171 LoadActivityList('ELEVEN_SKILL').then(res => {1172 // console.log(res);1173 var data = res.data.Data;1174 var nowDate = new Date().getDate();1175 var nowHours = new Date().getHours();1176 var isMorning = true;1177 if (nowHours >= 14 && nowHours < 22) {1178 isMorning = false;1179 }1180 var code = '';1181 var nowFlag = true;1182 var codeIndex = 0;1183 data.forEach((v,i) => {1184 v.START_TIME = v.START_TIME.replace(/-/g, "/").replace(/T/g, " ");1185 if (nowDate == new Date(v.START_TIME).getDate()) {1186 if (isMorning) {1187 if (new Date(v.START_TIME).getHours() == 12) {1188 code = v.RECID1189 nowFlag = false;1190 codeIndex=i;1191 }1192 } else {1193 if (new Date(v.START_TIME).getHours() == 20) {1194 code = v.RECID1195 nowFlag = false;1196 codeIndex = i;1197 }1198 }1199 }1200 });1201 if (nowFlag) {1202 code = data[0].RECID1203 }1204 GetReferenceProductList(1, 3, 1, 'ELEVEN_SKILL', code).then(res => {1205 if (!res.data.Data) return1206 var productList = [];1207 res.data.Data.forEach(element => {1208 var img = JSON.parse(element.ProductImage);1209 element.ProductImage = img[0].ServerUrl + img[0].FilePath + '.thumb.' + img[0].FileExt;1210 productList.push(element)1211 });1212 This.state.zqhd.skillData = productList;1213 This.state.zqhd.loadingFlag++;1214 1215 if (This.state.zqhd.skillData.length<3){1216 codeIndex++;1217 console.log(codeIndex);1218 GetReferenceProductList(1, 3, 1, 'ELEVEN_SKILL', data[codeIndex].RECID).then(res2=>{1219 res2.data.Data.forEach(element => {1220 var img = JSON.parse(element.ProductImage);1221 element.ProductImage = img[0].ServerUrl + img[0].FilePath + '.thumb.' + img[0].FileExt;1222 This.state.zqhd.skillData.push(element)1223 });1224 })1225 }1226 })1227 })1228 // èµè®¯1229 LoadAdvertList('IMAGE', 'HOME_ARTICLE_1', 1, 2, CheckTime).then(res => {1230 This.state.zqhd.information1 = HandleImageData(res);1231 This.state.zqhd.loadingFlag++;1232 })1233 LoadAdvertList('IMAGE', 'HOME_ARTICLE_2', 1, 3, CheckTime).then(res => {1234 This.state.zqhd.information2 = HandleImageData(res);1235 This.state.zqhd.loadingFlag++;1236 })1237 LoadAdvertList('IMAGE', 'HOME_VIDEO', 1, 5, CheckTime).then(res => {1238 res.data.Data.forEach(v => {1239 v.ImageUrl = JSON.parse(v.ImageUrl)[0].ServerUrl + JSON.parse(v.ImageUrl)[0].FilePath + '.thumb.' + JSON.parse(v.ImageUrl)[0].FileExt1240 });1241 // This.state.zqhd.homeVideo = HandleImageData(res);1242 This.state.zqhd.homeVideo = res.data.Data;1243 This.state.zqhd.loadingFlag++;1244 })1245 },1246 getDouRecommend(state, obj) {1247 var This = this;1248 var CheckTime = '';1249 GetReferenceProductList(obj.index, 10, 1, 'specialactivity', obj.code).then(function (res) {1250 for (var i = 0; i < res.data.Data.length; i++) {1251 var element = res.data.Data[i];1252 element.ProductImage =1253 JSON.parse(element.ProductImage)[0].ServerUrl +1254 JSON.parse(element.ProductImage)[0].FilePath + '.thumb.' + JSON.parse(element.ProductImage)[0].FileExt1255 state.zqhd.douRecommend[obj.prindex][obj.code].push(element);1256 }1257 })1258 }...
handleImageDataSpec.ts
Source:handleImageDataSpec.ts
1import HandleImageData from '../../utilities/handleImageData';2import sizeOf from 'image-size';3describe('Test handleImageData class methods and output ', () => {4 it('Test image name to save with resize 200 * 200 should be : 200-200-encenadaport.jpg', async () => {5 const parsingData = {6 filename: 'encenadaport.jpg',7 width: '200',8 height: '200'9 } as qs.ParsedQs;10 const imageData: HandleImageData = new HandleImageData(parsingData);11 imageData.findOrCreateImage();12 expect(imageData.imageName).toEqual('200-200-encenadaport.jpg');13 });14 it('Test save image and resizing that should equal 200 * 200 ', async () => {15 const parsingData = {16 filename: 'encenadaport.jpg',17 width: '200',18 height: '200'19 } as qs.ParsedQs;20 const handleImageData: HandleImageData = new HandleImageData(parsingData);21 handleImageData.findOrCreateImage();22 const filePath: string = await handleImageData.saveFileToDisk();23 const imageDiemnsions = sizeOf(filePath);24 expect(imageDiemnsions.width).toEqual(200);25 expect(imageDiemnsions.height).toEqual(200);26 });27 it('Test all class feature (resize - rotate - save to desk) image name should be : 200-200-90-encenadaport.jpg ', async () => {28 const parsingData = {29 filename: 'encenadaport.jpg',30 width: '200',31 height: '200',32 rotate: '90'33 } as qs.ParsedQs;34 const handleImageData: HandleImageData = new HandleImageData(parsingData);35 handleImageData.findOrCreateImage();36 const filePath: string = await handleImageData.saveFileToDisk();37 const imageDiemnsions = sizeOf(filePath);38 expect(handleImageData.imageName).toEqual('200-200-90-encenadaport.jpg');39 expect(imageDiemnsions.width).toEqual(200);40 expect(imageDiemnsions.height).toEqual(200);41 });...
images.ts
Source:images.ts
1import express from 'express';2import imageMiddleware from '../../utilities/imageMiddleware';3import imageQueryMiddleware from '../../utilities/imageQueryMiddleware';4import HandleImageData from '../../utilities/handleImageData';5const router = express();6router.get(7 '/',8 imageMiddleware,9 imageQueryMiddleware,10 async (req: express.Request, res: express.Response): Promise<void> => {11 const handleImageData: HandleImageData = new HandleImageData(req.query);12 handleImageData.findOrCreateImage();13 try {14 const newImagePath: string = await handleImageData.saveFileToDisk();15 res.sendFile(newImagePath);16 } catch (error) {17 res.send(`Invalid input for filename`);18 }19 }20);...
Using AI Code Generation
1var wpt = require('webpagetest');2var client = wpt('www.webpagetest.org');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9var wpt = require('webpagetest');10var client = wpt('www.webpagetest.org');11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17var wpt = require('webpagetest');18var client = wpt('www.webpagetest.org');19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25var wpt = require('webpagetest');26var client = wpt('www.webpagetest.org');27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32});
Using AI Code Generation
1var wpt = require('webpagetest');2var client = wpt('www.webpagetest.org');3var options = {4 videoParams: {5 }6};7client.runTest(options, function(err, data) {8 if (err) return console.error(err);9 console.log(data);10 client.getVideo(data.data.testId, 'video.mp4', function(err) {11 if (err) return console.error(err);12 console.log('Video downloaded');13 });14});15### `wpt(apiKey, options)`16### `wpt.runTest(options, callback)`
Using AI Code Generation
1var wpt = require('wpt.js');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.runTest(url, function(err, data) {4 if (err) return console.log(err);5 console.log(data);6 wpt.getTestResults(data.data.testId, function(err, data) {7 if (err) return console.log(err);8 console.log(data);9 wpt.handleImageData(data.data, 'image.png', function(err) {10 if (err) return console.log(err);11 console.log('done');12 });13 });14});
Using AI Code Generation
1var wpt = require('webpagetest');2var webPageTest = new wpt('www.webpagetest.org');3 console.log(data);4});5var wpt = require('webpagetest');6var webPageTest = new wpt('www.webpagetest.org');7 console.log(data);8});9var wpt = require('webpagetest');10var webPageTest = new wpt('www.webpagetest.org');11 console.log(data);12});13var wpt = require('webpagetest');14var webPageTest = new wpt('www.webpagetest.org');15 console.log(data);16});17var wpt = require('webpagetest');18var webPageTest = new wpt('www.webpagetest.org');19 console.log(data);20});21var wpt = require('webpagetest');22var webPageTest = new wpt('www.webpagetest.org');23 console.log(data);24});25var wpt = require('webpagetest');
Using AI Code Generation
1var wpt = require('webpagetest');2var options = {3};4var test = new wpt(options);5var location = 'Dulles:Chrome';6var timeout = 60000;7var runs = 3;8var label = 'testRun';9test.runTest(testURL, {10}, function(err, data) {11 if (err) return console.error(err);12 console.log(data);13});
Using AI Code Generation
1var wpt = require('webpagetest');2var webpagetest = new wpt('www.webpagetest.org', 'A.9a9f9d3c3e3a3a3b3c3b3a3a3a3a3a3a');3webpagetest.runTest(url, {location: 'Dulles:Chrome', runs: 1}, function(err, data) {4 if (err) return console.error(err);5 webpagetest.getTestResults(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log(data.data.median.firstView.SpeedIndex);8 });9});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!