极简天色之小夭天色

1、应用周末两天的时候,参考小天色的作风,撸了一个天色小顺序,【小夭天色】。
2、功用非常简朴,检察当前区域的天色和搜刮其他区域的天色,增加了能够天生图片分享出去。
3、上线后发明一个题目,就是极速供应的天色接口对区级市没有辨别,比方 上海有宝山区,东北那也有一个。就没有辨别。这是一个bug
4、其他有什么题目迎接人人提意见和发起。

迎接人人扫码体验

《极简天色之小夭天色》

概况以下

《极简天色之小夭天色》

《极简天色之小夭天色》

《极简天色之小夭天色》

《极简天色之小夭天色》

《极简天色之小夭天色》

《极简天色之小夭天色》

部份代码以下:

    <!-- 天生图片 -->
    <view class="saveimage" wx:if="{{canvasPic}}">
      <view class="loading" wx:if="{{loading}}"><image src="../images/loading.gif" class="loading"></image></view>
      <canvasdrawer painting="{{painting}}" bind:getImage="eventGetImage"/>
      <view class="picbox">
          <view class="saveimageCont"><image src="{{shareImage}}" mode="widthFix"></image></view>
          <button class="keep" catchtap='eventSave'>{{shareText}}</button> 
          <text class="keep keep2" bindtap="closesaveimage">返回</text>
      </view>
    </view>
        <!--挑选区域-->
        <view class="selectArea {{getLotion === '' ? 'nomargin' :'' }}" wx:if="{{selectArea}}">
            <!-- 返回 -->
            <view class="selectAreaBox" :dss="getLotion">
                <view class="back" wx:if="{{getLotion === 'null' || getLotion !== ''}}">
                    <view class="backIcon" bindtap="back">
                        <image src="../images/back.png" class="img"></image>
                    </view>
                </view>
                <view class="input">
                    <input type="text" class="Jinput" placeholder="请输入区域"  bindinput='writeArea' value="{{inpuText}}" ></input>
                    <image src="../images/serchicon.png" class="imgicon"></image>
                    <view class="clear" bindtap="clearInpuText"><image src="../images/clear.png" class="clearicon"></image></view>
                    <view class="sureBtn" bindtap="inputGoWeather"><image src="../images/surebtn.png" class="sureicon"></image></view>
                </view>
                <view class="tips">历史记录</view>
                <view class="hisCity">
                    <view class="hisCityBtn" data-city="{{list}}" wx:for="{{historyArea}}" wx:for-item="list" wx:key wx:if="historyArea.length > 0"  bindtap="goWeather">{{list}}</view>
                </view>
                <view class="tips">热点都市</view>
                <view class="recCity">
                     <view class="recCityBtn getLocation" bindtap="selectLocation"><image class="getLocationimg" src="../images/hoticon.png"></image>定位</view>
                    <view class="recCityBtn" data-city="{{list}}" wx:for="{{hotArea}}" wx:for-item="list" wx:key bindtap="goWeather">{{list}}</view>
                </view>
            </view>
        </view> 
 getWeatherData:function(city){
    var _this = this,
          thisdata = this.data,
          historyArea = thisdata.historyArea;
    wx.request({
      url: _this.data.api,
      data: {
        "city": city
      },
      method: 'get',
      header: {
        'Content-Type': 'application/json'
      },
      dataType: 'jsonp',
      jsonp: 'callback',
      success: function (res) {
        var res = res.data
        res = JSON.parse(res)
        if (res.status === "0") {
          var data = res['result']
          data.img = '../images/condicon/'+data.img+'b.png'
          _this.setData({
            getSuccess: 'true',
            getLotion: city,
            realdata: data,
            clock: data.updatetime,
            aqi: data['aqi'],
            aqiMsg: data.aqi.aqiinfo['affect'] + ',' + data.aqi.aqiinfo['measure'],
            life: data['index'],
            daily: data['daily'],
            hourly: data['hourly'],
            airPredict: '两小时以后天色' + data.hourly[2].weather + ' ,温度 ' + data.hourly[2].temp + '°',
            quality: data['aqi'].quality
          })
          // 搜刮返回胜利后 消灭 输入框,将搜刮效果放入历史记录
          // _this.$refs.clearText.value = ''
          if (thisdata.inpuText !== '') {
            if (thisdata.historyArea.indexOf(thisdata.inpuText) === -1) {
              historyArea.push(thisdata.inpuText)
              _this.setData({
                historyArea: historyArea
              })
            }
          }
          _this.back()
        } else {
          wx.showModal({
            title: '提醒',
            content: res.msg,
            success: function (res) {
              if (res.confirm) {
                _this.setData({
                  msgText: '位置猎取失利!!!请手动挑选',
                  loadingBtn: true
                })
              } else if (res.cancel) {
                console.log('用户点击作废')
              }
            }
          })
        }
      },
// 定位猎取
  selectLocation: function () {
    let _this = this
    _this.getlocation();
  },
  getlocation: function () {
    var _this = this
    wx.getLocation({
      type: 'wgs84',
      success: function (res) {
        console.log(res)
        var latitude = res.latitude
        var longitude = res.longitude
        var speed = res.speed
        var accuracy = res.accuracy
        qqmapsdk.reverseGeocoder({
          location: {
            latitude: latitude,
            longitude: longitude
          },
          success: function (res) { 
            console.log(res)
            _this.setData({
              getLotion: res.result.address_component.district ? res.result.address_component.district : res.result.address_component.city
            })
            wx.setNavigationBarTitle({
              title: res.result.address_component.district
            })
            _this.getWeatherData(res.result.address_component.district)
          }
        })
      },
      fail:function(res){
        _this.setData({
          msgText: '位置猎取失利!!!请手动挑选',
          loadingBtn:true
        })
      }
    })
  },
    原文作者:故事胶片
    原文地址: https://segmentfault.com/a/1190000017977639
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞