提交 4d714944 编写于 作者: api工厂's avatar api工厂

修复首页分类点进分类页面左侧分类未选中的问题

上级 497b0ac9
module.exports = {
version: '9.7.0',
note: '收货地址增加经纬度定位', // 这个为版本描述,无需修改
version: '9.7.1',
note: '修复首页分类点进分类页面左侧分类未选中的问题', // 这个为版本描述,无需修改
subDomain: 'tz', // 此处改成你自己的专属域名。什么是专属域名?请看教程 https://www.it120.cc/help/qr6l4m.html
sdkAppID: 1400450467, // 腾讯实时音视频应用编号,请看教程 https://www.it120.cc/help/nxoqsl.html
}
\ No newline at end of file
......@@ -37,8 +37,12 @@ Page({
let categories = [];
let categoryName = '';
let categoryId = '';
let activeCategory = 0
if (res.code == 0) {
if (this.data.categorySelected.id) {
activeCategory = res.data.findIndex(ele => {
return ele.id == this.data.categorySelected.id
})
const _curCategory = res.data.find(ele => {
return ele.id == this.data.categorySelected.id
})
......@@ -55,6 +59,7 @@ Page({
}
}
this.setData({
activeCategory,
categories: categories,
categorySelected: {
name: categoryName,
......@@ -122,7 +127,7 @@ Page({
}
})
const _categoryId = wx.getStorageSync('_categoryId')
wx.removeStorageSync('_categoryId')
// wx.removeStorageSync('_categoryId')
if (_categoryId) {
this.data.categorySelected.id = _categoryId
this.categories();
......
......@@ -33,7 +33,7 @@ Page({
},
tabClick: function(e) {
wx.setStorageSync("_categoryId", e.currentTarget.id)
wx.setStorageSync("_categoryId", e.currentTarget.dataset.id)
wx.switchTab({
url: '/pages/category/category',
})
......
......@@ -48,7 +48,7 @@
</view>
<view class="category-box">
<view class="category-list" wx:for="{{categories}}" wx:key="id">
<view class="category-column {{activeCategoryId == item.id ? 'type-item-on' : ''}}" bindtap="tabClick" id="{{item.id}}">
<view class="category-column {{activeCategoryId == item.id ? 'type-item-on' : ''}}" bindtap="tabClick" data-id="{{item.id}}">
<image mode="aspectFill" class="category-imgbox" src="{{item.icon}}"></image>
<view class="category-title">{{item.name}}</view>
</view>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册