{
"pages": [
"pages/home/home",
"pages/stores/stores",
"pages/goods/category/index",
"pages/cart/index",
"pages/usercenter/index",
"pages/usercenter/person-info/index",
"pages/usercenter/address/list/index",
"pages/usercenter/address/edit/index",
"pages/goods/details/index",
"pages/goods/search/index",
"pages/goods/result/index",
"pages/order/order-confirm/index",
"pages/order/receipt/index",
"pages/order/pay-result/index",
"pages/order/order-list/index",
"pages/order/order-detail/index",
"pages/goods/comments/index",
"pages/order/apply-service/index",
"pages/order/after-service-list/index",
"pages/order/after-service-detail/index",
"pages/goods/comments/create/index",
"pages/coupon/coupon-list/index",
"pages/coupon/coupon-detail/index",
"pages/coupon/coupon-activity-goods/index",
"pages/promotion-detail/index",
"pages/order/fill-tracking-no/index",
"pages/order/delivery-detail/index",
"pages/order/invoice/index",
"pages/usercenter/name-edit/index"
],
"tabBar": {
"custom": true,
"color": "#666666",
"selectedColor": "#FF5F15",
"backgroundColor": "#ffffff",
"borderStyle": "black",
"list": [
{
"pagePath": "pages/home/home",
"text": "店家笔记"
},
{
"pagePath": "pages/goods/category/index",
"text": "行业资讯"
},
{
"pagePath": "pages/stores/stores",
"text": "附近门店"
},
{
"pagePath": "pages/cart/index",
"text": "卖家笔记"
},
{
"pagePath": "pages/usercenter/index",
"text": "会员中心"
}
]
},
"requiredPrivateInfos": [
"getFuzzyLocation"
],
"lazyCodeLoading": "requiredComponents",
"usingComponents": {},
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json",
"permission": {
"scope.userFuzzyLocation": {
"desc": "你的位置信息将用于小程序为您推送商家的位置"
}
}
}
z这是我的app.json
附近门店这个栏目每次都需要点2次图标才能选中
视频:https://easylink.cc/548iqf
const cityData = require('./data.js').cityData; Page({ data: { rest: "", lat: "", lng: "", page: 1, pageSize: 15, multiArray: [ [], [], ], // 用于存储省市区数据 multiIndex: [0, 0], // 用于存储选择的省市区的索引 cities: ['北京', '上海', '广州', '深圳'], currentCity: '北京', searchQuery: '', selectedCity: '', selectedTitle: '', oneStoressData: [], noData: false, // 新增字段,用于判断是否显示“暂无数据” showModal: true, // 新增字段,用于显示弹窗 }, onLoad: function () { // 检查本地是否已存储手机号 const phoneNumber = wx.getStorageSync('phoneNumber'); if (phoneNumber) { this.setData({ showModal: false, phoneNumber: phoneNumber }); } if (!this.data.phoneNumber) { this.setData({ showModal: true }); } else { // let data = `title=${this.data.selectedTitle}&city=${this.data.selectedCity}`; // this.storesList(data); } const provinces = cityData.map(item => item.name); const cities = cityData[0].city; this.setData({ multiArray: [provinces, cities] }); // 获取用户位置 this.getUserLocation(); }, getUserLocation: function () { wx.getFuzzyLocation({ type: 'wgs84', isHighAccuracy: true, success: (res) => { console.log(res); const latitude = res.latitude; const longitude = res.longitude; // 调用腾讯位置服务 API 获取城市名称 this.reverseGeocode(latitude, longitude); }, fail: (err) => { console.log('获取位置失败', err); } }); }, reverseGeocode: function (latitude, longitude) { console.log(latitude, longitude); const key = 'kWPKGqN5uO3XxLdSuoFQM0WcCp26WjeE'; // 请替换为你自己的腾讯地图密钥 wx.request({ url: `https://api.map.baidu.com/reverse_geocoding/v3/?ak=${key}&output=json&coordtype=wgs84ll&location=${latitude},${longitude}`, success: (res) => { console.log(res.data.result); const city = res.data.result.addressComponent.city; const lat = res.data.result.location.lat; const lng = res.data.result.location.lng; this.setData({ lat: lat, lng: lng, selectedCity: city }); console.log(city, lat, lng); this.setCitySelection(city); let data = `title=${this.data.selectedTitle}&city=${this.data.selectedCity}`; this.storesList(data); }, fail: (err) => { console.log('逆地址解析失败', err); } }); }, setCitySelection: function (city) { let provinceIndex = 0; let cityIndex = 0; for (let i = 0; i < cityData.length; i++) { const cities = cityData[i].city; for (let j = 0; j < cities.length; j++) { if (cities[j].indexOf(city) !== -1) { provinceIndex = i; cityIndex = j; break; } } if (cityIndex !== 0) break; } this.setData({ multiArray: [ cityData.map(item => item.name), cityData[provinceIndex].city ], multiIndex: [provinceIndex, cityIndex] }); }, bindMultiPickerChange: function (e) { this.setData({ multiIndex: e.detail.value }); const selectedProvince = this.data.multiArray[0][this.data.multiIndex[0]]; const selectedCity = this.data.multiArray[1][this.data.multiIndex[1]]; this.setData({ selectedCity: selectedCity }); console.log(`选择的省份: ${selectedProvince}, 选择的城市: ${selectedCity}`); if (selectedCity == "全国") { this.seachAllData(0); } else { this.seachAllData(1); } }, onSearch: function () { this.seachAllData(2); }, seachAllData(type) { let data = ''; if (type === 0) { data = ``; } else if (type === 1) { data = `city=${this.data.selectedCity}`; } else if (type === 2) { data = `title=${this.data.selectedTitle}&city=${this.data.selectedCity}`; } this.setData({ page: 1, oneStoressData: [] }); console.log(data); this.storesList(data, true); }, bindMultiPickerColumnChange: function (e) { const data = { multiArray: this.data.multiArray, multiIndex: this.data.multiIndex }; data.multiIndex[e.detail.column] = e.detail.value; if (e.detail.column === 0) { const cities = cityData[e.detail.value].city; data.multiArray[1] = cities; data.multiIndex[1] = 0; } this.setData(data); }, onReserve: function (e) { const phoneNumber = e.currentTarget.dataset.id; wx.makePhoneCall({ phoneNumber: phoneNumber //仅为示例,并非真实的电话号码 }); }, 我页面已经跳过去了,nerwork请求啥的都有了 就是底下的图标没有亮, 我的js代码 也没有进行tab的其他操作啊 ?
参考这里:【小程序自定义tabbar,根据权限显示不同的tabbar
】https://developers.weixin.qq.com/community/develop/article/doc/00066ca64a8990e7cfb1bef3366013
自定义tabbar切换到对应页面后还要手动设置选中状态,可以参考文章
https://developers.weixin.qq.com/community/develop/article/doc/0004e6554dcc78585f5a5668456813
你这里使用了自定义tabbar,是否是受你这个页面的逻辑影响导致,例如:第一次点击后执行了耗时操作,或者点击后没有修改对tabbar的下标等
我的js代码 也没有进行tab的其他操作啊 ?
const data = {
multiArray: this.data.multiArray,
multiIndex: this.data.multiIndex
};
data.multiIndex[e.detail.column] = e.detail.value;
if (e.detail.column === 0) {
const cities = cityData[e.detail.value].city;
data.multiArray[1] = cities;
data.multiIndex[1] = 0;
}
this.setData(data);
},
onReserve: function (e) {
const phoneNumber = e.currentTarget.dataset.id;
wx.makePhoneCall({
phoneNumber: phoneNumber //仅为示例,并非真实的电话号码
});
},