detail.js 4.4 KB
function t(t, o, a) {
    return o in t ? Object.defineProperty(t, o, {
        value: a,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[o] = a, t;
}

var o, a = require("../../../utils/network.js");

getApp();

Page({
    data: (o = {
        rankchecked: !0,
        term_id: "",
        scrollTop: 0,
        scrollHeight: 0,
        hidden: !0,
        goodsList: [],
        order: ""
    }, t(o, "hidden", !1), t(o, "page", 1), t(o, "hasMore", !0), o),
    getgoods: function(t) {
        var o = this;
        a.POST({
            url: "index//ajax_goods_term",
            header: "application/x-www-form-urlencoded",
            params: {
                p: o.data.page,
                termid: o.data.term_id,
                order: t
            },
            success: function(t) {
                if (wx.showNavigationBarLoading(), "success" == t.data.state) {
                    console.log(t);
                    var a = t.data.goods;
                    o.setData({
                        goodsList: a
                    }), o.data.goodsList.length < 10 && o.setData({
                        hasMore: !1,
                        goodsList: a
                    }), wx.hideNavigationBarLoading();
                }
            }
        });
    },
    loadMore: function() {
        var t = this;
        t.setData({
            hasMore: !0
        }), console.log(t.data.hasMore), t.data.hasMore && (++t.data.page, a.POST({
            url: "index/ajax_goods_term",
            header: "application/x-www-form-urlencoded",
            params: {
                p: t.data.page,
                termid: t.data.term_id,
                order: ""
            },
            success: function(o) {
                wx.showNavigationBarLoading(), console.log(o.data.goods), "success" == o.data.state && (t.setData({
                    goodsList: t.data.goodsList.concat(o.data.goods),
                    hasMore: !1
                }), wx.hideNavigationBarLoading());
            }
        }));
    },
    onLoad: function(t) {
        this.getgoods(""), this.setData({
            term_id: t.term_id
        });
        var o = this;
        wx.getSystemInfo({
            success: function(t) {
                o.setData({
                    scrollHeight: t.windowHeight
                });
            }
        }), o.getgoods("");
    },
    multiple: function() {
        this.setData({
            order: "",
            page: 1
        }), this.getgoods("");
    },
    sales: function() {
        this.setData({
            order: "sales",
            page: 1
        }), this.getgoods("sales");
    },
    lastnew: function() {
        this.setData({
            order: "add_time",
            page: 1
        }), this.getgoods("add_time");
    },
    price: function() {
        "priceup" == this.data.order ? (this.setData({
            order: "pricedown"
        }), this.getgoods("pricedown")) : (this.setData({
            order: "priceup"
        }), this.getgoods("priceup"));
    },
    onReady: function() {
        this.getgoods("");
    },
    onShow: function() {
        this.getgoods("");
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function (options) {
     let that = this;
     let ouid;
     // 设置菜单中的转发按钮触发转发事件时的转发内容
     var shareObj = {
      title: '嗒咕商场', // 默认是小程序的名称(可以写slogan等)
      path: '/pages/start/start?share_id=' + wx.getStorageSync('ouid'), // 默认是当前页面,必须是以‘/’开头的完整路径
      imgUrl: '',//自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
      success: function (res) {
       // 转发成功之后的回调
       if (res.errMsg == 'shareAppMessage:ok') { }
      },
      fail: function () {
       // 转发失败之后的回调
       if (res.errMsg == 'shareAppMessage:fail cancel') {
        // 用户取消转发
       } else if (res.errMsg == 'shareAppMessage:fail') {
        // 转发失败,其中 detail message 为详细失败信息
       }
      },
      complete: function () {
       // 转发结束之后的回调(转发成不成功都会执行)
      }
     }
     return shareObj;
    },
});