接口API

1、和风天气:给城市名称给出天气+质量状况+未来天气预测

//获得未来三天的天气状况
  getForsecast: function(){
    var that = this;
    return new Promise(function(done){
      wx.request({
        url: 'https://free-api.heweather.com/s6/weather/forecast?location=' + that.data.cityname + '&key=289eb322373d499890558a037ee1d816',
        //必选参数为:location=城市名字 + key=自己申请的密钥
        success: function(res){
          that.setData({
            forecastData: res.data.HeWeather6[0].daily_forecast,
          })
        }
      })
    });
  },

2、腾讯地图:给经纬度返回城市名称

//得到城市名称
  getCity: function(data){
     return new Promise(function(done){
       //2、向腾讯发出网络请求,提交经纬度,并获取城市信息
       wx.request({
         //关于为什么这个url包含的网址用`,因为url里包含了变量
         url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + data + '&key=WV7BZ-IPMK2-PSLU2-C63EH-7FBMF-TTBX3',

         //最开始函数未拆分之前url内带变量,这样写
         //url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=WV7BZ-IPMK2-PSLU2-C63EH-7FBMF-TTBX3`,



         //请求成功
         success: function (locinfo) {
           console.log(locinfo, "地址信息");
           let cityname = locinfo.data.result.address_component.city;
           console.log(cityname, "城市名字");
           //发出消息。传给下一个人
           done(cityname);
         }
     });
  });
 },

3、豆瓣

 let index = 0;
 wx.request({
       url: "http://t.yushu.im/v2/movie/in_theaters?count=6&start="+index,
       //count=6一次请求六条数据
       //start:为请求数据的开始下标

       success: function(res){
            console.log(res.data.subjects);
            that.setData({
              movies: that.data.movies.concat(res.data.subjects)
            })
            index += 6;
       }
     })

4、

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值