category 改成tab 之后要修改传参数的方法了,switchTab不能带参数

master
Ge Hao 7 years ago
parent ed4459f004
commit 2174ba100e
  1. 35
      pages/category/category.js
  2. 6
      pages/index/index.js

@ -6,38 +6,39 @@ Page({
title: '',
items: null,
accountType: '',
categoryType: null
categoryType: null,
categoryTypeId: null
},
onLoad: function(params) {
onLoad: function() {
},
onShow() {
var that = this
this.setData({
title: '巴爷供销社 - ' + params.type,
categoryType: params.type
})
product.getCategories(params.typeId, function(result) {
var cateType = app.globalData.currentCateType
this.setData({categoryType: cateType.typeName, categoryTypeId: cateType.typeId})
if (app.globalData.currentCustomer) {
var accountType = app.globalData.currentCustomer.account_type
that.setData({accountType: accountType})
}
product.getCategories(that.data.categoryTypeId, function(result) {
var data = getApp().store.sync(result.data)
that.setData({items: data})
wx.setStorage({
key: `cate_${params.type}`,
key: `cate_${that.data.categoryType}`,
data: data
})
}, function(fail) {
var key = `cate_${params.type}`
var key = `cate_${that.data.categoryType}`
var data = wx.getStorage(key)
wx.setData({items: data})
})
},
onShow() {
if (app.globalData.currentCustomer) {
var accountType = app.globalData.currentCustomer.account_type
this.setData({accountType: accountType})
}
},
onReady() {
wx.setNavigationBarTitle({ title: this.data.title })
var title = '巴爷供销社 - ' + this.data.categoryType
wx.setNavigationBarTitle({ title: title})
},
bindTapProduct: function(e) {

@ -31,8 +31,10 @@ Page({
},
catchTapCategory: function (e) {
wx.navigateTo({
url: `../category/category?type=${e.currentTarget.dataset.type}&typeId=${e.currentTarget.dataset.typeid}`
var data = e.currentTarget.dataset
app.globalData.currentCateType = {typeName: data.type, typeId: data.typeid}
wx.switchTab({
url: `../category/category`
})
},

Loading…
Cancel
Save