收藏
回答

wx:if控制标签隐藏显示无效?

两个事件可以改变writeqh的值,控制view显示与隐藏,writeqhinfo有效,qrqh无效
<view class="ptaddress {{writeqh | writesh ? 'writingaddress':''}}" wx:if="{{type == '3'}}">
        <view class="{{writeqh?'ptstarting':writesh?'ptstartf':'ptstart'}}" bindtap='writeqhinfo'>
          <view class="imgview">
            <view class="ptqs" style='background-color: rgb(100,100,101);'></view>
          </view>
          <view wx:if="{{!writeqh}}" class="nametext" style="border-bottom:1rpx solid rgb(242,242,242);">
            <view wx:if="{{!haveqhinfo}}">请填写取货信息</view>
            <view wx:if="{{haveqhinfo}}">
              <view class="ptplaceinfo" style="color:rgb(3,3,3);">{{finalqh}}</view>
              <view class="ptplaceinfo" style="color:rgb(186,186,187);">{{qhrname}} {{qhrphone}}</view>
            </view>
          </view>
          <view wx:if="{{writeqh}}" class="wrqh">
            <view class="cu-form-group">
              <view class="title">联系人</view>
              <input placeholder="联系人姓名" bindinput="qhrname" value="{{qhrname}}"></input>
            </view>
            <button bindtap="qrqh" style="width:70%;background-color:rgb(44,109,255);border-radius:20rpx;color:white;">确定</button>
          </view>
        </view>
        <view class="{{writesh?'ptendplaceing':writeqh?'ptendplacef':'ptendplace'}}" bindtap='writeshinfo'>
          <view class="imgview">
            <view class="ptqs" style='background-color: rgb(245,45,86);'></view>
          </view>
          <view wx:if="{{!writesh}}" class="nametext" style="border-top:1rpx solid rgb(251,251,251)">
            <view>请填写送货信息</view>
            <!-- <view>
              <view class="ptplaceinfo">{{shplacename}}</view>
              <view class="ptplaceinfo">{{shplacename}}</view>
            </view> -->
          </view>
          <view wx:if="{{writesh}}" class="wrsh">
            <view class="cu-form-group">
              <view class="title">联系人</view>
              <input placeholder="联系人姓名" bindinput="shrname" value="{{shrname}}"></input>
            </view>
            <button bindtap="qrsh" style="width:70%;background-color:rgb(44,109,255);border-radius:20rpx;color:white;">确定</button>
          </view>
        </view>
  </view>
js代码:
  //填写取货地点
  writeqhinfo : function () {
    var that = this;
    that.setData({
      writeqh: true,
      writesh: false
    })
  },
  //填写送货点
  writeshinfo : function () {
    var that = this;
    that.setData({
      writesh: true,
      writeqh: false
    })
  },
qrqh : function (){
    var that = this;
    that.setData({
      haveqhinfo:true,//判断取货信息是否填写完整
      writesh: true,
      writeqh: false,
      finalqh: that.data.qhplacename + that.data.qhrlocation
    })
    console.log(that.data.writeqh)
  },
  qrsh: function () {
    var that = this;
    that.setData({
      haveshinfo: true,//判断取货信息是否填写完整
      finalsh: that.data.shplacename + that.data.shrlocation
    })
    console.log(that.data.finalsh)
  },
回答关注问题邀请回答
收藏
登录 后发表内容
问题标签