|
|
@@ -66,11 +66,11 @@ Page({
|
|
|
'return': '0',
|
|
|
'class': '5'
|
|
|
},
|
|
|
- window: false,
|
|
|
- iShiddenTip: false,
|
|
|
- isAuto: false, //是否自动授权;
|
|
|
- iShidden: true, //是否隐藏;
|
|
|
- isGoIndex: false, //是否返回首页;
|
|
|
+ window: false, // 是否显示优惠券窗口
|
|
|
+ iShiddenTip: false, // 是否显示提示
|
|
|
+ isAuto: true, // 是否自动授权;
|
|
|
+ iShidden: true, // 是否隐藏;
|
|
|
+ isGoIndex: false, // 是否返回首页;
|
|
|
navH: "",
|
|
|
recommend: {
|
|
|
loadend: false,
|
|
|
@@ -109,7 +109,13 @@ Page({
|
|
|
iShiddenTip: true
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
+ // 挖矿组件绑定
|
|
|
+ onNeedLogin: function () {
|
|
|
+ this.setData({
|
|
|
+ iShidden: false
|
|
|
+ })
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
@@ -122,16 +128,22 @@ Page({
|
|
|
wxh.selfLocation(1);
|
|
|
this.getCategoryData();
|
|
|
// this.getCoupon();
|
|
|
- this.get_host_product();
|
|
|
+ this.get_hot_product();
|
|
|
this.get_product_list();
|
|
|
this.setData({
|
|
|
navH: app.globalData.navHeight
|
|
|
});
|
|
|
- if (options.spid) app.globalData.spid = options.spid;
|
|
|
- if (options.scene) app.globalData.code = decodeURIComponent(options.scene);
|
|
|
- if (wx.getStorageSync('msg_key')) this.setData({
|
|
|
- iShiddenTip: true
|
|
|
- });
|
|
|
+ if (options.spid) {
|
|
|
+ app.globalData.spid = options.spid;
|
|
|
+ }
|
|
|
+ if (options.scene) {
|
|
|
+ app.globalData.code = decodeURIComponent(options.scene);
|
|
|
+ }
|
|
|
+ if (wx.getStorageSync('msg_key')) {
|
|
|
+ this.setData({
|
|
|
+ iShiddenTip: true
|
|
|
+ });
|
|
|
+ }
|
|
|
this.getTemlIds();
|
|
|
this.getLiveList();
|
|
|
},
|
|
|
@@ -140,15 +152,19 @@ Page({
|
|
|
let messageTmplIds = wx.getStorageSync(CACHE_SUBSCRIBE_MESSAGE);
|
|
|
if (!messageTmplIds) {
|
|
|
getTemlIds().then(res => {
|
|
|
- if (res.data)
|
|
|
+ if (res.data) {
|
|
|
wx.setStorageSync(CACHE_SUBSCRIBE_MESSAGE, JSON.stringify(res.data));
|
|
|
+ }
|
|
|
}).catch(() => {})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
//授权
|
|
|
onLoadFun: function () {
|
|
|
- //this.getCoupon();
|
|
|
+ // 挖矿组件认证回调
|
|
|
+ if (this.data.cpnMine != null) {
|
|
|
+ this.data.cpnMine.onLoadFun();
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
catchTouchMove: function (res) {
|
|
|
@@ -167,7 +183,9 @@ Page({
|
|
|
*/
|
|
|
onReady: function () {},
|
|
|
|
|
|
- /** 轮播监听 */
|
|
|
+ /**
|
|
|
+ * 轮播监听
|
|
|
+ */
|
|
|
bindchange(e) {
|
|
|
var index = e.detail.current;
|
|
|
this.setData({
|
|
|
@@ -219,21 +237,6 @@ Page({
|
|
|
logoUrl: res.data.logoUrl,
|
|
|
couponList: res.data.couponList,
|
|
|
});
|
|
|
- // 检测是否授权;scope.userInfo存在为授权;
|
|
|
- wx.getSetting({
|
|
|
- success(res) {
|
|
|
- if (!res.authSetting['scope.userInfo']) {
|
|
|
- that.setData({
|
|
|
- window: that.data.couponList.length ? true : false
|
|
|
- });
|
|
|
- } else {
|
|
|
- that.setData({
|
|
|
- window: false,
|
|
|
- iShidden: true
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
app.setUnread(res.data.notice);
|
|
|
})
|
|
|
@@ -282,7 +285,7 @@ Page({
|
|
|
/**
|
|
|
* 获取我的推荐
|
|
|
*/
|
|
|
- get_host_product: function (isPage) {
|
|
|
+ get_hot_product: function (isPage) {
|
|
|
var that = this;
|
|
|
if (that.data.recommend.loadend) return;
|
|
|
if (that.data.recommend.loading) return;
|
|
|
@@ -314,48 +317,49 @@ Page({
|
|
|
|
|
|
/** 点击上方活动标签按钮 */
|
|
|
onTapCategoryTabItem: function (event) {
|
|
|
- let that = this,
|
|
|
- activeTabIndex = event.detail.index;
|
|
|
+ let activeTabIndex = event.detail.index;
|
|
|
if (activeTabIndex <= 0 || activeTabIndex > this.data.categoryOne.children.length) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- that.setData({
|
|
|
- activeTabIndex: activeTabIndex
|
|
|
- })
|
|
|
- // 黑洞
|
|
|
this.setData({
|
|
|
- cpnMine: this.selectComponent('#mine'),
|
|
|
+ activeTabIndex: activeTabIndex
|
|
|
})
|
|
|
+
|
|
|
if (this.data.categoryOne.children[activeTabIndex - 1].id === 199) {
|
|
|
+ // 黑洞
|
|
|
+ if (this.data.cpnMine == null) {
|
|
|
+ this.setData({
|
|
|
+ cpnMine: this.selectComponent('#mine'),
|
|
|
+ })
|
|
|
+ }
|
|
|
var _ = this.data.cpnMine && this.data.cpnMine.show()
|
|
|
return
|
|
|
} else {
|
|
|
var _ = this.data.cpnMine && this.data.cpnMine.hide()
|
|
|
}
|
|
|
|
|
|
- that.setData({
|
|
|
+ this.setData({
|
|
|
'where.page': 1,
|
|
|
loadend: false,
|
|
|
loading: false,
|
|
|
- 'where.cid': that.data.categoryOne.id,
|
|
|
- 'where.sid': that.data.categoryOne.children[activeTabIndex - 1].id,
|
|
|
+ 'where.cid': this.data.categoryOne.id,
|
|
|
+ 'where.sid': this.data.categoryOne.children[activeTabIndex - 1].id,
|
|
|
categoryActive: 0
|
|
|
})
|
|
|
- that.get_product_list(true);
|
|
|
+ this.get_product_list(true);
|
|
|
},
|
|
|
|
|
|
productTap: function (e) {
|
|
|
- let that = this,
|
|
|
- index = e.currentTarget.dataset.indexn;
|
|
|
- that.setData({
|
|
|
+ let index = e.currentTarget.dataset.indexn;
|
|
|
+ this.setData({
|
|
|
categoryActive: index,
|
|
|
'where.page': 1,
|
|
|
loadend: false,
|
|
|
loading: false,
|
|
|
- 'where.sid': that.data.categoryOne[that.data.activeTabIndex - 1].children[index].id
|
|
|
+ 'where.sid': this.data.categoryOne[this.data.activeTabIndex - 1].children[index].id
|
|
|
})
|
|
|
- that.get_product_list(true);
|
|
|
+ this.get_product_list(true);
|
|
|
},
|
|
|
|
|
|
get_product_list: function (isPage) {
|
|
|
@@ -411,51 +415,42 @@ Page({
|
|
|
|
|
|
// 页面事件, 不再使用
|
|
|
setTime: function (e) {
|
|
|
- var that = this,
|
|
|
- index = e.currentTarget.dataset.index;
|
|
|
- that.setData({
|
|
|
+ let index = e.currentTarget.dataset.index;
|
|
|
+ this.setData({
|
|
|
killIndex: index,
|
|
|
status: that.data.timeList[index].status
|
|
|
})
|
|
|
- that.getSeckillLists();
|
|
|
+ // that.getSeckillLists();
|
|
|
},
|
|
|
|
|
|
// 不再触发
|
|
|
- getSeckillLists: function () {
|
|
|
- let that = this;
|
|
|
- let timeId = that.data.timeList[that.data.killIndex].id;
|
|
|
- getSeckillList(timeId, {
|
|
|
- page: 1,
|
|
|
- limit: 20
|
|
|
- }).then(res => {
|
|
|
- that.setData({
|
|
|
- seckillList: res.data
|
|
|
- })
|
|
|
-
|
|
|
- if (this.data.timeList.length) {
|
|
|
- let query = wx.createSelectorQuery().in(this);
|
|
|
- query.select('.timeLen').boundingClientRect(function (res) {
|
|
|
- if (res) {
|
|
|
- that.setData({
|
|
|
- scrollLeft: (that.data.killIndex - 1.8) * res.width
|
|
|
- });
|
|
|
- }
|
|
|
- }).exec();
|
|
|
- if (that.data.killIndex === that.data.seckillTimeIndex) {
|
|
|
- that.setData({
|
|
|
- killIndexLen: res.data.length
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }).catch(() => {});
|
|
|
- },
|
|
|
-
|
|
|
- // 秒杀详情
|
|
|
- // goDetail: function (e) {
|
|
|
- // let index = this.data.timeList[this.data.killIndex];
|
|
|
- // wx.navigateTo({
|
|
|
- // url: '/pages/activity/goods_seckill_details/index?id=' + e.currentTarget.dataset.id + '&time=' + index.stop + '&status=' + index.status
|
|
|
- // })
|
|
|
+ // getSeckillLists: function () {
|
|
|
+ // let that = this;
|
|
|
+ // let timeId = that.data.timeList[that.data.killIndex].id;
|
|
|
+ // getSeckillList(timeId, {
|
|
|
+ // page: 1,
|
|
|
+ // limit: 20
|
|
|
+ // }).then(res => {
|
|
|
+ // that.setData({
|
|
|
+ // seckillList: res.data
|
|
|
+ // })
|
|
|
+
|
|
|
+ // if (this.data.timeList.length) {
|
|
|
+ // let query = wx.createSelectorQuery().in(this);
|
|
|
+ // query.select('.timeLen').boundingClientRect(function (res) {
|
|
|
+ // if (res) {
|
|
|
+ // that.setData({
|
|
|
+ // scrollLeft: (that.data.killIndex - 1.8) * res.width
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // }).exec();
|
|
|
+ // if (that.data.killIndex === that.data.seckillTimeIndex) {
|
|
|
+ // that.setData({
|
|
|
+ // killIndexLen: res.data.length
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }).catch(() => {});
|
|
|
// },
|
|
|
|
|
|
/** 获取分类列表 */
|
|
|
@@ -469,52 +464,52 @@ Page({
|
|
|
},
|
|
|
|
|
|
/** 获取优惠券列表 不再触发*/
|
|
|
- getCoupon: function () {
|
|
|
- var that = this;
|
|
|
- getCoupons({
|
|
|
- page: 1,
|
|
|
- limit: 6
|
|
|
- }).then(res => {
|
|
|
- that.setData({
|
|
|
- getCouponList: res.data
|
|
|
- })
|
|
|
- }).catch(err => {
|
|
|
- // app.Tips({
|
|
|
- // title: err
|
|
|
- // });
|
|
|
- });
|
|
|
- },
|
|
|
+ // getCoupon: function () {
|
|
|
+ // var that = this;
|
|
|
+ // getCoupons({
|
|
|
+ // page: 1,
|
|
|
+ // limit: 6
|
|
|
+ // }).then(res => {
|
|
|
+ // that.setData({
|
|
|
+ // getCouponList: res.data
|
|
|
+ // })
|
|
|
+ // }).catch(err => {
|
|
|
+ // // app.Tips({
|
|
|
+ // // title: err
|
|
|
+ // // });
|
|
|
+ // });
|
|
|
+ // },
|
|
|
|
|
|
// 页面回调,不再触发
|
|
|
- receiveCoupon: function (e) {
|
|
|
- if (!app.globalData.isLog) {
|
|
|
- this.setData({
|
|
|
- iShidden: false
|
|
|
- });
|
|
|
- } else {
|
|
|
- var that = this;
|
|
|
- var list = that.data.getCouponList;
|
|
|
- var index = e.currentTarget.dataset.index;
|
|
|
- var id = that.data.getCouponList[index].id;
|
|
|
- getCouponReceive({
|
|
|
- couponId: id
|
|
|
- })
|
|
|
- .then(function () {
|
|
|
- list[index].is_use = true;
|
|
|
- that.setData({
|
|
|
- getCouponList: that.data.getCouponList
|
|
|
- })
|
|
|
- app.Tips({
|
|
|
- title: "领取成功"
|
|
|
- });
|
|
|
- })
|
|
|
- .catch(function (err) {
|
|
|
- // app.Tips({
|
|
|
- // title: err
|
|
|
- // });
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
+ // receiveCoupon: function (e) {
|
|
|
+ // if (!app.globalData.isLog) {
|
|
|
+ // this.setData({
|
|
|
+ // iShidden: false
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // var that = this;
|
|
|
+ // var list = that.data.getCouponList;
|
|
|
+ // var index = e.currentTarget.dataset.index;
|
|
|
+ // var id = that.data.getCouponList[index].id;
|
|
|
+ // getCouponReceive({
|
|
|
+ // couponId: id
|
|
|
+ // })
|
|
|
+ // .then(function () {
|
|
|
+ // list[index].is_use = true;
|
|
|
+ // that.setData({
|
|
|
+ // getCouponList: that.data.getCouponList
|
|
|
+ // })
|
|
|
+ // app.Tips({
|
|
|
+ // title: "领取成功"
|
|
|
+ // });
|
|
|
+ // })
|
|
|
+ // .catch(function (err) {
|
|
|
+ // // app.Tips({
|
|
|
+ // // title: err
|
|
|
+ // // });
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // },
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
@@ -553,7 +548,7 @@ Page({
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function () {
|
|
|
- this.get_host_product();
|
|
|
+ this.get_hot_product();
|
|
|
this.get_product_list();
|
|
|
},
|
|
|
|