network 检测在WiFi 下似乎有问题,先不要他了

wechat_user_type
Ge Hao 8 years ago
parent 81ad935d69
commit 942a4cda8d
  1. 47
      pages/index/index.js

@ -39,29 +39,30 @@ Page({
}) })
}) })
wx.getNetworkType({ product.getProducts(function(result) {
success: function(res) { var data = getApp().store.sync(result.data)
var networkType = res.networkType // 返回网络类型2g,3g,4g,wifi that.setData({
if (networkType) { items: data,
product.getProducts(function(result) { popularity_products: data.filter(product => product.flag === '最热'),
var data = getApp().store.sync(result.data) new_products: data.filter(product => product.flag === '新品'),
that.setData({ hot_products: data.filter(product => product.flag === '火爆'),
items: data, })
popularity_products: data.filter(product => product.flag === '最热'), wx.setStorageSync('products', data)
new_products: data.filter(product => product.flag === '新品'),
hot_products: data.filter(product => product.flag === '火爆'),
})
wx.setStorageSync('products', data)
})
} else {
cache = wx.getStorageSync('products')
if (cache) {
that.setData({'items': cache})
} else {
that.setData({'items': []})
}
}
}
}) })
// wx.getNetworkType({
// success: function(res) {
// var networkType = res.networkType // 返回网络类型2g,3g,4g,wifi
// if (networkType) {
// } else {
// cache = wx.getStorageSync('products')
// if (cache) {
// that.setData({'items': cache})
// } else {
// that.setData({'items': []})
// }
// }
// }
// })
} }
}) })

Loading…
Cancel
Save