You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.5 KiB
104 lines
2.5 KiB
var app = getApp();
|
|
var WXAPI = require('../../utils/server.js');
|
|
Page({
|
|
data: {
|
|
remind: '加载中',
|
|
},
|
|
onLoad: function (options) {
|
|
|
|
},
|
|
//下拉刷新
|
|
onPullDownRefresh: function () {
|
|
wx.showNavigationBarLoading() //在标题栏中显示加载
|
|
this.collection();
|
|
wx.hideNavigationBarLoading() //完成停止加载
|
|
wx.stopPullDownRefresh() //停止下拉刷新
|
|
},
|
|
//页面加载完成函数
|
|
onReady: function () {
|
|
var that = this;
|
|
},
|
|
onShow: function () {
|
|
// 页面显示
|
|
this.collection();
|
|
},
|
|
alldel: function () {
|
|
var that = this;
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '确定要清除全部商品吗?',
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
WXAPI.delallFavorites({
|
|
accessId: app.globalData.accessId,
|
|
storeId: 239,
|
|
storeType: 1,
|
|
}).then(res => {
|
|
if (res.code == 200) {
|
|
wx.showToast({
|
|
title: '清理成功!',
|
|
duration: 2000
|
|
});
|
|
that.collection();
|
|
} else {
|
|
wx.showToast({
|
|
title: res.message,
|
|
duration: 2000
|
|
});
|
|
}
|
|
});
|
|
} else if (res.cancel) {
|
|
console.log('用户点击取消')
|
|
}
|
|
}
|
|
})
|
|
},
|
|
collection: function () {
|
|
var that = this;
|
|
WXAPI.favorites({
|
|
accessId: app.globalData.accessId,
|
|
storeId: 239,
|
|
storeType: 1,
|
|
type: 1
|
|
}).then(res => {
|
|
if (res.code == 200) {
|
|
var data = res.data
|
|
that.setData({
|
|
list: data.list,
|
|
remind: ''
|
|
})
|
|
}
|
|
});
|
|
},
|
|
// 取消收藏
|
|
removeFavorites: function (e) {
|
|
console.log(e)
|
|
var that = this;
|
|
var collection_id = e.currentTarget.dataset.favId;
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '你确认取消收藏吗',
|
|
success: function (res) {
|
|
res.confirm && WXAPI.removeFavorites({
|
|
accessId: app.globalData.accessId,
|
|
storeId: 239,
|
|
storeType: 1,
|
|
collection: collection_id,
|
|
}).then(res => {
|
|
if (res.code == 200) {
|
|
wx.showToast({
|
|
title: res.data.succ,
|
|
duration: 2000
|
|
});
|
|
that.collection();
|
|
} else {
|
|
wx.showToast({
|
|
title: res.message,
|
|
duration: 2000
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|