13轮播图预览更换头像

导读:本篇文章讲解 13轮播图预览更换头像,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

预览

detail.wxml

<!-- 轮播 -->
<swiper>
  <swiper-item wx:for="{{ goodsInfo.slides }}" wx:key="index">
    <image 
      src="{{ 'http://localhost:3000' + item }}" 
      mode="widthFix"
      bindtap="handlePreview"
      data-url="{{ 'http://localhost:3000' + item }}"
     />
  </swiper-item>
</swiper>

detail.js

  // 预览界面
  handlePreview (e) {
    wx.previewImage({
      current: e.currentTarget.dataset.url, // 当前显示图片的http链接
      // 相对路径映射为绝对路径
      urls: this.data.goodsInfo.slides.map(item => 'http://localhost:3000' + item) // 需要预览的图片http链接列表
    })
  }

换头像

center.wxml

<!-- -----------------授权--------------------- -->
<!-- !users是storage不为空 -->
<view wx:if="{{ !users }}">
  <!-- open-type、getUserInfo、bindgetuserinfo 是固定的(官方) -->
  <button open-type="getUserInfo" bindgetuserinfo="handleGetUserInfo">授权</button>
</view>
<!-- 如果storage为空 -->
<view wx:else>
  <!-- 显示头像 -->
  <view style="text-align: center">
    <image src="{{ users.avatarUrl }}" bindtap="handleChangeImage"></image>
  </view>
  <!-- 显示昵称 -->
  <view>{{ users.nickName }}</view>
  <!-- 定位 -->
  <button bindtap="handleLocation">定位</button>
</view>

center.js

  // 定位
  handleLocation () {
      wx.getLocation({
        type: 'gcj02', //返回可以用于wx.openLocation的经纬度
        success (res) {
          const latitude = res.latitude
          const longitude = res.longitude
          wx.openLocation({
            latitude,
            longitude,
            scale: 18
          })
        }
      })
  }

app.json

  "permission": {
    "scope.userLocation": {
      "desc": "你的位置信息将用于小程序位置接口的效果展示"
    }
  }

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之家整理,本文链接:https://www.bmabk.com/index.php/post/4553.html

(0)
小半的头像小半

相关推荐

极客之家——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!