| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528 |
- <template>
- <view>
- <view class="top-fixed" :style="'height: '+ systems.barHeight + 'rpx;'">
- <image src="../../static/pages/images/topbg.png" class="topbg"></image>
- <view class="top-title" :style="'height: '+ systems.navigationHeight + 'rpx;top:' + systems.ktxStatusHeight + 'rpx;'">
- <image :src="about.CONFIG_PROJECT_TITLE_PIC" mode="heightFix"></image>
- </view>
- </view>
- <view :style="'height: '+ systems.barHeight + 'rpx;'"></view>
- <!-- <view class="tcon">
- <image src="../../static/pages/images/mbg.png" class="tcbg"></image>
- <view class="merchant ddflex">
- <image src="../../static/pages/images/blue/wdbg.png" mode="aspectFit" class="logo"></image>
- <view class="fflex">
- <view class="ddflex">
- <view class="merchant-name tover">世纪东城林雨店</view>
- <view class="change ddflex">切换<image src="../../static/pages/images/change.png"></image></view>
- </view>
- <view class="merchant-info ddflex"><image src="../../static/pages/images/pinzhi.png"></image>高品低价 售后无忧</view>
- </view>
- <button open-type="share" class="m-share"><image src="../../static/pages/images/share1.png"></image>分享</button>
- </view>
- <view class="con">
- <view class="search ddflex">
- <image src="../../static/pages/images/ssico.png"></image>
- <view class="fflex">搜索你想要的商品</view>
- </view>
- </view>
- </view> -->
- <view v-for="(item, index) in contact" :key="index" class="bgfff" style="overflow: hidden;">
- <storeOptionsNew
- v-if="item == 'store_options' || (item == 'sou' && top) || (item == 'type_district' && top_type)"
- :storeTemplate="storeTemplate"
- :merchant="merchant"
- :about="about"
- :guarantee="guarantee"
- :sousuoTemplate="sousuoTemplate"
- :typeDistrictTemplate="typeDistrictTemplate"
- :url="site"
- :web="url"
- :cloud="header.appId == 'ZQ1VK5oc17I387E' ? 'default' : ''"
- ></storeOptionsNew>
- <!-- 多门店选择模板和搜索模板 -->
- <popAd
- v-if="item == 'home_pop_up_ads'"
- :first="first"
- :popAdTemplate="popAdTemplate"
- :isLayerAd="isLayerAd"
- :popAdList="popAdList"
- :iscouponAd="iscouponAd"
- :storeShow="storeShow"
- ></popAd>
- <!-- 弹窗广告 -->
- <banner v-if="item == 'ad' && bannerShow" :bannerList="bannerList" :url="site" :web="url" :districtTemplate="districtTemplate"></banner>
- <!-- 走马灯 -->
- <bargain v-if="item == 'bargain' && bargainShow" :bargainList="bargainList" :url="site" :web="url" :bargainTemplate="bargainTemplate"></bargain>
- <!-- 砍价 -->
- <customers v-if="item == 'New_customers' && customersShow" :customersList="customersList" :url="site" :web="url" :customersTemplate="customersTemplate"></customers>
- <!-- 新客 -->
- <homecolumn v-if="item == 'homecolumn'" :homecolumnimg="homecolumnimg"></homecolumn>
- <!-- 首页专区 -->
- <joingroup v-if="item == 'joingroup' && joingroupShow" :joingroupList="joingroupList" :url="site" :web="url" :joingroupTemplate="joingroupTemplate"></joingroup>
- <!-- 拼团 -->
- <group
- v-if="item == 'group' && activityGroupShow"
- :activityGroup="activityGroup"
- :url="site"
- :web="url"
- :groupTemplate="groupTemplate"
- :merchant="merchant"
- :freshen="freshen"
- ></group>
- <!-- 社区团购 -->
- <pCategoryList
- v-if="item == 'p_list'"
- :homeTemplate="homeTemplate"
- :url="site"
- :web="url"
- :about="about"
- :templateType="templateType"
- :merchant="merchant"
- :freshen="freshen"
- :pCategoryList="pCategoryList"
- :pCategorShow="pCategorShow"
- ></pCategoryList>
- <!-- 分类 -->
- <recommend
- v-if="item == 'recommend' && recommendShow"
- :pageList="pageList"
- :recommendTemplate="recommendTemplate"
- :url="site"
- :web="url"
- :about="about"
- :categoryList="categoryList"
- ></recommend>
- <!-- 推荐 -->
- <seckill v-if="item == 'seckill' && seckillShow" :seckillList="seckillList" :url="site" :web="url" :seckillTemplate="seckillTemplate"></seckill>
- <!-- 秒杀 -->
- <selected v-if="item == 'chosen' && boutiqueShow" :boutiqueList="boutiqueList" :chosenTemplate="chosenTemplate" :url="site" :web="url" :about="about"></selected>
- <!-- 精选 -->
- <arrivals
- v-if="item == 'new_arrivals' && arrivalsShow"
- :arrivalsList="arrivalsList"
- :arrivalsTemplate="arrivalsTemplate"
- :url="site"
- :web="url"
- :about="about"
- ></arrivals>
- <!-- 新品上架 -->
- <hot v-if="item == 'hot_money' && hotShow" :hotList="hotList" :hotTemplate="hotTemplate" :url="site" :web="url" :about="about"></hot>
- <!-- 热门爆款 -->
- <specialTopic v-if="item == 'special'" :specialList="specialList"></specialTopic>
- <!-- 专题 -->
- <redEnvelopes
- v-if="item == 'red_envelopes'"
- :storeShow="storeShow"
- :iscouponAd="iscouponAd"
- :first="first"
- :couponAd="couponAd"
- @iscouponAd="hidecouponAd"
- ></redEnvelopes>
- <!-- 红包 -->
- <supplier
- v-if="item == 'supplier_premium' && supplierShow"
- :supplierTemplate="supplierTemplate"
- :web="merchant.type == 5 ? web : url"
- :supplierList="supplierList"
- :about="about"
- ></supplier>
- <!-- 供应商优品 -->
- <district v-if="item == 'king_kong_district' && districtShow" :url="site" :web="url" :districtTemplate="districtTemplate" :swiperHeight="swiperHeight"></district>
- <!-- 九宫格 金刚区 -->
- <suppliers
- v-if="item == 'sup_recommend' && supRecommendShow"
- :supRecommendList="supRecommendList"
- :url="site"
- :web="url"
- :supRecommendTemplate="supRecommendTemplate"
- ></suppliers>
- <!-- 供应商推荐 -->
- <single
- v-if="item == 'single_product' && singleShow"
- :pageList="singleList"
- :singleTemplate="singleTemplate"
- :merchant="merchant"
- :url="site"
- :web="url"
- :about="about"
- :categoryList="categoryList"
- ></single>
- <!-- 单产品推荐 -->
- </view>
- <switchStore v-if="switchStoreShow && contact.length > 0 && merchant.id" :first="first" :merchant="merchant" :storeShow="storeShow" @onFather="click"></switchStore>
- <!-- <component v-for="(item,index) in contact" ></component> -->
- <!-- <ad></ad> -->
- <block v-if="contactShow">
- <view class="spinner">
- <view class="spinner-container container1">
- <view class="circle1"></view>
- <view class="circle2"></view>
- <view class="circle3"></view>
- <view class="circle4"></view>
- </view>
- <view class="spinner-container container2">
- <view class="circle1"></view>
- <view class="circle2"></view>
- <view class="circle3"></view>
- <view class="circle4"></view>
- </view>
- <view class="spinner-container container3">
- <view class="circle1"></view>
- <view class="circle2"></view>
- <view class="circle3"></view>
- <view class="circle4"></view>
- </view>
- </view>
- <view class="lond">加载中···</view>
- </block>
- <view class="bgfff" style="overflow: hidden;">
- <swiper class="c-ban" indicator-dots="true" indicator-color="rgba(255,255,255,.5)" indicator-active-color="#fff">
- <swiper-item>
- <image src="../../static/pages/images/topbg.png" mode="aspectFill"></image>
- </swiper-item>
- <swiper-item>
- <image src="../../static/pages/images/topbg.png" mode="aspectFill"></image>
- </swiper-item>
- </swiper>
- <navigator class="head" hover-class="none" url="">
- <view class="titleNav dflex pdlr20">
- 附近好店
- <image src="/static/pages/images/more.png" class="more"></image>
- </view>
- </navigator>
- <view class="hot-shop">
- <navigator url="" hover-class="none" class="li ddflex">
- <image src="../../static/pages/images/mbg.png" mode="aspectFill" class="shop-img"></image>
- <view class="fflex">
- <view class="ddflex">
- <view class="shop-name tover fflex">艾康大健康新零售</view>
- <view class="shop-dis">2.5km</view>
- </view>
- <view class="shop-tag ddflex">
- <text>免费配送</text>
- </view>
- <view class="shop-info">
- 商品1125 | 销量657
- </view>
- <view class="shop-bri tover">老年保健品、OTC非处方药、少儿感冒药</view>
- </view>
- </navigator>
- <navigator url="" hover-class="none" class="li ddflex">
- <image src="../../static/pages/images/mbg.png" mode="aspectFill" class="shop-img"></image>
- <view class="fflex">
- <view class="ddflex">
- <view class="shop-name tover fflex">艾康大健康新零售</view>
- <view class="shop-dis">2.5km</view>
- </view>
- <view class="shop-tag ddflex">
- <text>免费配送</text>
- </view>
- <view class="shop-info">
- 商品1125 | 销量657
- </view>
- <view class="shop-bri tover">老年保健品、OTC非处方药、少儿感冒药</view>
- </view>
- </navigator>
- <navigator url="" hover-class="none" class="li ddflex">
- <image src="../../static/pages/images/mbg.png" mode="aspectFill" class="shop-img"></image>
- <view class="fflex">
- <view class="ddflex">
- <view class="shop-name tover fflex">艾康大健康新零售</view>
- <view class="shop-dis">2.5km</view>
- </view>
- <view class="shop-tag ddflex">
- <text>免费配送</text>
- </view>
- <view class="shop-info">
- 商品1125 | 销量657
- </view>
- <view class="shop-bri tover">老年保健品、OTC非处方药、少儿感冒药</view>
- </view>
- </navigator>
- <navigator url="" hover-class="none" class="li ddflex">
- <image src="../../static/pages/images/mbg.png" mode="aspectFill" class="shop-img"></image>
- <view class="fflex">
- <view class="ddflex">
- <view class="shop-name tover fflex">艾康大健康新零售</view>
- <view class="shop-dis">2.5km</view>
- </view>
- <view class="shop-tag ddflex">
- <text>免费配送</text>
- </view>
- <view class="shop-info">
- 商品1125 | 销量657
- </view>
- <view class="shop-bri tover">老年保健品、OTC非处方药、少儿感冒药</view>
- </view>
- </navigator>
- </view>
- </view>
- <footer-copyright v-if="logo"></footer-copyright>
- <!-- 订单购买轮播 -->
- <view :class="(marqueeOrderItem ? 'roll-notice ' : '') + 'dflex'" v-if="marqueeOrderItem">
- <image :src="marqueeOrderItem.avatar"></image>
- <view class="flex">{{ marqueeOrderItem.time }} 购买了{{ marqueeOrderItem.productName }}</view>
- </view>
- <contact-button img-url="/static/pages/images/kfico1.png" class-name="contact_index" button-text="客服"></contact-button>
- <view class="guide" @tap="hideGuide" v-if="first"><image src="/static/pages/images/guide.png" mode="widthFix"></image></view>
- <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 115) + 'rpx'"></view>
- <foot channel="home" :isUpdate="isUpdate"></foot>
- </view>
- </template>
- <script>
- //index.js
- //获取应用实例
- const app = getApp();
- const req = require('../../utils/request.js');
- const api = require('../../utils/api.js');
- const utils = require('../../utils/util.js');
- const mes = require('../../utils/requestmessage.js');
- const route = require('../../utils/route');
- const QQMapWX = require("../../utils/qqmap.js");
- import foot from '../../components/nav-bar/index';
- import footerCopyright from '../../components/footer-copyright/footer-copyright';
- import popAd from '../../template/popAd/popAd';
- import group from '../../template/activityGroup/activityGroup';
- import banner from '../../template/banner/banner';
- import bargain from '../../template/bargain/bargain';
- import customers from '../../template/customers/customers';
- import homecolumn from '../../template/homecolumn/homecolumn';
- import joingroup from '../../template/joingroup/joingroup';
- import pCategoryList from '../../template/pCategoryList/pCategoryList';
- import recommend from '../../template/recommend/recommend';
- import seckill from '../../template/seckill/seckill';
- import selected from '../../template/selected/selected';
- import arrivals from '../../template/arrivals/arrivals';
- import hot from '../../template/hot/hot';
- import specialTopic from '../../template/specialTopic/specialTopic';
- import storeOptions from '../../template/store_options/store_options';
- import storeOptionsNew from '../../template/store_options_new/store_options';
- import redEnvelopes from '../../template/red_envelopes/index';
- import supplier from '../../template/supplier/supplier';
- import district from '../../template/king_kong_district/king_kong_district';
- import switchStore from '../../template/switchStore/switchStore';
- import suppliers from '../../template/suppliers/suppliers';
- import single from '../../template/single/single';
- export default {
- data() {
- return {
- systems: {},
- header: req.header,
- bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
- swiperCurrent: 0,
- swiperGrid: 0,
- bannerList: [],
- categoryList: [],
- //产品分类列表
- page: 1,
- boutiqueList: {},
- //精品榜单
- arrivalsList: {},
- hotList: {},
- pageList: {},
- //产品列表
- isLoad: true,
- hasmore: true,
- merchant: {},
- activityGroup: {
- products: []
- },
- couponList: {},
- //优惠券,
- isRemind: false,
- isUpdate: false,
- // 是否更新消息
- first: true,
- //是否显示提示加入我的小程序
- isLayerAd: true,
- //广告
- homeTemplate: [],
- //首页栏目配置
- pCategoryList: [],
- storeShow: true,
- templateType: {
- module_ad: 'ad',
- //广告
- module_type_district: 'type_district',
- //分类导航
- module_p_list: 'p_list',
- //品类专区
- module_group: 'group',
- //团购
- module_live: 'live',
- //直播
- module_sou: 'sou',
- //搜索
- module_special: 'special',
- //专题
- module_chosen: 'chosen',
- //精选
- module_new_arrivals: 'new_arrivals',
- //新品上架
- module_hot_money: 'hot_money',
- //热门爆款
- module_recommend: 'recommend',
- //推荐产品
- module_store_options: 'store_options',
- //多门店选择
- module_home_pop_up_ads: 'home_pop_up_ads',
- //首页弹窗广告
- module_joingroup: 'joingroup',
- //拼团
- module_seckill: 'seckill',
- //秒杀
- module_bargain: 'bargain',
- //砍价
- module_customers: 'New_customers',
- //新客
- module_homecolumn: 'homecolumn',
- //首页专区
- module_Timely_delivery_open: 'Timely_delivery_open',
- //及时达页面
- module_supplier_premium: 'supplier_premium', //供应商模块
- module_red_envelopes: 'red_envelopes', //优惠券
- module_king_kong_district: 'king_kong_district', //金刚区
- module_sup_recommend: 'sup_recommend', //供应商推荐
- module_single_product: 'single_product' //供应商推荐
- },
- buyOrderMarqueeList: [],
- listI: -1,
- isNotice: false,
- TabList: [
- {
- //秒杀时间
- label: '今天',
- active: true,
- state: '抢购中',
- dayType: 1,
- time: ''
- },
- {
- label: '明天',
- state: '预热中',
- active: false,
- time: '',
- dayType: 2
- },
- {
- label: '后天',
- state: '预热中',
- dayType: 3,
- time: ''
- },
- {
- label: '',
- state: '预热中',
- dayType: 4,
- active: false,
- time: ''
- },
- {
- label: '',
- state: '预热中',
- dayType: 5,
- active: false,
- time: ''
- }
- ],
- joingroupList: {
- products: []
- },
- //拼团
- bargainList: {
- products: []
- },
- //砍价
- customersList: {
- products: []
- },
- //新客
- freshen: true,
- swiperHeight: 0,
- url: '',
- web: '',
- site: '',
- internet: '',
- storeTemplate: {},
- typeDistrictTemplate: {},
- sousuoTemplate: {},
- popAdTemplate: {},
- districtTemplate: {},
- Timelyimg: '',
- timelyTemplate: {},
- homecolumnimg: [],
- customersTemplate: {},
- joingroupTemplate: {},
- supplierTemplate: {},
- seckillTemplate: {},
- bargainTemplate: {},
- specialTemplate: {},
- chosenTemplate: {},
- arrivalsTemplate: {},
- hotTemplate: {},
- groupTemplate: {},
- recommendTemplate: {},
- supRecommendTemplate: {},
- singleTemplate: {},
- specialList: [],
- contact: [],
- seckillList: {
- products: []
- },
- about: {},
- Is_Store_Price_Stock: '',
- guarantee: [],
- current: '',
- animationData: '',
- content: '',
- popAdList: {},
- supplierList: {},
- supRecommendList: {},
- singlePage: 1,
- isLoadSingle: true,
- hasmoreSingle: true,
- singleList: {},
- iscouponAd: false,
- couponAd: {},
- logo: false,
- top: Boolean,
- top_type: Boolean,
- switchStoreShow: Boolean,
- bargainShow: Boolean,
- contactShow: true,
- seckillShow: false,
- joingroupShow: false,
- activityGroupShow: false,
- customersShow: false,
- districtShow: false,
- recommendShow: false,
- boutiqueShow: false,
- arrivalsShow: false,
- hotShow: false,
- supplierShow: false,
- supRecommendShow: false,
- singleShow: false,
- pCategorShow: false,
- bannerShow: false,
- List: [],
- marqueeOrderItemIndex: 0,
- marqueeOrderItem: '',
- // isShowTime: false
- };
- },
- components: {
- foot,
- footerCopyright,
- banner,
- group,
- bargain,
- popAd,
- customers,
- homecolumn,
- joingroup,
- pCategoryList,
- recommend,
- seckill,
- selected,
- arrivals,
- hot,
- specialTopic,
- storeOptions,
- storeOptionsNew,
- redEnvelopes,
- supplier,
- district,
- switchStore,
- suppliers,
- single
- },
- props: {},
- onLoad: async function(options) {
- // console.log("扫码进去参数===" + JSON.stringify(options));
- // if (options.scene) {
- // // this.scene = options.scene || '1290926887903780865';
- // this.scene = options.scene;
- // await this.loadCodeParams();
- // }
- // wx.setNavigationBarColor({
- // frontColor: '#ffffff',
- // backgroundColor: req.public.titleTopBgColor,
- // })
- // this.getPopAd()
- this.query = options;
- if (options.custom_params) {
- let obj = decodeURIComponent(opt.custom_params);
- obj = JSON.parse(obj);
- // console.log(obj)
- req.setStorage('pidCode', obj.userId);
- }
- if (options.isShare) {
- if (options.userId) {
- req.setStorage('pidCode', options.userId);
- }
- }
- setInterval(() => {
- this.setData({
- isNotice: true
- });
- }, 10000); // this.init();
-
- QQMapWX.initMap();
- req.getLocation(res => {
- const to = {
- latitude: res.latitude,
- longitude: res.longitude
- };
- QQMapWX.reverseGeocoder(to, resp => {
- });
- });
- },
- async onShow() {
- let _ts = this;
- await this.getConfig().then(res => {
- // console.log("debug1", res);
- _ts.getMerchant();
- });
- await this.getHomeTemplateConfig();
- uni.setNavigationBarColor({
- frontColor: '#ffffff',
- backgroundColor: req.public.titleTopBgColor
- });
- _ts.setData({
- isUpdate: !_ts.isUpdate
- });
- // console.log('this.freshen=='+this.freshen)
- let first = req.getStorage('first');
- if (first !== false)
- _ts.setData({
- first: true
- });
- else
- _ts.setData({
- first: false
- });
- },
- onUnload() {
- // this.isShowTime = false;
- this.clearAllTimer(1);
- this.clearAllTimer(2);
- this.clearAllTimer(3);
- this.clearAllTimer(4);
- },
- onHide() {
- // this.isShowTime = false;
- this.clearAllTimer(1);
- this.clearAllTimer(2);
- this.clearAllTimer(3);
- this.clearAllTimer(4);
- },
- onShareAppMessage: function() {
- let path = '/pages/index/index?isShare=' + true;
- if (req.getStorage('userInfo')) {
- path += '&userId=' + req.getStorage('userInfo').id;
- }
- if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
- path += '&merchantId=' + req.getStorage('MERCHANT').id;
- if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
- path += '&shopId=' + req.getStorage('smallShop').id;
- }
- }
- let title = '';
- if (this.merchant && this.merchant.title && this.merchant.title != '默认门店') {
- title = this.merchant.title;
- } else {
- title = this.about.CONFIG_PROJECT_TITLE;
- }
- console.log(title);
- // console.log(path);
- return {
- title: (req.excludeSpecial(req.getStorage('userInfo').nickName) ? req.excludeSpecial(req.getStorage('userInfo').nickName) : '') + '为你推荐' + title,
- // imageUrl: this.data.seckill[0].pic
- // path: '/product/detail/detail?id=' + this.query.id + '&isShare=' + true + '&userId=' + req.getStorage('userInfo').id
- path: path
- };
- },
- onShareTimeline() {
- let path = 'isShare=' + true;
- if (req.getStorage('userInfo')) {
- path += '&userId=' + req.getStorage('userInfo').id;
- }
- if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
- path += '&merchantId=' + req.getStorage('MERCHANT').id;
- if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
- path += '&shopId=' + req.getStorage('smallShop').id;
- }
- }
- let title = '';
- if (this.merchant && this.merchant.title && this.merchant.title != '默认门店') {
- title = this.merchant.title;
- } else {
- title = this.about.CONFIG_PROJECT_TITLE;
- }
- // console.log(path);
- return {
- title: (req.excludeSpecial(req.getStorage('userInfo').nickName) ? req.excludeSpecial(req.getStorage('userInfo').nickName) : '') + '为你推荐' + title,
- // imageUrl: this.data.seckill[0].pic
- // path: '/product/detail/detail?id=' + this.query.id + '&isShare=' + true + '&userId=' + req.getStorage('userInfo').id
- query: path
- };
- },
- onReachBottom() {},
- methods: {
- hidecouponAd(iscouponAd) {
- this.iscouponAd = false;
- app.globalData.isredenvelopes = false;
- },
- getMerchant() {
- let _ts = this;
- if (req.header.appId == 'ZQ1VK5oc17I387E') {
- // 默认门店
- let merchant = req.getStorage('defaultMerchant');
- var timestamp = Date.parse(new Date());
- merchant.time = timestamp + 1 * 60 * 1000;
- if (merchant) {
- req.setStorage('MERCHANT', merchant);
- _ts.setData({
- merchant: merchant
- });
- console.log('》》》》获取当前的门店>>>>>>>>', merchant);
- _ts.init(merchant);
- } else {
- return new Promise((resolve, reject) => {
- req.getRequest(
- '/api/merchant/list',
- {
- page: 0,
- limit: 10000
- },
- res => {
- console.log('获取到门店列表>>>>>>>>', res);
- var data = res.filter(it => it.isDefault == 1);
- var timestamp = Date.parse(new Date());
- res[0].time = timestamp + 1 * 60 * 1000;
- _ts.setData({
- merchant: data[0]
- });
- // console.log(data)
- console.log('缓存当前的门店>>>>>>>>', data[0]);
- req.setStorage('defaultMerchant', data[0]);
- req.setStorage('MERCHANT', data[0]);
- _ts.init(data[0]);
- resolve();
- }
- );
- });
- }
- } else {
- return new Promise((resolve, reject) => {
- api.getMerchant(_ts.query, req, data => {
- if (data == 1) {
- uni.showModal({
- title: '温馨提示',
- content: '获取定位失败,请前往设置打开定位权限',
- showCancel: false,
- success(res) {
- if (res.confirm) {
- // console.log('用户点击确定');
- uni.openSetting({
- success(res) {
- console.log(res.authSetting); // res.authSetting = {
- }
- });
- }
- }
- });
- } else {
- _ts.merchant = data;
- _ts.init(data);
- }
- resolve();
- });
- });
- }
- },
- getBuyOrderMarquee(isToTime) {
- console.log('getBuyOrderMarquee数据获取>>>>>>');
- req.getRequest('/api/product/buyDynamic', {}, data => {
- this.isShowTime = true;
- this.buyOrderMarqueeList = data;
- if (isToTime) {
- console.log('1111111111getBuyOrderMarquee数据获取>>>>>>');
- if (this.buyOrderMarqueeList && this.buyOrderMarqueeList.length > 0) {
- this.marqueeOrderItem = this.buyOrderMarqueeList[this.marqueeOrderItemIndex];
- this.marqueeOrderItemIndex++;
- this.getMarqueeOrderItem();
- }
- }
- });
- },
- // 首页轮播最新购买记录
- getMarqueeOrderItem() {
- var tha = this;
- setTimeout(function() {
- // console.log('数据tha.marqueeOrderItemIndex>>>>', tha.marqueeOrderItemIndex);
- tha.marqueeOrderItem = tha.buyOrderMarqueeList[tha.marqueeOrderItemIndex];
- if (tha.marqueeOrderItemIndex >= tha.buyOrderMarqueeList.length - 1) {
- tha.marqueeOrderItemIndex = 0;
- } else {
- tha.marqueeOrderItemIndex++;
- }
- tha.getMarqueeOrderItem();
- }, 5000);
- },
- async init(merchant) {
- // this.getHomeTemplateConfig();
- // console.log(this.Is_Store_Price_Stock, this.Is_Store_Price_Stock, this.about);
- let url = '';
- let web = '';
- let site = '';
- let internet = '';
- if (merchant.type == 5) {
- url = '&merchantId=' + merchant.merchantDTO.id + '&shopId=' + merchant.id;
- web = '&smallShop=true';
- site = '?merchantId=' + merchant.merchantDTO.id + '&shopId=' + merchant.id;
- internet = '?smallShop=true';
- } else {
- url = '&merchantId=' + merchant.id;
- web = '&merchantId=' + merchant.id;
- site = '?merchantId=' + merchant.id;
- internet = '?merchantId=' + merchant.id;
- }
- // console.log(url, web);
- this.setData({
- url: url,
- web: web,
- site: site,
- internet: internet
- }); // await this.getConfig();
- // await this.getCategory(); // await this.getCoupon();
- },
- // getpCategoryList: function(e) {
- // console.log(e.detail, "qqqqq")
- // this.pCategoryList = e.detail
- // },
- // getPopAd(){
- // //弹窗广告
- // let popAd = that.data.homeTemplate.filter(it => it.module == that.data.templateType.module_home_pop_up_ads);
- // if (popAd && popAd.length > 0 && popAd[0].state == 0) {
- // that.setData({ popAdTemplate: popAd[0] });
- // await this.getBannerList(popAd[0].module, popAd[0].contentId);
- // }
- // },
- async getRqeDatas() {
- console.log('getRqeDatas');
- this.getBuyOrderMarquee(!this.isShowTime);
- let that = this; //多门店
- let store = that.homeTemplate.filter(it => it.module == that.templateType.module_store_options);
- that.setData({
- storeTemplate: store[0]
- }); //搜索
- let sousuo = that.homeTemplate.filter(it => it.module == that.templateType.module_sou);
- that.setData({
- sousuoTemplate: sousuo[0]
- });
- //分类导航
- let typeDistrict = that.homeTemplate.filter(it => it.module == that.templateType.module_type_district);
- that.setData({
- typeDistrictTemplate: typeDistrict[0]
- });
- //弹窗广告
- let popAd = that.homeTemplate.filter(it => it.module == that.templateType.module_home_pop_up_ads);
- if (popAd && popAd.length > 0 && popAd[0].state == 0) {
- that.setData({
- popAdTemplate: popAd[0]
- });
- if (that.freshen) {
- await that.getBannerList(popAd[0].module, popAd[0].contentId);
- }
- } // 及时达
- // let Timely = that.data.homeTemplate.filter(it => it.module == that.data.templateType.module_Timely_delivery_open);
- // if (Timely && Timely.length > 0 && Timely[0].state == 0) {
- // that.setData({ TimelyTemplate: Timely[0] });
- // await this.getTimelyList(Timely[0].module, Timely[0].contentId);
- // }
- let Timely = that.homeTemplate.filter(it => it.module == that.templateType.module_Timely_delivery_open);
- if (Timely.length > 0 && Timely[0].state == 0) {
- // console.log(Timely);
- let Timelyimg = Timely[0].contentId.split(','); // if (Timely[0] != '' && Timely[1] != '' && Timely[2] != '') {
- // if (Timely.length == 3) {
- that.setData({
- Timelyimg: Timelyimg[0],
- timelyTemplate: Timely[0]
- });
- // console.log(Timelyimg); // }
- // }
- }
- // 金刚区
- let district = that.homeTemplate.filter(it => it.module == that.templateType.module_king_kong_district);
- if (district && district.length > 0 && district[0].state == 0) {
- let data = district[0];
- data.content = JSON.parse(district[0].content);
- that.districtTemplate = data;
- if (data.contentId == 2) {
- that.districtShow = true;
- }
- console.log(that.districtTemplate, '=============');
- }
- //顶部banner
- let ad = that.homeTemplate.filter(it => it.module == that.templateType.module_ad);
- if (ad && ad.length > 0 && ad[0].state == 0) {
- if (that.freshen) {
- await that.getBannerList(ad[0].module, ad[0].contentId);
- }
- } //首页专区
- let homecolumn = that.homeTemplate.filter(it => it.module == that.templateType.module_homecolumn);
- if (homecolumn.length > 0 && homecolumn[0].state == 0) {
- let homecolumnimg = homecolumn[0].contentId.split(',');
- if (homecolumnimg[0] != '' && homecolumnimg[1] != '' && homecolumnimg[2] != '') {
- if (homecolumnimg.length == 3) {
- // console.log(homecolumnimg);
- that.setData({
- homecolumnimg: homecolumnimg
- });
- }
- }
- } // 新客
- let customers = that.homeTemplate.filter(it => it.module == that.templateType.module_customers);
- if (customers && customers.length > 0 && customers[0].state == 0) {
- that.setData({
- customersTemplate: customers[0]
- });
- await that.customersListFun(customers[0]);
- } //拼团
- let joingroup = that.homeTemplate.filter(it => it.module == that.templateType.module_joingroup);
- if (joingroup && joingroup.length > 0 && joingroup[0].state == 0) {
- that.setData({
- joingroupTemplate: joingroup[0]
- });
- await that.joingroupListFun(joingroup[0]);
- } // 供应商
- let supplier = that.homeTemplate.filter(it => it.module == that.templateType.module_supplier_premium);
- if (supplier && supplier.length > 0 && supplier[0].state == 0) {
- that.setData({
- supplierTemplate: supplier[0]
- });
- if (that.freshen) {
- await that.getsupplierList(supplier[0]);
- }
- } //秒杀
- let seckill = that.homeTemplate.filter(it => it.module == that.templateType.module_seckill);
- if (seckill && seckill.length > 0 && seckill[0].state == 0) {
- that.setData({
- seckillTemplate: seckill[0]
- });
- await that.seckillListFun(seckill[0]);
- } //砍价
- let bargain = that.homeTemplate.filter(it => it.module == that.templateType.module_bargain);
- if (bargain && bargain.length > 0 && bargain[0].state == 0) {
- that.setData({
- bargainTemplate: bargain[0]
- });
- await that.bargainListFun(bargain[0]);
- } //专题
- let special = that.homeTemplate.filter(it => it.module == that.templateType.module_special);
- if (special && special.length > 0 && special[0].state == 0) {
- that.setData({
- specialTemplate: special[0]
- });
- if (that.freshen) {
- await that.getSpecialList(special[0]);
- }
- } //精选
- let chosen = that.homeTemplate.filter(it => it.module == that.templateType.module_chosen);
- if (chosen && chosen.length > 0 && chosen[0].state == 0) {
- that.setData({
- chosenTemplate: chosen[0]
- });
- if (that.freshen) {
- await that.getBoutiqueList(chosen[0]);
- } // }
- } //团购
- //新品上架
- let arrivals = that.homeTemplate.filter(it => it.module == that.templateType.module_new_arrivals);
- if (arrivals && arrivals.length > 0 && arrivals[0].state == 0) {
- that.setData({
- arrivalsTemplate: arrivals[0]
- });
- if (that.freshen) {
- await that.getArrivalsList(arrivals[0]);
- } // }
- }
- //热门爆款
- let hot = that.homeTemplate.filter(it => it.module == that.templateType.module_hot_money);
- if (hot && hot.length > 0 && hot[0].state == 0) {
- that.setData({
- hotTemplate: hot[0]
- });
- if (that.freshen) {
- await that.getHotList(hot[0]);
- } // }
- }
- let group = that.homeTemplate.filter(it => it.module == that.templateType.module_group);
- if (group && group.length > 0 && group[0].state == 0) {
- that.setData({
- groupTemplate: group[0]
- });
- await that.loadGroup(group[0]);
- }
- //推荐产品
- let recommend = that.homeTemplate.filter(it => it.module == that.templateType.module_recommend);
- if (recommend && recommend.length > 0 && recommend[0].state == 0) {
- that.setData({
- recommendTemplate: recommend[0]
- });
- if (that.freshen) {
- await that.getPageList();
- }
- }
- //单产品推荐
- let single = that.homeTemplate.filter(it => it.module == that.templateType.module_single_product);
- if (single && single.length > 0 && single[0].state == 0) {
- that.setData({
- singleTemplate: single[0]
- });
- if (that.freshen) {
- await that.getSinglePageList();
- }
- }
- //品类专区
- let p_list = that.homeTemplate.filter(it => it.module == that.templateType.module_p_list && it.state == 0);
- // that.pCategoryList = p_list;
- that.List = p_list;
- if (that.freshen) {
- if (!that.pCategorShow) {
- for (var i = 0; i < that.List.length; i++) {
- await that.getPListProduct(that.List[i], i).then(data => {
- data = data.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
- return it;
- });
- var res = {
- displayStyle: that.List[i].theme,
- lineNumber: that.List[i].lineNumber,
- products: data
- };
- that.List[i].productList = res;
- let arr = [];
- that.List.forEach(it => {
- if (it.productList) {
- arr.push(it);
- }
- });
- that.pCategoryList = that.List;
- if (arr.length == that.List.length) {
- that.pCategorShow = true;
- }
- });
- }
- }
- }
- // 红包优惠券
- let coupon = that.homeTemplate.filter(it => it.module == that.templateType.module_red_envelopes && app.globalData.isredenvelopes);
- if (coupon && coupon.length > 0 && coupon[0].state == 0) {
- if (!req.getStorage('userInfo')) {
- that.setData({
- iscouponAd: true,
- couponAd: coupon[0]
- });
- } else {
- req.getRequest(
- '/api/coupon/checkCoupon',
- {
- id: coupon[0].contentId
- },
- res => {
- if (res == 1) {
- that.setData({
- iscouponAd: true,
- couponAd: coupon[0]
- });
- } else if (res == 0) {
- that.setData({
- iscouponAd: false
- });
- }
- }
- );
- }
- // console.log(coupon[0])
- } else {
- that.setData({
- iscouponAd: false
- });
- }
- // 供应商推荐
- let supRecommend = that.homeTemplate.filter(it => it.module == that.templateType.module_sup_recommend);
- if (supRecommend && supRecommend.length > 0 && supRecommend[0].state == 0) {
- that.setData({
- supRecommendTemplate: supRecommend[0]
- });
- if (that.freshen) {
- await that.getSupRecommendList();
- }
- }
- that.getCategory();
- that.setData({
- freshen: false
- });
- that.logo = true;
- },
- // 动态产品分类
- getPListProduct(pCategory, idx) {
- // return new Promise((resolve, reject) => {
- // console.log(idx)
- let that = this;
- let pList = [];
- let form = {
- limit: pCategory.number,
- categoryId: pCategory.contentId // isRecommend:1
- };
- // //小店
- if ((that.merchant && that.merchant.type == 5) || (that.shopId && that.merchantId)) {
- form.merchantId = that.merchant.merchantDTO.id;
- var sid = that.merchant.id;
- if (that.shopId && that.merchantId) (form.merchantId = that.merchantId), (form.sid = that.shopId);
- return new Promise((resolve, reject) => {
- req.getRequest('/api/shopProduct/list', form, data => {
- resolve(data);
- });
- });
- }
- //非小店
- if (that.merchant && that.merchant.type != 5) {
- form.merchantId = that.merchant.id;
- return new Promise((resolve, reject) => {
- req.getRequest('/api/product/list', form, data => {
- resolve(data);
- });
- });
- }
- // })
- },
- //新客
- customersListFun(customersTemplate) {
- let _ts = this;
- _ts.clearAllTimer(4);
- if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
- let from = {
- page: this.page,
- limit: customersTemplate.number,
- type: 6,
- merchantId: this.merchant.merchantDTO.id,
- sid: this.merchant.id
- };
- if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
- req.getRequest('/api/shopProduct/list', from, res => {
- res = res.list.map(it => {
- it.isRemind = it.remindId;
- return it;
- });
- let arrObjFilter;
- arrObjFilter = {
- displayStyle: customersTemplate.theme,
- lineNumber: customersTemplate.lineNumber,
- products: res.filter(ele => ele.end == false)
- };
- this.setData({
- customersList: arrObjFilter,
- customersShow: true
- });
- _ts.initGroupTimer(4);
- });
- }
- if (this.merchant && this.merchant.type != 5) {
- let from = {
- page: 1,
- limit: customersTemplate.number,
- type: 4,
- tag: 'home'
- };
- from.merchantId = this.merchant.id;
- req.getRequest('/api/activity/list', from, data => {
- data = data.map(it => {
- it.isRemind = it.remindId;
- return it;
- });
- let arrObjFilter;
- arrObjFilter = {
- displayStyle: customersTemplate.theme,
- lineNumber: customersTemplate.lineNumber,
- products: data.filter(ele => ele.end == false)
- };
- _ts.setData({
- customersList: arrObjFilter,
- customersShow: true
- });
- _ts.initGroupTimer(4);
- });
- }
- },
- getSupRecommendList() {
- return new Promise((resolve, reject) => {
- req.getRequest('/api/supplier/recommend', {}, res => {
- if (res && res.length > 0) {
- this.supRecommendList = res;
- this.supRecommendShow = true;
- }
- });
- });
- },
- // 获取专题
- getSpecialList(special) {
- let that = this;
- let form = {
- page: 1,
- limit: special.number
- };
- req.getRequest('/api/special/list', form, data => {
- if (data) {
- that.setData({
- specialList: data
- });
- }
- });
- },
- getUrl2(e) {
- // 2 普通产品详情 4社区团购产品详情 5优惠券列表 6直播列表 7社区团购列表 9分类列表 10直播间 11拼团列表 12秒杀列表 13砍价列表 14新客列表 15新客详情 16秒杀详情 17砍价详情 18 拼团详情
- var dt = e.currentTarget.dataset;
- var url = '';
- var id = '';
- var acid = '';
- if (dt.content != '') {
- let conunt = dt.content.split('_');
- id = conunt[1];
- acid = conunt[0];
- }
- if (dt.type * 1 == 2 && dt.content != '') {
- url = 'product/detail/detail?id=' + dt.content;
- } else if (dt.type * 1 == 4) {
- url = 'product/groupDetail/groupDetail?acid=' + acid + '&id=' + id;
- } else if (dt.type * 1 == 5) {
- url = 'product/coupon/coupon';
- } else if (dt.type * 1 == 6) {
- url = 'pages/live/live';
- } else if (dt.type * 1 == 7) {
- url = 'product/groupList/groupList' + dt.merchant;
- } else if (dt.type * 1 == 9 && dt.content != '') {
- url = 'product/list/list?id=' + dt.content;
- } else if (dt.type * 1 == 10) {
- url = 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + dt.content;
- // console.log(
- // url); // url=`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${dt.content}`
- } else if (dt.type * 1 == 11) {
- url = 'activity/group/index/index' + dt.merchant;
- } else if (dt.type * 1 == 12) {
- url = 'activity/seckill/seckill' + dt.merchant;
- } else if (dt.type * 1 == 13) {
- url = 'activity/bargain/index/index' + dt.merchant;
- } else if (dt.type * 1 == 14) {
- url = 'activity/newbornZone/newbornZone' + dt.merchant;
- } else if (dt.type * 1 == 15 && dt.content != '') {
- url = 'activity/newbornDetails/newbornDetails?acid=' + acid + '&id=' + id;
- } else if (dt.type * 1 == 16 && dt.content != '') {
- url = 'activity/seckillDetails/seckillDetails?acid=' + acid + '&id=' + id;
- } else if (dt.type * 1 == 17 && dt.content != '') {
- url = 'activity/bargain/detail/detail?acid=' + acid + '&id=' + id;
- } else if (dt.type * 1 == 18 && dt.content != '') {
- url = 'activity/group/detail/detail?acid=' + acid + '&id=' + id;
- } else {
- url = '';
- }
- if (dt.type * 1 == 6) app.globalData.switchTab(url);
- else app.globalData.openPage(url);
- this.hideAd();
- },
- //获取首页模板配置
- getHomeTemplateConfig() {
- let _ts = this;
- let page = 'index';
- //荣康模板配置、小店产品==门店产品
- // if (this.merchant && this.merchant.type == 5 || this.shopId && this.merchantId) page = 'shopIndex'
- req.getRequest(
- '/api/template/getTemplate',
- {
- page: page
- },
- data => {
- let arr = [];
- data.forEach(it => {
- arr.push(it.module);
- });
- this.setData({
- contact: [...new Set(arr)],
- contactShow: false
- });
- if (this.contact.indexOf('sou') != -1 && this.contact.indexOf('store_options') != -1) {
- this.top = false;
- } else {
- this.top = true;
- }
- if (this.contact.indexOf('sou') != -1 && this.contact.indexOf('type_district') != -1) {
- this.top_type = false;
- } else {
- this.top_type = true;
- }
- console.log(this.contact.indexOf('sou') != -1, this.contact.indexOf('store_options') != -1, this.contact.indexOf('type_district') != -1, this.top);
- console.log(this.contact);
- this.setData({
- homeTemplate: data
- });
- this.getRqeDatas();
- }
- );
- },
- //社区团购商品
- loadGroup(groupTemplate) {
- let _ts = this;
- _ts.clearAllTimer(1);
- if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
- let from = {
- page: this.page,
- limit: groupTemplate.number,
- type: 2,
- merchantId: this.merchant.merchantDTO.id,
- sid: this.merchant.id
- };
- if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
- req.getRequest('/api/shopProduct/list', from, res => {
- res = res.list.map(it => {
- it.isRemind = it.remindId;
- return it;
- });
- let arrObjFilter;
- arrObjFilter = {
- displayStyle: groupTemplate.theme,
- lineNumber: groupTemplate.lineNumber,
- products: res.filter(ele => ele.end == false)
- };
- this.setData({
- activityGroup: arrObjFilter,
- activityGroupShow: true
- });
- _ts.initGroupTimer(1);
- });
- }
- if (this.merchant && this.merchant.type != 5) {
- let from = {
- page: 1,
- limit: groupTemplate.number,
- type: 1,
- tag: 'home'
- };
- from.merchantId = this.merchant.id;
- req.getRequest('/api/activity/list', from, data => {
- data = data.map(it => {
- it.isRemind = it.remindId;
- return it;
- });
- data = {
- displayStyle: groupTemplate.theme,
- lineNumber: groupTemplate.lineNumber,
- products: data
- };
- _ts.setData({
- activityGroup: data,
- activityGroupShow: true
- });
- _ts.initGroupTimer(1);
- });
- }
- },
- //拼团商品
- joingroupListFun(joingroupTemplate) {
- let _ts = this;
- _ts.clearAllTimer(2);
- if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
- let from = {
- page: this.page,
- limit: joingroupTemplate.number,
- type: 4,
- merchantId: this.merchant.merchantDTO.id,
- sid: this.merchant.id
- };
- if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
- req.getRequest('/api/shopProduct/list', from, res => {
- res = res.list.map(it => {
- it.isRemind = it.remindId;
- return it;
- });
- let arrObjFilter;
- arrObjFilter = {
- displayStyle: joingroupTemplate.theme,
- lineNumber: joingroupTemplate.lineNumber,
- products: res.filter(ele => ele.end == false)
- };
- this.setData({
- joingroupList: arrObjFilter,
- joingroupShow: true
- });
- _ts.initGroupTimer(2);
- });
- }
- if (this.merchant && this.merchant.type != 5) {
- let from = {
- page: 1,
- limit: joingroupTemplate.number,
- type: 3,
- dayType: 1,
- tag: 'home'
- };
- from.merchantId = this.merchant.id;
- req.getRequest('/api/activity/listNew', from, data => {
- data = data.list.map(it => {
- it.isRemind = it.remindId;
- return it;
- });
- let arrObjFilter;
- arrObjFilter = {
- displayStyle: joingroupTemplate.theme,
- lineNumber: joingroupTemplate.lineNumber,
- products: data.filter(ele => ele.end == false)
- };
- _ts.setData({
- joingroupList: arrObjFilter,
- joingroupShow: true
- });
- _ts.initGroupTimer(2);
- });
- }
- },
- //砍价
- bargainListFun(bargainTemplate) {
- let _ts = this;
- _ts.clearAllTimer(3);
- if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
- let from = {
- page: this.page,
- limit: bargainTemplate.number,
- type: 7,
- merchantId: this.merchant.merchantDTO.id,
- sid: this.merchant.id
- };
- if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
- req.getRequest('/api/shopProduct/list', from, res => {
- res = res.list.map(it => {
- it.isRemind = it.remindId;
- return it;
- });
- let arrObjFilter;
- arrObjFilter = {
- displayStyle: bargainTemplate.theme,
- lineNumber: bargainTemplate.lineNumber,
- products: res.filter(ele => ele.end == false)
- };
- this.setData({
- bargainList: arrObjFilter,
- bargainShow: true
- });
- _ts.initGroupTimer(3);
- });
- }
- if (this.merchant && this.merchant.type != 5) {
- let from = {
- page: 1,
- limit: bargainTemplate.number,
- type: 5,
- tag: 'home'
- };
- from.merchantId = this.merchant.id;
- req.getRequest('/api/activity/listNew', from, data => {
- data = data.list.map(it => {
- it.isRemind = it.remindId;
- return it;
- });
- let arrObjFilter;
- arrObjFilter = {
- displayStyle: bargainTemplate.theme,
- lineNumber: bargainTemplate.lineNumber,
- products: data.filter(ele => ele.end == false)
- };
- _ts.setData({
- bargainList: arrObjFilter,
- bargainShow: true
- });
- _ts.initGroupTimer(3);
- });
- }
- },
- //秒杀商品
- seckillListFun(seckillTemplate) {
- let _ts = this;
- _ts.clearAllTimer(5);
- //获取小店推荐的产品
- if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
- let from = {
- page: this.page,
- limit: seckillTemplate.number,
- type: 3,
- merchantId: this.merchant.merchantDTO.id,
- sid: this.merchant.id
- };
- if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
- req.getRequest('/api/shopProduct/list', from, res => {
- res = res.list.map(it => {
- it.isRemind = it.remindId;
- return it;
- });
- let arrObjFilter;
- arrObjFilter = {
- displayStyle: seckillTemplate.theme,
- lineNumber: seckillTemplate.lineNumber,
- products: res.filter(ele => ele.end == false)
- };
- this.setData({
- seckillList: arrObjFilter,
- seckillShow: true
- });
- _ts.initGroupTimer(5);
- });
- }
- //获取门店推荐的产品
- if (this.merchant && this.merchant.type != 5) {
- let from = {
- page: 1,
- limit: seckillTemplate.number,
- type: 2,
- tag: 'home'
- };
- from.merchantId = this.merchant.id;
- req.getRequest('/api/activity/list', from, res => {
- res = res.map(it => {
- it.num = (it.sellStock / it.quantity) * 100;
- it.isRemind = it.remindId;
- return it;
- });
- res.sort(function(a, b) {
- return Date.parse(a.startTime) - Date.parse(b.startTime);
- });
- let arrObjFilter;
- arrObjFilter = {
- displayStyle: seckillTemplate.theme,
- lineNumber: seckillTemplate.lineNumber,
- products: res.filter(ele => ele.end == false)
- };
- _ts.setData({
- seckillList: arrObjFilter,
- seckillShow: true
- });
- _ts.initGroupTimer(5);
- });
- }
- },
- getConfig() {
- var _this = this;
- return new Promise((res, rej) => {
- req.g(
- '/api/config',
- data => {
- req.setStorage('configRes', JSON.stringify(data));
- this.about = data;
- if (!data.Index_Store_Confirm || data.Index_Store_Confirm == 0) {
- _this.setData({
- switchStoreShow: false,
- storeShow: false
- });
- } else {
- _this.setData({
- switchStoreShow: true
- });
- }
- // console.log(data.Index_Store_Confirm, "====", !data.Index_Store_Confirm, typeof(res
- // .Index_Store_Confirm))
- uni.setNavigationBarTitle({
- // title: res['CONFIG_PROJECT_TITLE'],
- title: data['CONFIG_PROJECT_TITLE']
- });
- // console.log(data.Is_Store_Price_Stock);
- if (data.Is_Store_Price_Stock) {
- this.Is_Store_Price_Stock = data.Is_Store_Price_Stock;
- }
- this.setData({
- Is_Store_Price_Stock: data.Is_Store_Price_Stock
- });
- if (data.b2c_service_guarantee && data.b2c_service_guarantee != null) {
- this.setData({
- guarantee: data.b2c_service_guarantee.split(';').filter(it => {
- return (it = it && it.trim());
- })
- });
- }
- req.setStorage('appName', data['CONFIG_PROJECT_TITLE']);
- req.setStorage('productDiy', data['Product_Foot-Diy']);
- res(data);
- },
- true
- );
- });
- },
- //1为社区团购,2为拼团,3为砍价
- initGroupTimer(type) {
- //社区拼图定时器
- let _ts = this;
- let list = [];
- if (type == 1) list = this.activityGroup.products;
- else if (type == 2) list = this.joingroupList.products;
- else if (type == 3) list = this.bargainList.products;
- else if (type == 4) list = this.customersList.products;
- else if (type == 5) list = this.seckillList.products;
- if (list && list.length > 0) {
- // let activityGroup = this.data.activityGroup;
- for (let i = 0, len = list.length; i < len; i++) {
- let group = list[i];
- let nowTime = new Date(group.nowTime.replace(/-/g, '/')).getTime();
- let startTime = new Date(group.startTime.replace(/-/g, '/')).getTime();
- let endTime = new Date(group.endTime.replace(/-/g, '/')).getTime();
- if (!group.start) endTime = startTime;
- let times = parseInt((endTime - nowTime) / 1000);
- let timer = setInterval(() => {
- times--;
- let data = {};
- if (times === 0) {
- //重新加载列表
- if (type == 1) data['activityGroup.products[' + i + '].end'] = true;
- else if (type == 2) data['joingroupList.products[' + i + '].end'] = true;
- else if (type == 3) data['bargainList.products[' + i + '].end'] = true;
- else if (type == 4) data['customersList.products[' + i + '].end'] = true;
- else if (type == 5) data['seckillList.products[' + i + '].end'] = true;
- clearInterval(timer);
- } else {
- let n = utils.formatDayTimes(times);
- if (type == 1) data['activityGroup.products[' + i + '].times'] = n;
- else if (type == 2) data['joingroupList.products[' + i + '].times'] = n;
- else if (type == 3) data['bargainList.products[' + i + '].times'] = n.split(/:|天/g);
- else if (type == 4) data['customersList.products[' + i + '].times'] = n;
- else if (type == 5) data['seckillList.products[' + i + '].times'] = n;
- }
- _ts.setData(data);
- }, 1000);
- if (type == 1) this.activityGroup.products[i]['timer'] = timer;
- else if (type == 2) this.joingroupList.products[i]['timer'] = timer;
- else if (type == 3) this.bargainList.products[i]['timer'] = timer;
- else if (type == 4) this.customersList.products[i]['timer'] = timer;
- // let fs = [];
- else if (type == 5) this.seckillList.products[i]['timer'] = timer;
- // fs['activityGroup[' + i + '].timer'] = timer;
- // _ts.setData(fs);
- }
- }
- },
- /**
- * 轮播切换
- */
- // swiperChange({
- // detail
- // }) {
- // // if (detail.source !== "touch") return;
- // if (this.current == 0 && this.swiperCurrent > 1) {
- // //卡死时,重置current为正确索引
- // this.setData({
- // current: this.swiperCurrent
- // });
- // } else {
- // //正常轮转时,记录正确页码索引
- // this.setData({
- // swiperCurrent: detail.current
- // });
- // } // this.setData({
- // // swiperCurrent: detail.current
- // // })
- // },
- /**
- * 轮播dots点击轮播
- */
- // dotEvent(e) {
- // this.setData({
- // current: e.currentTarget.dataset.current
- // });
- // },
- search() {
- // app.openPage('pages/search/search')
- app.globalData.openPage('pages/search/search?merchantId=' + this.merchant.id);
- },
- merchantFun() {
- app.globalData.openPage('pages/nearby/nearby');
- },
- saoma() {
- var _this = this; // 允许从相机和相册扫码
- uni.scanCode({
- success: res => {
- uni.navigateTo({
- url: '/' + res.path
- }); // this.scene = '1290926887903780865';
- this.loadCodeParams();
- }
- });
- },
- update(content) {
- var that = this;
- var animation = uni.createAnimation(); // 旧消息向上平移
- animation.translateY(-50).step({
- duration: 1000,
- timingFunction: 'ease-in'
- }); // 为了实现下一条新内容向上平移的效果,必须把内容很快平移到下方,并且不能被用户看见,这里其原理类似轮播图的思路。
- // 实现方法:动画时间设置为1ms,过渡效果设置为’动画第一帧就跳至结束状态直到结束‘
- animation
- .opacity(0)
- .translateY(50)
- .step({
- duration: 1000,
- timingFunction: 'step-start'
- }); // 新消息向上平移的同时恢复透明
- animation
- .opacity(1)
- .translateY(0)
- .step({
- duration: 1000,
- timingFunction: 'ease-out'
- });
- that.setData({
- animationData: animation.export()
- }); // 更新内容的延时必须大于第一步动画时间
- setTimeout(() => {
- that.setData({
- content: content
- });
- }, 500000);
- },
- getListInfo() {
- if (this.listI >= this.contentList.length - 1) {
- this.listI = -1;
- this.getListInfo();
- } else {
- this.listI++;
- }
- return this.contentList[this.listI];
- },
- loadCodeParams() {
- let _ts = this;
- return new Promise((resolve, reject) => {
- if (!_ts.scene) {
- resolve();
- return false;
- }
- req.getRequest(
- '/api/code/params',
- {
- scene: _ts.scene
- },
- data => {
- req.setStorage('pidCode', data.userId);
- resolve();
- }
- );
- });
- },
- getBannerList(module, contentId) {
- //banner图
- let that = this;
- req.getRequest(
- '/api/banner',
- {
- groupId: contentId
- },
- data => {
- if (module == that.templateType.module_ad) {
- that.setData({
- bannerList: data,
- bannerShow: true
- });
- } else {
- that.setData({
- popAdList: data[0]
- });
- }
- }
- );
- },
- getCategory() {
- //产品分类
- let that = this;
- // if (this.districtTemplate) {
- // } else {
- req.getRequest(
- '/api/category/list',
- {
- pid: 0
- },
- res => {
- res = res.map((it, index) => {
- it.index = index;
- return it;
- });
- let newList = this.group(res, 8);
- let data = newList; // .filter(it => it.length >= 8)
- // console.log(newList, data, data.length);
- if (data && data.length > 0 && data[0].length <= 4) {
- this.setData({
- swiperHeight: '100px'
- });
- } else {
- this.setData({
- swiperHeight: '200px'
- });
- }
- that.setData({
- categoryList: data
- });
- }
- );
- // }
- },
- // getCoupon() {
- // req.getRequest('/api/coupon/list', { page: 1, limit: 3 }, res => {
- // this.setData({
- // couponList: res
- // })
- // })
- // },
- toCoupon() {
- req.isLogin().then(success => {
- if (success) {
- app.globalData.openPage('product/coupon/coupon');
- }
- });
- },
- recieveCoupon(e) {
- let index = e.currentTarget.dataset.index;
- const coupon = this.couponList[index];
- if (coupon.userReceive > -1 && coupon.userCount >= coupon.userReceive) {
- return req.msg('超出优惠券领取限制,无法领取');
- }
- let _ts = this;
- req.postRequest(
- '/api/coupon/receive',
- {
- id: coupon.id
- },
- res => {
- req.msg('领取成功', () => {
- this.getCoupon();
- });
- }
- );
- },
- getsupplierList(supplierTemplate) {
- let form = {
- page: 1,
- limit: supplierTemplate.number,
- merchantId: this.merchant.id,
- supplier: supplierTemplate.contentId
- }; // form.supplier="1351512705560240130"
- req.getRequest('/api/product/list', form, res => {
- res = res.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
- return it;
- });
- res = {
- displayStyle: supplierTemplate.theme,
- lineNumber: supplierTemplate.lineNumber,
- products: res
- };
- this.setData({
- supplierList: res,
- supplierShow: true
- });
- });
- },
- getBoutiqueList(boutiqueTemplate) {
- if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
- let from = {
- page: this.page,
- limit: boutiqueTemplate.number,
- type: 1,
- merchantId: this.merchant.merchantDTO.id,
- sid: this.merchant.id,
- attr: 'boutique'
- };
- if (boutiqueTemplate.content != '') {
- from.contentId = boutiqueTemplate.contentId;
- }
- if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
- req.getRequest('/api/shopProduct/list', from, res => {
- res = res.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
- return it;
- });
- res = {
- displayStyle: boutiqueTemplate.theme,
- lineNumber: boutiqueTemplate.lineNumber,
- products: res
- };
- this.setData({
- boutiqueList: res,
- boutiqueShow: true
- });
- });
- }
- if (this.merchant && this.merchant.type != 5) {
- let form = {
- page: 1,
- limit: boutiqueTemplate.number,
- attr: 'boutique',
- merchantId: this.merchant.id
- };
- if (boutiqueTemplate.content != '') {
- form.contentId = boutiqueTemplate.contentId;
- }
- req.getRequest('/api/product/list', form, res => {
- res = res.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
- return it;
- });
- res = {
- displayStyle: boutiqueTemplate.theme,
- lineNumber: boutiqueTemplate.lineNumber,
- products: res
- };
- this.setData({
- boutiqueList: res,
- boutiqueShow: true
- });
- });
- }
- },
- // 新品上架
- getArrivalsList(arrivalsTemplate) {
- if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
- let from = {
- page: this.page,
- limit: arrivalsTemplate.number,
- type: 1,
- merchantId: this.merchant.merchantDTO.id,
- sid: this.merchant.id,
- attr: 'news'
- };
- if (arrivalsTemplate.content != '') {
- from.contentId = arrivalsTemplate.contentId;
- }
- if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
- req.getRequest('/api/shopProduct/list', from, res => {
- res = res.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
- return it;
- });
- res = {
- displayStyle: arrivalsTemplate.theme,
- lineNumber: arrivalsTemplate.lineNumber,
- products: res
- };
- this.setData({
- arrivalsList: res,
- arrivalsShow: true
- });
- });
- }
- if (this.merchant && this.merchant.type != 5) {
- let form = {
- page: 1,
- limit: arrivalsTemplate.number,
- attr: 'news',
- merchantId: this.merchant.id
- };
- if (arrivalsTemplate.content != '') {
- form.contentId = arrivalsTemplate.contentId;
- }
- req.getRequest('/api/product/list', form, res => {
- res = res.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
- return it;
- });
- res = {
- displayStyle: arrivalsTemplate.theme,
- lineNumber: arrivalsTemplate.lineNumber,
- products: res
- };
- this.setData({
- arrivalsList: res,
- arrivalsShow: true
- });
- });
- }
- },
- // 热门爆款
- getHotList(hotTemplate) {
- if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
- let from = {
- page: this.page,
- limit: hotTemplate.number,
- type: 1,
- merchantId: this.merchant.merchantDTO.id,
- sid: this.merchant.id,
- attr: 'sell_well'
- };
- if (hotTemplate.content != '') {
- from.contentId = hotTemplate.contentId;
- }
- if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
- req.getRequest('/api/shopProduct/list', from, res => {
- res = res.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
- return it;
- });
- res = {
- displayStyle: hotTemplate.theme,
- lineNumber: hotTemplate.lineNumber,
- products: res
- };
- this.setData({
- hotList: res,
- hotShow: true
- });
- });
- }
- if (this.merchant && this.merchant.type != 5) {
- let form = {
- page: 1,
- limit: hotTemplate.number,
- attr: 'sell_well',
- merchantId: this.merchant.id
- };
- if (hotTemplate.content != '') {
- form.contentId = hotTemplate.contentId;
- }
- req.getRequest('/api/product/list', form, res => {
- res = res.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
- return it;
- });
- res = {
- displayStyle: hotTemplate.theme,
- lineNumber: hotTemplate.lineNumber,
- products: res
- };
- this.setData({
- hotList: res,
- hotShow: true
- });
- });
- }
- },
- getPageList() {
- //Recommend
- // console.log(this.isLoad); // if (!this.data.isLoad) return false;
- // this.data.isLoad = false;
- let that = this;
- console.log('门店' + this.merchantId);
- if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
- let from = {
- page: that.page,
- limit: that.recommendTemplate.number,
- type: 1,
- merchantId: this.merchant.merchantDTO.id,
- sid: this.merchant.id,
- attr: 'Recommend'
- };
- if (that.recommendTemplate.content != '') {
- from.contentId = that.recommendTemplate.contentId;
- }
- if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
- req.getRequest('/api/shopProduct/list', from, data => {
- if (data && data.length >= 10) that.isLoad = true;
- if (that.page > 1) data = that.pageList.concat(data);
- // console.log(data);
- data = data.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
- return it;
- });
- data = {
- displayStyle: that.recommendTemplate.theme,
- lineNumber: that.recommendTemplate.lineNumber,
- products: data
- };
- that.setData({
- pageList: data,
- hasmore: data && data.length > 0,
- recommendShow: true
- });
- });
- }
- if (this.merchant && this.merchant.type != 5) {
- let form = {
- page: that.page,
- limit: that.recommendTemplate.number,
- attr: 'Recommend',
- merchantId: this.merchant.id
- };
- if (that.recommendTemplate.content != '') {
- form.contentId = that.recommendTemplate.contentId;
- }
- req.getRequest('/api/product/list', form, res => {
- if (res && res.length >= 10) that.isLoad = true;
- if (that.page > 1) res = that.pageList.concat(res);
- res = res.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
- return it;
- });
- res = {
- displayStyle: that.recommendTemplate.theme,
- lineNumber: that.recommendTemplate.lineNumber,
- products: res
- };
- that.setData({
- pageList: res,
- hasmore: res && res.length > 0,
- recommendShow: true
- });
- });
- }
- },
- getSinglePageList() {
- //Recommend
- // console.log(this.isLoad); // if (!this.data.isLoad) return false;
- // this.data.isLoad = false;
- let that = this;
- console.log('门店' + this.merchantId);
- if ((this.merchant && this.merchant.type == 5) || (this.shopId && this.merchantId)) {
- let from = {
- page: that.singlePage,
- limit: that.singleTemplate.number,
- type: 1,
- merchantId: this.merchant.merchantDTO.id,
- sid: this.merchant.id
- };
- if (that.singleTemplate.content != '') {
- from.contentId = that.singleTemplate.contentId;
- delete from.attr;
- } else {
- from.attr = 'Recommend';
- }
- if (this.shopId && this.merchantId) (from.merchantId = this.merchantId), (from.sid = this.shopId);
- req.getRequest('/api/shopProduct/list', from, data => {
- if (data && data.length >= 10) that.isLoadSingle = true;
- if (that.singlePage > 1) data = that.singleList.concat(data);
- // console.log(data);
- data = data.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
- return it;
- });
- data = {
- displayStyle: that.singleTemplate.theme,
- lineNumber: that.singleTemplate.lineNumber,
- products: data
- };
- that.setData({
- singleList: data,
- hasmoreSingle: data && data.length > 0,
- singleShow: true
- });
- });
- }
- if (this.merchant && this.merchant.type != 5) {
- let form = {
- page: that.singlePage,
- limit: that.singleTemplate.number,
- merchantId: this.merchant.id
- };
- if (that.singleTemplate.content != '') {
- form.contentId = that.singleTemplate.contentId;
- delete form.attr;
- } else {
- form.attr = 'Recommend';
- }
- req.getRequest('/api/product/list', form, res => {
- if (res && res.length >= 10) that.isLoadSingle = true;
- if (that.singlePage > 1) res = that.singleList.concat(res);
- res = res.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
- return it;
- });
- res = {
- displayStyle: that.singleTemplate.theme,
- lineNumber: that.singleTemplate.lineNumber,
- products: res
- };
- that.setData({
- singleList: res,
- hasmoreSingle: res && res.length > 0,
- singleShow: true
- });
- });
- }
- },
- toDetail(e) {
- let id = e.currentTarget.dataset.id;
- let url = e.currentTarget.dataset.url;
- app.globalData.openPage('product/detail/detail?id=' + id + url); // app.openPage("product/detail/detail?id=" + id)
- },
- // 新客列表
- tocustomersList(event) {
- const index = event.currentTarget.dataset.index;
- const activity = this.customersList.products[index];
- const url = event.currentTarget.dataset.url;
- app.globalData.openPage('activity/newbornDetails/newbornDetails?acid=' + activity.id + '&id=' + activity.productId + url); // app.openPage('activity/newbornDetails/newbornDetails?acid=' + activity.id + "&id=" + activity.productId);
- },
- addShopCart(e) {
- let state = e.currentTarget.dataset.state;
- let skuId = e.currentTarget.dataset.skuid;
- let id = e.currentTarget.dataset.id;
- let _ts = this;
- let params = {
- skuId: skuId,
- quantity: 1,
- merchantId: this.merchant.id,
- productId: id
- }; // if(state!=1){
- // return req.msg('您来晚了,商品已经下架')
- // }
- req.postRequest('/api/purchase/cart', params, res => {
- _ts.setData({
- isUpdate: !_ts.isUpdate
- });
- req.msg('加入购物车成功');
- });
- },
- toGroupRemind(event) {
- const index = event.currentTarget.dataset.index;
- const activity = this.activityGroup.products[index];
- const url = event.currentTarget.dataset.url;
- app.globalData.openPage('product/groupDetail/groupDetail?acid=' + activity.id + '&id=' + activity.productId + url); // app.openPage('product/groupDetail/groupDetail?acid=' + activity.id + "&id=" + activity.productId);
- },
- toSeckillList(event) {
- const index = event.currentTarget.dataset.index;
- const activity = this.seckillList[index];
- const url = event.currentTarget.dataset.url;
- app.globalData.openPage('activity/seckillDetails/seckillDetails?acid=' + activity.id + '&id=' + activity.productId + url); // app.openPage('activity/seckillDetails/seckillDetails?acid=' + activity.id + "&id=" + activity.productId);
- },
- addActivityRemind(event) {
- const index = event.currentTarget.dataset.index;
- const id = event.currentTarget.dataset.id;
- const type = event.currentTarget.dataset.type; // if(req.getStorage('userInfo')){
- // }
- req.postRequest(
- '/api/activity/remind',
- {
- activityId: id
- },
- res => {
- mes.remind().then(res => res);
- // mes.remind().then(res=>res)
- // mes.requsetmessage()
- req.msg('订阅提醒成功');
- let data = {};
- if (type == 1) data['activityGroup.products[' + index + '].isRemind'] = true;
- else if (type == 2) data['joingroupList.products[' + index + '].isRemind'] = true;
- else if (type == 3) data['seckillList.products[' + index + '].isRemind'] = true;
- else if (type == 4) data['bargainList.products[' + index + '].isRemind'] = true;
- else if (type == 5) data['customersList.products[' + index + '].isRemind'] = true;
- this.setData(data);
- }
- );
- },
- // 九宫格
- // dotGrid(e) {
- // if (!this.districtTemplate) {
- // if (this.categoryList[e.currentTarget.dataset.current].length <= 4) {
- // this.setData({
- // swiperHeight: '100px'
- // })
- // } else {
- // this.setData({
- // swiperHeight: '200px'
- // })
- // }
- // } else {
- // if (that.districtTemplate.content.lines == 2) {
- // if (that.districtTemplate.lineNumber == 3) {
- // if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[e.currentTarget.dataset.current].flat(
- // Infinity).length <= 3) {
- // that.setData({
- // swiperHeight: '120px'
- // })
- // } else {
- // that.setData({
- // swiperHeight: '216px'
- // })
- // }
- // }
- // if (that.districtTemplate.lineNumber == 4) {
- // if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[e.currentTarget.dataset.current].flat(
- // Infinity).length <= 4) {
- // that.setData({
- // swiperHeight: '100px'
- // })
- // } else {
- // that.setData({
- // swiperHeight: '200px'
- // })
- // }
- // }
- // }
- // }
- // this.setData({
- // swiperGrid: e.currentTarget.dataset.current
- // });
- // },
- group(array, subGroupLength) {
- let index = 0;
- let newArray = [];
- while (index < array.length) {
- newArray.push(array.slice(index, (index += subGroupLength)));
- }
- return newArray;
- },
- cancelActivityRemind(event) {
- const index = event.currentTarget.dataset.index;
- const id = event.currentTarget.dataset.id;
- const type = event.currentTarget.dataset.type;
- if (req.header.appId == 'ZQ1VK5oc17I387E') {
- } else {
- req.postRequest(
- '/api/activity/cancel/remind',
- {
- id: id
- },
- res => {
- req.msg('取消提醒成功');
- let data = {};
- if (type == 1) data['activityGroup.products[' + index + '].isRemind'] = false;
- else if (type == 2) data['joingroupList.products[' + index + '].isRemind'] = false;
- else if (type == 3) data['seckillList.products[' + index + '].isRemind'] = false;
- else if (type == 4) data['bargainList.products[' + index + '].isRemind'] = false;
- else if (type == 5) data['customersList.products[' + index + '].isRemind'] = false;
- this.setData(data);
- }
- );
- }
- },
- clearAllTimer(type) {
- // console.log(this.activityGroup, this.joingroupList, this.bargainList, this.customersList);
- if (type == 1) {
- this.activityGroup.products.forEach(it => clearInterval(it.timer));
- this.activityGroup.products.forEach(it => clearInterval(it.times));
- } else if (type == 2) {
- this.joingroupList.products.forEach(it => clearInterval(it.timer));
- this.joingroupList.products.forEach(it => clearInterval(it.times));
- } else if (type == 3) {
- this.bargainList.products.forEach(it => clearInterval(it.timer));
- this.bargainList.products.forEach(it => clearInterval(it.times));
- } else if (type == 4) {
- this.customersList.products.forEach(it => clearInterval(it.timer));
- this.customersList.products.forEach(it => clearInterval(it.times));
- } else if (type == 5) {
- this.seckillList.products.forEach(it => clearInterval(it.timer));
- this.seckillList.products.forEach(it => clearInterval(it.times));
- }
- },
- hideGuide() {
- //关闭提示加入我的小程序
- this.setData({
- first: false
- });
- req.setStorage('first', false);
- },
- hideAd() {
- //关闭广告
- // if(this.data.first==false){
- this.setData({
- isLayerAd: false
- }); // }
- app.globalData.isLayerAd = false;
- },
- click(e) {
- // console.log(e)
- this.storeShow = e;
- },
- goUrl(event) {
- //跳转链接
- let url = event.currentTarget.dataset.url;
- app.globalData.openPage(url);
- }
- },
- mounted() {
- const systemInfo = uni.getSystemInfoSync();
- // px转换到rpx的比例
- let pxToRpxScale = 750 / systemInfo.windowWidth;
- let systems = {
- ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
- navigationHeight: 44 * pxToRpxScale // 导航栏的高度
- };
- systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
- this.systems = systems;
- }
- };
- </script>
- <style>
- @import "./main.css";
- </style>
|