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.
 

37 lines
905 B

var app = getApp()
const product = require('../../utils/product.js')
Page({
data: {items: [], slides: []},
onLoad: function() {
var that = this
product.getSlides().then(function(result) {
that.setData({'slides': result.data.data})
wx.setStorage({
key:"indexSlides",
data:result.data
})
})
wx.getNetworkType({
success: function(res) {
var networkType = res.networkType // 返回网络类型2g,3g,4g,wifi
if (networkType) {
product.getProducts().then(function(result) {
that.data.items = result.data.data
wx.setStorageSync('products', result.data)
})
} else {
cache = wx.getStorageSync('products')
if (cache) {
this.data.items = cache
} else {
this.data.items = []
}
}
}
})
}
})