购物车页面收货地址实现

接口未正确配置:wx.chooseAddress、wx.chooseLocation、wx.getL

  "requiredPrivateInfos": [
      "getLocation",
      "chooseAddress"
  ]
<!-- 收货地址 开始 -->
<view class="recevie_address_row">
    <view class="address_btn" wx:if="{{!address}}">
        <button type="warn" plain bindtap="handleChooseAddress">获取收货地址</button>
    </view>

    <view wx:else class="user_info_row">
        <view class="user_info">
            <view>收货人:{{address.userName}},{{address.telNumber}}</view>
            <view>{{address.provinceName+address.cityName+address.countyName+address.detailInfo}}</view>
        </view>

        <view class="change_address_btn">
            <button size="mini" plain>更换地址</button>
        </view>
    </view>
</view>
<!-- 收货地址 结束 -->
.recevie_address_row{
    .address_btn{
        padding: 20rpx;
        button{
            width: 60%;
        }
    }
    
    .user_info_row{
        display: flex;
        padding: 20rpx;
        .user_info{
            flex:5;
        }
        .change_address_btn{
            flex: 3;
            text-align: right;
            button{
                border: 1px solid gray;
                font-weight: normal;
            }
        }
    }
}
{
  "usingComponents": {},
  "navigationBarTitleText": "购物车"
}
// pages/cart/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    address:{}
  },
  handleChooseAddress(){ 
      console.log("handleChooseAddress")
    wx.chooseAddress({
        success:(result)=>{
            console.log(result)
            wx.setStorageSync('address', result)
        },
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    console.log("show")
    const address=wx.getStorageSync('address')
    this.setData({
        address
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})

你可能感兴趣的:(分布式小程序电商2,chrome,javascript,前端)