From 01e95a2387233b4f1ae2541696e933ecf3105e02 Mon Sep 17 00:00:00 2001 From: antploy Date: Sat, 25 Sep 2021 11:00:01 +0800 Subject: [PATCH] 分销小店 分类 品牌和国家跳转优化 --- app.json | 8 ++++---- packageA/pages/distribution/shop/shop.js | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------ packageA/pages/distribution/shop/shop.wxml | 718 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- packageC/pages/goods/distributionCategoryList/index.js | 25 ++++++++++++++++++++----- packageC/pages/goods/distributionCategoryList/index.wxss | 6 +++++- packageC/pages/goods/goodsList/goodsList.js | 91 +++++-------------------------------------------------------------------------------------- pages/distribution/distribution.js | 3 +++ pages/index/index/index.js | 915 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 8 files changed, 979 insertions(+), 987 deletions(-) diff --git a/app.json b/app.json index 2a1a647..afb1fdc 100644 --- a/app.json +++ b/app.json @@ -226,9 +226,9 @@ "sitemapLocation": "sitemap.json", "usingComponents": { "customtabbar":"custom-tab-bar/index" - } - - + }, + "useExtendedLib": { + "weui": true + } - } \ No newline at end of file diff --git a/packageA/pages/distribution/shop/shop.js b/packageA/pages/distribution/shop/shop.js index a412f34..951e5b5 100644 --- a/packageA/pages/distribution/shop/shop.js +++ b/packageA/pages/distribution/shop/shop.js @@ -23,7 +23,7 @@ Page({ isShowRow: false,//控制视图切换状态 isHiddenDropdown: true,//控制筛选下拉菜单显隐 - list: null, + list: [], isLoading: false, // 检测是否已经发送请求,防止重复发送请求 noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 pageNum: 1, // 当前页数 @@ -44,7 +44,6 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - console.log(options); wx.setNavigationBarTitle({ title: "我的小店", }); @@ -76,32 +75,20 @@ Page({ } - - // 判断会员是否授权登录, - // 没有登录则跳转到登录页, - // 已登录则设置已登录状态,请求加载签到数据 - // isLogin记录登录状态 - // app.isLogin().then(function(data) { - // // 1.登录成功 - // self.setData({ - // isLogin: true, - // userInfo: data, - // currentQuery: { - // store_id: app.globalData.setting.stoid, - // user_id: app.globalData.user_id, - // }, - // }); - // // 2.请求全部商品数据 - // self.getData(true, '/api/weshop/users/distribut/pagemyshop', self.data.currentQuery); - // // 3.请求新品 - // app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2', { - // data: self.data.currentQuery, - // }).then(function(res) { - // self.setData({ - // newList: res.data.data, - // }); - // }) - // }); + if (options?.brand_id) { + this.setData({ + brand_id: options.brand_id, + is_router:true + }) + // this.getData(true, '/api/weshop/users/distribut/pagemyshop', this.data.currentQuery); + } + if (options?.nation_id) { + this.setData({ + nation_id: options.nation_id, + is_router:true + }) + // this.getData(true, '/api/weshop/users/distribut/pagemyshop', this.data.currentQuery); + } }, /** @@ -125,42 +112,16 @@ Page({ user_id: app.globalData.user_id, }, }); - // 请求数据 - app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?orderType=desc', { - data: this.data.currentQuery, - }).then(res => { - self.setData({ - list: res.data.data, - total: res.data.data.total, - }); - }); - - // 新品 - app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2&orderType=desc', { - data: self.data.currentQuery, - }).then(res => { - self.setData({ - newList: res.data.data, - }); - }); - // 广告banner - app.request.promiseGet("/api/weshop/ad/page", { - data: { - pid: 401, - enabled: 1, - store_id: app.globalData.setting.stoid, - } - }).then(res => { - if (res.data.code == 0 && res.data.data) { - let item = res.data.data.pageData[0]; - if (item && item.ad_code) { - self.setData({ - ad_img: item.ad_code, - }); - }; - }; - }); - + !this.data.is_router&&this.initData(); + this.data.is_router&&this.getData(true,"/api/weshop/users/distribut/pagemyshop?orderType=desc",this.data.currentQuery); + let total=wx.getStorageSync('total'); + let newListTotal=wx.getStorageSync('newListTotal'); + if(total>0&&newListTotal>0){ + this.setData({ + total, + newListTotal + }) + } }; } //被人分享点击开的 @@ -259,9 +220,50 @@ Page({ inputVal: app.globalData.key_word, }) this.search(); - } + }; + }, + //初始化数据 + initData() { + + // 全部商品 + app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?orderType=desc', { + data: this.data.currentQuery, + }).then(res => { + wx.setStorageSync('total', res.data.data.total); + this.setData({ + total: res.data.data.total, + list:res.data.data.pageData, + }); + }); + // 新品 + app.request.promiseGet('/api/weshop/users/distribut/pagemyshop?type=2&orderType=desc', { + data: this.data.currentQuery, + }).then(res => { + wx.setStorageSync('newListTotal', res.data.data.total); + this.setData({ + newListTotal: res.data.data.total, + }); + }); + + // 广告banner + app.request.promiseGet("/api/weshop/ad/page", { + data: { + pid: 401, + enabled: 1, + store_id: app.globalData.setting.stoid, + } + }).then(res => { + if (res.data.code == 0 && res.data.data) { + let item = res.data.data.pageData[0]; + if (item && item.ad_code) { + this.setData({ + ad_img: item.ad_code, + }); + }; + }; + }); + // } }, - /** * 生命周期函数--监听页面隐藏 */ @@ -273,7 +275,11 @@ Page({ * 生命周期函数--监听页面卸载 */ onUnload: function () { - app.globalData.key_word=null; + console.log('onun'); + app.globalData.key_word = null; + app.globalData.nid = null; + app.globalData.bid = null; + // wx.removeStorageSync(key); }, /** @@ -395,20 +401,18 @@ Page({ search() { let data = this.data.currentQuery; data.key = this.data.inputVal; - if (data.orderField) { - delete data.orderField; - }; - if (data.page) { - delete data.page; - }; + delete data.page; + delete data.brand_id; + delete data.nation_id; this.setData({ - currentTabIndex: 4, + currentTabIndex: this.data.currentTabIndex, isSort: false, isDescending: false, currentQuery: data, pageNum: 1, }); this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); + app.globalData.key_word=null; }, /** @@ -484,9 +488,6 @@ Page({ if (data.page) {// 清除page delete data.page; }; - - - if (currentIndex == 0) { if (data.orderField) {// 清除orderField delete data.orderField; @@ -508,6 +509,9 @@ Page({ }; data.orderType = 'desc'; this.data.currentQuery = data; + delete data.brand_id; + delete data.nation_id; + console.log(data); this.getData(true, '/api/weshop/users/distribut/pagemyshop', data); }, @@ -535,7 +539,19 @@ Page({ * 请求数据 */ getData: function (isInit, url, data) { - + let { brand_id, nation_id } = this.data; + if (brand_id - 0) { + delete data.nation_id; + // delete data.key; + data.brand_id = brand_id; + this.data.brand_id=null; + }; + if (nation_id - 0) { + delete data.brand_id; + // delete data.key; + data.nation_id = nation_id; + this.data.nation_id=null; + }; app.request.promiseGet(url, { data: data, isShowLoading: true, @@ -545,16 +561,19 @@ Page({ if (res.data.code == 0) { self.setData({ - isLoading: false + isLoading: false, + // is_router:false, }); if (isInit) {// 第一次加载 + console.log('first',res); self.setData({ - list: res.data.data, + list: res.data.data.pageData, }); + console.log(self.data.list); } else { self.setData({ - 'list.pageData': self.data.list.pageData.concat(res.data.data.pageData) + list: self.data.list.concat(res.data.data.pageData) }); }; @@ -566,7 +585,7 @@ Page({ } else { self.setData({ - 'list.pageData': [] + list: [] }); }; @@ -574,7 +593,7 @@ Page({ .catch(function (err) { console.log('出错拉!!!!', err); self.setData({ - 'list.pageData': [] + list: [] }); }); }, @@ -668,12 +687,12 @@ Page({ */ clickAll() { let data = this.data.currentQuery; - if (data.page) delete data.page; if (data.orderField) delete data.orderField; if (data.orderType) delete data.orderType; if (data.key) delete data.key; - + delete data.brand_id; + delete data.nation_id; this.setData({ pageNum: 1, noMore: false, @@ -689,11 +708,12 @@ Page({ clickNew() { let data = this.data.currentQuery; - if (data.page) delete data.page; - if (data.orderField) delete data.orderField; - if (data.orderType) delete data.orderType; - if (data.key) delete data.key; - + delete data.page; + delete data.orderField; + delete data.orderType; + delete data.key; + delete data.brand_id; + delete data.nation_id; this.setData({ pageNum: 1, noMore: false, diff --git a/packageA/pages/distribution/shop/shop.wxml b/packageA/pages/distribution/shop/shop.wxml index dfa6459..b8ec430 100644 --- a/packageA/pages/distribution/shop/shop.wxml +++ b/packageA/pages/distribution/shop/shop.wxml @@ -1,359 +1,365 @@ - - - - - - - - - {{userInfo2.nickname}} - - - - - {{userInfo.nickname}} - - - - - - {{filter.show_default(total)}} - 全部商品 - - - {{filter.show_default(newList.total)}} - 新品 - - - - 会员中心 - - - - - - - - - - - - - - 搜索 - - - - - - - {{item}} - - {{item}} - - - - - - - - - - - - - - - - - - {{item.goods_name}} - - - - - {{item.prom_integral}}积分 - + - - - - {{item.prom_price}} - - - - - - - {{item.market_price}} - - - - - - - - - - - - - - - {{filter.toFix(item[card_field],2)}} - - - {{card_name}} - - - - - - - - {{item.market_price}} - - - - - - - - - {{filter.toFix(item.shop_price,2)}} - - - - - - - {{item.market_price}} - - - - - - - - - - - - {{filter.toFix(item.shop_price,2)}} - - - - - {{item.market_price}} - - - - - - - {{filter.toFix(g_filter.get_card_price(item,card_list,0),2)}} - - - {{g_filter.get_card_price(item,card_list,1)}} - - - - - - - - - - {{filter.toFix(item.shop_price,2)}} - - - - - - - {{item.market_price}} - - - - - - - - - - - - {{filter.toFix(item.shop_price,2)}} - - - - - - - {{item.market_price}} - - - - - - - - - - - - - - - - - - - - {{item.goods_name}} - - - - {{item.prom_integral}}积分 - + - - - - {{item.prom_price}} - - - - - - - {{item.market_price}} - - - - - - - - - - - - - - - {{filter.toFix(item[card_field],2)}} - - - {{card_name}} - - - - - - - - {{item.market_price}} - - - - - - - - - {{filter.toFix(item.shop_price,2)}} - - - - - - - {{item.market_price}} - - - - - - - - - - - - {{filter.toFix(item.shop_price,2)}} - - - - - {{item.market_price}} - - - - - - - {{filter.toFix(g_filter.get_card_price(item,card_list,0),2)}} - - - {{g_filter.get_card_price(item,card_list,1)}} - - - - - - - - - - {{filter.toFix(item.shop_price,2)}} - - - - - - - {{item.market_price}} - - - - - - - - - - - - {{filter.toFix(item.shop_price,2)}} - - - - - - - {{item.market_price}} - - - - - - 分成金额:{{filter.toFix(item.commission,2)}} - - - - - - - - - - - - - - - - - + + + + + + + + + + + + {{userInfo2.nickname}} + + + + + + + {{userInfo.nickname}} + + + + + {{filter.show_default(total)}} + 全部商品 + + + {{filter.show_default(newListTotal)}} + 新品 + + + + + + 会员中心 + + + + + + + + + + + + + 搜索 + + + + + + {{item}} + + + {{item}} + + + + + + + + + + + + + + + + + {{item.goods_name}} + + + + + {{item.prom_integral}} + 积分 + + + + + + + {{item.prom_price}} + + + + + + + {{item.market_price}} + + + + + + + + + + + + + + + {{filter.toFix(item[card_field],2)}} + + + {{card_name}} + + + + + + + + {{item.market_price}} + + + + + + + + + {{filter.toFix(item.shop_price,2)}} + + + + + + + {{item.market_price}} + + + + + + + + + + + + {{filter.toFix(item.shop_price,2)}} + + + + + {{item.market_price}} + + + + + + + {{filter.toFix(g_filter.get_card_price(item,card_list,0),2)}} + + + {{g_filter.get_card_price(item,card_list,1)}} + + + + + + + + + + {{filter.toFix(item.shop_price,2)}} + + + + + + + {{item.market_price}} + + + + + + + + + + + + {{filter.toFix(item.shop_price,2)}} + + + + + + + {{item.market_price}} + + + + + + + + + + + + + + + + + {{item.goods_name}} + + + + + {{item.prom_integral}} + 积分 + + + + + + + {{item.prom_price}} + + + + + + + {{item.market_price}} + + + + + + + + + + + + + + + {{filter.toFix(item[card_field],2)}} + + + {{card_name}} + + + + + + + + {{item.market_price}} + + + + + + + + + {{filter.toFix(item.shop_price,2)}} + + + + + + + {{item.market_price}} + + + + + + + + + + + + {{filter.toFix(item.shop_price,2)}} + + + + + {{item.market_price}} + + + + + + + + {{filter.toFix(g_filter.get_card_price(item,card_list,0),2)}} + + + + {{g_filter.get_card_price(item,card_list,1)}} + + + + + + + + + + {{filter.toFix(item.shop_price,2)}} + + + + + + + {{item.market_price}} + + + + + + + + + + + + {{filter.toFix(item.shop_price,2)}} + + + + + + + {{item.market_price}} + + + + + + + 分成金额: + {{filter.toFix(item.commission,2)}} + + + + + + + + \ No newline at end of file diff --git a/packageC/pages/goods/distributionCategoryList/index.js b/packageC/pages/goods/distributionCategoryList/index.js index d0f6d6d..a876f80 100644 --- a/packageC/pages/goods/distributionCategoryList/index.js +++ b/packageC/pages/goods/distributionCategoryList/index.js @@ -292,16 +292,31 @@ Page({ //跳转到品牌的商品列表 go_brand: function (t) { - var cid = t.currentTarget.dataset.bid; - var lurl = "../../goods/goodsList/goodsList?brand_id=" + cid; - wx.navigateTo({ url: lurl }); + var bid = t.currentTarget.dataset.bid; + // getApp().globalData.bid=bid; + // console.log(getApp().globalData.bid); + // let page=getCurrentPages(); + // let prePage=page[page.length-2]; + // console.log(prePage); + // prePage.setData({ + // brand_id:cid, + // }) + var lurl = "/packageA/pages/distribution/shop/shop?brand_id=" + bid; + // var lurl = "/packageA/pages/distribution/shop/shop"; + // wx.redirectTo({ url: lurl }); + wx.navigateTo({ url: lurl }) + // wx.navigateBack() }, //跳转到国别的商品列表 go_nation: function (t) { - var cid = t.currentTarget.dataset.nid; - var lurl = "../../goods/goodsList/goodsList?nation_id=" + cid; + var nid = t.currentTarget.dataset.nid; + // getApp().globalData.nid=nid; + var lurl = "/packageA/pages/distribution/shop/shop?nation_id=" + nid; + // var lurl = "/packageA/pages/distribution/shop/shop"; wx.navigateTo({ url: lurl }); + + // wx.navigateBack() }, //获取国别 get_nation: function () { diff --git a/packageC/pages/goods/distributionCategoryList/index.wxss b/packageC/pages/goods/distributionCategoryList/index.wxss index 89fc5fd..f158e1b 100644 --- a/packageC/pages/goods/distributionCategoryList/index.wxss +++ b/packageC/pages/goods/distributionCategoryList/index.wxss @@ -27,7 +27,11 @@ swiper{ min-height:200rpx; height: auto; } - +.navgation{ + height: 300rpx; + width: 100%; + background-color: blue; +} /*--搜索--*/ .search-box { width: 100% !important; diff --git a/packageC/pages/goods/goodsList/goodsList.js b/packageC/pages/goods/goodsList/goodsList.js index 036cb27..9b2df74 100644 --- a/packageC/pages/goods/goodsList/goodsList.js +++ b/packageC/pages/goods/goodsList/goodsList.js @@ -72,9 +72,7 @@ Page({ if (getApp().globalData.userInfo) { url += "&user_id=" + getApp().globalData.userInfo.user_id; } - this.setData({ - baseUrl:url, - }) + this.requestGoodsList(url); //优惠活动的凑单 if (t.prom_type == 3) { if (0 != t.prom_id && t.prom_id != undefined) { url += "&prom_id=" + t.prom_id; } @@ -89,8 +87,6 @@ Page({ } }) } - this.getInitData() - getApp().getConfig2(function (rs) { //计算等级价相关 var swithc_list = rs.switch_list; @@ -121,12 +117,7 @@ Page({ }) }, 500) } - }); - - }, - async getInitData(){ - await this.getShopGoods(); - await this.requestGoodsList(this.data.baseUrl); + }); }, //设置优惠券的 set_prom_list: async function (arr) { @@ -135,7 +126,6 @@ Page({ //优惠的实际内容 var content = JSON.parse(arr[i].preferential_type); arr[i].content = content; - //--送礼包-- if (content.is_libao) { //-- 获取 -- @@ -172,34 +162,6 @@ Page({ this.resetData(), this.requestGoodsList(url); }, - //分销小店的商品 - async getShopGoods() { - let data= { - store_id: oo.stoid, - user_id: getApp().globalData.user_id, - page:this.data.page, - pageSize:2000, - }; - // this.setData({ - // is_go:0 - // }) - // a.init(this, "", "shopGoodsData"); - // let url=`/api/weshop/users/distribut/pagemyshop?orderType=desc&store_id=${oo.stoid}&user_id=${getApp().globalData.user_id}`; - let url=`/api/weshop/users/distribut/pagemyshop?orderType=desc`; - const distriGoods = await getApp().request.promiseGet(url, { - data: data, - isShowLoading: false, - }); - console.log(distriGoods,1); - if (distriGoods.data.code == 0 && distriGoods.data.data.pageData.length > 0) { - this.setData({ - shopGoodsData: distriGoods.data.data.pageData, - }) - } - // this.requestGoodsList(url) - }, - - requestGoodsList: async function (t) { if(this.data.is_no_more){ @@ -216,57 +178,18 @@ Page({ } t += "&page=" + e.data.currentPage; - t += "&pageSize=" + 2000; + t += "&pageSize=" + 20; t +="&store_id=" +oo.stoid; const { data: res } = await getApp().request.promiseGet(t, { isShowLoading: true, }) console.log(res); - if (res.code == 0 && res.data.pageData.length > 0) { - let arr = []; - arr = res.data.pageData.filter(obj => this.data.shopGoodsData.some(item => item.goods_id == obj.goods_id)); - console.log(arr); this.setData({ - requestData: arr, - is_no_more:1, + requestData: res.data.pageData, + }); - // if (res.data.page > 1) { - // this.setData({ - // requestData: this.data.requestData.concat(arr), - // // select_classify_on: index, - // }); - // } else { - // this.setData({ - // requestData: arr, - // // select_classify_on: index, - // }); - // }; } - // a.request(t, - // function (t) { - // let arr=[]; - // e.setData({ is_go: 1 }); - // null == e.data.allData && (e.data.allData = Object.assign({}, t.data.result)), - // wx.stopPullDownRefresh(); - - // arr = e.data.requestData.filter(obj => e.data.shopGoodsData.some(item => item.goods_id == obj.goods_id)); - // // e.data.requestData.map(item => { - // // e.data.shopGoodsData.forEach(i => { - // // if (i.nation_id = item.nation_id) { - // // return item - // // } - // // }); - // // arr.push(item); - // // }); - // console.log(arr); - // // e.setData({ - // // requestData: arr, - // // }); - // }, - // null, { is_mainshow: 1, isonsale: 1, store_id: oo.stoid } - // ); - }, getInput(e) { this.setData({ @@ -280,10 +203,6 @@ Page({ t.showWarning("请输入搜索关键词"); return false } - // this.search(val); - // wx.navigateTo({ - // url: `/packageA/pages/distribution/shop/shop?key_word=${val}`, - // }); wx.navigateBack({ delta: 2 }); diff --git a/pages/distribution/distribution.js b/pages/distribution/distribution.js index e76fa70..708d871 100644 --- a/pages/distribution/distribution.js +++ b/pages/distribution/distribution.js @@ -83,6 +83,9 @@ Page({ //-- 获取分销的内容 -- self.show_dis(); }) + wx.removeStorageSync('total'); + wx.removeStorageSync('newListTotal'); + }, diff --git a/pages/index/index/index.js b/pages/index/index/index.js index a7360d1..2f21fb2 100644 --- a/pages/index/index/index.js +++ b/pages/index/index/index.js @@ -1,8 +1,8 @@ -var e = function(e) { - return e && e.__esModule ? e : { - default: e - }; - }(require("../../../utils/LoadMore.js")), +var e = function (e) { + return e && e.__esModule ? e : { + default: e + }; +}(require("../../../utils/LoadMore.js")), t = getApp(), a = t.request, o = t.globalData.setting, @@ -72,123 +72,123 @@ Page({ is_disgraceful: 0, //是否显示新人广告 new_image: "", //新人有礼弹窗图片 new_nav: "", //新人页面跳转地址 - w_holiday_pop:0, - - showHongbao: false, - showHongbaoSmall: false, - - is_full_screen_show:0, //全屏显示 - sec_show:3, //倒计时的秒数 - full_ad:null, //全屏广告 - full_screen:0, //全屏广告 - + w_holiday_pop: 0, + + showHongbao: false, + showHongbaoSmall: false, + + is_full_screen_show: 0, //全屏显示 + sec_show: 3, //倒计时的秒数 + full_ad: null, //全屏广告 + full_screen: 0, //全屏广告 + }, - onLoad: async function(tt) { - console.log("进入首页-------------"); - console.log(tt); - var th = this; - var first_leader=tt.first_leader; - if(!first_leader && tt.scene){ - var first_leader_str= decodeURIComponent(tt.scene); - var f_arr=first_leader_str.split("_"); - first_leader=f_arr[0] && parseFloat(f_arr[0])>0?f_arr[0]:null; - //注册门店 - if(f_arr[1] && parseFloat(f_arr[1])>0){ - getApp().globalData.store_number=f_arr[1]; + onLoad: async function (tt) { + console.log("进入首页-------------"); + console.log(tt); + var th = this; + var first_leader = tt.first_leader; + if (!first_leader && tt.scene) { + var first_leader_str = decodeURIComponent(tt.scene); + var f_arr = first_leader_str.split("_"); + first_leader = f_arr[0] && parseFloat(f_arr[0]) > 0 ? f_arr[0] : null; + //注册门店 + if (f_arr[1] && parseFloat(f_arr[1]) > 0) { + getApp().globalData.store_number = f_arr[1]; + } + } + + getApp().getConfig(function (e) { + //--首页的问题-- + if (getApp().globalData.config && getApp().globalData.config.store_name != undefined && getApp().globalData.config.store_name != null) { + wx.setNavigationBarTitle({ + title: getApp().globalData.config.store_name, + }); + } else { + wx.setNavigationBarTitle({ + title: getApp().globalData.setting.appName, + }); + }; + }); + + + var th = this; + getApp().getConfig2(function (config2) { + if (config2 && config2.is_overdue == 1) { + getApp().promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=5", {}).then(res => { + var o = res; + if (o.data.code == 0) { + var ob = { isout: 0, isbuy: 1 }; + var arr = o.data.data.pageData; + var isbuy = 0; + //----如果数组不为空---- + if (arr.length > 0) { + arr.forEach(function (val, ind) { + if (val.is_sy == 0 && val.type == 5) { + isbuy = 1; + var now = ut.gettimestamp(); + if (now > val.end_time) ob.isout = 1; + return false; + } + }) + } + ob.isbuy = isbuy; + + var pages = getCurrentPages(); //获取加载的页面 + var currentPage = pages[pages.length - 1]; //获取当前页面的对象 + + console.log("当前路由"); + console.log(currentPage.route); + + + th.setappdata(ob); + + if (ob.isbuy && !ob.isout) { + th.onload_init(); + } + } else { + th.onload_init(); + } + }) + } + + else { + th.onload_init(); + } + }) + + if (first_leader) { + //-- user_id代过来免登录 -- + getApp().globalData.first_leader = first_leader; + //调用接口判断是不是会员 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => { + if (res.data.code == 0) { + getApp().globalData.guide_id = res.data.data.id; } - } - - getApp().getConfig(function(e){ - //--首页的问题-- - if (getApp().globalData.config && getApp().globalData.config.store_name != undefined && getApp().globalData.config.store_name != null) { - wx.setNavigationBarTitle({ - title: getApp().globalData.config.store_name, - }); - } else { - wx.setNavigationBarTitle({ - title: getApp().globalData.setting.appName, - }); - }; - }); - - - var th = this; - getApp().getConfig2(function(config2){ - if(config2 && config2.is_overdue==1){ - getApp().promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=5",{}).then(res=>{ - var o=res; - if (o.data.code == 0) { - var ob = { isout: 0, isbuy: 1 }; - var arr = o.data.data.pageData; - var isbuy = 0; - //----如果数组不为空---- - if (arr.length > 0) { - arr.forEach(function (val, ind) { - if (val.is_sy == 0 && val.type == 5) { - isbuy = 1; - var now = ut.gettimestamp(); - if (now > val.end_time) ob.isout = 1; - return false; - } - }) - } - ob.isbuy = isbuy; - - var pages = getCurrentPages(); //获取加载的页面 - var currentPage = pages[pages.length - 1]; //获取当前页面的对象 - - console.log("当前路由"); - console.log(currentPage.route); - - - th.setappdata(ob); - - if(ob.isbuy && !ob.isout){ - th.onload_init(); - } - }else{ - th.onload_init(); - } - }) - } - - else{ - th.onload_init(); - } - }) - - if(first_leader){ - //-- user_id代过来免登录 -- - getApp().globalData.first_leader=first_leader; - //调用接口判断是不是会员 - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+os.stoid+"/"+first_leader,{}).then(res=>{ - if(res.data.code==0){ - getApp().globalData.guide_id=res.data.data.id; - } - }) - } - - // 判断是否有红包活动 - getApp().request.promiseGet('/api/weshop/redmoney/redConfig/get/'+getApp().globalData.setting.stoid, { - data: {} - }).then(function(data) { - // console.log('909090909090----->', data.data.code); - let code = data.data.code; - if(code == 0) { - - th.setData({ - showHongbao: true, - }); - } else if(code == -1) { - th.setData({ - showHongbao: false, - }); - }; - }); - - - // console.log(9090909); + }) + } + + // 判断是否有红包活动 + getApp().request.promiseGet('/api/weshop/redmoney/redConfig/get/' + getApp().globalData.setting.stoid, { + data: {} + }).then(function (data) { + // console.log('909090909090----->', data.data.code); + let code = data.data.code; + if (code == 0) { + + th.setData({ + showHongbao: true, + }); + } else if (code == -1) { + th.setData({ + showHongbao: false, + }); + }; + }); + + + // console.log(9090909); //看一下商家是否开通了权益 //--初始化是否有打勾-- getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", { @@ -201,12 +201,12 @@ Page({ th.setData({ is_boot: is_init }); - - if(!is_init){ - th.setData({ - swiperimage: [] - }); - } + + if (!is_init) { + th.setData({ + swiperimage: [] + }); + } } }) @@ -215,75 +215,75 @@ Page({ //t.editTabBar(th,o.stoid,th.data.url); }, - - async onload_init(){ - var th=this; - await this.init_load(); - //显示的时候要开启计时器 - this.data.is_timer = 1; - //如果是自定义模板 - if (this.data.isTemplate) { - //---先获取会员--- - t.getUserFir(function() { - th.is_festival(); - var new_nav = th.data.new_nav; - if (new_nav == "") { - th.is_new(); - } - setTimeout(function () { - if (getApp().globalData.user_id) getApp().requestCardNum(th); - },500) - - }); - } else { - await this.init_fir(); - wx.setNavigationBarColor({ - frontColor: '#ffffff', // 必写项 - backgroundColor: '#ff7295', // 必写项 - }) - } - - //--正再拼团中的处理-- - var url = "/api/weshop/order/pageTuan?pt_status=2&is_pt=1&store_id=" + os.stoid + "&pageSize=6&page=1" - await getApp().request.promiseGet(url, {}).then(res => { - if (res.data.code == 0 && res.data.data && res.data.data.pageData) { - th.data.pt_timer_arr = res.data.data.pageData; - } - }) - if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) { - for (var i in th.data.pt_timer_arr) { - var p_item = th.data.pt_timer_arr[i]; - await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + p_item.user_id, { - 1: 1 - }).then(res => { - th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic; - th.data.pt_timer_arr[i].nickname = res.data.data.nickname; - }) - } - th.Interval_pt(); - } - - //---处理正在6个分类---- - await getApp().request.promiseGet("/api/weshop/goodscategory/page", { - data: { - store_id: os.stoid, - pageSize: 5, - is_show: 1, - level:1 - } - }).then(res => { - if (res.data.data) { - var gd_category = res.data.data.pageData; - th.setData({ - gd_category: gd_category - }); - } - }) + + async onload_init() { + var th = this; + await this.init_load(); + //显示的时候要开启计时器 + this.data.is_timer = 1; + //如果是自定义模板 + if (this.data.isTemplate) { + //---先获取会员--- + t.getUserFir(function () { + th.is_festival(); + var new_nav = th.data.new_nav; + if (new_nav == "") { + th.is_new(); + } + setTimeout(function () { + if (getApp().globalData.user_id) getApp().requestCardNum(th); + }, 500) + + }); + } else { + await this.init_fir(); + wx.setNavigationBarColor({ + frontColor: '#ffffff', // 必写项 + backgroundColor: '#ff7295', // 必写项 + }) + } + + //--正再拼团中的处理-- + var url = "/api/weshop/order/pageTuan?pt_status=2&is_pt=1&store_id=" + os.stoid + "&pageSize=6&page=1" + await getApp().request.promiseGet(url, {}).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.pageData) { + th.data.pt_timer_arr = res.data.data.pageData; + } + }) + if (th.data.pt_timer_arr && th.data.pt_timer_arr.length > 0) { + for (var i in th.data.pt_timer_arr) { + var p_item = th.data.pt_timer_arr[i]; + await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + p_item.user_id, { + 1: 1 + }).then(res => { + th.data.pt_timer_arr[i].head_pic = res.data.data.head_pic; + th.data.pt_timer_arr[i].nickname = res.data.data.nickname; + }) + } + th.Interval_pt(); + } + + //---处理正在6个分类---- + await getApp().request.promiseGet("/api/weshop/goodscategory/page", { + data: { + store_id: os.stoid, + pageSize: 5, + is_show: 1, + level: 1 + } + }).then(res => { + if (res.data.data) { + var gd_category = res.data.data.pageData; + th.setData({ + gd_category: gd_category + }); + } + }) }, - - + + //关闭新用户领取广告 - close_disgraceful: function() { + close_disgraceful: function () { var th = this; th.setData({ is_disgraceful: 0 @@ -291,10 +291,10 @@ Page({ }, async onShow() { - var th=this; - //-- 登录回来判断弹框 -- - var userInfo=getApp().globalData.userInfo; - if(userInfo){ + var th = this; + //-- 登录回来判断弹框 -- + var userInfo = getApp().globalData.userInfo; + if (userInfo) { th.is_festival(); var new_nav = th.data.new_nav; if (new_nav == "") { @@ -303,64 +303,64 @@ Page({ } //优惠券要实时更新 - getApp().getConfig2(function(e) { + getApp().getConfig2(function (e) { var json_d = JSON.parse(e.switch_list); - th.setData({is_closecoupon: json_d.is_closecoupon}) - th.setData({is_topstore: json_d.is_show_storeselect}) - },1) - - if (typeof this.getTabBar === 'function' && this.getTabBar()) { - var index=getApp().getPageIndex(this); - this.getTabBar().setData({ - active: index //数字是当前页面在tabbar的索引 - }) - - getApp().requestCardNum(this); - } - - var th = this; - - var show=getApp().globalData.isLoad_ad; - setTimeout(function(){ - //user没有及时更新 - var userInfo=getApp().globalData.userInfo; - if(!userInfo || !userInfo.user_id) userInfo=null; - //有加载过一次首页,就显示 - if(show || userInfo || getApp().globalData.user_id){ - setTimeout(function(){ - full_screen.get_the_full_screen(th); - },800) - //动画效果 - if(!th.data.f_hidden){ - wx.showLoading({ - title:'加载中..' - }); - setTimeout(function(){ - th.setData({f_hidden:1}) - wx.hideLoading(); - },960) - } - }else{ - getApp().globalData.isLoad_ad=1; - } - },500) - - - + th.setData({ is_closecoupon: json_d.is_closecoupon }) + th.setData({ is_topstore: json_d.is_show_storeselect }) + }, 1) + + if (typeof this.getTabBar === 'function' && this.getTabBar()) { + var index = getApp().getPageIndex(this); + this.getTabBar().setData({ + active: index //数字是当前页面在tabbar的索引 + }) + + getApp().requestCardNum(this); + } + + var th = this; + + var show = getApp().globalData.isLoad_ad; + setTimeout(function () { + //user没有及时更新 + var userInfo = getApp().globalData.userInfo; + if (!userInfo || !userInfo.user_id) userInfo = null; + //有加载过一次首页,就显示 + if (show || userInfo || getApp().globalData.user_id) { + setTimeout(function () { + full_screen.get_the_full_screen(th); + }, 800) + //动画效果 + if (!th.data.f_hidden) { + wx.showLoading({ + title: '加载中..' + }); + setTimeout(function () { + th.setData({ f_hidden: 1 }) + wx.hideLoading(); + }, 960) + } + } else { + getApp().globalData.isLoad_ad = 1; + } + }, 500) + + + }, //当隐藏的时候就关闭计时器 - onHide: function() { + onHide: function () { this.data.is_timer = 0; - if(this.data.pt_timer) clearInterval(this.data.pt_timer); - if(this.data.w_holiday_pop) clearInterval(this.data.w_holiday_pop); - if(this.data.full_screen) clearInterval(this.data.full_screen); - this.data.w_holiday_pop=0; + if (this.data.pt_timer) clearInterval(this.data.pt_timer); + if (this.data.w_holiday_pop) clearInterval(this.data.w_holiday_pop); + if (this.data.full_screen) clearInterval(this.data.full_screen); + this.data.w_holiday_pop = 0; }, //同步初始加载 async init_load() { - var th=this; + var th = this; //因为营销版本的功能包含了自定义模板的功能,是同时的 //读取全局是否有弄自定义模板 await api.get_template_fir(o.stoid).then(res => { @@ -368,6 +368,7 @@ Page({ if (data && data.length > 0) { var temp_data = data[0]; var t_arr = JSON.parse(temp_data.json_str); + console.log(t_arr); th.setData({ template_arr: t_arr, isTemplate: 1, @@ -375,11 +376,11 @@ Page({ }); //---如果有设定顶部的颜色的时候-- - if(temp_data.top_color && temp_data.top_color!='null' ){ + if (temp_data.top_color && temp_data.top_color != 'null') { - var top_w_color="#ffffff"; - if(temp_data.top_word_color && temp_data.top_word_color=='black'){ - top_w_color="#000000"; + var top_w_color = "#ffffff"; + if (temp_data.top_word_color && temp_data.top_word_color == 'black') { + top_w_color = "#000000"; } wx.setNavigationBarColor({ frontColor: top_w_color, // 必写项 @@ -390,15 +391,11 @@ Page({ } }) - - - - - }, //---读取数据内容--- async init_fir() { + console.log('init_fir'); var th = this; //----广告---- var e = this; @@ -407,24 +404,24 @@ Page({ enabled: 1 } }).then(res => { - - if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){ - var a = res.data.data.pageData; - var arr = new Array(); - for (var i = 0; i < a.length; i++) { - var tt = { - 'ad_code': o.imghost + a[i].ad_code, - 'media_link': '', - 'ad_weapplink':a[i].ad_weapplink - }; - arr.push(tt); - } - if (arr.length > 0) e.setData({ - banner: arr, - }); - - wx.stopPullDownRefresh(); - } + + if (res.data.code == 0 && res.data.data.pageData && res.data.data.pageData.length > 0) { + var a = res.data.data.pageData; + var arr = new Array(); + for (var i = 0; i < a.length; i++) { + var tt = { + 'ad_code': o.imghost + a[i].ad_code, + 'media_link': '', + 'ad_weapplink': a[i].ad_weapplink + }; + arr.push(tt); + } + if (arr.length > 0) e.setData({ + banner: arr, + }); + + wx.stopPullDownRefresh(); + } }) //-----秒杀----- @@ -447,7 +444,7 @@ Page({ //当前时间戳 var nt = ut.gettimestamp(); - flash_data.forEach(function(val, ind) { + flash_data.forEach(function (val, ind) { if (val.start_time > nt) flash_data[ind].status = 0; else if (val.end_time > nt) flash_data[ind].status = 1; if (val.buy_num >= val.goods_num) flash_data[ind].status = 2; @@ -464,6 +461,34 @@ Page({ //th.countDown(); } }); + //-----预售---- + //调用接口获取数据 + await getApp().request.get("/api/weshop/marketing/marketingPresellList/page", { + data: { + is_end: 0, + store_id: os.stoid, + pageSize: 10, + timetype: 1 + }, + success: function (res) { + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { + var list = th.data.goodlist ? th.data.goodlist : []; + var arr = res.data.data.pageData; + //数组合起来 + for (var i in arr) { + list.push(arr[i]); + } + th.setData({ goodlist: list }); + if (arr.length < 10) { + th.setData({ no_more: 1 }) + } + } else { + th.setData({ no_more: 1 }) + } + th.setData({ is_get: 1 }) + + } + }); //----拼单----- await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2", { @@ -482,7 +507,7 @@ Page({ //获取当前 var nt = ut.gettimestamp(); - pd_data.forEach(function(val, ind) { + pd_data.forEach(function (val, ind) { if (val.start_time > nt) pd_data[ind].status = 0; else if (val.end_time > nt) pd_data[ind].status = 1; if (val.buy_num >= val.goods_num) pd_data[ind].status = 2; @@ -559,6 +584,7 @@ Page({ for (var i = 0; i < new_data.length; i += 3) { arr.push(new_data.slice(i, i + 3)); } + console.log(arr); th.setData({ hotGoods: arr, }); @@ -569,33 +595,33 @@ Page({ this.setData({ ishow: 1 }); - + //---先获取会员--- - t.getUserFir(function() { - th.is_festival(); - var new_nav = th.data.new_nav; - if (new_nav == "") { - th.is_new(); - } - - setTimeout(function () { - if (getApp().globalData.user_id) getApp().requestCardNum(th); - },500) - + t.getUserFir(function () { + th.is_festival(); + var new_nav = th.data.new_nav; + if (new_nav == "") { + th.is_new(); + } + + setTimeout(function () { + if (getApp().globalData.user_id) getApp().requestCardNum(th); + }, 500) + }); - - setTimeout(function() { - var goods_list = th.selectComponent("#goods_list"); //组件的id - goods_list.init(); - goods_list.get_list(); + + setTimeout(function () { + var goods_list = th.selectComponent("#goods_list"); //组件的id + goods_list.init(); + goods_list.get_list(); }, 2000) }, //--判断小程序是否过期-- - setappdata: function(t) { + setappdata: function (t) { if (t.isout == 1) wx.reLaunch({ - url: "/pages/error/error?msg=该商城已到期,暂停浏览!\r\n可联系:"+getApp().globalData.config.store_tel, + url: "/pages/error/error?msg=该商城已到期,暂停浏览!\r\n可联系:" + getApp().globalData.config.store_tel, }); if (t.isbuy == 0) wx.reLaunch({ @@ -603,40 +629,39 @@ Page({ }); }, //---加载更多是靠这个函数---- - onReachBottom: function() { + onReachBottom: function () { var goods_list = this.selectComponent("#goods_list"); //组件的id if (goods_list) goods_list.get_list(); - if(getApp().globalData.func_list) - { - for(let i in getApp().globalData.func_list){ - let item=getApp().globalData.func_list[i]; - item.re_show(); - } - } + if (getApp().globalData.func_list) { + for (let i in getApp().globalData.func_list) { + let item = getApp().globalData.func_list[i]; + item.re_show(); + } + } }, - onPullDownRefresh: function(e) { + onPullDownRefresh: function (e) { this.data.recommend = null, this.data.currentPage = 1, n.resetConfig(), this.requestHomePage(), this.requestRecommend(); }, - requestRecommend(){}, - requestHomePage(){}, + requestRecommend() { }, + requestHomePage() { }, - onUnload: function() { + onUnload: function () { this.destroyActivityTimer(); }, - setCountTime: function(e) { + setCountTime: function (e) { e.diffTime || (e.diffTime = new Date().getTime() - 1e3 * e.server_time), this.setData({ "sale.diffTime": e.diffTime }), this.setData({ "sale.good": e.flash_sale_goods[0] }), this.destroyActivityTimer(), this.createActivityTimer(); }, - createActivityTimer: function() { + createActivityTimer: function () { var e = this.data.sale, t = this; - this.data.timer = setInterval(function() { + this.data.timer = setInterval(function () { var a = 1e3 * e.good.end_time - new Date().getTime() + e.diffTime, o = i.transTime(a); a <= 0 ? t.requestHomePage() : t.setData({ @@ -644,11 +669,11 @@ Page({ }); }, 1e3); }, - destroyActivityTimer: function() { + destroyActivityTimer: function () { this.data.timer && (clearInterval(this.data.timer), this.data.timer = null); }, - onPageScroll: function(e) { - this.data.scrollTop=e.scrollTop; + onPageScroll: function (e) { + this.data.scrollTop = e.scrollTop; var t = getCurrentPages(); "pages/index/index/index" == t[t.length - 1].route; /*--(e.scrollTop > 10 ? wx.setNavigationBarColor({ @@ -659,37 +684,37 @@ Page({ backgroundColor: "#eeeeee" }));--*/ }, - jumpSearch: function() { + jumpSearch: function () { wx.navigateTo({ url: "/pages/goods/search/search" }); }, - onShareAppMessage: function(e) { - var url="/pages/index/index/index"; - var userInfo=getApp().globalData.userInfo; - //是分销商才带 - if(userInfo){ - url+="?first_leader="+userInfo.user_id; - } - console.log("---首页---分享--"); - var title="商城首页" + onShareAppMessage: function (e) { + var url = "/pages/index/index/index"; + var userInfo = getApp().globalData.userInfo; + //是分销商才带 + if (userInfo) { + url += "?first_leader=" + userInfo.user_id; + } + console.log("---首页---分享--"); + var title = "商城首页" //分享 - if(getApp().globalData.config && getApp().globalData.config.store_name){ - title=getApp().globalData.config.store_name; - }else if(getApp().globalData.setting.appName){ - title=getApp().globalData.setting.appName; - } - - var ob={ - title: title, - path:url, - }; - console.log(ob); + if (getApp().globalData.config && getApp().globalData.config.store_name) { + title = getApp().globalData.config.store_name; + } else if (getApp().globalData.setting.appName) { + title = getApp().globalData.setting.appName; + } + + var ob = { + title: title, + path: url, + }; + console.log(ob); return ob; }, //图片失败,默认图片 - bind_bnerr: function(e) { + bind_bnerr: function (e) { var _errImg = e.target.dataset.errorimg; var _errObj = {}; _errObj[_errImg] = this.data.url + "/miniapp/images/del/logo.jpg"; @@ -697,7 +722,7 @@ Page({ }, //图片失败,默认图片 - bind_bnerr2: function(e) { + bind_bnerr2: function (e) { var _errImg = e.target.dataset.errorimg; var _errurl = e.target.dataset.url; var _errObj = {}; @@ -706,7 +731,7 @@ Page({ }, //图片失败,默认图片 - bind_bnerr3: function(e) { + bind_bnerr3: function (e) { var _errImg = e.target.dataset.errorimg; var _Img = e.target.dataset.img; if (_Img != undefined) { @@ -821,19 +846,19 @@ Page({ setTimeout(th.countDown2, 1000); }, - bannerSwiperChange: function(e) { + bannerSwiperChange: function (e) { var index = e.detail.current; this.setData({ banner_index: index }); }, - flashSwiperChange: function(e) { + flashSwiperChange: function (e) { var index = e.detail.current; this.setData({ flash_index: index }); }, - ptSwiperChange: function(e) { + ptSwiperChange: function (e) { var index = e.detail.current; this.setData({ pt_index: index @@ -842,13 +867,13 @@ Page({ Interval_pt() { var th = this; - this.data.pt_timer = setInterval(function() { + this.data.pt_timer = setInterval(function () { var item = ut.get_rand_item(th.data.pt_timer_arr); th.setData({ pt_timer_active: 1, pt_timer_item: item }); - setTimeout(function() { + setTimeout(function () { th.setData({ pt_timer_active: 0 }); @@ -858,7 +883,7 @@ Page({ //---扫一扫的函数--- - getScancode: function() { + getScancode: function () { var _this = this; // 允许从相机和相册扫码 wx.scanCode({ @@ -872,16 +897,16 @@ Page({ }, //跳转到分类 - go_cate: function() { + go_cate: function () { getApp().goto("/pages/goods/categoryList/categoryList"); }, - go_url: function(e) { + go_url: function (e) { var url = e.currentTarget.dataset.url; getApp().goto(url); }, - bind_bnerr_icon: function(e) { + bind_bnerr_icon: function (e) { var def = "/miniapp/images/no_cate_def.png"; var _err = e.currentTarget.dataset.err; var ob = {}; @@ -890,7 +915,7 @@ Page({ }, //跳转到分类的商品列表 - go_cate2: function(t) { + go_cate2: function (t) { var cid = t.currentTarget.dataset.cid; var pid = t.currentTarget.dataset.pid; var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid; @@ -898,13 +923,13 @@ Page({ url: lurl }); }, - new_nav: function(e) { + new_nav: function (e) { var th = this; var new_nav = th.data.new_nav; getApp().goto(new_nav); }, //跳转到权益 - go_quanyi: function(t) { + go_quanyi: function (t) { var user_info = getApp().globalData.userInfo; if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { wx.navigateTo({ @@ -916,7 +941,7 @@ Page({ getApp().goto("/pages/user/userqy/userqy"); }, - imageLoad: function(e) { + imageLoad: function (e) { var imgwidth = e.detail.width; var imgheight = e.detail.height; //宽高比 @@ -928,7 +953,7 @@ Page({ }); }, //判断该用户是否是新会员 - is_new: function() { + is_new: function () { var th = this; wx.hideLoading(); getApp().request.promiseGet("/api/weshop/marketing/newpeople/act/judge", { @@ -964,20 +989,20 @@ Page({ th.setData({ is_disgraceful: 1 }) - }else{ - th.check_holiday_pop(); //节日的弹窗 - } - + } else { + th.check_holiday_pop(); //节日的弹窗 + } + }) - }else{ - th.check_holiday_pop(); //节日的弹窗 - } - + } else { + th.check_holiday_pop(); //节日的弹窗 + } + }) }, - - is_festival: function(e) { + + is_festival: function (e) { var th = this; var url = "/api/weshop/marketing/holiday/act/judge"; getApp().request.promiseGet(url, { @@ -991,24 +1016,24 @@ Page({ var giftBagId = res.data.data.gifBagId; //礼包id var nav_url = "/pages/giftpack/festival/festival?actId=" + actid + '&' + 'actType=' + 3 + '&' + 'giftBagId=' + giftBagId; var swiperimage = th.data.swiperimage; - var actBoundImg = res.data.data.actBoundImg?res.data.data.actBoundImg:'/miniapp/images/default_g_img.gif'; - - th.data.holiday_image= res.data.data.actImg; - th.data.holiday_url=nav_url; - + var actBoundImg = res.data.data.actBoundImg ? res.data.data.actBoundImg : '/miniapp/images/default_g_img.gif'; + + th.data.holiday_image = res.data.data.actImg; + th.data.holiday_url = nav_url; + var img = { image: actBoundImg, nav_url: nav_url, - id:res.data.data.id, - type:'festival' + id: res.data.data.id, + type: 'festival' + } + + for (var i in swiperimage) { + var item = swiperimage[i]; + if (item.id == img.id && item.type == img.type) { + return false; + } } - - for(var i in swiperimage){ - var item=swiperimage[i]; - if(item.id ==img.id && item.type==img.type){ - return false; - } - } swiperimage.unshift(img); th.setData({ @@ -1018,82 +1043,82 @@ Page({ } }) }, - + //弹出节日有礼 - check_holiday_pop:function(){ - var th=this; - getApp().waitfor2(th,'w_holiday_pop','holiday_image',function(){ - //等到结果才显示 - if(th.data.holiday_image){ - th.setData({ - new_image: th.data.holiday_image, - new_nav: th.data.holiday_url, - is_disgraceful: 1 - }) - } - }) + check_holiday_pop: function () { + var th = this; + getApp().waitfor2(th, 'w_holiday_pop', 'holiday_image', function () { + //等到结果才显示 + if (th.data.holiday_image) { + th.setData({ + new_image: th.data.holiday_image, + new_nav: th.data.holiday_url, + is_disgraceful: 1 + }) + } + }) }, - - go_ad:function(e){ - var url=e.currentTarget.dataset.url; - if(!url || url=='') return; - if(url[0]!='/') url='/'+url; - getApp().goto(url); + + go_ad: function (e) { + var url = e.currentTarget.dataset.url; + if (!url || url == '') return; + if (url[0] != '/') url = '/' + url; + getApp().goto(url); }, - + //导航跳转 - nav_goto:function(e){ - var url=e.currentTarget.dataset.url; - if(!url || url=='') return; - if(url[0]!='/') url='/'+url; - getApp().goto(url); - if(this.data.showHongbao) { - this.setData({ - showHongbao: false, - showHongbaoSmall: true, //显示抢红包小图标 - }); - } - }, - - //----跳转到搭配购买---- - go_test:function () { - wx.navigateTo({ url: "/packageA/pages/goods_share/goods_share", }) - }, - - + nav_goto: function (e) { + var url = e.currentTarget.dataset.url; + if (!url || url == '') return; + if (url[0] != '/') url = '/' + url; + getApp().goto(url); + if (this.data.showHongbao) { + this.setData({ + showHongbao: false, + showHongbaoSmall: true, //显示抢红包小图标 + }); + } + }, + + //----跳转到搭配购买---- + go_test: function () { + wx.navigateTo({ url: "/packageA/pages/goods_share/goods_share", }) + }, + + onShareTimeline() { - // getApp().getConfig(function(t) { - // return { - // title: '首页-' + getApp().globalData.config.store_name, - // } - // }); - var store_name=getApp().globalData.config?getApp().globalData.config.store_name:''; - if(!store_name) - store_name=getApp().globalData.setting.appName; - return { - title: '首页-' + store_name, - } - }, - - - // 关闭首页抢红包主弹窗,显示侧边栏抢红包小图标 - closeHongbao() { - this.setData({ - showHongbao: false, //关闭抢红包主弹窗 - showHongbaoSmall: true, //显示抢红包小图标 - }); - }, - - /*-- 全屏广告 --*/ - close_full_screen(){ - this.setData({is_full_screen_show:0,sec_show:0}); - }, - //-- 跳转到满屏广告的链接 -- - go_full_ad(){ - if(!this.data.full_ad) return false; - if(!this.data.full_ad.ad_weapplink) return false; - getApp().goto(this.data.full_ad.ad_weapplink); - this.close_full_screen(); - }, + // getApp().getConfig(function(t) { + // return { + // title: '首页-' + getApp().globalData.config.store_name, + // } + // }); + var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : ''; + if (!store_name) + store_name = getApp().globalData.setting.appName; + return { + title: '首页-' + store_name, + } + }, + + + // 关闭首页抢红包主弹窗,显示侧边栏抢红包小图标 + closeHongbao() { + this.setData({ + showHongbao: false, //关闭抢红包主弹窗 + showHongbaoSmall: true, //显示抢红包小图标 + }); + }, + + /*-- 全屏广告 --*/ + close_full_screen() { + this.setData({ is_full_screen_show: 0, sec_show: 0 }); + }, + //-- 跳转到满屏广告的链接 -- + go_full_ad() { + if (!this.data.full_ad) return false; + if (!this.data.full_ad.ad_weapplink) return false; + getApp().goto(this.data.full_ad.ad_weapplink); + this.close_full_screen(); + }, }); \ No newline at end of file -- libgit2 0.21.4