123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- // newsShop/pages/patternMenu/patternMenu.js
- let app = getApp();
- let host = app.globalData.servsers; // 请求的url
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- host: host,
- requestState: true, //检测请求状态是否结束了
- filterStatic: false,
- goodsList: [],
- page: 1, //默认是第一页
- limit: 20, //一页20条数据
- requestState: true, //默认是可以向下请求的
- loginStatic: false, //登陆状态,默认为false
- tabBar: {
- "color": "#2d2d2d",
- "selectedColor": "#e81021",
- "borderStyle": "white",
- "backgroundColor": "#fff",
- "list": [{
- "pagePath": "/pages/index/index",
- "iconPath": "../../images/news/home.png",
- "selectedIconPath": "images/news/home_select.png",
- "text": "首页"
- },
- {
- "pagePath": "/pages/kind/index",
- "iconPath": "../../images/news/classify.png",
- "selectedIconPath": "images/news/classify_select.png",
- "text": "分类"
- },
- {
- "pagePath": "/pages/car/index",
- "iconPath": "../../images/news/car.png",
- "selectedIconPath": "images/news/car_select.png",
- "text": "购物车"
- },
- {
- "pagePath": "/pages/mine/mine",
- "iconPath": "../../images/news/user.png",
- "selectedIconPath": "images/news/user_select.png",
- "text": "我的"
- }
- ]
- },
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
-
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- let that = this;
- that.setData({
- goodsList:[],
- })
- if (!wx.getStorageSync('channelIdObj')) { // 还没有登录过渠道
- wx.navigateTo({
- url: '/pages/login/login?url=/pages/momo/momo&&type=1&&back=2',
- })
- } else {
- that.getGiftList(that)
- }
- if (wx.getStorageSync('channelIdObj').channelId) {
- that.setData({
- loginStatic: true,
- })
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- let that = this;
- if (that.data.requestState) {
- that.setData({
- page: that.data.page + 1
- })
- that.getGiftList(that)
- }
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- getGiftList(that) {
- let data = {
- limit: that.data.limit, // 一页20条数据
- offset: that.data.page, //当前页数
- channelId: wx.getStorageSync('channelIdObj').channelId ? wx.getStorageSync('channelIdObj').channelId : ""
- }
- wx.request({
- url: host + '/queryAllCommodityByChannelId',
- method: 'get',
- data: data,
- success(res) {
- let dataArray = that.data.goodsList;
- res.data.rows.forEach(el => {
- el.logo = el.commodity_logo.split(",")
- })
- dataArray.push(...res.data.rows)
- that.setData({
- goodsList: dataArray,
- requestState: res.data.rows.length == that.data.limit
- })
- }
- })
- },
- toGoodsDetail(e) { // 进入商品详情页
- let that = this,
- id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/buy/buy?com_id=' + id,
- })
- }
- })
|