收藏
回答

底部tab栏目点击有跳转但没选中颜色,需要二次点击

框架类型 问题类型 终端类型 微信版本 基础库版本
小程序 Bug 微信iOS客户端 7.1 3
{
  "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

回答关注问题邀请回答
收藏

4 个回答

  • carry
    carry
    星期四 16:46
    const cityData = require('./data.js').cityData;
    
    
    Page({
      data: {
        rest"",
        lat"",
        lng"",
        page1,
        pageSize15,
        multiArray: [
          [],
          [],
        ], // 用于存储省市区数据
        multiIndex: [00], // 用于存储选择的省市区的索引
        cities: ['北京''上海''广州''深圳'],
        currentCity'北京',
        searchQuery'',
        selectedCity'',
        selectedTitle'',
        oneStoressData: [],
        noDatafalse// 新增字段,用于判断是否显示“暂无数据”
        showModaltrue// 新增字段,用于显示弹窗
      },
      onLoadfunction () {
        // 检查本地是否已存储手机号
        const phoneNumber = wx.getStorageSync('phoneNumber');
        if (phoneNumber) {
          this.setData({
            showModalfalse,
            phoneNumber: phoneNumber
          });
        }
    
    
        if (!this.data.phoneNumber) {
          this.setData({
            showModaltrue
          });
        } 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();
      },
    
    
      getUserLocationfunction () {
        wx.getFuzzyLocation({
          type'wgs84',
          isHighAccuracytrue,
          success(res) => {
            console.log(res);
            const latitude = res.latitude;
            const longitude = res.longitude;
    
    
            // 调用腾讯位置服务 API 获取城市名称
            this.reverseGeocode(latitude, longitude);
          },
          fail(err) => {
            console.log('获取位置失败', err);
          }
        });
      },
    
    
      reverseGeocodefunction (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);
          }
        });
      },
    
    
      setCitySelectionfunction (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 !== 0break;
        }
    
    
        this.setData({
          multiArray: [
            cityData.map(item => item.name),
            cityData[provinceIndex].city
          ],
          multiIndex: [provinceIndex, cityIndex]
        });
      },
    
    
      bindMultiPickerChangefunction (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);
        }
      },
      onSearchfunction () {
        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({
          page1,
          oneStoressData: []
        });
        console.log(data);
        this.storesList(data, true);
      },
    
    
      bindMultiPickerColumnChangefunction (e{
        const data = {
          multiArraythis.data.multiArray,
          multiIndexthis.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);
      },
    
    
      onReservefunction (e{
        const phoneNumber = e.currentTarget.dataset.id;
        wx.makePhoneCall({
          phoneNumber: phoneNumber //仅为示例,并非真实的电话号码
        });
      },  我页面已经跳过去了,nerwork请求啥的都有了 就是底下的图标没有亮,
    我的js代码 也没有进行tab的其他操作啊 ?
    
    星期四 16:46
    有用
    回复
  • 星跃
    星跃
    星期四 13:53

    参考这里:【小程序自定义tabbar,根据权限显示不同的tabbar

    https://developers.weixin.qq.com/community/develop/article/doc/00066ca64a8990e7cfb1bef3366013

    星期四 13:53
    有用
    回复
  • showms
    showms
    星期四 11:20

    自定义tabbar切换到对应页面后还要手动设置选中状态,可以参考文章

    https://developers.weixin.qq.com/community/develop/article/doc/0004e6554dcc78585f5a5668456813

    星期四 11:20
    有用
    回复 2
    • carry
      carry
      星期四 16:43
      好像跟我这个没啥关系? 我页面已经跳过去了,nerwork请求啥的都有了 就是底下的图标没有亮
      星期四 16:43
      回复
    • showms
      showms
      星期四 18:03回复carry
      页面跳过去后要手动再置为选中状态哈,看下文章
      星期四 18:03
      回复
  • Wei
    Wei
    星期四 11:09

    你这里使用了自定义tabbar,是否是受你这个页面的逻辑影响导致,例如:第一次点击后执行了耗时操作,或者点击后没有修改对tabbar的下标等

    星期四 11:09
    有用
    回复 2
    • carry
      carry
      星期四 16:45
      我页面已经跳过去了,nerwork请求啥的都有了 就是底下的图标没有亮,
      我的js代码 也没有进行tab的其他操作啊 ?
      星期四 16:45
      回复
    • carry
      carry
      星期四 16:46
      老哥 代码贴在底下回复
      星期四 16:46
      回复
登录 后发表内容