yuminge-app/yun-min-program-plugin-master/packageC/entry_orders/home/home.js

143 lines
2.9 KiB
JavaScript

// packageC/entry_orders/home/home.js
var app = getApp();
import util from '../../../utils/util.js';
Page({
/**
* 页面的初始数据
*/
data: {
classifyBol:true,
goodsInfoList:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getActivityInfo();
this.getGoodsInfo();
},
classifyBolbtn(){
console.log(this.data.classifyBol);
this.setData({
classifyBol:!this.data.classifyBol
});
},
gotoSearch(){
wx.navigateTo({
url: '/packageB/member/category/search_v2/search_v2?fromPage=1&&kind=POrder',
});
},
goback(e){
wx.navigateBack({
delta: 2
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
getActivityInfo() {
let that = this;
var urlStr = app.getNetAddresss('plugin.pending-order.frontend.wholesale-area.index');
app._getNetWork({
url: urlStr,
success: function (resdata) {
var res = resdata.data;
if (res.result == 1) {
console.log(res);
that.setData({
activity:res.data.activity,
activity_time: res.data.activity.end_time
});
// console.log(that.data.activity_time)
// console.log(Date.parse(util.formatTime(new Date())))
var nowTime = Date.parse(util.formatTime(new Date()));
var setTime = Date.parse(that.data.activity_time.replace(/-/g, '/'));
// console.log(Date.parse(that.data.activity_time.replace(/-/g, '/')))
if (nowTime > setTime){
that.setData({
isfot : false
});
}else{
that.setData({
isfot: true
});
}
}
},
fail: function (res) {
console.log(res);
}
});
},
getGoodsInfo(){
let that = this;
var urlStr = app.getNetAddresss('plugin.pending-order.frontend.wholesale-area.goods-list');
app._getNetWork({
url: urlStr,
data:{
page:1
},
success: function (resdata) {
var res = resdata.data;
if (res.result == 1) {
console.log(res.data.data);
let goods = that.data.goodsInfoList;
goods.push(...res.data.data);
that.setData({
goods:goods
});
}
},
fail: function (res) {
console.log(res);
}
});
}
});