favourableList.js 3.17 KB
// pack-cookbook/pages/favourableList.js
import util from '../../utils/util'
import App from '../../utils/api';
Page({

    /**
     * 页面的初始数据
     */
    data: {
        sellerName: '',
        sellerid: '',
        oid: '',
        types:'',
        priceInfo: '',
        scoreInfo: '',
        certificate: '',
        rid:'',
        list: [],
		dataStr: Date.now() * 1 / 1000,
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.setData({
            sellerName: options.sellerName,
            sellerid: options.sellerid,
            oid: options.oid,
            types:options.types,
            rid:options.rid?options.rid:'',
        })
        console.log('options',{...options});
        this.getList()
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {},
    getList() {
        App.Activity.GetNewRechargeList({
            sellerid: this.data.sellerid,
        }).then(res => {
            let arr=[]
            res.data.forEach(i=>{
                if(i.status!='1'){
                    arr.push(i)
                }
            })
            let list = arr;
            list.forEach((item,index) => {
                item.recharge_lists = item.recharge_list ? JSON.parse(item.recharge_list) : '';
                let recharge_lists = item.recharge_lists;
                item.priceInfo = '';
                item.scoreInfo = '';
                item.certificate = '';
                if (recharge_lists.is_price == '1') item.priceInfo = '会员充值满' + item.recharge_money + '元赠送' + item.recharge_lists.price + '元余额';
                if (recharge_lists.is_score == '1') item.scoreInfo = '会员充值满' + item.recharge_money + '元赠送' + item.recharge_lists.score + '积分';
                if (recharge_lists.is_coupons == '1' && recharge_lists.coupons_names.length > 0) item.certificate = recharge_lists.coupons_names.join('、');
            })
            // 筛选出 未过期的 && 开启状态的充值活动
            list = list.filter(item=>{return (this.data.dataStr<(item.etime*1) || !item.etime) && item.is_open == '1'})
            this.setData({
                list
            })
        })
    },
    gogoSingle(e) {
        const id = e.currentTarget.dataset['id'];
        let url = util.http_build_query({
            sid: this.data.sellerid,
            name: this.data.sellerName,
            types: this.data.types,
            oid: this.data.oid,
            rid:this.data.rid?this.data.rid:'',
            id
        }, '/pack-activity/pack/vipRecharge')
        wx.navigateTo({
            url
        })
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})