- wx:for创建stepper组件,为什么点击加减号,数量同时增加或减少?但是价格没问题,求大神指教
[图片][图片][图片] data-index也是对的,为什么点击加减号时,两个组件的数字同时变化? 但是,修改价格,就没问题,不同时变化?我哪里出问题了,就是找不出原因来!求大神指教!!在线等,憋得慌 这段代码如下:商品信息productList从后台读取数据过来 //WXML中部分代码 <block wx:for='{{productList}}' wx:key='code'> <!-- 循环的 --> <view class='list-wrap'> <view class='item-wrap group'> <view class='item image bgwhite'> <view class='item-column width25 none-border'><image mode="aspectFill" class="product-image" src='{{item.imageUrl}}'></image></view> <view class='item-column width45 none-border word-wrap align-center'>{{item.brand.name}}{{item.name}}{{item.proCode}}</view> <view class="item-column {{manageOption?'':'column'}} width30 none-border align-center right"> <block wx:if='{{manageOption}}'> <image class="option-delete" hover-class='btn-hover' data-index='{{index}}' bindtap='deleteOption' src="{{iconImageDir}}deleteactive.png"></image> </block> <block wx:else> <view class='product-price'> <input type="digit" data-index='{{index}}' bindblur='changeProductPrice' placeholder="0.00 {{company.coin.unit}}" placeholder-class='placeholder-style {{nameClass}}' style='color:#008FD1' class="input" value='{{priceList[index]}}'></input> </view> <view class='product-count'> <view class="stepper"> <!-- 减号 --> <view class="stepper-minus {{stepperList[index].minus?'disabled':''}}" data-index="{{index}}" hover-class='btn-hover' bindtap="bindStepperMinus">-</view> <!-- 数值 --> <input class='stepper-number' data-index="{{index}}" disabled="{{stepperList[index].disabled?'true':''}}" type="digit" bindchange="bindStepperNumber" value="{{stepperList[index].number}}" /> <!-- 加号 --> <view class="stepper-plus {{stepperList[index].plus || stepperList[index].disabled?'disabled':''}}" data-index="{{index}}" hover-class='btn-hover' bindtap="bindStepperPlus">+</view> </view> </view> </block> </view> </view> <view class='item bgwhite'> <view class='item-column width20 default align-center'><view style="width:100%;text-align:center">{{item.typeStr}}</view></view> <view class='item-column width80 right default'>小计 {{amountList[index]}} {{company.coin.unit}}</view> </view> </view> </view> </block> //js中部分代码: onLoad: function (options) { this.getPurchaseInfo(options.purchaseCode); }, //在onshow里面初始化,stepperList、amountList、priceList等信息 //加减号事件函数 /* 点击减号 */ bindStepperMinus: function (e) { var stepperList = this.data.stepperList; var idx = e.currentTarget.dataset.index; if (!stepperList[idx].disabled) { //当大于1时,可以减 if (stepperList[idx].number > stepperList[idx].min) { stepperList[idx].number--; } stepperList[idx].minus = stepperList[idx].number == stepperList[idx].min ? true : false; stepperList[idx].plus = stepperList[idx].number == stepperList[idx].max ? true : false; //添加内容 var productList = this.data.productList; var priceList = this.data.priceList; var amountList = this.data.amountList; amountList[idx] = (priceList[idx] * stepperList[idx].number).toFixed(2); productList[idx].amount = amountList[idx]; productList[idx].price = priceList[idx]; productList[idx].buyCount = stepperList[idx].number; var totalCount = 0; var totalAmount = 0; var length = productList.length; for (var i = 0; i < length;i++){ totalCount += parseFloat(stepperList[i].number); totalAmount += parseFloat(amountList[i]); } var twoAmount = this.data.twoAmount; this.setData({ stepperList: stepperList, productList: productList, amountList: amountList, totalCount: totalCount.toFixed(2), totalAmount: totalAmount.toFixed(2), bankAmount: (totalAmount - twoAmount).toFixed(2) }); } },
2021-02-28 - 小程序连接低功耗蓝牙一维扫码枪,为何读取不到扫描枪扫描的数据?
wx.notifyBLECharacteristicValueChange({ characteristicId: cid, deviceId: did, serviceId: sid, state: true, complete:function(res){ console.log('notify启用'); console.log(res); wx.onBLECharacteristicValueChange((result) => { console.log('监听特征值变化'); var dataView = new DataView(result.value,0); console.log(dataView.getInt8(0)); }) } }) [图片] 一直到这一步,都连接成功 [图片] 然后,我使用扫码枪扫描时,为何onBLECharacteristicValueChange没有任何新的数据? 哪位大神给指点指点?
2020-07-25