|
@@ -3,7 +3,7 @@ const _Http = getApp().globalData.http,
|
|
|
import currency from "../../utils/currency";
|
|
|
Page({
|
|
|
data: {
|
|
|
- hidePrice: wx.getStorageSync('hidePrice'),
|
|
|
+ hidePrice: wx.getStorageSync('hidePrice'),
|
|
|
loading: true,
|
|
|
params: {}, //请求体
|
|
|
result: [], //返回结果
|
|
@@ -47,7 +47,7 @@ Page({
|
|
|
symbol: "¥",
|
|
|
precision: 2
|
|
|
}).format();
|
|
|
-
|
|
|
+
|
|
|
let newPrice = this.data.newPrice;
|
|
|
res.data = res.data.map(value => {
|
|
|
if (value.attinfos.length != 0) {
|
|
@@ -58,6 +58,7 @@ Page({
|
|
|
if (newPrice) value.newPrice = CNY(value[newPrice] || 0);
|
|
|
value.brandName = value.brand.map(name => name.brandname)
|
|
|
value.tradefields = value.tradefield.map(name => name.tradefield)
|
|
|
+ value.qty = value.orderminqty;
|
|
|
return value;
|
|
|
})
|
|
|
this.setData({
|
|
@@ -140,9 +141,50 @@ Page({
|
|
|
onReady() {
|
|
|
this.selectComponent("#ListBox").setHeight(".total", this);
|
|
|
},
|
|
|
+ /* 步进器输入框失去焦点 */
|
|
|
+ inputBlur(e) {
|
|
|
+ const {
|
|
|
+ index
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
+ let item = this.data.list[index];
|
|
|
+ let qty = 0;
|
|
|
+ if (item.orderminqty > e.detail.value) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '输入数量低于最低起订量!',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ qty = item.orderminqty;
|
|
|
+ } else if (item.orderminqty < e.detail.value) {
|
|
|
+ var currencyRounding = value => currency(value, {
|
|
|
+ increment: item.orderaddqty
|
|
|
+ });
|
|
|
+ qty = currency(currencyRounding(currency(e.detail.value).subtract(item.orderminqty)).format()).add(item.orderminqty).value;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ qty = e.detail.value;
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ [`list[${index}].qty`]: 0
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ [`list[${index}].qty`]: qty
|
|
|
+ });
|
|
|
+ },
|
|
|
+ stepperChange(e) {
|
|
|
+ const {
|
|
|
+ index
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
+ let item = this.data.list[index];
|
|
|
+ if (e.type == 'plus') {
|
|
|
+ item.qty += (item.orderaddqty) - 0
|
|
|
+ } else {
|
|
|
+ item.qty -= item.orderaddqty
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ [`list[${index}]`]: item
|
|
|
+ })
|
|
|
+ },
|
|
|
onUnload() {
|
|
|
- //回收数据
|
|
|
getApp().globalData.handleSelect = null;
|
|
|
-
|
|
|
}
|
|
|
})
|