// pages/followGoods/followGoods.js
|
var listData = require('../../data/test-data.js');
|
var utils = require("../../utils/util.js");
|
var app = getApp();
|
|
// var has
|
|
Page({
|
|
/**
|
* 页面的初始数据
|
*/
|
data: {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面加载
|
*/
|
onLoad: function(options) {
|
// var followGoods = listData.followGoods;
|
// this.setData({
|
// followGoods:followGoods
|
// })
|
wx.request({
|
url: utils.getUrl('/shopping/confirm.do?m=isLogin'),
|
header: {
|
"Cookie": "JSESSIONID=" + wx.getStorageSync('sessionID')
|
},
|
success: res => {
|
if(!utils.requestError(res)){
|
return false;
|
}
|
|
if (!res.data.isLogin) {
|
wx.redirectTo({
|
url: '../authorize/authorize'
|
})
|
return false;
|
}
|
|
},
|
fail: function(errmsg) {
|
utils.requestFail(errmsg,'/shopping/confirm.do');
|
}
|
})
|
|
// 获取设置
|
|
wx.request({
|
url: utils.getUrl('/shopping/getSettingEntity.do'),
|
header: {
|
"Cookie": "JSESSIONID=" + wx.getStorageSync('sessionID')
|
},
|
success: res => {
|
|
wx.hideLoading();
|
// if (res.data.error && res.data.error.warning !== "") {
|
// utils.showModal(res.data.error.warning);
|
// return false;
|
// }
|
if(!utils.requestError(res)){
|
return false;
|
}
|
|
this.setData({
|
homeLayoutStyle: res.data.homeLayoutStyle
|
})
|
|
// if (res.data.homeLayoutStyle=="Cosmo"){
|
// return false;
|
// }
|
|
},
|
fail: function(errmsg) {
|
utils.requestFail(errmsg,'/shopping/getSettingEntity.do');
|
}
|
})
|
|
|
},
|
|
// 取消关注
|
cancelFollow: function(e) {
|
var that = this;
|
var matcode = e.currentTarget.dataset.matcode;
|
console.log(e)
|
wx.showModal({
|
title: '',
|
content: '确定要取消关注吗?',
|
success: res => {
|
if (res.confirm) {
|
// var followGoods = listData.followGoods;
|
// followGoods.splice(index,1);
|
// that.setData({
|
// followGoods: followGoods
|
// })
|
|
wx.showLoading();
|
wx.request({
|
url: utils.getUrl('/shopping/wishlist.do?m=del&matcode=' + matcode),
|
header: {
|
"Cookie": "JSESSIONID=" + wx.getStorageSync('sessionID')
|
},
|
success: res => {
|
|
wx.hideLoading();
|
if(!utils.requestError(res)){
|
return false;
|
}
|
|
// this.setData({
|
// followGoods: res.data.list
|
// })
|
this.getFollowgoods();
|
|
},
|
fail: function(errmsg) {
|
utils.requestFail(errmsg,'/shopping/wishlist.do');
|
}
|
})
|
} else if (res.cancel) {
|
console.log('用户点击取消')
|
}
|
}
|
})
|
},
|
|
// 前往商品
|
goDetail(e) {
|
if(this.data.homeLayoutStyle=="Normal"){
|
wx.navigateTo({
|
url: '../detail/detail?matcode='+e.currentTarget.dataset.matcode,
|
})
|
}
|
// else if(this.data.homeLayoutStyle=="Cosmo"){
|
// wx.navigateTo({
|
// url: '../detail/detail?id=' + e.currentTarget.dataset.matcode,
|
// })
|
// }
|
},
|
|
// 获取关注商品列表
|
getFollowgoods(e) {
|
wx.showLoading();
|
wx.request({
|
url: utils.getUrl('/shopping/wishlist.do?m=getWishList'),
|
header: {
|
"Cookie": "JSESSIONID=" + wx.getStorageSync('sessionID')
|
},
|
success: res => {
|
|
wx.hideLoading();
|
if(!utils.requestError(res)){
|
return false;
|
}
|
|
this.setData({
|
followGoods: res.data.list
|
})
|
|
|
},
|
fail: function(errmsg) {
|
utils.requestFail(errmsg,'/shopping/wishlist.do');
|
}
|
})
|
},
|
|
/**
|
* 生命周期函数--监听页面初次渲染完成
|
*/
|
onReady: function() {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面显示
|
*/
|
onShow: function() {
|
this.getFollowgoods();
|
},
|
|
/**
|
* 生命周期函数--监听页面隐藏
|
*/
|
onHide: function() {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面卸载
|
*/
|
onUnload: function() {
|
|
},
|
|
/**
|
* 页面相关事件处理函数--监听用户下拉动作
|
*/
|
onPullDownRefresh: function() {
|
|
},
|
|
/**
|
* 页面上拉触底事件的处理函数
|
*/
|
onReachBottom: function() {
|
|
},
|
|
/**
|
* 用户点击右上角分享
|
*/
|
// onShareAppMessage: function() {
|
|
// }
|
})
|