收藏
回答

添加省市区地址电话姓名不能保存到页面

问题模块 框架类型 API/组件名称 终端类型 微信版本 基础库版本
API和组件 小程序 wx.chooseAddress(OBJECT) 工具 V1.023 V1.022

域名明明是对的,为什么不行?



这里保存不了!什么原因?




购物车数据如何跳转到另一个页面去结算?


请专家帮忙解惑!谢谢!


你想反馈一个 Bug 还是 提一个需求?


如果是 Bug:


* Bug 表现是什么?预期表现是什么?


* 如何复现?


* 提供一个最简复现 Demo


如果是需求:


* 你希望有什么能力?


* 你需要这个能力的场景是 ?


最后一次编辑于  2018-01-27  (未经腾讯允许,不得转载)
回答关注问题邀请回答
收藏

12 个回答

  • 万瑞达/文忠
    万瑞达/文忠
    2018-02-03

    老师,怎么不回答?

    2018-02-03
    赞同
    回复
  • 万瑞达/文忠
    万瑞达/文忠
    2018-01-29

    老师专家,怎么没有回贴?

    2018-01-29
    赞同
    回复
  • 万瑞达/文忠
    万瑞达/文忠
    2018-01-29

    以下是user.wxml代码

    <view class="main">
        <view class="header">
            <image src="{{thumb}}" class="thumb"></image>       
            <text class="nickname">{{nickname}}</text>    
        </view>
        <view class="address-box">
            <view class="address-manage">
                <navigator url="/pages/component/address/address">添加您的收货地址</navigator>
            </view>
            <view wx:if="{{hasAddress}}" class="address-list">
                <view>{{addressData.linkMan}}</view>
                <view>{{addressData.mobile}}</view>
                <view>{{selProvince}}{{selCity}}{{selDistrict}}</view>
                <view>{{addressData.address}}</view>
                <view>{{addressData.code}}</view>
            </view>
        </view>
        <view class="orders-box">
            <view class="orders">我的订单</view>
            <view class="orders-list" wx:for="{{orders}}" wx:key="index">
                <view class="orders-number">订单编号:{{item.number}}</view>
                <view class="orders-detail">
                    <image src="{{item.thumb}}"></image>
                    <view class="">{{item.name}}</view>
                    <view class="">{{item.count}}</view>
                    <text class="orders-status">{{item.status}}</text>
                </view>
                <view class="orders-footer">
                    <text>实付:¥{{item.money}}</text>
                    <button size="mini" class="orders-btn" bindtap="payOrders">付款</button>
                </view>
            </view>
        </view>
    </view>

    以下是user.jsl代码

    Page({
      data: {
        thumb: '',
        nickname: '',
         
        orders: [],
        hasAddress: false,
        address: {}
      },
      onLoad() {
        var self = this;
        /**
         * 获取用户信息
         */
        wx.getUserInfo({
          success: function (res) {
            self.setData({
              thumb: res.userInfo.avatarUrl,
              nickname: res.userInfo.nickName
            })
          }
        }),
     
          /**
           * 发起请求获取订单列表信息
           */
          wx.request({
          url: 'https://638058639.gzwrd168.com',
            success(res) {
              self.setData({
                orders: res.data.orders
              })
            }
          })
      },
      onShow() {
        var self = this;
        /**
         * 获取本地缓存 地址信息
         */
        wx.getStorage({
          key: 'address',
          success: function (res) {
            self.setData({
              hasAddress: true,
              address: res.data
            })
          }
        })
      },
      /**
       * 发起支付请求
       */
      payOrders() {
        wx.requestPayment({
          timeStamp: 'String1',
          nonceStr: 'String2',
          package: 'String3',
          signType: 'MD5',
          paySign: 'String4',
          success: function (res) {
            console.log(res)
          },
          fail: function (res) {
            wx.showModal({
              title: '支付提示',
              content: '<text>',
              showCancel: false
            })
          }
        })
      }
    })

    老师,

    帮帮看看如何显示在user页面上!谢谢!

    2018-01-29
    赞同
    回复
  • 万瑞达/文忠
    万瑞达/文忠
    2018-01-29
    var commonCityData = require('../../utils/city.js')
    //获取应用实例
    var app = getApp()
    Page({
      data: {
        provinces: [],
        citys: [],
        districts: [],
        selProvince: '请选择',
        selCity: '请选择',
        selDistrict: '请选择',
        selProvinceIndex: 0,
        selCityIndex: 0,
        selDistrictIndex: 0
      },
      bindCancel: function () {
        wx.navigateBack({})
      },
      bindSave: function (e) {
        var that = this;
        var linkMan = e.detail.value.linkMan;
        var address = e.detail.value.address;
        var mobile = e.detail.value.mobile;
        var code = e.detail.value.code;
     
        if (linkMan == "") {
          wx.showModal({
            title: '提示',
            content: '请填写联系人姓名',
            showCancel: false
          })
          return
        }
        if (mobile == "") {
          wx.showModal({
            title: '提示',
            content: '请填写手机号码',
            showCancel: false
          })
          return
        }
        if (this.data.selProvince == "请选择") {
          wx.showModal({
            title: '提示',
            content: '请选择地区',
            showCancel: false
          })
          return
        }
        if (this.data.selCity == "请选择") {
          wx.showModal({
            title: '提示',
            content: '请选择地区',
            showCancel: false
          })
          return
        }
        var cityId = commonCityData.cityData[this.data.selProvinceIndex].cityList[this.data.selCityIndex].id;
        var districtId;
        if (this.data.selDistrict == "请选择" || !this.data.selDistrict) {
          districtId = '';
        } else {
          districtId = commonCityData.cityData[this.data.selProvinceIndex].cityList[this.data.selCityIndex].districtList[this.data.selDistrictIndex].id;
        }
        if (address == "") {
          wx.showModal({
            title: '提示',
            content: '请填写详细地址',
            showCancel: false
          })
          return
        }
        if (code == "") {
          wx.showModal({
            title: '提示',
            content: '请填写邮编',
            showCancel: false
          })
          return
        }
        var apiAddoRuPDATE = "add";
        var apiAddid = that.data.id;
        if (apiAddid) {
          apiAddoRuPDATE = "update";
        } else {
          apiAddid = 0;
        }
        wx.request({
          url: 'https://638058639.gzwrd168.com',
          data: {
            token: app.globalData.token,
            id: apiAddid,
            provinceId: commonCityData.cityData[this.data.selProvinceIndex].id,
            cityId: cityId,
            districtId: districtId,
            linkMan: linkMan,
            address: address,
            mobile: mobile,
            code: code,
            isDefault: 'true'
          },
          success: function (res) {
            if (res.data.code != 0) {
              // 登录错误
              wx.hideLoading();
              wx.showModal({
                title: '失败',
                content: res.data.msg,
                showCancel: false
              })
              return;
            }
            // 跳转到结算页面
            wx.navigateBack({})
          }
        })
      },
      initCityData: function (level, obj) {
        if (level == 1) {
          var pinkArray = [];
          for (var i = 0; i < commonCityData.cityData.length; i++) {
            pinkArray.push(commonCityData.cityData[i].name);
          }
          this.setData({
            provinces: pinkArray
          });
        } else if (level == 2) {
          var pinkArray = [];
          var dataArray = obj.cityList
          for (var i = 0; i < dataArray.length; i++) {
            pinkArray.push(dataArray[i].name);
          }
          this.setData({
            citys: pinkArray
          });
        } else if (level == 3) {
          var pinkArray = [];
          var dataArray = obj.districtList
          for (var i = 0; i < dataArray.length; i++) {
            pinkArray.push(dataArray[i].name);
          }
          this.setData({
            districts: pinkArray
          });
        }
     
      },
      bindPickerProvinceChange: function (event) {
        var selIterm = commonCityData.cityData[event.detail.value];
        this.setData({
          selProvince: selIterm.name,
          selProvinceIndex: event.detail.value,
          selCity: '请选择',
          selCityIndex: 0,
          selDistrict: '请选择',
          selDistrictIndex: 0
        })
        this.initCityData(2, selIterm)
      },
      bindPickerCityChange: function (event) {
        var selIterm = commonCityData.cityData[this.data.selProvinceIndex].cityList[event.detail.value];
        this.setData({
          selCity: selIterm.name,
          selCityIndex: event.detail.value,
          selDistrict: '请选择',
          selDistrictIndex: 0
        })
        this.initCityData(3, selIterm)
      },
      bindPickerChange: function (event) {
        var selIterm = commonCityData.cityData[this.data.selProvinceIndex].cityList[this.data.selCityIndex].districtList[event.detail.value];
        if (selIterm && selIterm.name && event.detail.value) {
          this.setData({
            selDistrict: selIterm.name,
            selDistrictIndex: event.detail.value
          })
        }
      },
      onLoad: function (e) {
        var that = this;
        this.initCityData(1);
        var id = e.id;
        if (id) {
          // 初始化原数据
          wx.showLoading();
          wx.request({
            url: 'https://638058639.gzwrd168.com',
            data: {
              token: app.globalData.token,
              id: id
            },
            success: function (res) {
              wx.hideLoading();
              if (res.data.code == 0) {
                that.setData({
                  id: id,
                  addressData: res.data.data,
                  selProvince: res.data.data.provinceStr,
                  selCity: res.data.data.cityStr,
                  selDistrict: res.data.data.areaStr
                });
                that.setDBSaveAddressId(res.data.data);
                return;
              } else {
                wx.showModal({
                  title: '提示',
                  content: '无法获取快递地址数据',
                  showCancel: false
                })
              }
            }
          })
        }
      },
      setDBSaveAddressId: function (data) {
        var retSelIdx = 0;
        for (var i = 0; i < commonCityData.cityData.length; i++) {
          if (data.provinceId == commonCityData.cityData[i].id) {
            this.data.selProvinceIndex = i;
            for (var j = 0; j < commonCityData.cityData[i].cityList.length; j++) {
              if (data.cityId == commonCityData.cityData[i].cityList[j].id) {
                this.data.selCityIndex = j;
                for (var k = 0; k < commonCityData.cityData[i].cityList[j].districtList.length; k++) {
                  if (data.districtId == commonCityData.cityData[i].cityList[j].districtList[k].id) {
                    this.data.selDistrictIndex = k;
                  }
                }
              }
            }
          }
        }
      },
      selectCity: function () {
     
      },
      deleteAddress: function (e) {
        var that = this;
        var id = e.currentTarget.dataset.id;
        wx.showModal({
          title: '提示',
          content: '确定要删除该收货地址吗?',
          success: function (res) {
            if (res.confirm) {
              wx.request({
                url: 'https://638058639.gzwrd168.com',
                data: {
                  token: app.globalData.token,
                  id: id
                },
                success: (res) => {
                  wx.navigateBack({})
                }
              })
            } else if (res.cancel) {
              console.log('用户点击取消')
            }
          }
        })
      },
       
      bindName(e) {
        this.setData({
          'addressData.linkMan': e.detail.value
        })
      },
      bindPhone(e) {
        this.setData({
          'addressData.mobile': e.detail.value
        })
      },
      bindDetail(e) {
        this.setData({
          'selProvince': e.detail.value
        })
      },
      bindDetail(e) {
        this.setData({
          'selCity': e.detail.value
        })
      },
      bindDetail(e) {
        this.setData({
          'selDistrict': e.detail.value
        })
      },
      bindDetail(e) {
        this.setData({
          'addressData.address': e.detail.value
        })
      },
      bindDetail(e) {
        this.setData({
          'addressData.code': e.detail.value
        })
      }
    })

    以上是address.js代码

    2018-01-29
    赞同
    回复
  • 万瑞达/文忠
    万瑞达/文忠
    2018-01-29

    新手啊哥,不会写代码?

    2018-01-29
    赞同
    回复
  • 〰Astorm
    〰Astorm
    2018-01-29
    如何将收货人信息内容显示在下方页面?
    你选择收货地址如果用的是wx.chooseAddress,那在你选择地址后,回调会返回收货地址信息啊,你把那个信息获取再显示不就好了


    文字在js里如何换行?

    加"\n"....

    2018-01-29
    赞同
    回复
  • 万瑞达/文忠
    万瑞达/文忠
    2018-01-28

    文字在js里如何换行?

    2018-01-28
    赞同
    回复
  • 万瑞达/文忠
    万瑞达/文忠
    2018-01-28

    如何将收货人信息内容



    显示在下方页面?



    十万火急,求你了!小蟲,帮帮忙!

    2018-01-28
    赞同
    回复
  • 万瑞达/文忠
    万瑞达/文忠
    2018-01-28

    按你说的,把域名后面部分去掉后可以保存了,非常感谢,但如何将收货人信息内容显示在下方页面?


    2018-01-28
    赞同
    回复
  • 〰Astorm
    〰Astorm
    2018-01-28

    你觉得我这两个箭头指的链接相等吗,明显第一个多了一个“undefined”吧,你得搞清楚这个undefined哪里来的

    2018-01-28
    赞同
    回复

正在加载...