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.

46 lines
1.1 KiB

8 years ago
var app = getApp()
8 years ago
const product = require('../../utils/product.js')
8 years ago
Page({
8 years ago
data: {items: [], slides: []},
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
}
})