123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616 |
- // 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,//购买数量
- commodityChannelPrice:null, //渠道价格
- channelName:null,
- _carTotal:null,// 购物车全部数量
- },
- //重置所有变量
- 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, //默认
- loginStatic: false, //登陆状态,默认为false
- })
- },
- 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);
- let showPrice = (res.data.maxAndMin.min == res.data.maxAndMin.max) ? res.data.maxAndMin.min : (res.data.maxAndMin.min + '-' + res.data.maxAndMin.max);
- //有此商品
- 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,
- channelId: wx.getStorageSync('channelIdObj').channelId ? wx.getStorageSync('channelIdObj').channelId : ""
- },
- 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,
- product_channel_price: groupList[i].product_channel_price, //添加渠道价格
- };
- dataList[dataTit] = dataContList;
- }
- that.setData({
- sumTotal: sumTotal,
- groupList: groupList,
- dataList: dataList,
- showNum: sumTotal,
- commodityChannelPrice: res.data.data[0].product_channel_price,
-
- })
- if (that.data.loginStatic && res.data.data[0].product_channel_price){
- that.setData({
- showPrice: res.data.data[0].product_channel_price,
- })
- }
- 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();
- }
- }
- }
- })
- console.log(res, "res,showPrice")
-
- // if(that.data.loginStatic){
- // showPrice =
- // }
- that.setData({
- showPrice: showPrice,
- 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.getCarNum(that)
- that.setData({
- channelName: wx.getStorageSync('channelName')
- })
- that.loadFun();
- if (wx.getStorageSync('channelIdObj').channelId) {
- that.setData({
- loginStatic: true,
- })
- }
- },
- // 获取购物车数量
- getCarNum(that){
- console.log("开始执行")
- let un_id = getApp().globalData.un_id,
- host = getApp().globalData.servsers,
- data = {
- user_id: un_id,
- channel_account_id: wx.getStorageSync('channelIdObj').channelAccountId ? wx.getStorageSync('channelIdObj').channelAccountId : "",
- channel_id: wx.getStorageSync('channelIdObj').channelId ? wx.getStorageSync('channelIdObj').channelId : ""
- }
- wx.request({
- url: host + "/shoppingcartapi/shoppingcartview",
- data: data,
- 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 {
- that.setData({
- _carTotal: res.data.total
- })
- }
- }
- });
- },
- //获得对象的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],
- product_channel_price: [sku.product_channel_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) {
- console.log(sku,"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],
- product_channel_price:[sku.product_channel_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;
- console.log(prices,"prices")
- 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; //当前规格下的价格
- if(that.data.loginStatic){ // 表示是渠道价格
- console.log(SKUResult[selectedIds.join('-')].product_channel_price,"SKUResult[selectedIds.join('-')].product_channel_price")
- showPrice = SKUResult[selectedIds.join('-')].product_channel_price[0] ? SKUResult[selectedIds.join('-')].product_channel_price : showPrice //当前规格下的渠道价格
- }
- 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 * 1;
- let num = this.data.minNumber;
- console.log(showNum, num,"showNum")
- if (num >= showNum){
- that.setData({
- hiddenmodal: false,
- modalCont: '超出库存',
- minNumber: showNum
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true,
- })
- }, 1000)
- return false;
- }else{
- console.log(num, showNum)
- num++;
- if (num == showNum){
- this.setData({
- "minNumber": num,
- })
- }else{
- this.setData({
- "minNumber": num,
- })
- }
- }
- },
- //绑定减数量事件
- minusCount(e) {
- let that = this;
- let num = that.data.minNumber;
- let minnum = that.data.num;
- if (num <= minnum) {
- that.setData({
- hiddenmodal: false,
- modalCont: '起订量为' + minnum + '件',
- })
- setTimeout(function () {
- that.setData({
- hiddenmodal: true,
- })
- }, 1000)
- return false;
- }
- num--;
- that.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 = [];
- console.log(number,"点击购买时获取的数量")
- 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;//起订量
- console.log("第二次获取", that.data.minNumber)
- 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);
- // consolle.log("商品数量",num)
- 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
- channel_account_id: wx.getStorageSync('channelIdObj').channelAccountId ? wx.getStorageSync('channelIdObj').channelAccountId : ""
- },
- 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 {
- that.getCarNum(that)
- }
- }
- })
- } 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');
|