| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250 |
- <template>
- <view>
- <!--mine/shop/shop.wxml-->
- <view v-for="(item,index) in contact" :key="index">
- <storeOptions v-if="item=='store_options'||(item=='sou'&&top)" :storeTemplate="storeTemplate"
- :merchant="merchant" :about="about" :guarantee="guarantee" :sousuoTemplate="sousuoTemplate" :url="site"
- :web="url"></storeOptions>
- <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>
- <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>
- <district v-if="item=='king_kong_district'&&districtShow" :url="site" :web="url"
- :districtTemplate="districtTemplate">
- </district>
- </view>
- <switchStore v-if="switchStoreShow&&contact.length>0&&merchant.id" :first="first" :merchant="merchant"
- :storeShow="storeShow" @onFather="click"></switchStore>
- <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>
- <footer-copyright v-if="logo"></footer-copyright>
- <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&&header.appId=='ZQ1VK5oc17I387E'">
- <image src="/static/pages/images/guide.png" mode="widthFix"></image>
- </view>
- <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 115) + 'rpx'"></view>
- <foot channel="shop" :isUpdate="isUpdate"></foot>
- </view>
- </template>
- <script>
- // mine/shop/shop.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");
- 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 specialTopic from "../../template/specialTopic/specialTopic";
- import storeOptions from "../../template/store_options/store_options";
- import redEnvelopes from "../../template/red_envelopes/index";
- import district from "../../template/king_kong_district/king_kong_district";
- import switchStore from "../../template/switchStore/switchStore";
- export default {
- data() {
- return {
- header: req.header,
- bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
- swiperCurrent: 0,
- swiperGrid: 0,
- bannerList: [],
- categoryList: [],
- //产品分类列表
- page: 1,
- boutiqueList: {},
- //精品榜单
- 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_p_list: 'p_list',
- //产品分类
- module_group: 'group',
- //团购
- module_live: 'live',
- //直播
- module_sou: 'sou',
- //搜索
- module_special: 'special',
- //专题
- module_chosen: 'chosen',
- //精选
- 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', //金刚区
- },
- contentList: [{
- pic: "/static/pages/images/bar.png",
- name: '好风依旧',
- time: '4秒前'
- }, {
- pic: "/static/pages/images/bar.png",
- name: '杨鑫',
- time: '20秒前'
- }, {
- pic: "/static/pages/images/bar.png",
- name: '杨鑫',
- time: '5秒前'
- }],
- 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: {},
- sousuoTemplate: {},
- popAdTemplate: {},
- districtTemplate: {},
- Timelyimg: "",
- timelyTemplate: {},
- homecolumnimg: [],
- customersTemplate: {},
- joingroupTemplate: {},
- supplierTemplate: {},
- seckillTemplate: {},
- bargainTemplate: {},
- specialTemplate: {},
- chosenTemplate: {},
- groupTemplate: {},
- recommendTemplate: {},
- specialList: [],
- contact: [],
- seckillList: {
- products: []
- },
- about: {},
- Is_Store_Price_Stock: "",
- guarantee: [],
- current: "",
- animationData: "",
- content: "",
- popAdList: {},
- supplierList: {},
- iscouponAd: false,
- couponAd: {},
- logo: false,
- top: Boolean,
- switchStoreShow: Boolean,
- bargainShow: Boolean,
- contactShow: true,
- seckillShow: false,
- joingroupShow: false,
- activityGroupShow: false,
- customersShow: false,
- districtShow: false,
- recommendShow: false,
- boutiqueShow: false,
- supplierShow: false,
- pCategorShow: false,
- bannerShow: false,
- List:[]
- };
- },
- components: {
- foot,
- footerCopyright,
- banner,
- group,
- bargain,
- popAd,
- customers,
- homecolumn,
- joingroup,
- pCategoryList,
- recommend,
- seckill,
- selected,
- specialTopic,
- storeOptions,
- redEnvelopes,
- district,
- switchStore
- },
- props: {},
- onLoad: function(options) {
- setInterval(() => {
- this.setData({
- isNotice: true
- });
- }, 10000);
- let _ts = this;
- // console.log(options,"789456123");
- this.query = options;
- if (options.scene) {
- this.scene = options.scene;
- }
- if (options.isShare) {
- if (options.userId) {
- req.setStorage('pidCode', options.userId);
- }
- }
- if (options.merchantId && options.shopId) {
- this.setData({
- merchantId: options.merchantId,
- shopId: options.shopId
- });
- }
- uni.setNavigationBarColor({
- frontColor: '#ffffff',
- backgroundColor: req.public.titleTopBgColor
- });
- // this.getConfig()
- // this.setData({
- // 'TabList[0].dayType': this.GetDateStr(0),
- // 'TabList[1].dayType': this.GetDateStr(1),
- // 'TabList[2].dayType': this.GetDateStr(2),
- // })
- // console.log(this.TabList); // this.getuserInfo()
- },
- onShow() {
- let _ts = this;
- // console.log(this.freshen);
- _ts.setData({
- isUpdate: !_ts.isUpdate,
- isLoad: true,
- page: 1
- });
- let first = req.getStorage('first');
- if (first !== false) _ts.setData({
- first: true
- });
- else _ts.setData({
- first: false
- });
- this.getHomeTemplateConfig();
- this.getConfig().then(res => {
- // console.log("debug1", res);
- _ts.getMerchant()
- })
- },
- onUnload() {
- this.clearAllTimer(1);
- this.clearAllTimer(2);
- this.clearAllTimer(3);
- this.clearAllTimer(4);
- },
- onHide() {
- this.clearAllTimer(1);
- this.clearAllTimer(2);
- this.clearAllTimer(3);
- this.clearAllTimer(4);
- },
- // goUrl(event) {//跳转链接
- // let url = event.currentTarget.dataset.url;
- // app.openPage(url + '&&hideShop=' + false)
- // },
- // toSeckillList(event) {
- // const id = event.currentTarget.dataset.id
- // const productId = event.currentTarget.dataset.productid
- // console.log(event.currentTarget.dataset)
- // app.openPage('activity/seckillDetails/seckillDetails?acid=' + id + "&id=" + productId + '&&hideShop=' + false);
- // },
- onShareAppMessage: function() {
- let path = '/pages/timelyDelivery/timelyDelivery?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;
- }
- }
- // console.log(path);
- return {
- title: (req.excludeSpecial(req.getStorage('userInfo').nickName) ? req.excludeSpecial(req.getStorage(
- 'userInfo').nickName) : '') + '为你推荐' + this.merchant.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;
- }
- }
- // console.log(path);
- return {
- title: (req.excludeSpecial(req.getStorage('userInfo').nickName) ? req.excludeSpecial(req.getStorage(
- 'userInfo').nickName) : '') + '为你推荐' + this.merchant.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() { // this.data.page++;
- // this.loadGroup();
- // this.getPageList()
- },
- methods: {
- //获取首页模板配置
- getHomeTemplateConfig() {
- let _ts = this;
- req.getRequest('/api/template/getTemplate', {
- page: 'shopIndex'
- }, 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
- }
- this.setData({
- homeTemplate: data
- });
- this.getRqeDatas()
- });
- },
- hideGuide() {
- //关闭提示加入我的小程序
- this.setData({
- first: false
- });
- req.setStorage('first', false);
- },
- getBannerList(module, contentId) {
- //banner图
- let that = this;
- req.getRequest('/api/banner', {
- groupId: contentId
- }, data => {
- // console.log(data);
- if (module == that.templateType.module_ad) {
- that.setData({
- bannerList: data,
- bannerShow: true
- });
- } else {
- that.setData({
- popAdList: data[0]
- });
- }
- });
- },
- getUrl2(e) {
- 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;
- } 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();
- },
- hideAd() {
- //关闭广告
- // if(this.data.first==false){
- this.setData({
- isLayerAd: false
- }); // }
- },
- merchantFun() {
- if (!this.query.merchantId) {
- // console.log("111");
- app.globalData.openPage('pages/nearby/nearby');
- } else {
- // console.log("222");
- app.globalData.openPage('pages/nearby/nearby?isChoose=true');
- }
- },
- /**
- *
- * 设置tab导航
- */
- // switchTab(event) {
- // let index = event.currentTarget.dataset.index;
- // let dataTime = event.currentTarget.dataset.datatime
- // let def = this.data.TabList.findIndex(it => it.active);
- // let d = {};
- // console.log(index, def, dataTime)
- // d[`TabList[${def}].active`] = false;
- // d[`TabList[${index}].active`] = true;
- // console.log(d)
- // this.data.isLoad = true;
- // // this.data.form.page = 1;
- // d['pageList'] = [];
- // // this.data.form.dayType = this.data.TabList[index].dayType;
- // this.setData(d);
- // this.seckill(this.data.TabList[index].dayType)
- // this.clearAllTimer();
- // // this.getDate()
- // },
- search() {
- // if(req.getStorage('smallShop')){
- // app.openPage('pages/search/search')
- // }else{
- app.globalData.openPage('pages/search/search?merchantId=' + this.merchant.id); // }
- },
- async init(merchant) {
- this.getHomeTemplateConfig();
- // this.getRqeDatas()
- 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.freshen);
- this.setData({
- url: url,
- web: web,
- site: site,
- internet: internet
- });
- this.setData({
- freshen: false
- });
- },
- async getRqeDatas() {
- 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 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 (this.freshen) {
- await this.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 = this.homeTemplate.filter(it => it.module == this.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) {
- this.setData({
- Timelyimg: Timelyimg[0]
- }); // }
- // }
- }
- //顶部banner
- let ad = that.homeTemplate.filter(it => it.module == that.templateType.module_ad);
- if (ad && ad.length > 0 && ad[0].state == 0) {
- await this.getBannerList(ad[0].module, ad[0].contentId);
- }
- // 金刚区
- 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)
- this.districtTemplate = data
- this.districtShow = true
- // console.log(this.districtTemplate, "=============");
- }
- //首页专区
- let homecolumn = this.homeTemplate.filter(it => it.module == this.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);
- this.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 this.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 this.joingroupListFun(joingroup[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 this.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 this.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]
- });
- await this.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]
- });
- await this.getBoutiqueList(chosen[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 this.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]
- });
- // console.log(this.recommendTemplate);
- await this.getPageList();
- } //底部推荐列表
- let p_list = that.homeTemplate.filter(it => it.module == that.templateType.module_p_list && it.state ==
- 0);
- that.List = p_list
- // that.pCategoryList = p_list;
- if (that.freshen) {
- if (!that.pCategorShow) {
- for (var i = 0; i < that.List.length; i++) {
- // console.log(i)
- await that.getPListProduct(that.List[i], i);
- }
- }
- }
- // 红包优惠券
- let coupon = that.homeTemplate.filter(it => it.module == that.templateType.module_red_envelopes);
- if (coupon && coupon.length > 0 && coupon[0].state == 0 && app.globalData.isredenvelopes) {
- if (!req.getStorage('userInfo')) {
- this.setData({
- iscouponAd: true,
- couponAd: coupon[0]
- });
- } else {
- req.getRequest('/api/coupon/checkCoupon', {
- id: coupon[0].contentId
- }, res => {
- if (res == 1) {
- this.setData({
- iscouponAd: true,
- couponAd: coupon[0]
- });
- } else if (res == 0) {
- this.setData({
- iscouponAd: false
- });
- }
- });
- }
- // console.log(coupon[0]);
- } else {
- that.setData({
- iscouponAd: false
- });
- }
- this.getCategory();
- this.logo = true
- },
- // 领红包
- redEnvelopes() {
- if (!req.getStorage('userInfo')) {
- let params = '?couponId=' + this.couponAd.contentId;
- req.redirectIndex(params);
- } else {
- req.postRequest('/api/coupon/receiveCoupon', {
- id: this.couponAd.contentId
- }, data => {
- // console.log(data);
- if (data == 1) {
- this.setData({
- iscouponAd: false
- });
- return req.msg('领取成功');
- }
- }); // console.log(1233)
- } // req.isLogin().then(success => {
- // console.log(success)
- // if (success) {
- // this.setData({iscouponAd:false})
- // }
- // })
- },
- // 关闭优惠券广告
- hidecouponAd() {
- this.setData({
- iscouponAd: false
- });
- app.globalData.isredenvelopes = false
- },
- //新客
- 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);
- });
- }
- },
- getPListProduct(pCategory, idx) {
- let that = this;
- let form = {
- limit: pCategory.number,
- categoryId: pCategory.contentId // isRecommend:1
- };
- if (this.merchant && this.merchant.type == 5 || this.shopId && this.merchantId) {
- form.merchantId = this.merchant.merchantDTO.id;
- var sid = this.merchant.id;
- if (this.shopId && this.merchantId) form.merchantId = this.merchantId, form.sid = this.shopId;
- req.getRequest('/api/shopProduct/list', form, data => {
- data = data.list.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs =
- true;
- return it;
- });
- var res = {
- displayStyle: pCategory.theme,
- lineNumber: pCategory.lineNumber,
- products: data
- }
- // console.log(data, that.pCategoryList, idx, that.pCategoryList[idx])
- that.List[idx].productList = res
- // console.log(that.List[idx].productList)
- that.setData({
- pCategoryList: that.List,
-
- });
- let arr = []
- that.List.forEach(it => {
- if (it.productList) {
- arr.push(it)
- }
- })
- if (arr.length == that.List.length) {
- that.pCategorShow = true
- }
-
- });
- }
- if (this.merchant && this.merchant.type != 5) {
- form.merchantId = this.merchant.id;
- req.getRequest('/api/product/list', form, data => {
- data = data.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs =
- true;
- return it;
- });
- var res = {
- displayStyle: pCategory.theme,
- lineNumber: pCategory.lineNumber,
- products: data
- }
- // console.log(data, that.pCategoryList, idx, that.pCategoryList[idx])
- that.List[idx].productList = res
- // console.log(that.List[idx].productList)
- that.setData({
- pCategoryList: that.List,
-
- });
- let arr = []
- that.List.forEach(it => {
- if (it.productList) {
- arr.push(it)
- }
- })
- if (arr.length == that.List.length) {
- that.pCategorShow = 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
- });
- }
- });
- },
- //社区团购商品
- 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);
- });
- }
- },
- /**
- *
- * 产品活动开始时间转换 year-month-day hour:minute:00
- *
- */
- getDate(str) {
- var strArr = str.split(' ');
- var time = strArr[0].toString().split('-');
- var hose = strArr[1].toString().split(':');
- var hour = hose[0];
- var minute = hose[1];
- var day = time[2];
- var month = time[1];
- var year = time[0];
- date = (month + '月' + day + '日').toString();
- date1 = (hour + ':' + minute).toString();
- date2 = strArr[0];
- return date, date1, date2;
- },
- /**
- * 时间转换
- */
- getda(str) {
- var strArr = str.split('-');
- var day = strArr[2];
- var month = strArr[1];
- var year = strArr[0];
- date = (month + '月' + day + '日').toString();
- return date;
- },
- //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
- });
- },
- 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];
- },
- getCategory() {
- //产品分类
- let that = this;
- req.getRequest('/api/category/list', {
- pid: 0
- }, res => {
- res = res.map((it, index) => {
- it.index = index;
- return it;
- });
- let newList = this.group(res, 8);
- // console.log(newList);
- let data;
- if (!newList) {} else {
- data = newList; // .filter(it => it.length >= 8)
- }
- // console.log(newList, data);
- 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();
- });
- });
- },
- getBoutiqueList(boutiqueTemplate) {
- // console.log(this.merchant, ',++++++++++++++++++++++++++++++++++++++++++');
- 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
- });
- });
- }
- },
- getPageList() {
- //Recommend
- let that = this; // 类型:1 普通商品 2 社区团购订单 3 秒杀订单 4 拼团订单 5 及时达订单 6 新客特价 7 优惠砍价
- 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
- });
- });
- }
- },
- // 新客列表
- tocustomersList(event) {
- const index = event.currentTarget.dataset.index;
- const activity = this.customersList.products[index];
- app.globalData.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 (this.merchant.type == 5) {
- params.merchantId = this.merchant.merchantDTO.id;
- params.shopId = this.merchant.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];
- app.globalData.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;
- req.postRequest('/api/activity/remind', {
- activityId: id
- }, res => {
- // mes.remind().then(res=>res)
- // mes.requsetmessage()
- mes.remind().then(res => res);
- 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.categoryList[e.currentTarget.dataset.current].length <= 4) {
- this.setData({
- swiperHeight: 100
- });
- } else {
- this.setData({
- swiperHeight: 200
- });
- }
- 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);
- clearInterval(it.times);
- });
- } else if (type == 2) {
- this.joingroupList.products.forEach(it => {
- clearInterval(it.timer);
- clearInterval(it.times);
- });
- } else if (type == 3) {
- this.bargainList.products.forEach(it => {
- clearInterval(it.timer);
- clearInterval(it.times);
- });
- } else if (type == 4) {
- this.customersList.products.forEach(it => {
- clearInterval(it.timer);
- clearInterval(it.times);
- });
- } else if (type == 5) {
- this.seckillList.products.forEach(it => clearInterval(it.timer));
- this.seckillList.products.forEach(it => clearInterval(it.times));
- }
- },
- goUrl(event) {
- //跳转链接
- let url = event.currentTarget.dataset.url;
- app.globalData.openPage(url);
- },
- swiperGridFun({
- detail
- }) {
- if (detail.source !== "touch") return;
- if (this.categoryList[detail.current].length <= 4) {
- this.setData({
- swiperHeight: 100
- });
- } else {
- this.setData({
- swiperHeight: 200
- });
- }
- this.setData({
- swiperGrid: detail.current
- });
- },
- getMerchant() {
- let _ts = this
- this.query.type = "shopindex"
- api.getMerchant(this.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 {
- this.merchant = data
- this.init(data)
- }
- })
- },
- 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);
- });
- },
- // 获取普通产品
- // loadGroup(data) {
- // let _ts = this;
- // console.log(this.data.isLoad)
- // if (!this.data.isLoad) return false;
- // this.data.isLoad = false;
- // console.log(data)
- // // type
- // // 类型:1 普通商品 2 社区团购订单 3 秒杀订单 4 拼团订单 5 及时达订单 6 新客特价 7 优惠砍价
- // if (data && data.type == 5 || (this.data.shopId && this.data.merchantId)) {
- // let from = { page: _ts.data.page, limit: 10, type: 1, merchantId: data.merchantDTO.id, sid: data.id }
- // if (this.data.shopId && this.data.merchantId) from.merchantId = this.data.merchantId, from.sid = this.data.shopId
- // req.getRequest('/api/shopProduct/list', from, data => {
- // if (data && data.length >= 10) _ts.data.isLoad = true;
- // if (_ts.data.page > 1) data = _ts.data.activityGroup.concat(data);
- // data = data.map(it => {
- // it.isRemind = it.remindId;
- // return it
- // });
- // _ts.setData({ activityGroup: data, ['shopType.products']: data });
- // })
- // }
- // if (data && data.type != 5) {
- // req.getRequest('/api/product/list', { page: _ts.data.page, limit: 10, merchantId: data.id }, data => {
- // if (data && data.length >= 10) _ts.data.isLoad = true;
- // if (_ts.data.page > 1) data = _ts.data.activityGroup.concat(data);
- // data = data.map(it => {
- // it.isRemind = it.remindId;
- // return it
- // });
- // _ts.setData({ activityGroup: data, ['shopType.products']: data });
- // })
- // }
- // },
- // // 获取推荐产品
- // recommend(data) {
- // let that = this
- // // 类型:1 普通商品 2 社区团购订单 3 秒杀订单 4 拼团订单 5 及时达订单 6 新客特价 7 优惠砍价
- // if (data && data.type == 5 || (this.data.shopId && this.data.merchantId)) {
- // let from = { page: 1, limit: 6, type: 1, merchantId: data.merchantDTO.id, sid: data.id, attr: 'Recommend' }
- // if (this.data.shopId && this.data.merchantId) from.merchantId = this.data.merchantId, from.sid = this.data.shopId
- // req.getRequest('/api/shopProduct/list', from, data => {
- // data = data.map(it => {
- // it.isRemind = it.remindId;
- // return it
- // });
- // that.setData({ recommendList: data });
- // })
- // }
- // if (data && data.type != 5) {
- // req.getRequest('/api/product/list', { page: that.data.page, limit: 6, attr: 'Recommend', merchantId: data.id }, res => {
- // // if (res && res.length >= 10) that.data.isLoad = true;
- // // if (that.data.page > 1) res = that.data.recommendList.concat(res);
- // that.setData({
- // recommendList: res,
- // })
- // })
- // }
- // },
- // // 获取社区团购产品
- // group() {
- // let _ts = this;
- // // type
- // // 类型:1 普通商品 2 社区团购订单 3 秒杀订单 4 拼团订单 5 及时达订单 6 新客特价 7 优惠砍价
- // req.getRequest('/api/shopProduct/list', { page: 1, limit: 3, type: 2, userId: this.query.userId }, data => {
- // data = data.list.map(it => {
- // it.isRemind = it.remindId;
- // return it
- // });
- // let obj = data.filter(ele => ele.end == false)
- // // console.log(data.filter(ele=>ele.end==false))
- // _ts.setData({ group: obj });
- // // console.log(this.data.activityGroup)
- // _ts.initGroupTimer(2);
- // })
- // },
- // // 0 今天 1明天 2后天
- // GetDateStr(AddDayCount) {
- // var dd = new Date();
- // dd.setDate(dd.getDate() + AddDayCount);//获取AddDayCount天后的日期
- // var y = dd.getFullYear();
- // var m = dd.getMonth() + 1;//获取当前月份的日期
- // var d = dd.getDate();
- // return y + "-" + m + "-" + d;
- // },
- // // 获取秒杀产品
- // seckill(dataTime) {
- // let _ts = this;
- // // type
- // // 类型:1 普通商品 2 社区团购订单 3 秒杀订单 4 拼团订单 5 及时达订单 6 新客特价 7 优惠砍价
- // req.getRequest('/api/shopProduct/list', { page: 1, limit: 3, type: 3, userId: this.query.userId, dayType: dataTime }, data => {
- // data = data.list.map(it => {
- // it.isRemind = it.remindId;
- // return it
- // });
- // let obj = data.filter(ele => ele.end == false)
- // // console.log(data)
- // _ts.setData({ seckill: obj });
- // // console.log(this.data.activityGroup)
- // if (obj.length < 1) {
- // this.setData({ ishow: true })
- // } else {
- // this.setData({ ishow: false })
- // }
- // var now = new Date();
- // var next = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1);
- // this.NextTime(next, function (hour, minute, second) {
- // hour = _ts.lpad(hour, 2)
- // minute = _ts.lpad(minute, 2)
- // second = _ts.lpad(second, 2);
- // res = [hour, minute, second]
- // _ts.setData({ timer: res })
- // });
- // _ts.initGroupTimer(3);
- // })
- // },
- // // 获取拼团产品
- // joingroup() {
- // let _ts = this;
- // // type
- // // 类型:1 普通商品 2 社区团购订单 3 秒杀订单 4 拼团订单 5 及时达订单 6 新客特价 7 优惠砍价
- // req.getRequest('/api/shopProduct/list', { page: 1, limit: 3, type: 4, userId: this.query.userId }, data => {
- // data = data.list.map(it => {
- // it.isRemind = it.remindId;
- // return it
- // });
- // let arrObjFilter = data.filter(ele => ele.end == false)
- // console.log(arrObjFilter)
- // _ts.setData({ joingroup: arrObjFilter });
- // // console.log(this.data.activityGroup)
- // _ts.initGroupTimer(4);
- // })
- // },
- 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();
- });
- });
- },
- saoma() {
- var _this = this; // 允许从相机和相册扫码
- uni.scanCode({
- success: res => {
- uni.navigateTo({
- url: '/' + res.path
- }); // this.scene = '1290926887903780865';
- this.loadCodeParams();
- }
- });
- },
- // 获取砍价产品
- // bargain() {
- // let _ts = this;
- // // type
- // // 类型:1 普通商品 2 社区团购订单 3 秒杀订单 4 拼团订单 5 及时达订单 6 新客特价 7 优惠砍价
- // req.getRequest('/api/shopProduct/list', { page: 1, limit: 3, type: 7, userId: this.query.userId }, data => {
- // data = data.list.map(it => {
- // it.isRemind = it.remindId;
- // return it
- // });
- // console.log(data)
- // let arrObjFilter = data.filter(ele => ele.end == false)
- // _ts.setData({ bargain: arrObjFilter });
- // // console.log(this.data.activityGroup)
- // _ts.initGroupTimer(7);
- // })
- // },
- // // 获取新客产品
- // //2为社区团购,4为拼团,7为砍价
- // initGroupTimer(type) {
- // //社区拼图定时器
- // let _ts = this;
- // let list = [];
- // if (type == 2) list = this.data.group;
- // else if (type == 4) list = this.data.joingroup;
- // else if (type == 7) list = this.data.bargain;
- // // console.log(this.data.joingroupList)
- // 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);
- // console.log(times)
- // let timer = setInterval(() => {
- // times--;
- // let data = {};
- // if (times === 0) {
- // //重新加载列表
- // if (type == 2) data['group[' + i + '].end'] = true;
- // else if (type == 4) data['joingroup[' + i + '].end'] = true;
- // else if (type == 7) data['bargain[' + i + '].end'] = true;
- // clearInterval(timer);
- // } else {
- // let n = utils.formatDayTimes(times);
- // if (type == 2) data['group[' + i + '].times'] = n;
- // else if (type == 4) data['joingroup[' + i + '].times'] = n;
- // else if (type == 7) data['bargain[' + i + '].times'] = n.split(/:|天/g);
- // }
- // _ts.setData(data);
- // }, 1000);
- // if (type == 2) this.data.group[i]['timer'] = timer;
- // else if (type == 4) this.data.joingroup[i]['timer'] = timer;
- // else if (type == 7) this.data.bargain[i]['timer'] = timer;
- // // let fs = [];
- // // fs['activityGroup[' + i + '].timer'] = timer;
- // // _ts.setData(fs);
- // }
- // }
- // },
- // // 一天倒计时
- // NextTime(next, cb) {
- // var t;
- // (function ft() {
- // var dif = (next.getTime() - (new Date()).getTime()) / 1000;
- // if (dif > 0) {
- // t = setTimeout(ft, 1000);
- // if (cb)
- // cb(Math.floor(dif % 86400 / 3600), Math.floor(dif % 3600 / 60), Math.floor(dif % 60));
- // } else {
- // clearTimeout(t);
- // }
- // })();
- // return function () {
- // clearTimeout(t);
- // };
- // },
- // lpad(num, n) {
- // var len = num.toString().length;
- // while (len < n) {
- // num = "0" + num;
- // len++;
- // }
- // return num;
- // },
- // toGroupRemind(event) {
- // const index = event.currentTarget.dataset.index;
- // const activity = this.data.group[index];
- // console.log(activity)
- // app.openPage('product/groupDetail/groupDetail?acid=' + activity.id + "&id=" + activity.productId + "&hideShop=" + false);
- // console.log('acid', activity.id)
- // console.log('productId', activity.productId)
- // },
- // addActivityRemind(event) {
- // const index = event.currentTarget.dataset.index;
- // const id = event.currentTarget.dataset.id;
- // const type = event.currentTarget.dataset.type;
- // mes.remind().then(res => res)
- // req.postRequest('/api/activity/remind', { activityId: id }, res => {
- // req.msg('订阅提醒成功');
- // let data = {};
- // if (type == 1) data['activityGroup[' + index + '].isRemind'] = true;
- // else if (type == 2) data['joingroup[' + index + '].isRemind'] = true;
- // else if (type == 3) data['seckill[' + index + '].isRemind'] = true;
- // else if (type == 4) data['bargain[' + index + '].isRemind'] = true;
- // this.setData(data);
- // })
- // },
- // cancelActivityRemind(event) {
- // const index = event.currentTarget.dataset.index;
- // const id = event.currentTarget.dataset.id;
- // const type = event.currentTarget.dataset.type;
- // req.postRequest('/api/activity/cancel/remind', { id: id }, res => {
- // req.msg('取消提醒成功');
- // let data = {};
- // if (type == 1) data['activityGroup[' + index + '].isRemind'] = false;
- // else if (type == 2) data['joingroup[' + index + '].isRemind'] = false;
- // else if (type == 3) data['seckill[' + index + '].isRemind'] = false;
- // else if (type == 4) data['bargain[' + index + '].isRemind'] = false;
- // this.setData(data);
- // })
- // },
- // clearAllTimer() {
- // this.data.activityGroup.forEach(it => clearInterval(it.timer));
- // },
- // // 获取头像和名字
- // getuserInfo() {
- // let that = this;
- // req.getRequest('/api/user/getInfo', { userId: this.query.userId }, data => {
- // console.log(data)
- // data.nickName = req.excludeSpecial(data.nickName)
- // this.setData({ userInfo: data })
- // console.log(this.data.userInfo)
- // })
- // },
- toDetail(e) {
- // let id = e.currentTarget.dataset.id;
- // app.openPage("product/detail/detail?id=" + id + '&&hideShop=' + false)
- let id = e.currentTarget.dataset.id;
- let merchantId = e.currentTarget.dataset.merchant;
- let shopId = e.currentTarget.dataset.shopid;
- if (!shopId) {
- if (!merchantId) {
- app.globalData.openPage("product/detail/detail?id=" + id);
- } else {
- app.globalData.openPage("product/detail/detail?id=" + id + "&merchantId=" + merchantId);
- }
- } else {
- app.globalData.openPage("product/detail/detail?id=" + id + "&merchantId=" + merchantId + "&shopId=" +
- shopId);
- }
- }
- }
- };
- </script>
- <style>
- @import "./index.css";
- </style>
|