12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549 |
- // buy.js
- var app = getApp();
- var WxParse = require('../../wxParse/wxParse.js');
- //规格
- var Style1 = [];
- var Style2 = [];
- var Style3 = [];
- var Style4 = [];
- var Style5 = [];
- let animationShowHeight = 1000;
- Page({
- data: {
- allHidden : '',
- authorize: 0,
- urlHttp: '',
- com_id: "",//商品id
- shangpin_id: '',//商品id
- banner: '',
- bannerSml: '',//商品弹窗的小图
- title: '',//商品名称
- intro: '',//商品详情
- minPrice : 0,//最低价格
- maxPrice : 0,//最高价格
- newPrice: '',//现价
- oldPrice: '',//原价
- goodPrice: 0,//商品单独的价格
- showPrice: 0,//显示的区间价格【 (商品价格 + 礼盒价格) 】
- num: 1, //起订量
- cycle: 1,//定制周期
- recommend: "",
- collectState: false,//是否收藏
- //品牌信息
- brandid: '',
- brandtitle: '',
- brandname: '',
- brandlogo: '',
- brandBanner: '',
- bannerShare: '',//分享链接上显示的图片
- goodsService: [], //服务
- giftboxsize: '', //礼盒长度
- gixboxService: [], //礼盒
- dingzhiService: [],//定制工艺
- Style1: [], //规格
- Style2: [],
- Style3: [],
- Style4: [],
- Style5: [],
- //每一类规格的数量
- style1: 0,
- style2: 0,
- style3: 0,
- style4: 0,
- style5: 0,
- //规格每个类别的类别名称
- style1_name: '',
- style2_name: '',
- style3_name: '',
- style4_name: '',
- style5_name: '',
-
- //立即购买中的规格,当前选中状态
- ruleClick1: "-",
- ruleClick2: "-",
- ruleClick3: "-",
- ruleClick4: "-",
- ruleClick5: "-",
- dingZhiClick: "-",//定制
- boxClick: "-",//礼盒选中状态
- //规格回显值
- rule1: "",
- rule2: "",
- rule3: "",
- rule4: "",
- rule5: "",
- selectBox: "",//选择的礼盒名称
- selectDingZhi: '',//选择的定制工艺
- //选中的规格组合id
- sheetid1: '',
- sheetid2: '',
- sheetid3: '',
- sheetid4: '',
- sheetid5: '',
- imagewidth: 0,//缩放后的宽
- imageheight: 0,//缩放后的高
- imageheight1: 0,
- state: '',//滚动条状态(有 auto/无 hidden)
- carts: [],
- hiddenmodal: true, //弹窗
- modalCont: '',
- stateId: 0,//判断是点击的加入购物车 - 0 / 立即购买 - 1
- maxHeight: 0,
- imgList: [],//banner数组
- serviceIsShow: false,
- isShow: false,
- chooseFlag: 0,
- chooseResult: 0,
- animationData: {},
- animationDataBuy: {},
- animationDataSer: {},
- animation: {},
- styleLen: 0,
- soldOutShow: false,//商品下架提示信息
- isSpecialGood: false, //特定具有时效性的商品标识
- specialGoodMsgShowCount: 0,//特定具有时效性的商品,提示显示次数
- cont_hidden: '',
- showBtn: false, //是否显示右侧返回首页按钮
- isSelectNew: 0, //默认
- from_flag: 0,//入口来源【 0:分享 商品列表】
- neibuFlag: 0,
- loadingFlag: 0,//所有规格加载完成的标志
- groupList: [], //组合信息
- sumTotal: 0, //总库存
- showNum: 0, //显示的库存数量
- keys: {},//总类别集合
- keys2: {},
- dataList: {},//组合类别集合对象
- SKUResult: {},//保存最后的组合结果信息
- sizeList: [], //总规格类别
- modelStyleNum: 0,//规格总类别数
- styleAllNum: 0, //分类规格总数量
- clickBoxPrice : 0, //选中的礼盒的价格
- saveStyleId : '', //最终选取的组合id
- clickNum: 0,//规格已选择数量
- cartNum: 0,//footer购物车显示的数量
- minNumber: 0,//购买数量
- },
- //重置所有变量
- resetVar : function(e){
- var that = this;
- that.setData({
- allHidden: '',
- goodPrice: 0,//商品单独的价格
- showPrice: 0,//显示的区间价格【 (商品价格 + 礼盒价格) 】
- num: 1, //起订量
- cartNum: 0,//footer购物车显示的数量
- minNumber: 0,//购买数量
- goodsService: [], //服务
- giftboxsize: '', //礼盒长度
- gixboxService: [], //礼盒
- dingzhiService: [],//定制工艺
- Style1: [], //规格
- Style2: [],
- Style3: [],
- Style4: [],
- Style5: [],
- //立即购买中的规格,当前选中状态
- ruleClick1: "-",
- ruleClick2: "-",
- ruleClick3: "-",
- ruleClick4: "-",
- ruleClick5: "-",
- boxClick: "-",//礼盒选中状态
- dingZhiClick: "-",//定制
- //规格回显值
- rule1: "",
- rule2: "",
- rule3: "",
- rule4: "",
- rule5: "",
- selectBox: "",//选择的礼盒名称
- selectDingZhi: '',//选择的定制工艺
- sheetid1: '',
- sheetid2: '',
- sheetid3: '',
- sheetid4: '',
- sheetid5: '',
- loadingFlag: 0,//所有规格加载完成的标志
- groupList: [], //组合信息
- showNum: 0, //显示的库存数量
- sumTotal: 0, //总库存
- dataList: {}, //组合类别集合对象
- SKUResult: {}, //保存最后的组合结果信息
- clickNum: 0,//规格已选择数量
- clickBoxPrice: 0, //选中的礼盒的价格
- saveStyleId: '', //最终选取的组合id
- hiddenmodal: true, //弹窗
- modalCont: '',
- stateId: 0,//判断是点击的加入购物车 - 0 / 立即购买 - 1
- maxHeight: 0,
- serviceIsShow: false,
- isShow: false,
- chooseFlag: 0,
- chooseResult: 0,
- animationData: {},
- animationDataBuy: {},
- animationDataSer: {},
- animation: {},
- styleLen: 0,
- isSpecialGood: false, //特定具有时效性的商品标识
- specialGoodMsgShowCount: 0,//特定具有时效性的商品,提示显示次数
- cont_hidden: '',
- isSelectNew: 0, //默认
- })
- },
- onLoad: function (options) {
- var that = this;
- var host = getApp().globalData.servsers;
- var un_id = getApp().globalData.un_id;
- var neibuFlag = options.flag;//来自内部员工,则为0
- if (options.flag == undefined) {
- neibuFlag = 1;
- } else {
- wx.hideShareMenu();
- }
- if (options.from_flag == 1) {//从分享链接进入
- that.setData({
- showBtn: true
- })
- } else {
- that.setData({
- showBtn: false
- })
- }
- that.setData({
- urlHttp: host,
- com_id: options.com_id,
- from_flag: options.from_flag,
- neibuFlag: neibuFlag,
- })
- //检测商品是否下架
- wx.request({
- url: host + "commodityapi/commoditview",
- data: {
- com_id: options.com_id
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- console.log(res);
- //有此商品
- if (res.data.total > 0) {
- if (res.data.commodity.commodity_flag == '1') {//此商品为下架商品
- that.setData({
- soldOutShow: true
- })
- }
- }
- var article1 = res.data.commodity.commodity_details;
- WxParse.wxParse('article1', 'html', res.data.commodity.commodity_details, that, 5)
- var acceptance = res.data.commodity.commodity_acceptance;
- if (acceptance != null && acceptance != '') {
- wx.request({//服务保证
- url: host + "acceptanceapi/findBuy",
- data: {
- id: acceptance
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.total > 0) {
- that.setData({
- goodsService: res.data.rows
- })
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- });
- }
- //是否收藏
- if (un_id != undefined && un_id != '' && un_id != null) {
- wx.request({
- url: host + "collectionapi/findAllforxcx",
- data: {
- user_id: un_id,
- collection_clas: 2,
- collection_name: options.com_id,
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.total != 0) {
- that.setData({
- collectState: true
- })
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- })
- }
- that.setData({
- tuijian: res.data.commodity,
- banner: res.data.images,
- bannerShare: res.data.images[0],
- bannerSml: host + 'images/' + res.data.images[0],
- title: res.data.commodity.commodity_name,
- shangpin_id: res.data.commodity.id,
- intro: res.data.commodity.commodity_des,
- newPrice: res.data.commodity.commodity_sale,
- oldPrice: res.data.commodity.commodity_cost,
- cycle: res.data.commodity.commodity_cyc,
- minNumber: res.data.commodity.commodity_num,
- num: res.data.commodity.commodity_num,
- recommend: res.data.commodity.commodity_recommend,
- });
- var imgList = [];
- for (var i = 0; i < that.data.banner.length; i++) {
- imgList[i] = host + 'images/' + that.data.banner[i];
- }
- that.setData({
- imgList: imgList
- })
- wx.setNavigationBarTitle({
- title: res.data.commodity.commodity_name
- })
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- })
- },
- //渲染
- loadFun: function (e) {
- var that = this;
- var host = getApp().globalData.servsers;
- var un_id = getApp().globalData.un_id;
- that.resetVar();
- //检测商品是否下架
- wx.request({
- url: host + "commodityapi/commoditview",
- data: {
- com_id: that.data.com_id
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- console.log(res);
- //有此商品
- if (res.data.total > 0) {
- if (res.data.commodity.commodity_flag == '1') {//此商品为下架商品
- that.setData({
- soldOutShow: true
- })
- }
- }
- var loadingFlag = that.data.loadingFlag;//所有规则加载标识
- var giftbox = res.data.commodity.commodity_giftbox;
- if (giftbox != null && giftbox != '') {
- wx.request({//礼盒
- url: host + "giftboxapi/findBuy",
- data: {
- id: giftbox
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.total > 0) {
- that.setData({
- giftboxsize: res.data.total,
- gixboxService: res.data.rows
- })
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- });
- }
- var process = res.data.commodity.commodity_process;
- if (process != null && process != '') {
- wx.request({//定制
- url: host + "processapi/findBuy",
- data: {
- id: process
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.total > 0) {
- that.setData({
- iconNum: res.data.total,
- dingzhiService: res.data.rows
- });
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- });
- }
- var styleLength = 0;
- var keys = new Array();
- var keys2 = '';
- var modelStyleNum = 0;//规格总类别数量
- //所有规格的数量
- var styleAllNum = 0;
- var loadingFlag = 0;
- var style1 = res.data.commodity.style1;
- if (style1 != null && style1 != '' && style1 != undefined) {
- keys2 = '1_0';
- modelStyleNum++;
- wx.request({
- url: host + "datasheetapi/findAllforid",
- data: {
- id: style1
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- console.log("style");
- console.log(res);
- if (res.data.total > 0) {
- that.setData({
- style1_name: res.data.rows[0].datasheet_com_name,
- style1: res.data.total,
- Style1: res.data.rows,
- });
- styleAllNum += res.data.total;
- keys[0] = new Array();
- for (var j = 0; j < res.data.total; j++) { //二维长度为5
- keys[0][j] = res.data.rows[j].datasheet_id;
- that.data.sizeList.push(res.data.rows[j]);
- that.data.Style1[j].clickTrue = true;
- }
- that.setData({
- Style1: that.data.Style1,
- keys: keys,
- })
- loadingFlag++;
- if (loadingFlag == 6) {
- //组合sku
- that.initSKU();
- }
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- });
- } else {
- loadingFlag++;
- if (loadingFlag == 6) {
- //组合sku
- that.initSKU();
- }
- }
- var style2 = res.data.commodity.style2;
- if (style2 != null && style2 != '' && style2 != undefined) {
- modelStyleNum++;
- keys2 = keys2 + '-2_0';
- wx.request({
- url: host + "datasheetapi/findAllforid",
- data: {
- id: style2
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.total > 0) {
- styleAllNum += res.data.total;
- that.setData({
- style2_name: res.data.rows[0].datasheet_com_name,
- style2: res.data.total,
- Style2: res.data.rows,
- });
- keys[1] = new Array();
- for (var j = 0; j < res.data.total; j++) { //二维长度为5
- keys[1][j] = res.data.rows[j].datasheet_id;
- that.data.sizeList.push(res.data.rows[j]);
- that.data.Style2[j].clickTrue = true;
- }
- that.setData({
- Style2: that.data.Style2,
- keys: keys
- })
- loadingFlag++;
- if (loadingFlag == 6) {
- //组合sku
- that.initSKU();
- }
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- });
- } else {
- loadingFlag++;
- if (loadingFlag == 6) {
- //组合sku
- that.initSKU();
- }
- }
- var style3 = res.data.commodity.style3;
- if (style3 != null && style3 != '' && style3 != undefined) {
- modelStyleNum++;
- keys2 = keys2 + '-3_0';
- wx.request({
- url: host + "datasheetapi/findAllforid",
- data: {
- id: style3
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.total > 0) {
- styleAllNum += res.data.total;
- that.setData({
- style3_name: res.data.rows[0].datasheet_com_name,
- style3: res.data.total,
- Style3: res.data.rows,
- });
- keys[2] = new Array();
- for (var j = 0; j < res.data.total; j++) { //二维长度为5
- keys[2][j] = res.data.rows[j].datasheet_id;
- that.data.sizeList.push(res.data.rows[j]);
- that.data.Style3[j].clickTrue = true;
- }
- that.setData({
- Style3: that.data.Style3,
- keys: keys
- });
- loadingFlag++;
- if (loadingFlag == 6) {
- //组合sku
- that.initSKU();
- }
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- });
- } else {
- loadingFlag++;
- if (loadingFlag == 6) {
- //组合sku
- that.initSKU();
- }
- }
- var style4 = res.data.commodity.style4;
- if (style4 != null && style4 != '' && style4 != undefined) {
- modelStyleNum++;
- keys2 = keys2 + '-4_0';
- wx.request({
- url: host + "datasheetapi/findAllforid",
- data: {
- id:style4
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.total > 0) {
- styleAllNum += res.data.total;
- that.setData({
- style4_name: res.data.rows[0].datasheet_com_name,
- style4: res.data.total,
- Style4: res.data.rows,
- });
- keys[3] = new Array();
- for (var j = 0; j < res.data.total; j++) { //二维长度为5
- keys[3][j] = res.data.rows[j].datasheet_id;
- that.data.sizeList.push(res.data.rows[j]);
- that.data.Style4[j].clickTrue = true;
- }
- that.setData({
- Style4: that.data.Style4,
- keys: keys
- })
- loadingFlag++;
- if (loadingFlag == 6) {
- //组合sku
- that.initSKU();
- }
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- });
- } else {
- loadingFlag++;
- if (loadingFlag == 6) {
- //组合sku
- that.initSKU();
- }
- }
- var style5 = res.data.commodity.style5;
- if (style5 != null && style5 != '' && style5 != undefined) {
- modelStyleNum++;
- keys2 = keys2 + '-5_0';
- wx.request({
- url: host + "datasheetapi/findAllforid",
- data: {
- id: style5
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res.data.total > 0) {
- styleAllNum += res.data.total;
- that.setData({
- style5_name: res.data.rows[0].datasheet_com_name,
- style5: res.data.total,
- Style5: res.data.rows,
- });
- keys[4] = new Array();
- for (var j = 0; j < res.data.total; j++) {
- keys[4][j] = res.data.rows[j].datasheet_id;
- that.data.sizeList.push(res.data.rows[j]);
- that.data.Style5[j].clickTrue = true;
- }
- that.setData({
- Style5: that.data.Style5,
- keys: keys
- })
- loadingFlag++;
- if (loadingFlag == 6) {
- //组合sku
- that.initSKU();
- }
- }
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- });
- } else {
- loadingFlag++;
- if (loadingFlag == 6) {
- //组合sku
- that.initSKU();
- }
- }
- var dataList = new Object();
- //获取商品规则的组合【价格和库存】
- wx.request({
- url: host + 'api/commodityGroup/getAllGroupByCommodityId',
- data: {
- commodityId: that.data.com_id
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- console.log("CommodityId:");
- console.log(res);
- if (res.data.code == '200') {
- if (res.data.data.length > 0){
- var groupList = res.data.data;
- var sumTotal = 0;
- var dataLen = groupList.length;
- for (var i = 0; i < dataLen; i++) {
- sumTotal += groupList[i].product_repertory;
- var dataTit = groupList[i].datasheet_id;
- var dataContList = {
- id: groupList[i].id,
- product_price: groupList[i].product_price,
- product_repertory: groupList[i].product_repertory
- };
- dataList[dataTit] = dataContList;
- }
- that.setData({
- sumTotal: sumTotal,
- groupList: groupList,
- dataList: dataList,
- showNum: sumTotal
- })
- loadingFlag++;
- if (loadingFlag == 6) {
- //组合sku
- that.initSKU();
- }
- }else{
- that.setData({
- sumTotal: 0,
- showNum: 0
- })
- //每一个规则类别下的详细种类数量
- var style1 = that.data.style1;
- var style2 = that.data.style2;
- var style3 = that.data.style3;
- var style4 = that.data.style4;
- var style5 = that.data.style5;
- if (style1 > 0) {
- for (var j = 0; j < style1; j++) {
- that.data.Style1[j].clickTrue = false;
- that.setData({
- Style1: that.data.Style1,
- })
- }
- }
- if (style2 > 0) {
- for (var j = 0; j < style2; j++) {
- that.data.Style2[j].clickTrue = false;
- that.setData({
- Style2: that.data.Style2,
- })
- }
- }
- if (style3 > 0) {
- for (var j = 0; j < style3; j++) {
- var datasheetId = that.data.Style3[j].datasheet_id;
- that.data.Style3[j].clickTrue = false;
- that.setData({
- Style3: that.data.Style3,
- })
- }
- }
- if (style4 > 0) {
- for (var j = 0; j < style4; j++) {
- that.data.Style4[j].clickTrue = false;
- that.setData({
- Style4: that.data.Style4,
- })
- }
- }
- if (style5 > 0) {
- for (var j = 0; j < style5; j++) {
- that.data.Style5[j].clickTrue = false;
- that.setData({
- Style5: that.data.Style5,
- })
- }
- }
- that.setData({
- allHidden: 'allHidden'
- })
- wx.hideLoading();
- }
- }
- }
- })
- that.setData({
- showPrice: (res.data.maxAndMin.min == res.data.maxAndMin.max) ? res.data.maxAndMin.min :(res.data.maxAndMin.min + '-' + res.data.maxAndMin.max),
- minPrice: res.data.maxAndMin.min,//最低价格
- maxPrice: res.data.maxAndMin.max,//最高价格
- minNumber: res.data.commodity.commodity_num,
- num: res.data.commodity.commodity_num,
- keys2: [keys2],
- modelStyleNum: modelStyleNum,
- sizeList: that.data.sizeList,
- styleAllNum: styleAllNum,
- loadingFlag: that.data.loadingFlag
- });
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- });
- wx.getSystemInfo({
- success: function (res) {
- animationShowHeight = res.windowHeight;
- }
- })
- // 显示遮罩层
- var animation = wx.createAnimation({
- duration: 200,
- timingFunction: 'linear',
- })
- this.animation = animation
- animation.bottom(-animationShowHeight).step()
- this.setData({
- animationDataBuy: animation.export()
- })
- setTimeout(function () {
- animation.bottom(-animationShowHeight).step()
- this.setData({
- animationDataBuy: animation.export()
- })
- }.bind(this), 200)
- },
- onShow:function(e){
- var that = this;
- wx.showLoading({
- title: '',
- icon: 'loading',
- mask: true,
- success: function () {
- }
- })
- that.loadFun();
- },
- //获得对象的key
- getObjKeys: function (obj) {
- var that = this;
- if (obj !== Object(obj)) throw new TypeError('Invalid object');
- var keys = [];
- for (var key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
- keys[keys.length] = key;
- }
- }
- return keys;
- },
- //初始化得到结果集
- initSKU: function () {
- var that = this;
- var dataList = that.data.dataList;//已有的规则组合信息
- //数据已有组合类
- var i, j, skuKeys = that.getObjKeys(dataList);
- //每一个规则类别下的详细种类数量
- var style1 = that.data.style1;
- var style2 = that.data.style2;
- var style3 = that.data.style3;
- var style4 = that.data.style4;
- var style5 = that.data.style5;
- for (i = 0; i < skuKeys.length; i++) {
- var skuKey = skuKeys[i];//一条SKU信息key
- var sku = dataList[skuKey]; //一条SKU信息value
- var skuKeyAttrs = skuKey.split("-"); //SKU信息key属性值数组
- skuKeyAttrs.sort(function (value1, value2) {
- return parseInt(value1) - parseInt(value2);
- });
- //对每个SKU信息key属性值进行拆分组合
- var combArr = that.combInArray(skuKeyAttrs);
- for (j = 0; j < combArr.length; j++) {
- that.addSKUResult(combArr[j], sku);
- }
- //结果集接放入SKUResult
- var SKUResult = that.data.SKUResult;
- SKUResult[skuKeyAttrs.join("-")] = {
- product_repertory: sku.product_repertory,
- product_price: [sku.product_price]
- };
- }
- var SKUResultLength = Object.keys(SKUResult).length;
- var forNum1 = 0, forNum2 = 0, forNum3 = 0, forNum4 = 0, forNum5 = 0;
- //初始化,现有单独规格是否有库存
- if (style1 > 0) {
- for (var j = 0; j < style1; j++) {
- var datasheetId = that.data.Style1[j].datasheet_id;
- if (!SKUResult[datasheetId]) {
- forNum1++;
- that.data.Style1[j].clickTrue = false;
- } else {
- that.data.Style1[j].clickTrue = true;
- }
- that.setData({
- Style1: that.data.Style1,
- })
- }
- }
- if (style2 > 0) {
- for (var j = 0; j < style2; j++) {
- var datasheetId = that.data.Style2[j].datasheet_id;
- if (!SKUResult[datasheetId]) {
- forNum2++;
- that.data.Style2[j].clickTrue = false;
- } else {
- that.data.Style2[j].clickTrue = true;
- }
- that.setData({
- Style2: that.data.Style2,
- })
- }
- }
- if (style3 > 0) {
- for (var j = 0; j < style3; j++) {
- var datasheetId = that.data.Style3[j].datasheet_id;
- if (!SKUResult[datasheetId]) {
- forNum3++;
- that.data.Style3[j].clickTrue = false;
- } else {
- that.data.Style3[j].clickTrue = true;
- }
- that.setData({
- Style3: that.data.Style3,
- })
- }
- }
- if (style4 > 0) {
- for (var j = 0; j < style4; j++) {
- var datasheetId = that.data.Style4[j].datasheet_id;
- if (!SKUResult[datasheetId]) {
- forNum4++;
- that.data.Style4[j].clickTrue = false;
- } else {
- that.data.Style4[j].clickTrue = true;
- }
- that.setData({
- Style4: that.data.Style4,
- })
- }
- }
- if (style5 > 0) {
- for (var j = 0; j < style5; j++) {
- var datasheetId = that.data.Style5[j].datasheet_id;
- if (!SKUResult[datasheetId]) {
- forNum5++;
- that.data.Style5[j].clickTrue = false;
- } else {
- that.data.Style5[j].clickTrue = true;
- }
- that.setData({
- Style5: that.data.Style5,
- })
- }
- }
- that.setData({
- SKUResult: SKUResult,
- allHidden: 'allHidden'
- })
- wx.hideLoading();
- },
- //把组合的key放入结果集SKUResult
- addSKUResult: function ( combArrItem, sku) {
- var that = this;
- var key = combArrItem.join("-");
- var SKUResult = that.data.SKUResult;
- if (SKUResult[key]) {//SKU信息key属性·
- SKUResult[key].product_repertory += sku.product_repertory;
- SKUResult[key].product_price.push(sku.product_price);
- } else {
- SKUResult[key] = {
- product_repertory: sku.product_repertory,
- product_price: [sku.product_price]
- };
- }
- that.setData({
- SKUResult: SKUResult
- })
- },
- /**
- * 从数组中生成指定长度的组合
- * 方法: 先生成[0,1...]形式的数组, 然后根据0,1从原数组取元素,得到组合数组
- */
- combInArray: function (aData) {
- var that = this;
- if (!aData || !aData.length) {
- return [];
- }
- var len = aData.length;
- var aResult = [];
- for (var n = 1; n < len; n++) {
- var aaFlags = that.getCombFlags(len, n);
- while (aaFlags.length) {
- var aFlag = aaFlags.shift();
- var aComb = [];
- for (var i = 0; i < len; i++) {
- aFlag[i] && aComb.push(aData[i]);
- }
- aResult.push(aComb);
- }
- }
- return aResult;
- },
- /**
- * 得到从 m 元素中取 n 元素的所有组合
- * 结果为[0,1...]形式的数组, 1表示选中,0表示不选
- */
- getCombFlags: function (m, n) {
- var that = this;
- if (!n || n < 1) {
- return [];
- }
- var aResult = [];
- var aFlag = [];
- var bNext = true;
- var i, j, iCnt1;
- for (i = 0; i < m; i++) {
- aFlag[i] = i < n ? 1 : 0;
- }
- aResult.push(aFlag.concat());
- while (bNext) {
- iCnt1 = 0;
- for (i = 0; i < m - 1; i++) {
- if (aFlag[i] == 1 && aFlag[i + 1] == 0) {
- for (j = 0; j < i; j++) {
- aFlag[j] = j < iCnt1 ? 1 : 0;
- }
- aFlag[i] = 0;
- aFlag[i + 1] = 1;
- var aTmp = aFlag.concat();
- aResult.push(aTmp);
- if (aTmp.slice(-n).join("").indexOf('0') == -1) {
- bNext = false;
- }
- break;
- }
- aFlag[i] == 1 && iCnt1++;
- }
- }
- return aResult;
- },
- //选择规格时的判断 - 判断价格和库存
- chooseStyleSetData: function (datasheetId, clickNum) {
- var that = this;
- var styleAllNum = that.data.styleAllNum;
- var modelStyleNum = that.data.modelStyleNum;
- var clickBoxPrice = that.data.clickBoxPrice;//已选礼盒价格
- var SKUResult = that.data.SKUResult;
- //每个大规格下选择的小规格id
- var ruleClick1 = that.data.ruleClick1;
- var ruleClick2 = that.data.ruleClick2;
- var ruleClick3 = that.data.ruleClick3;
- var ruleClick4 = that.data.ruleClick4;
- var ruleClick5 = that.data.ruleClick5;
- //每一个规则类别下的详细种类数量
- var style1 = that.data.style1;
- var style2 = that.data.style2;
- var style3 = that.data.style3;
- var style4 = that.data.style4;
- var style5 = that.data.style5;
- if (clickNum > 0) {
- //获得组合key价格
- var selectedIds = [];
- (that.data.sheetid1 == '') ? '' : selectedIds.push(that.data.sheetid1);
- (that.data.sheetid2 == '') ? '' : selectedIds.push(that.data.sheetid2);
- (that.data.sheetid3 == '') ? '' : selectedIds.push(that.data.sheetid3);
- (that.data.sheetid4 == '') ? '' : selectedIds.push(that.data.sheetid4);
- (that.data.sheetid5 == '') ? '' : selectedIds.push(that.data.sheetid5);
- console.log("selectedIds:");
- console.log(selectedIds);
- selectedIds.sort(function (value1, value2) {
- return parseInt(value1) - parseInt(value2);
- });
- var len = selectedIds.length;
- console.log("selectedIds.join('-'):"+selectedIds.join('-'));
- var prices = SKUResult[selectedIds.join('-')].product_price;
- var maxPrice = parseFloat(Math.max.apply(Math, prices)) + + parseFloat(clickBoxPrice);
- var minPrice = parseFloat(Math.min.apply(Math, prices)) + + parseFloat(clickBoxPrice);
-
- var showNum = SKUResult[selectedIds.join('-')].product_repertory;//当前规格下的库存
- var showPrice = maxPrice > minPrice ? minPrice + "-" + maxPrice : maxPrice; //当前规格下的价格
- var num = this.data.minNumber;//当前数量
- if (num >= showNum){
- that.setData({
- minNumber: showNum
- })
- }
- that.setData({
- showPrice: showPrice,
- showNum: showNum
- })
- var siblingsSelectedObj = [];//已点选
- var siblingsSelectedObjId = [];//已点选的id的集合
- var noClickList = [];//未点选的id的集合
- var oldNoClickList = [];
- if (style1 > 0) {
- for (var i = 0; i < style1; i++) {
- var datasheet_id = that.data.Style1[i].datasheet_id;
- if (i == ruleClick1) {
- siblingsSelectedObjId.push(datasheet_id);
- } else {
- noClickList.push(datasheet_id);
- oldNoClickList.push(datasheet_id);
- }
- }
- }
- if (style2 > 0) {
- for (var i = 0; i < style2; i++) {
- var datasheet_id = that.data.Style2[i].datasheet_id;
- if (i == ruleClick2) {
- siblingsSelectedObjId.push(datasheet_id);
- } else {
- noClickList.push(datasheet_id);
- oldNoClickList.push(datasheet_id);
- }
- }
- }
- if (style3 > 0) {
- for (var i = 0; i < style3; i++) {
- var datasheet_id = that.data.Style3[i].datasheet_id;
- console.log("3-datasheetId: " + datasheet_id);
- console.log("3-1: " + i);
- console.log("3-ruleClick3: " + ruleClick3);
- if (i == ruleClick3) {
- siblingsSelectedObjId.push(datasheet_id);
- } else {
- noClickList.push(datasheet_id);
- oldNoClickList.push(datasheet_id);
- }
- }
- }
- if (style4 > 0) {
- for (var i = 0; i < style4; i++) {
- var datasheet_id = that.data.Style4[i].datasheet_id;
- if (i == ruleClick4) {
- siblingsSelectedObjId.push(datasheet_id);
- } else {
- noClickList.push(datasheet_id);
- oldNoClickList.push(datasheet_id);
- }
- }
- }
- if (style5 > 0) {
- for (var i = 0; i < style5; i++) {
- var datasheet_id = that.data.Style5[i].datasheet_id;
- if (i == ruleClick5) {
- siblingsSelectedObjId.push(datasheet_id);
- } else {
- noClickList.push(datasheet_id);
- oldNoClickList.push(datasheet_id);
- }
- }
- }
- var selectedLength = 0;
- for (var i = 0; i < noClickList.length; i++) {
- var selectedLength = 0;
- var siblingsSelectedObjId = '';//选中规格的id
- var testAttrIds = [];//从选中节点中去掉选中的兄弟节点
-
- if (style1 > 0 && ruleClick1 != '-') {
- for (var m = 0; m < style1; m++){
- if (that.data.Style1[m].datasheet_id == noClickList[i]){
- if (that.data.Style1[ruleClick1].datasheet_id != noClickList[i]) {
- selectedLength = 1;
- siblingsSelectedObjId = that.data.Style1[ruleClick1].datasheet_id;
- break;
- }
- }
- }
- }
- if (style2 > 0 && ruleClick2 != '-') {
- for (var m = 0; m < style2; m++) {
- if (that.data.Style2[m].datasheet_id == noClickList[i]) {
- if (that.data.Style2[ruleClick2].datasheet_id != noClickList[i]) {
- selectedLength = 1;
- siblingsSelectedObjId = that.data.Style2[ruleClick2].datasheet_id;
- break;
- }
- }
- }
- }
- if (style3 > 0 && ruleClick3 != '-') {
- for (var m = 0; m < style3; m++) {
- if (that.data.Style3[m].datasheet_id == noClickList[i]) {
- if (that.data.Style3[ruleClick3].datasheet_id != noClickList[i]) {
- selectedLength = 1;
- siblingsSelectedObjId = that.data.Style3[ruleClick3].datasheet_id;
- break;
- }
- }
- }
- }
- if (style4 > 0 && ruleClick4 != '-') {
- for (var m = 0; m < style4; m++) {
- if (that.data.Style4[m].datasheet_id == noClickList[i]) {
- if (that.data.Style4[ruleClick4].datasheet_id != noClickList[i]) {
- selectedLength = 1;
- siblingsSelectedObjId = that.data.Style4[ruleClick4].datasheet_id;
- break;
- }
- }
- }
- }
- if (style5 > 0 && ruleClick5 != '-') {
- for (var m = 0; m < style5; m++) {
- if (that.data.Style5[m].datasheet_id == noClickList[i]) {
- if (that.data.Style5[ruleClick5].datasheet_id != noClickList[i]) {
- selectedLength = 1;
- siblingsSelectedObjId = that.data.Style5[ruleClick5].datasheet_id;
- break;
- }
- }
- }
- }
- if (selectedLength ) {
- for (var j = 0; j < len; j++) {
- (selectedIds[j] != siblingsSelectedObjId) && testAttrIds.push(selectedIds[j]);
- }
- } else {
- testAttrIds = selectedIds.concat();
- }
- testAttrIds = testAttrIds.concat(noClickList[i]);
- testAttrIds.sort(function (value1, value2) {
- return parseInt(value1) - parseInt(value2);
- });
- if (style1 > 0) {
- for (var k = 0; k < style1; k++) {
- if (that.data.Style1[k].datasheet_id == noClickList[i]) {
- if (!SKUResult[testAttrIds.join('-')]) {
- that.data.Style1[k].clickTrue = false;
- if (that.data.ruleClick1 == k) {
- that.data.ruleClick1 = '-';
- }
- } else {
- that.data.Style1[k].clickTrue = true;
- }
- }
- }
- }
- if (style2 > 0) {
- for (var k = 0; k < style2; k++) {
- if (that.data.Style2[k].datasheet_id == noClickList[i]) {
- if (!SKUResult[testAttrIds.join('-')]) {
- that.data.Style2[k].clickTrue = false;
- if (that.data.ruleClick2 == k){
- that.data.ruleClick2 = '-';
- }
- } else {
- that.data.Style2[k].clickTrue = true;
- }
- }
- }
- }
- if (style3 > 0) {
- for (var k = 0; k < style3; k++) {
- if (that.data.Style3[k].datasheet_id == noClickList[i]) {
- if (!SKUResult[testAttrIds.join('-')]) {
- that.data.Style3[k].clickTrue = false;
- if (that.data.ruleClick3 == k) {
- that.data.ruleClick3 = '-';
- }
- } else {
- that.data.Style3[k].clickTrue = true;
- }
- }
- }
- }
- if (style4 > 0) {
- for (var k = 0; k < style4; k++) {
- if (that.data.Style4[k].datasheet_id == noClickList[i]) {
- if (!SKUResult[testAttrIds.join('-')]) {
- that.data.Style4[k].clickTrue = false;
- if (that.data.ruleClick4 == k) {
- that.data.ruleClick4 = '-';
- }
- } else {
- that.data.Style4[k].clickTrue = true;
- }
- }
- }
- }
- if (style5 > 0) {
- for (var k = 0; k < style5; k++) {
- if (that.data.Style5[k].datasheet_id == noClickList[i]) {
- if (!SKUResult[testAttrIds.join('-')]) {
- that.data.Style5[k].clickTrue = false;
- if (that.data.ruleClick5 == k) {
- that.data.ruleClick5 = '-';
- }
- } else {
- that.data.Style5[k].clickTrue = true;
- }
- }
- }
- }
- }
- } else {
- var showPrice = that.data.showPrice;
- var showPrice = that.data.newPrice;
- var showNum = that.data.showNum;
- that.setData({
- showPrice: showPrice,
- showNum: showNum
- })
- }
- that.setData({
- Style1: that.data.Style1,
- Style2: that.data.Style2,
- Style3: that.data.Style3,
- Style4: that.data.Style4,
- Style5: that.data.Style5,
- ruleClick1: that.data.ruleClick1,
- ruleClick2: that.data.ruleClick2,
- ruleClick3: that.data.ruleClick3,
- ruleClick4: that.data.ruleClick4,
- ruleClick5: that.data.ruleClick5
- })
- },
- //立即购买下的规格选择
- ruleSelect: function (e) {
- var that = this
- var id = e.currentTarget.dataset.id;
- var datasheetId = e.currentTarget.dataset.sheetid;//规格id
- var ruleNum = e.currentTarget.dataset.rule;//当前规格1-5
- var styleLen = that.data.styleLen;
- var clickNum = that.data.clickNum;
- var clickBoxPrice = that.data.clickBoxPrice;
- if (ruleNum == 1) {
- if (that.data.ruleClick1 == id) {//当前为选中状态,变为取消状态
- clickNum = clickNum - 1;
- that.setData({
- ruleClick1: '-',
- rule1: '',
- styleLen: styleLen--,
- clickNum: clickNum,
- sheetid1: ''
- })
- } else {
- if (that.data.ruleClick1 == '-') {
- clickNum = clickNum + 1;
- that.setData({
- clickNum: clickNum,
- })
- }
- that.setData({
- ruleClick1: id,
- rule1: that.data.Style1[id].datasheet_name,
- styleLen: styleLen++,
- sheetid1: datasheetId
- })
- }
- } else if (ruleNum == 2) {
- if (that.data.ruleClick2 == id) {
- clickNum = clickNum - 1;
- that.setData({
- ruleClick2: '-',
- rule2: '',
- styleLen: styleLen--,
- clickNum: clickNum,
- sheetid2: ''
- })
- } else {
- if (that.data.ruleClick2 == '-') {
- clickNum = clickNum + 1;
- that.setData({
- clickNum: clickNum,
- })
- }
- that.setData({
- ruleClick2: id,
- rule2: that.data.Style2[id].datasheet_name,
- styleLen: styleLen++,
- sheetid2: datasheetId
- })
- }
- } else if (ruleNum == 3) {
- if (that.data.ruleClick3 == id) {
- clickNum = clickNum - 1;
- that.setData({
- ruleClick3: '-',
- rule3: '',
- styleLen: styleLen--,
- clickNum: clickNum,
- sheetid3: ''
- })
- } else {
- if (that.data.ruleClick3 == '-') {
- clickNum = clickNum + 1;
- that.setData({
- clickNum: clickNum,
- })
- }
- that.setData({
- ruleClick3: id,
- rule3: that.data.Style3[id].datasheet_name,
- styleLen: styleLen++,
- sheetid3: datasheetId,
- })
- }
- } else if (ruleNum == 4) {
- if (that.data.ruleClick4 == id) {
- clickNum = clickNum - 1;
- that.setData({
- ruleClick4: '-',
- rule4: '',
- styleLen: styleLen--,
- clickNum: clickNum,
- sheetid4: ''
- })
- } else {
- if (that.data.ruleClick4 == '-') {
- clickNum = clickNum + 1;
- that.setData({
- clickNum: clickNum,
- })
- }
- that.setData({
- ruleClick4: id,
- rule4: that.data.Style4[id].datasheet_name,
- styleLen: styleLen++,
- sheetid4: datasheetId
- })
- }
- } else {
- if (that.data.ruleClick5 == id) {
- clickNum = clickNum - 1;
- that.setData({
- ruleClick5: '-',
- rule5: '',
- styleLen: styleLen--,
- clickNum: clickNum,
- sheetid5: ''
- })
- } else {
- if (that.data.ruleClick5 == '-') {
- clickNum = clickNum + 1;
- that.setData({
- clickNum: clickNum,
- })
- }
- that.setData({
- ruleClick5: id,
- rule5: that.data.Style5[id].datasheet_name,
- styleLen: styleLen++,
- sheetid5: datasheetId
- })
- }
- }
- //分别与已点规格组合,判断是否有库存可选
- that.chooseStyleSetData(datasheetId, clickNum);
- if (that.data.styleLen == 0) {
- that.setData({
- chooseResult: 0
- })
- } else {
- that.setData({
- chooseResult: 1
- })
- }
- },
- //立即购买下的选择礼盒
- boxSelect: function (options) {
- var that = this
- var id = options.currentTarget.dataset.id;
- var boxPrice = that.data.gixboxService[id].box_price;
- var modelStyleNum = that.data.modelStyleNum;//规格类别数
- var clickNum = that.data.clickNum;
- if (boxPrice == '' || boxPrice == null || boxPrice == undefined) {
- that.setData({
- clickBoxPrice: 0
- })
- }
- if (that.data.boxClick == id) {//变为取消状态
- if (modelStyleNum == clickNum) {
- that.setData({
- showPrice: parseFloat(that.data.showPrice) - parseFloat(boxPrice)
- })
- }
- that.setData({
- boxClick: '-',
- selectBox: '',
- clickBoxPrice : 0
- })
- if (that.data.styleLen == 0) {
- that.setData({
- chooseResult: 0
- })
- }
-
- } else {
- if (modelStyleNum == clickNum) {
- that.setData({
- showPrice: parseFloat(that.data.showPrice) - parseFloat(that.data.clickBoxPrice) + parseFloat(boxPrice)
- })
- }
- that.setData({
- chooseResult: 1,
- boxClick: id,
- selectBox: that.data.gixboxService[id].giftbox_name,
- clickBoxPrice: boxPrice
- })
- }
-
- },
- //立即购买下的定制
- dingZhiSelect: function (options) {
- var that = this
- var id = options.currentTarget.dataset.id;
- if (that.data.dingZhiClick == id) {//变为取消状态
- that.setData({
- dingZhiClick: '-',
- selectDingZhi: ''
- })
- } else {
- that.setData({
- chooseResult: 1,
- dingZhiClick: id,
- selectDingZhi: that.data.dingzhiService[id].process_name
- })
- }
- //判断当前是否有选择的规格
- if (that.data.styleLen == 0) {
- that.setData({
- chooseResult: 0
- })
- } else {
- that.setData({
- chooseResult: 1
- })
- }
- },
- //绑定加数量事件
- addCount(e) {
- var that = this;
- var showNum = that.data.showNum;
- let num = this.data.minNumber;
- if (num >= showNum){
- that.setData({
- hiddenmodal: false,
- modalCont: '超出库存',
- minNumber: showNum
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true,
- })
- }, 1000)
- return false;
- }else{
- num++;
- if (num == showNum){
- this.setData({
- "minNumber": num,
- })
- }else{
- this.setData({
- "minNumber": num,
- })
- }
- }
- },
- //绑定减数量事件
- minusCount(e) {
- let num = this.data.minNumber;
- let minnum = this.data.num;
- if (num <= minnum) {
- that.setData({
- hiddenmodal: false,
- modalCont: '起订量为' + minnum + '件',
- minNumber: showNum
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true,
- })
- }, 1000)
- return false;
- }
- num--;
- this.setData({
- "minNumber": num
- })
- },
- //手动填写数量
- writeNum: function (e) {
- var that = this;
- var val = e.detail.value;
- var minnum = that.data.num;//起订量
- var showNum = that.data.showNum;//获取库存
- if (parseInt(val) >= parseInt(showNum)) {//大于库存
- that.setData({
- minNumber: showNum
- })
- } else if (parseInt(val) < parseInt(minnum)) {//小于起订量
- that.setData({
- minNumber: minnum
- })
- } else {
- that.setData({
- minNumber: val
- })
- }
- },
- //加入购物车 - 打开选择弹窗
- addCart: function (e) {
- var that = this;
- var scrollTop = that.data.scrollTop;
- var com_id = that.data.com_id;//商品id
- var specialGoodMsgShowCount = that.data.specialGoodMsgShowCount;//有时效性的商品,提示显示的次数
- //判断商品是否已下架,若下架则不可点击
- var soldOutShow = that.data.soldOutShow;
- if (soldOutShow == true) {
- return false;
- }
- that.setData({
- chooseFlag: 0,//判断进入购买的入口【底部footer】
- stateId: 0,
- cont_hidden: 'cont_hidden'
- });
- wx.getSystemInfo({
- success: function (res) {
- animationShowHeight = res.windowHeight;
- }
- })
- // 显示遮罩层
- var animation = wx.createAnimation({
- duration: 400,
- timingFunction: 'linear',
- })
- this.animation = animation
- animation.opacity(0).step()
- this.setData({
- isShow: true,
- windBgShow: animation.export()
- })
- setTimeout(function () {
- animation.opacity(1).step()
- this.setData({
- windBgShow: animation.export()
- })
- }.bind(this), 200)
- //内容
- animation.bottom(-animationShowHeight).step()
- this.setData({
- animationDataBuy: animation.export()
- })
- setTimeout(function () {
- animation.bottom(0).step()
- this.setData({
- animationDataBuy: animation.export()
- })
- }.bind(this), 200);
- //判断是否是特定的时效商品
- if (com_id == '3419') {
- if (specialGoodMsgShowCount == 0) {
- that.setData({
- isSpecialGood: true,
- specialGoodMsgShowCount: specialGoodMsgShowCount + 1
- })
- }
- }
- },
- //立即购买 - 打开选择弹窗
- buyCart: function (e) {
- var that = this;
- var scrollTop = that.data.scrollTop;
- var com_id = that.data.com_id;//商品id
- var specialGoodMsgShowCount = that.data.specialGoodMsgShowCount;//有时效性的商品,提示显示的次数
- //判断商品是否已下架,若下架则不可点击
- var soldOutShow = that.data.soldOutShow;
- if (soldOutShow == true) {
- return false;
- }
- this.setData({
- chooseFlag: 0,//判断进入购买的入口【底部footer】
- stateId: 1,
- cont_hidden: 'cont_hidden'
- })
- wx.getSystemInfo({
- success: function (res) {
- animationShowHeight = res.windowHeight;
- }
- })
- var animation = wx.createAnimation({
- duration: 400,
- timingFunction: 'linear',
- })
- this.animation = animation
- animation.opacity(0).step()
- this.setData({
- isShow: true,
- windBgShow: animation.export()
- })
- setTimeout(function () {
- animation.opacity(1).step()
- this.setData({
- windBgShow: animation.export()
- })
- }.bind(this), 200)
- // 显示遮罩层
- animation.bottom(-animationShowHeight).step()
- this.setData({
- animationDataBuy: animation.export()
- })
- setTimeout(function () {
- animation.bottom(0).step()
- this.setData({
- animationDataBuy: animation.export()
- })
- }.bind(this), 200);
- //判断是否是特定的时效商品
- if (com_id == '3419') {
- if (specialGoodMsgShowCount == 0) {
- that.setData({
- isSpecialGood: true,
- specialGoodMsgShowCount: specialGoodMsgShowCount + 1
- })
- }
- }
- },
- //跳转到购物车
- linkCart(e) {
- console.log(e)
- wx.switchTab({
- url: '/pages/car/index',
- })
- },
- //收藏
- collect: function (e) {
- var dataState = e.currentTarget.dataset.state;
- var host = getApp().globalData.servsers;
- var un_id = getApp().globalData.un_id;
- var openid = getApp().globalData.openid;
- var that = this;
- if ((un_id == undefined || un_id == '' || un_id == null) || (openid == undefined || openid == '' || openid == null)) {
- wx.navigateTo({
- url: '/pages/authorize/authorize?link=buy',
- })
- } else {
- if (!dataState) {
- //后台增加收藏用户收藏数据
- wx.request({
- url: host + "collectionapi/insertcollection",
- data: {
- user_id: un_id,
- collection_clas: 2,
- collection_name: that.data.com_id,
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- })
- this.setData({
- collectState: true
- })
- } else {
- wx.request({
- url: host + "collectionapi / deleteforxcx",
- data: {
- user_id: un_id,
- collection_clas: 2,
- collection_name: that.data.com_id,
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- })
- this.setData({
- collectState: false
- })
- }
- }
- },
- //立即购买-去付款
- tz: function (e) {
- var that = this;
- var host = getApp().globalData.servsers;
- var un_id = getApp().globalData.un_id;
- var openid = getApp().globalData.openid;
- var id = e.currentTarget.dataset.id;
- let carts = this.data.carts;
- var shangpin_id = this.data.shangpin_id;
- var name = this.data.title;
- var logo = this.data.bannerSml;
- var cost = this.data.newPrice;
- var cyc = this.data.cycle;
- var number = this.data.minNumber;
- var limitNum = this.data.num;//起订量
- var acceptance = this.data.title;
- var region = this.data.title;
- var specifications = this.data.title;
- var comGroupId = [];
- var styleName1 = '', styleName2 = '', styleName3 = '', styleName4 = '', styleName5 = '';
- var styleId1 = '', styleId2 = '', styleId3 = '', styleId4 = '', styleId5 = '';
- //规格 : 名称 当前选中的index 当前选中的对应数据Id
- var style1 = that.data.Style1;
- var style1 = that.data.Style1;
- if (style1 == undefined || style1 == '' || style1 == null) {
- styleName1 = '';
- styleId1 = '';
- } else {
- var styleIndex1 = that.data.ruleClick1;
- if (styleIndex1 == '-') {
- that.setData({
- hiddenmodal: false,
- modalCont: '请选择' + that.data.style1_name
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true
- })
- }, 1000)
- return false;
- } else {
- styleId1 = that.data.Style1[styleIndex1].id;
- styleName1 = that.data.Style1[styleIndex1].datasheet_name;
- comGroupId.push(that.data.Style1[styleIndex1].datasheet_id);
- }
- }
- var style2 = that.data.Style2;
- if (style2 == undefined || style2 == '' || style2 == null) {
- styleName2 = '';
- styleId2 = '';
- } else {
- var styleIndex2 = that.data.ruleClick2;
- if (styleIndex2 == '-') {
- that.setData({
- hiddenmodal: false,
- modalCont: '请选择' + that.data.style2_name
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true
- })
- }, 1000)
- return false;
- } else {
- styleId2 = that.data.Style2[styleIndex2].id;
- styleName2 = that.data.Style2[styleIndex2].datasheet_name;
- comGroupId.push(that.data.Style2[styleIndex2].datasheet_id);
- }
- }
- var style3 = that.data.Style3;
- if (style3 == undefined || style3 == '' || style3 == null) {
- styleName3 = '';
- styleId3 = '';
- } else {
- var styleIndex3 = that.data.ruleClick3;
- if (styleIndex3 == '-') {
- that.setData({
- hiddenmodal: false,
- modalCont: '请选择' + that.data.style3_name
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true
- })
- }, 1000)
- return false;
- } else {
- styleId3 = that.data.Style3[styleIndex3].id;
- styleName3 = that.data.Style3[styleIndex3].datasheet_name;
- comGroupId.push(that.data.Style3[styleIndex3].datasheet_id);
- }
- }
- var style4 = that.data.Style4;
- if (style4 == undefined || style4 == '' || style4 == null) {
- styleName4 = '';
- styleId4 = '';
- } else {
- var styleIndex4 = that.data.ruleClick4;
- if (styleIndex4 == '-') {
- that.setData({
- hiddenmodal: false,
- modalCont: '请选择' + that.data.style4_name
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true
- })
- }, 1000)
- return false;
- } else {
- styleId4 = that.data.Style4[styleIndex4].id;
- styleName4 = that.data.Style1[styleIndex4].datasheet_name;
- comGroupId.push(that.data.Style4[styleIndex4].datasheet_id);
- }
- }
- var style5 = that.data.Style5;
- if (style5 == undefined || style5 == '' || style5 == null) {
- styleName5 = '';
- styleId5 = '';
- } else {
- var styleIndex5 = that.data.ruleClick5;
- if (styleIndex5 == '-') {
- that.setData({
- hiddenmodal: false,
- modalCont: '请选择' + that.data.style5_name
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true
- })
- }, 1000)
- return false;
- } else {
- styleId5 = that.data.Style5[styleIndex5].id;
- styleName5 = that.data.Style5[styleIndex5].datasheet_name;
- comGroupId.push(that.data.Style5[styleIndex5].datasheet_id);
- }
- }
- var comGroupIdVal = comGroupId.join('-');
- var saveStyleId = '';
- for (var i = 0; i < that.data.groupList.length;i++){
- if (that.data.groupList[i].datasheet_id == comGroupIdVal){
- saveStyleId = that.data.groupList[i].id;
- }
- }
- //礼盒 名称 当前选中的index 当前选中的对应数据Id
- var selectBox = this.data.gixboxService;
- if (selectBox == undefined || selectBox == '') {
- var selectBoxName = '';
- var selectBoxId = -1;
- var selectBoxPrice = 0;
- } else {
- var gixboxIndex = this.data.boxClick;
- if (gixboxIndex == '-') {
- that.setData({
- hiddenmodal: false,
- modalCont: '请选择礼盒'
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true
- })
- }, 1000)
- return false;
- } else {
- var selectBoxId = this.data.gixboxService[gixboxIndex].id;
- var selectBoxName = this.data.gixboxService[gixboxIndex].giftbox_name;
- var selectBoxPrice = this.data.gixboxService[gixboxIndex].box_price;
- }
- }
- //定制 名称 当前选中的index 当前选中的对应数据Id
- var selectDingZhi = this.data.dingzhiService;
- if (selectDingZhi == undefined || selectDingZhi == '') {
- var selectDingZhiName = '';
- var selectDingZhiId = -1;
- } else {
- var selectDingZhiIndex = this.data.dingZhiClick;
- if (selectDingZhiIndex == '-') {
- that.setData({
- hiddenmodal: false,
- modalCont: '请选择定制'
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true
- })
- }, 1000)
- return false;
- } else {
- var selectDingZhiId = this.data.dingzhiService[selectDingZhiIndex].id;
- var selectDingZhiName = this.data.dingzhiService[selectDingZhiIndex].process_name;
- }
- }
- if ((un_id == undefined || un_id == '' || un_id == null) || (openid == undefined || openid == '' || openid == null)) {
- wx.navigateTo({
- url: '/pages/authorize/authorize?link=buy',
- })
- } else {
- var name = that.data.title;
- var com_id = that.data.com_id;
- var logo = that.data.bannerSml;
- var cost = that.data.newPrice;
- var acceptance = that.data.acceptance;
- var cyc = that.data.cycle;
- var minNumber = that.data.minNumber;
- var limitNum = that.data.num;//起订量
- var allPrice = parseFloat(that.data.showPrice);//商品总价格【价格 + 礼盒价格】
- var goodPrice = parseFloat(that.data.showPrice) - parseFloat(that.data.clickBoxPrice);//商品单独的价格
- if (id == 0) {//加入购物车
- let num = parseInt(that.data.minNumber);
- let oldNum = parseInt(that.data.cartNum);
- let newNum = oldNum + num;
- if (newNum > 99) {
- that.setData({
- 'cartNum': '99+'
- })
- } else {
- that.setData({
- 'cartNum': newNum
- })
- }
- //加入购物车
- wx.request({
- url: host + "shoppingcartapi/insertshoppingcart",
- data: {
- user_id: un_id,
- com_id: com_id,
- name: name,
- logo: logo,
- cost: goodPrice,
- cyc: cyc,
- num: minNumber,
- minNumber: limitNum,
- acceptance: acceptance,
- flag: 1,
- giftbox: selectBoxId,
- giftbox_name: selectBoxName,
- box_price: that.data.clickBoxPrice,
- process: selectDingZhiId,
- process_name: selectDingZhiName,
- style1_name: styleName1,
- style1: styleId1,
- style2_name: styleName2,
- style2: styleId2,
- style3_name: styleName3,
- style3: styleId3,
- style4_name: styleName4,
- style4: styleId4,
- style5_name: styleName5,
- style5: styleId5,
- comGroupId: saveStyleId,//商品组合规格id
- },
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- }
- })
- } else {
- carts = [{
- id: shangpin_id,
- com_id: shangpin_id,
- name: name,
- logo: logo,
- cost: goodPrice,//商品单独的价格
- cyc: cyc,
- num: minNumber,
- acceptance: acceptance,
- region: region,
- specifications: specifications,
- flag: 1,
- giftbox: selectBoxId,
- giftbox_name: selectBoxName,
- box_price: that.data.clickBoxPrice,
- style1: styleId1,
- style1_name: styleName1,
- style2: styleId2,
- style2_name: styleName2,
- style3: styleId3,
- style3_name: styleName3,
- style4: styleId4,
- style4_name: styleName4,
- style5: styleId5,
- style5_name: styleName5,
- process: selectDingZhiId,
- process_name: selectDingZhiName,
- new_price: that.data.showPrice,
- com_group_id: saveStyleId,//商品组合规格id
- }];
- this.setData({
- carts: carts
- })
- var newCarts = JSON.stringify(that.data.carts);
- newCarts = newCarts.replace(/&/g, "zss");
- wx.navigateTo({
- url: '/pages/confirmOrder/confirmOrder?carts=' + newCarts,
- })
- }
- wx.getSystemInfo({
- success: function (res) {
- animationShowHeight = res.windowHeight;
- }
- })
- // 关闭遮罩层
- var animation = wx.createAnimation({
- duration: 400,
- timingFunction: 'linear'
- })
- this.animation = animation;
- animation.bottom(0).step()
- this.setData({
- isShow: false,
- cont_hidden: '',
- animationDataBuy: animation.export()
- })
- setTimeout(function () {
- animation.bottom(-animationShowHeight).step()
- this.setData({
- animationDataBuy: animation.export()
- })
- }.bind(this), 200)
- animation.opacity(1).step()
- this.setData({
- windBgShow: animation.export()
- })
- setTimeout(function () {
- animation.opacity(0).step()
- this.setData({
- isShow: false,
- windBgShow: animation.export()
- })
- }.bind(this), 200)
- }
- },
- imageLoad: function (e) {
- var that = this;
- var imageSize = {};
- var originalWidth = e.detail.width;//图片原始宽
- var originalHeight = e.detail.height;//图片原始高
- var originalScale = originalHeight / originalWidth;//图片高宽比
- wx.getSystemInfo({
- success: function (res) {
- var windowWidth = res.windowWidth;
- var windowHeight = res.windowHeight;
- var windowscale = windowHeight / windowWidth;//屏幕高宽比
- imageSize.imageHeight = (windowWidth * originalHeight) / originalWidth;
- }
- })
- that.setData({
- imageheight: imageSize.imageHeight,
- })
- },
- windOpen: function () {
- console.log("延时调用");
- },
- windClose: function () {
- this.setData({
- hidden: true
- });
- },
- previewImg: function (e) {//banner图预览
- var that = this;
- var currentUrl = e.currentTarget.dataset.src;
- wx.previewImage({
- current: currentUrl,
- urls: that.data.imgList
- })
- },
- //显示选择商品&定制详情
- showGoodsInfor: function () {
- var that = this;
- var scrollTop = that.data.scrollTop;
- that.setData({
- chooseFlag: 1,
- cont_hidden: 'cont_hidden'
- })
- wx.getSystemInfo({
- success: function (res) {
- animationShowHeight = res.windowHeight;
- }
- })
- // 显示遮罩层
- var animation = wx.createAnimation({
- duration: 400,
- timingFunction: 'linear',
- })
- this.animation = animation
- animation.opacity(0).step()
- this.setData({
- isShow: true,
- windBgShow: animation.export()
- })
- setTimeout(function () {
- animation.opacity(1).step()
- this.setData({
- windBgShow: animation.export()
- })
- }.bind(this), 200)
- //内容
- animation.bottom(-animationShowHeight).step()
- this.setData({
- animationDataBuy: animation.export()
- })
- setTimeout(function () {
- animation.bottom(0).step()
- this.setData({
- animationDataBuy: animation.export()
- })
- }.bind(this), 200)
- },
- showServiceInfor: function () {//显示服务
- var that = this;
- var scrollTop = that.data.scrollTop;
- that.setData({
- stateId: 0,
- cont_hidden: 'cont_hidden'
- });
- wx.getSystemInfo({
- success: function (res) {
- animationShowHeight = res.windowHeight;
- }
- })
- var animation = wx.createAnimation({
- duration: 400,
- timingFunction: 'linear',
- })
- this.animation = animation
- animation.opacity(0).step()
- this.setData({
- isShow: true,
- windBgShow: animation.export()
- })
- setTimeout(function () {
- animation.opacity(1).step()
- this.setData({
- windBgShow: animation.export()
- })
- }.bind(this), 200)
- animation.bottom(-animationShowHeight).step()
- this.setData({
- animationDataSer: animation.export()
- })
- setTimeout(function () {
- animation.bottom(0).step()
- this.setData({
- animationDataSer: animation.export()
- })
- }.bind(this), 200)
- },
- closeBuy: function () {//关闭购买弹窗
- var that = this;
- wx.getSystemInfo({
- success: function (res) {
- animationShowHeight = res.windowHeight;
- }
- })
- var animation = wx.createAnimation({
- duration: 400,
- timingFunction: 'linear',
- })
- this.animation = animation
- animation.opacity(1).step()
- this.setData({
- windBgShow: animation.export()
- })
- setTimeout(function () {
- animation.opacity(0).step()
- this.setData({
- isShow: false,
- windBgShow: animation.export(),
- cont_hidden: ''
- })
- }.bind(this), 200)
- // 显示遮罩层
- animation.bottom(0).step()
- this.setData({
- animationDataBuy: animation.export()
- })
- setTimeout(function () {
- animation.bottom(-animationShowHeight).step()
- this.setData({
- animationDataBuy: animation.export()
- })
- }.bind(this), 200)
- },
- closeService: function () {//关闭服务弹窗
- var that = this;
- that.setData({
- chooseFlag: 0,
- cont_hidden: ''
- })
- wx.getSystemInfo({
- success: function (res) {
- animationShowHeight = res.windowHeight;
- }
- })
- var animation = wx.createAnimation({
- duration: 400,
- timingFunction: 'linear',
- })
- this.animation = animation
- animation.opacity(1).step()
- this.setData({
- windBgShow: animation.export()
- })
- setTimeout(function () {
- animation.opacity(0).step()
- this.setData({
- isShow: false,
- windBgShow: animation.export()
- })
- }.bind(this), 200)
- // 内容
- animation.bottom(0).step()
- this.setData({
- animationDataSer: animation.export()
- })
- setTimeout(function () {
- animation.bottom(-animationShowHeight).step()
- this.setData({
- animationDataSer: animation.export()
- })
- }.bind(this), 200)
- },
- onShareAppMessage: function (res) {//页面分享
- var that = this;
- var host = getApp().globalData.servsers;
- if (res.from === 'button') {
- // 来自页面内转发按钮
- }
- return {
- title: that.data.title,
- path: '/pages/buy/buy?com_id=' + that.data.com_id + '&from_flag=' + 1,
- imageUrl: host + 'images/' + that.data.bannerShare,
- success: function (res) {
- // 转发成功
- that.setData({
- hiddenmodal: false,
- modalCont: '分享成功'
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true
- })
- }, 1000)
- },
- fail: function (res) {
- // 取消分享、转发失败
- }
- }
- },
- //关闭具有时效性商品的购买提示
- closeMsg: function () {
- var that = this;
- that.setData({
- isSpecialGood: false
- })
- },
- //返回首页
- backIndex: function (e) {
- wx.switchTab({
- url: '/pages/index/index',
- })
- }
- })
- var that;
- var imageUtil = require('../../utils/util.js');
|