- 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) },
2020-06-19 - 小程序scroll-view能实现自动滚动吗?
不是轮播图,像网页中表格那样自动滚动,展示信息: [图片]
2020-04-22 - 两个数值比较,结果发现输入11的时候大于100等于true?
下面是js代码: cashmoney: function (e) { var that = this; var amounts = that.data.amounts; var money = that.data.money; console.log(that.data.amounts + "============================" + that.data.money) console.log(that.data.amounts>that.data.money) if (!(/^$|^([0-9]{1}|[1-9]+\d*)(.{0,1}\d{1,2})?$/.test(that.data.amounts)) || that.data.amounts.substring(0, 1) == 0 || amounts > money) { wx.showToast({ icon: "none", title: '请输入合理的金额!', duration:1500 }) }else{ console.log(app.globalData.weixinAccount+"============================"+app.globalData.zhifubaoAccount) } } 这是输入框: <view class="cash-money"> <input type="digit" placeholder="请输入要提现的金额" bindinput="moneyinput" value="{{amounts}}"></input> </view> 这是输出结果, [图片]
2020-01-21 - 小程序发布后有的手机偶尔请求不到数据?
appid:wxbf6c789fed81a2c4 调试基础库:2.9.4 我的手机正常访问,我同事的小米第一天进去请求不到数据,第二天都正常了,还有部分手机也是一样请求不到数据
2020-01-16 - 小程序第一次授权获取不到openid
小程序第一次授权获取不到openid,需要重新编译一下之后才能获取。 代码如下: 这是授权过了走的代码: wx.getSetting({ success: function (res) { if (res.authSetting['scope.userInfo']) { wx.getUserInfo({ success: function (res) { that.setData({ avatarUrl: res.userInfo.avatarUrl, userInfo: res.userInfo }), // 用户已经授权过,不需要显示授权页面,所以不需要改变 isHide 的值 // 根据自己的需求有其他操作再补充 // 我这里实现的是在用户授权成功后,调用微信的 wx.login 接口,从而获取code wx.login({ success: res => { // 获取到用户的 code 之后:res.code //console.log("用户的code:" + res.code); that.setData({ code: res.code }), //请求获取openid wx.request({ url: app.globalData.url + '/appInterface/getOpenid.do?code=' + res.code, //url: app.globalData.url + '/appInterface/getOpenid.do', method: 'GET', // data:{ // code: res.code // }, header: { 'Content-Type': 'application/json' }, success: function (ares) { //将openid设置为所有页面都能访问 app.globalData.openid = ares.data.obj //默认请求注册会员 // wx.request({ // url: app.globalData.url + '/appInterface/addUser.do', // data: { // userOpenid: ares.data.obj, // userNick: that.data.userInfo.nickName, // userHadimag: that.data.userInfo.avatarUrl // }, // method: 'POST', // header: { // 'Content-Type': 'application/x-www-form-urlencoded' // }, // success: function (bres) { // } // }) } }) //授权成功跳转到首页 wx.reLaunch({ url: '/pages/login/login' }) } }); } }); } else { // 用户没有授权 // 改变 isHide 的值,显示授权页面 that.setData({ isHide: true }); } } }); 这是第一次授权时走的代码: bindGetUserInfo: function (e) { if (e.detail.userInfo) { //用户按了允许授权按钮 var that = this; // 获取到用户的信息了,打印到控制台上看下 console.log("用户的信息如下:"); console.log(e.detail.userInfo); //授权成功后,通过改变 isHide 的值,让实现页面显示出来,把授权页面隐藏起来 that.setData({ isHide: false }); wx.getUserInfo({ success: function (res) { that.setData({ avatarUrl: res.userInfo.avatarUrl, userInfo: res.userInfo }), // 用户已经授权过,不需要显示授权页面,所以不需要改变 isHide 的值 // 根据自己的需求有其他操作再补充 // 我这里实现的是在用户授权成功后,调用微信的 wx.login 接口,从而获取code wx.login({ success: res => { // 获取到用户的 code 之后:res.code console.log("用户的code:" + res.code); wx.request({ url: app.globalData.url + '/appInterface/getOpenid.do?code=' + res.code, //url: app.globalData.url + '/appInterface/getOpenid.do', method: 'GET', // data:{ // code: res.code // }, header: { 'Content-Type': 'application/json' }, success: function (ares) { //将openid设置为所有页面都能访问 app.globalData.openid = ares.data.obj //默认请求注册会员 // wx.request({ // url: app.globalData.url + '/appInterface/addUser.do', // data: { // userOpenid: ares.data.obj, // userNick: that.data.userInfo.nickName, // userHadimag: that.data.userInfo.avatarUrl // }, // method: 'POST', // header: { // 'Content-Type': 'application/x-www-form-urlencoded' // }, // success: function (bres) { // } // }) } }) wx.reLaunch({ url: '/pages/login/login' }) } }); } }); } else { //用户按了拒绝按钮 wx.showModal({ title: '警告', content: '您点击了拒绝授权,将无法进入小程序,请授权之后再进入!!!', showCancel: false, confirmText: '返回授权', success: function (res) { // 用户没有授权成功,不需要改变 isHide 的值 if (res.confirm) { console.log('用户点击了“返回授权”'); } } }); } }, 各路大佬快来帮帮忙吧
2019-12-30