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.

53 lines
1.4 KiB

8 years ago
const product = require('../../utils/product.js')
8 years ago
Page({
8 years ago
data: {
categories: [2,6,7],
8 years ago
items: [],
slides: [],
navs: [{icon: "../../images/1.png", name: "资产"},
{icon: "../../images/1.png", name: "直销"},
{icon: "../../images/1.png", name: "严选"},
{icon: "../../images/1.png", name: "包装"}]
8 years ago
},
8 years ago
bindShowProduct: function (e) {
wx.navigateTo({
url: `../show_product/show_product?id=${e.currentTarget.dataset.id}`
})
},
8 years ago
onLoad: function() {
var that = this
8 years ago
8 years ago
product.getSlides().then(function(result) {
var data = getApp().store.sync(result.data)
that.setData({'slides': data})
8 years ago
wx.setStorage({
key:"indexSlides",
data:data
8 years ago
})
})
8 years ago
wx.getNetworkType({
success: function(res) {
var networkType = res.networkType // 返回网络类型2g,3g,4g,wifi
if (networkType) {
8 years ago
product.getProducts().then(function(result) {
var data = getApp().store.sync(result.data)
that.setData({'items': data})
wx.setStorageSync('products', data)
8 years ago
})
} else {
cache = wx.getStorageSync('products')
if (cache) {
that.setData({'items': cache})
} else {
that.setData({'items': []})
}
}
8 years ago
}
})
8 years ago
}
})