|
@@ -2,10 +2,9 @@
|
|
|
//获取应用实例
|
|
|
var app = getApp();
|
|
|
let host = app.globalData.servsers; // 请求的url
|
|
|
-var coupon = [
|
|
|
- {
|
|
|
- coupon_monry : '1000',
|
|
|
- coupon_rule : '9999',
|
|
|
+var coupon = [{
|
|
|
+ coupon_monry: '1000',
|
|
|
+ coupon_rule: '9999',
|
|
|
coupon_name: '新年专属红包',
|
|
|
coupon_begin_time: '2018-01-01',
|
|
|
coupon_end_time: '2018-02-08'
|
|
@@ -30,18 +29,17 @@ var coupon = [
|
|
|
Page({
|
|
|
data: {
|
|
|
urlHttp: '',
|
|
|
- host : '',
|
|
|
- scrollLeft: 0,//tab标题的滚动条位置
|
|
|
- search:{
|
|
|
- placeholder:"输入搜索关键字"
|
|
|
- },
|
|
|
- navTab:[
|
|
|
- {
|
|
|
- url:'/',
|
|
|
- icon:'icon-dingzhijiaju',
|
|
|
- src:'../../images/news/nav_01.png',
|
|
|
- text:'杯类'
|
|
|
+ host: '',
|
|
|
+ scrollLeft: 0, //tab标题的滚动条位置
|
|
|
+ search: {
|
|
|
+ placeholder: "输入搜索关键字"
|
|
|
},
|
|
|
+ navTab: [{
|
|
|
+ url: '/',
|
|
|
+ icon: 'icon-dingzhijiaju',
|
|
|
+ src: '../../images/news/nav_01.png',
|
|
|
+ text: '杯类'
|
|
|
+ },
|
|
|
{
|
|
|
url: '/',
|
|
|
icon: 'icon-dingzhijiaju',
|
|
@@ -67,12 +65,11 @@ Page({
|
|
|
text: '包袋'
|
|
|
}
|
|
|
],
|
|
|
- navArray:[
|
|
|
- {
|
|
|
- src:'/images/news/nav_1.png',
|
|
|
- bg:'#fafcff',
|
|
|
- type:0,
|
|
|
- href:'/'
|
|
|
+ navArray: [{
|
|
|
+ src: '/images/news/nav_1.png',
|
|
|
+ bg: '#fafcff',
|
|
|
+ type: 0,
|
|
|
+ href: '/'
|
|
|
},
|
|
|
{
|
|
|
src: '/images/news/nav_2.png',
|
|
@@ -93,11 +90,11 @@ Page({
|
|
|
href: '/pages/patternMenu/patternMenu'
|
|
|
}
|
|
|
],
|
|
|
- specArray:[],
|
|
|
- navList:["推荐","中秋","改良生活","优化办公","智能科技"],
|
|
|
+ specArray: [],
|
|
|
+ navList: ["推荐", "中秋", "改良生活", "优化办公", "智能科技"],
|
|
|
firstActive: "header_nav_active",
|
|
|
- currentItem : '',
|
|
|
- flag:true,
|
|
|
+ currentItem: '',
|
|
|
+ flag: true,
|
|
|
banners: [],
|
|
|
rexiao: [],
|
|
|
tuijian: [],
|
|
@@ -131,29 +128,33 @@ Page({
|
|
|
find_yuedu: '',
|
|
|
find_shoucang: '',
|
|
|
datatime: new Date().getTime(),
|
|
|
-
|
|
|
+
|
|
|
city_name: '',
|
|
|
- jingpin: {// 发现精品
|
|
|
- id: 1, src: "../../images/jingxuan_banner.jpg", title: "各星座员工生日礼品如何选", liulan: 117, zan: 34
|
|
|
+ jingpin: { // 发现精品
|
|
|
+ id: 1,
|
|
|
+ src: "../../images/jingxuan_banner.jpg",
|
|
|
+ title: "各星座员工生日礼品如何选",
|
|
|
+ liulan: 117,
|
|
|
+ zan: 34
|
|
|
},
|
|
|
page: 1,
|
|
|
hasMore: true,
|
|
|
- hidden : '',
|
|
|
- winHeight: "",//窗口高度
|
|
|
+ hidden: '',
|
|
|
+ winHeight: "", //窗口高度
|
|
|
coupon: coupon, //优惠劵
|
|
|
- showCoupon : false,
|
|
|
- couponSta : 0,//对于用户来说,是否是第一次显示
|
|
|
- un_id : '',
|
|
|
- showMsg : true, //显示切换模式提示
|
|
|
- showChangeModel : false, //显示切换模式确认弹窗
|
|
|
- bannerFlag : 0, //banner数量
|
|
|
- recommendArray:[], // /推荐数组
|
|
|
- goodsNewsArray:[], //按照时间排序来
|
|
|
+ showCoupon: false,
|
|
|
+ couponSta: 0, //对于用户来说,是否是第一次显示
|
|
|
+ un_id: '',
|
|
|
+ showMsg: true, //显示切换模式提示
|
|
|
+ showChangeModel: false, //显示切换模式确认弹窗
|
|
|
+ bannerFlag: 0, //banner数量
|
|
|
+ recommendArray: [], // /推荐数组
|
|
|
+ goodsNewsArray: [], //按照时间排序来
|
|
|
// channelId:null ,//用户登录后的id
|
|
|
- page:1, //默认第一页
|
|
|
- limit:10, //展示的数量
|
|
|
- requestState:true, //请求状态,默认是有数据的
|
|
|
- loginStatic:false, //登陆状态,默认为false
|
|
|
+ page: 1, //默认第一页
|
|
|
+ limit: 10, //展示的数量
|
|
|
+ requestState: true, //请求状态,默认是有数据的
|
|
|
+ loginStatic: false, //登陆状态,默认为false
|
|
|
},
|
|
|
|
|
|
//tab切换
|
|
@@ -162,7 +163,7 @@ Page({
|
|
|
var name = options.currentTarget.dataset.name;
|
|
|
var des = options.currentTarget.dataset.des;
|
|
|
var forid = options.currentTarget.dataset.forid;
|
|
|
- wx:wx.navigateTo({
|
|
|
+ wx: wx.navigateTo({
|
|
|
url: '/pages/kindSecondList/kindSecondList?classify_name=' + name + '&classify_des=' + des + '&id=' + forid
|
|
|
})
|
|
|
},
|
|
@@ -172,14 +173,14 @@ Page({
|
|
|
var that = this;
|
|
|
var host = getApp().globalData.servsers;
|
|
|
var current = e.detail.current;
|
|
|
- if (e.detail.current == 0){
|
|
|
+ if (e.detail.current == 0) {
|
|
|
var forid = 0;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
var forid = that.data.navList[e.detail.current - 1].id;
|
|
|
var forname = that.data.navList[e.detail.current - 1].classify_name;
|
|
|
var classifydes = that.data.navList[e.detail.current - 1].classify_des;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
this.setData({
|
|
|
currentItem: e.detail.current
|
|
|
})
|
|
@@ -232,7 +233,7 @@ Page({
|
|
|
//设置当前样式
|
|
|
that.setData({
|
|
|
'firstActive': "",
|
|
|
- 'currentItem':0,
|
|
|
+ 'currentItem': 0,
|
|
|
flag: true,
|
|
|
})
|
|
|
}
|
|
@@ -255,11 +256,11 @@ Page({
|
|
|
var host = getApp().globalData.servsers;
|
|
|
var un_id = getApp().globalData.un_id;
|
|
|
that.setData({
|
|
|
- urlHttp : host
|
|
|
+ urlHttp: host
|
|
|
})
|
|
|
//首页banner
|
|
|
wx.request({
|
|
|
- url: host+"homebannerapi/homebannerall",
|
|
|
+ url: host + "homebannerapi/homebannerall",
|
|
|
data: {},
|
|
|
method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
|
header: {
|
|
@@ -272,11 +273,11 @@ Page({
|
|
|
});
|
|
|
console.log(res.data.rows);
|
|
|
//判断banner位置是否为空
|
|
|
- for (var i = 0; i < res.data.rows.length;i++){
|
|
|
+ for (var i = 0; i < res.data.rows.length; i++) {
|
|
|
var bannerFlag = that.data.bannerFlag;
|
|
|
- if (bannerFlag > 0){
|
|
|
+ if (bannerFlag > 0) {
|
|
|
return false;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
if (res.data.rows[i].banner_flag == 0) {
|
|
|
bannerFlag++;
|
|
|
that.setData({
|
|
@@ -284,7 +285,7 @@ Page({
|
|
|
})
|
|
|
return false;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
//console.log(that.data.banners);
|
|
|
if (res == null || res.data == null) {
|
|
@@ -293,13 +294,13 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
|
|
|
//品牌定制
|
|
|
wx.request({
|
|
|
url: host + "brandapi/findforfirst",
|
|
|
data: {},
|
|
|
- method: 'GET',
|
|
|
+ method: 'GET',
|
|
|
header: {
|
|
|
'Accept': 'application/json'
|
|
|
},
|
|
@@ -308,7 +309,7 @@ Page({
|
|
|
that.setData({
|
|
|
hidden: 'hidden'
|
|
|
})
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
var img = res.data.rows[0].brand_logo;
|
|
|
that.setData({
|
|
|
title1: res.data.rows[0].brand_name,
|
|
@@ -342,7 +343,7 @@ Page({
|
|
|
// })
|
|
|
} else {
|
|
|
var img = res.data.rows[0].brand_logo;
|
|
|
- that.setData({
|
|
|
+ that.setData({
|
|
|
title3: res.data.rows[2].brand_name,
|
|
|
intro3: res.data.rows[2].brand_des,
|
|
|
src3: res.data.rows[2].brand_logo,
|
|
@@ -369,11 +370,11 @@ Page({
|
|
|
winHeight: calc
|
|
|
});
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
+ });
|
|
|
+
|
|
|
},
|
|
|
|
|
|
- onReady:function(e){
|
|
|
+ onReady: function (e) {
|
|
|
var that = this;
|
|
|
var host = getApp().globalData.servsers;
|
|
|
|
|
@@ -419,39 +420,39 @@ Page({
|
|
|
})
|
|
|
var un_id = res.data.unionId;
|
|
|
|
|
|
- if (parseInt(nowTime) >= parseInt(beginTimestamp) && parseInt(nowTime) <= parseInt(endTimestamp)) {//当前日期在优惠劵领取时间内
|
|
|
+ if (parseInt(nowTime) >= parseInt(beginTimestamp) && parseInt(nowTime) <= parseInt(endTimestamp)) { //当前日期在优惠劵领取时间内
|
|
|
console.log("un_id:" + un_id);
|
|
|
- if (un_id != undefined && un_id != '' && un_id != null){
|
|
|
- wx.request({//优惠活动-对于用户来说,是否应该显示
|
|
|
- url: host + "mycouponapi/getAlertFlag",
|
|
|
- data: {
|
|
|
- user_id: un_id,
|
|
|
- batch_no: 1,
|
|
|
- alert_num: 1//优惠活动对于每个用户来说,一共显示的次数
|
|
|
- },
|
|
|
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
|
- header: {
|
|
|
- 'Accept': 'application/json'
|
|
|
- },
|
|
|
- success: function (res) {
|
|
|
- if (res.data == 0) {
|
|
|
- that.setData({
|
|
|
- showCoupon: true
|
|
|
- })
|
|
|
- } else {
|
|
|
- that.setData({
|
|
|
- showCoupon: false
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- if (res == null || res.data == null) {
|
|
|
- console.error('网络请求失败');
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (un_id != undefined && un_id != '' && un_id != null) {
|
|
|
+ wx.request({ //优惠活动-对于用户来说,是否应该显示
|
|
|
+ url: host + "mycouponapi/getAlertFlag",
|
|
|
+ data: {
|
|
|
+ user_id: un_id,
|
|
|
+ batch_no: 1,
|
|
|
+ alert_num: 1 //优惠活动对于每个用户来说,一共显示的次数
|
|
|
+ },
|
|
|
+ method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
|
+ header: {
|
|
|
+ 'Accept': 'application/json'
|
|
|
+ },
|
|
|
+ success: function (res) {
|
|
|
+ if (res.data == 0) {
|
|
|
+ that.setData({
|
|
|
+ showCoupon: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.setData({
|
|
|
+ showCoupon: false
|
|
|
+ })
|
|
|
}
|
|
|
- });
|
|
|
+
|
|
|
+ if (res == null || res.data == null) {
|
|
|
+ console.error('网络请求失败');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
if (res == null || res.data == null) {
|
|
|
console.error('网络请求失败');
|
|
@@ -463,20 +464,20 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
|
|
|
footerTap: app.footerTap,
|
|
|
|
|
|
- onShow:function(){
|
|
|
+ onShow: function () {
|
|
|
var that = this;
|
|
|
- that.onLoad();
|
|
|
+ that.onLoad();
|
|
|
//商品推荐
|
|
|
that.getGoodsRecommendList(that);
|
|
|
// 按照时间排序
|
|
|
that.setData({
|
|
|
- goodsNewsArray:[],
|
|
|
- page:1,
|
|
|
+ goodsNewsArray: [],
|
|
|
+ page: 1,
|
|
|
})
|
|
|
that.getGoodsNews(that)
|
|
|
that.getSpecList(that)
|
|
@@ -488,27 +489,27 @@ Page({
|
|
|
},
|
|
|
|
|
|
//跳转到“发现”tab页
|
|
|
- find:function(e){
|
|
|
+ find: function (e) {
|
|
|
wx.switchTab({
|
|
|
- url : "/pages/find/index"
|
|
|
+ url: "/pages/find/index"
|
|
|
})
|
|
|
},
|
|
|
- getSpecList(that){
|
|
|
+ getSpecList(that) {
|
|
|
wx.request({
|
|
|
- url: host+'/classifyapi/classifyTwoAll',
|
|
|
- method:'get',
|
|
|
- data:{
|
|
|
- classifyHigher:3072
|
|
|
+ url: host + '/classifyapi/classifyTwoAll',
|
|
|
+ method: 'get',
|
|
|
+ data: {
|
|
|
+ classifyHigher: 3072
|
|
|
},
|
|
|
- success:function(res){
|
|
|
+ success: function (res) {
|
|
|
console.log(res)
|
|
|
that.setData({
|
|
|
- specArray:res.data.rows
|
|
|
+ specArray: res.data.rows
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- onReachBottom(){
|
|
|
+ onReachBottom() {
|
|
|
var that = this;
|
|
|
if (that.data.requestState) {
|
|
|
that.setData({
|
|
@@ -520,9 +521,9 @@ Page({
|
|
|
},
|
|
|
//下拉刷新
|
|
|
onPullDownRefresh: function (e) {
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
- onShareAppMessage: function (res) {//页面分享
|
|
|
+ onShareAppMessage: function (res) { //页面分享
|
|
|
var that = this;
|
|
|
var host = getApp().globalData.servsers;
|
|
|
if (res.from === 'button') {
|
|
@@ -530,10 +531,10 @@ Page({
|
|
|
console.log(res.target)
|
|
|
}
|
|
|
return {
|
|
|
- title:'大良造-精良之选,用心造物!',
|
|
|
+ title: '大良造-精良之选,用心造物!',
|
|
|
path: '/pages/index/index',
|
|
|
success: function (res) {
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
// 转发失败
|
|
@@ -541,23 +542,23 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
//关闭优惠劵弹窗
|
|
|
- closeCoupon:function(e){
|
|
|
+ closeCoupon: function (e) {
|
|
|
var that = this;
|
|
|
that.setData({
|
|
|
- showCoupon : false
|
|
|
+ showCoupon: false
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//关闭切换模式提示
|
|
|
- closeMsg:function(e){
|
|
|
+ closeMsg: function (e) {
|
|
|
var that = this;
|
|
|
that.setData({
|
|
|
- showMsg : false
|
|
|
+ showMsg: false
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//打开切换提示
|
|
|
- openChangeModel:function(e){
|
|
|
+ openChangeModel: function (e) {
|
|
|
var that = this;
|
|
|
that.setData({
|
|
|
showMsg: false,
|
|
@@ -566,10 +567,10 @@ Page({
|
|
|
},
|
|
|
|
|
|
//跳转至一键选礼
|
|
|
- goChooseGift:function(e){
|
|
|
+ goChooseGift: function (e) {
|
|
|
var that = this;
|
|
|
that.setData({
|
|
|
- showChangeModel : false
|
|
|
+ showChangeModel: false
|
|
|
})
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/patternMenu/patternMenu'
|
|
@@ -577,35 +578,35 @@ Page({
|
|
|
},
|
|
|
|
|
|
//关闭切换模式确认弹窗
|
|
|
- closeChangeModel:function(e){
|
|
|
+ closeChangeModel: function (e) {
|
|
|
var that = this;
|
|
|
that.setData({
|
|
|
showChangeModel: false
|
|
|
})
|
|
|
},
|
|
|
- // 商品推荐
|
|
|
- getGoodsRecommendList(that){
|
|
|
- let data ={
|
|
|
+ // 商品推荐
|
|
|
+ getGoodsRecommendList(that) {
|
|
|
+ let data = {
|
|
|
limit: 6,
|
|
|
offset: 1,
|
|
|
channelId: wx.getStorageSync('channelIdObj').channelId ? wx.getStorageSync('channelIdObj').channelId : ""
|
|
|
}
|
|
|
wx.request({
|
|
|
url: host + '/commodityapi/queryCommodityGroom',
|
|
|
- method:"get",
|
|
|
+ method: "get",
|
|
|
data: data,
|
|
|
- success(res){
|
|
|
+ success(res) {
|
|
|
res.data.rows.forEach(el => {
|
|
|
el.logo = el.commodity_logo.split(",")
|
|
|
})
|
|
|
that.setData({
|
|
|
- recommendArray:res.data.rows
|
|
|
+ recommendArray: res.data.rows
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
// 按时间排序来的
|
|
|
- getGoodsNews(that){
|
|
|
+ getGoodsNews(that) {
|
|
|
let data = {
|
|
|
limit: that.data.limit,
|
|
|
offset: that.data.page,
|
|
@@ -618,25 +619,26 @@ Page({
|
|
|
success(res) {
|
|
|
let goods = that.data.goodsNewsArray;
|
|
|
console.log(goods)
|
|
|
- if (that.data.page == 1){
|
|
|
+ if (that.data.page == 1) {
|
|
|
goods = [];
|
|
|
}
|
|
|
goods.push(...res.data.rows);
|
|
|
console.log(goods)
|
|
|
that.setData({
|
|
|
goodsNewsArray: goods,
|
|
|
- requestState: res.data.rows.length === that.data.limit
|
|
|
+ requestState: res.data.rows.length === that.data.limit
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
toGoodsDetail(e) { // 进入商品详情页
|
|
|
- let that = this, id = e.currentTarget.dataset.id;
|
|
|
+ let that = this,
|
|
|
+ id = e.currentTarget.dataset.id;
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/buy/buy?com_id=' + id,
|
|
|
})
|
|
|
},
|
|
|
- navTap(e){
|
|
|
+ navTap(e) {
|
|
|
// console.log(e);
|
|
|
let item = e.currentTarget.dataset.item;
|
|
|
if (item.type == 1 && !wx.getStorageSync('channelIdObj')) { // 表示是优质的杯,并且还没有登录过渠道
|
|
@@ -649,16 +651,16 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- tapMomo(){
|
|
|
- if (!wx.getStorageSync('channelIdObj')) { // 还没有登录过渠道
|
|
|
- wx.navigateTo({
|
|
|
- url: '/pages/login/login?url=/pages/momo/momo',
|
|
|
- })
|
|
|
- } else {
|
|
|
- wx.switchTo({
|
|
|
- url: '/pages/momo/momo',
|
|
|
- })
|
|
|
- }
|
|
|
+ tapMomo() {
|
|
|
+ // if (!wx.getStorageSync('channelIdObj')) { // 还没有登录过渠道
|
|
|
+ // wx.navigateTo({
|
|
|
+ // url: '/pages/login/login?url=/pages/momo/momo',
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // wx.switchTo({
|
|
|
+ // url: '/pages/momo/momo',
|
|
|
+ // })
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
})
|
|
@@ -674,4 +676,4 @@ var pinpai = []
|
|
|
// 人气推荐
|
|
|
var tuijian = []
|
|
|
var that;
|
|
|
-var Util = require('../../utils/util.js');
|
|
|
+var Util = require('../../utils/util.js');
|