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.

38 lines
905 B

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
onLoad: function() {
var that = this
8 years ago
8 years ago
product.getSlides().then(function(result) {
that.setData({'slides': result.data.data})
wx.setStorage({
key:"indexSlides",
data:result.data
})
})
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) {
8 years ago
that.data.items = result.data.data
wx.setStorageSync('products', result.data)
8 years ago
})
} else {
cache = wx.getStorageSync('products')
if (cache) {
this.data.items = cache
} else {
this.data.items = []
}
}
8 years ago
}
})
8 years ago
}
})