Handy_Cao 2 jaren geleden
bovenliggende
commit
a7f2b9e210

+ 4 - 22
GuangZuan/miniprogram/mHome/pages/presell/new/index.ts

@@ -2,7 +2,7 @@ import { queryPermancePlanTmp } from "../../../../services/api/orders/index"
 import { accountid, clientType, getErrorMsg, isEncrypted, marketid, protoHeader, timetample, userid } from "../../../../services/utils"
 import { hideLoading, showLoading, showModel, showToast } from "../../../../utils/message/index"
 import services from "../../../../services/index"
-import { formatDate } from "../../../../utils/util"
+import { formatDate, getDecimalNum } from "../../../../utils/util"
 import { sendMsgToMQ } from "../../../../services/api/common/index"
 import { encryptBody } from "../../../../utils/websocket/crypto"
 import { FunCode } from "../../../../constants/enum/funcode"
@@ -195,26 +195,8 @@ Page({
 
   // input输入中
   getInputNum (e: any) {
-    let amount = e.detail
-    let num = null
-    // 小数点后最多只能输入两位
-    num = amount.replace(new RegExp('^(\\d+\\.\\d{2}).+'), '$1')
-    // 小数点开头得话,让前面加个0   eg: 0.xx
-    const startPoint = /^\./g
-    if (startPoint.test(num)) { num = amount.replace(startPoint, '0.') }
-
-    // 若没有小数点,前面输入多个0,去掉0取整
-    // if(num有值 && 没有小数点 && 不等于'0')
-    if (num && !num.includes('.') && num !== '0') { num = +num }
-    // 若出现多个小数点,则替换为1个
-    const morePoint = /\.+(\d*|\.+)\./g
-    if (morePoint.test(num)) {
-      num = amount
-        .replace(/\.{2,}/g, ".")
-        .replace(".", "$#$")
-        .replace(/\./g, "")
-        .replace("$#$", ".")
-    }
+    /// 截取2位小数位
+    let num = getDecimalNum(e.detail)
     switch (e.target.id) {
       case 'maxbuyqty':   /// 最大采购单位
         this.setData({ maxbuyqty: num})
@@ -255,7 +237,7 @@ Page({
         }
         // 上传完成需要更新 fileList
         const { fileList = [] } = this.data;
-        fileList.push({ ...file, url: res.data});
+        fileList.push({ ...file, url: res.data });
         this.setData({ fileList });
         /// 设置文件路径
         this.setData({ filePath: JSON.parse(res.data)[0].filePath })

+ 6 - 46
GuangZuan/miniprogram/mHome/pages/purchase/new/index.ts

@@ -2,7 +2,7 @@ import { queryPermancePlanTmp } from "../../../../services/api/orders/index"
 import { accountid, clientType, getErrorMsg, isEncrypted, marketid, protoHeader, timetample, userid } from "../../../../services/utils"
 import { hideLoading, showLoading, showModel, showToast } from "../../../../utils/message/index"
 import services from "../../../../services/index"
-import { formatDate } from "../../../../utils/util"
+import { formatDate, getDecimalNum } from "../../../../utils/util"
 import { FunCode } from "../../../../constants/enum/funcode"
 import { sendMsgToMQ } from "../../../../services/api/common/index"
 import { encryptBody } from "../../../../utils/websocket/crypto"
@@ -217,27 +217,8 @@ Page({
 
   // input输入中
   getInputNum (e: any) {
-    let amount = e.detail
-    let num = null
-    // 小数点后最多只能输入两位
-    num = amount.replace(new RegExp('^(\\d+\\.\\d{2}).+'), '$1')
-
-    // 小数点开头得话,让前面加个0   eg: 0.xx
-    const startPoint = /^\./g
-    if (startPoint.test(num)) { num = amount.replace(startPoint, '0.') }
-
-    // 若没有小数点,前面输入多个0,去掉0取整
-    // if(num有值 && 没有小数点 && 不等于'0')
-    if (num && !num.includes('.') && num !== '0') { num = +num }
-    // 若出现多个小数点,则替换为1个
-    const morePoint = /\.+(\d*|\.+)\./g
-    if (morePoint.test(num)) {
-      num = amount
-        .replace(/\.{2,}/g, ".")
-        .replace(".", "$#$")
-        .replace(/\./g, "")
-        .replace("$#$", ".")
-    }
+    /// 截取两位小数位
+    let num = getDecimalNum(e.detail)
     switch (e.target.id) {
       case 'maxbuyqty':   /// 最大采购单位
         this.setData({ maxbuyqty: num})
@@ -363,7 +344,7 @@ Page({
   /**
    * 新增价格
    */
-  addPrice(e: any) {
+  addPrice() {
     this.setData({
       datas: this.data.datas.concat([{price: 0.0, qty: 0.0, step: this.data.datas.length+1}]) 
     })
@@ -393,29 +374,8 @@ Page({
     const row = <number><unknown>ids[0]
     const id = ids[1]
     var obj = this.data.datas[row-1]
-
-    let amount = e.detail
-    let num = null
-    // 小数点后最多只能输入两位
-    num = amount.replace(new RegExp('^(\\d+\\.\\d{2}).+'), '$1')
-
-    // 小数点开头得话,让前面加个0   eg: 0.xx
-    const startPoint = /^\./g
-    if (startPoint.test(num)) { num = amount.replace(startPoint, '0.') }
-
-    // 若没有小数点,前面输入多个0,去掉0取整
-    // if(num有值 && 没有小数点 && 不等于'0')
-    if (num && !num.includes('.') && num !== '0') { num = +num }
-    // 若出现多个小数点,则替换为1个
-    const morePoint = /\.+(\d*|\.+)\./g
-
-    if (morePoint.test(num)) {
-      num = amount
-        .replace(/\.{2,}/g, ".")
-        .replace(".", "$#$")
-        .replace(/\./g, "")
-        .replace("$#$", ".")
-    }
+    /// 截取两位小数
+    let num = getDecimalNum(e.detail)
     /// 数据赋值
     if (id === "qty") { obj.qty = num } else { obj.price = num }
     /// 删除数据

+ 1 - 1
GuangZuan/miniprogram/mMine/pages/myorders/list/index.ts

@@ -538,7 +538,7 @@ Page({
   /**
    * 刷新数据
    */
-  onLoad(options: any) {
+  onLoad() {
     /// 刷新数据
     this.reloadData()
   },

+ 8 - 2
GuangZuan/miniprogram/mTrade/pages/delistingsell/index.ts

@@ -3,7 +3,7 @@ import { sendMsgToMQ } from "../../../services/api/common/index";
 import { queryMyWRPosition, queryPermancePlanTmp } from "../../../services/api/orders/index";
 import { accountid, clientType, getErrorMsg, isEncrypted, loginQuery, marketid, protoHeader, timetample, userid } from "../../../services/utils";
 import { hideLoading, showLoading, showModel, showToast } from "../../../utils/message/index";
-import { isnullstr } from "../../../utils/util";
+import { getDecimalNum, isnullstr } from "../../../utils/util";
 import { encryptBody } from "../../../utils/websocket/crypto";
 
 Page({
@@ -49,6 +49,12 @@ Page({
     wx.navigateBack()
   },
 
+  // input输入中
+  getInputNum (e: any) {
+    /// 截取2位小数位
+    this.setData({ applyPrice: getDecimalNum(e.detail) })
+  },
+
     /**
    * 每行选中触发事件
    */
@@ -141,7 +147,7 @@ Page({
 
   check(): boolean {
     /// 请选择仓单数据
-    if (this.data.wrPositon.ladingbillid === "" ) {
+    if (this.data.wrPositon.ladingbillid === undefined ) {
       showToast('请选择仓单数据!')
       return false
     }

+ 1 - 1
GuangZuan/miniprogram/mTrade/pages/delistingsell/index.wxml

@@ -56,7 +56,7 @@
   <view class="container__operator">
     <van-cell-group in>
       <van-field label="汇率:" readonly value="{{ rate }}" />
-      <van-field label="价格(¥)" type="digit" clearable required adjust-position placeholder="请输入价格" model:value="{{ applyPrice }}" />
+      <van-field label="价格(¥)" type="digit" clearable required adjust-position placeholder="请输入价格" model:value="{{ applyPrice }}" bind:input="getInputNum"/>
       <van-field label="备注:" clearable adjust-position placeholder="请输入备注信息" model:value="{{ remark }}" />
     </van-cell-group>
   </view>

+ 1 - 3
GuangZuan/miniprogram/mTrade/pages/listingbuy/index.ts

@@ -140,9 +140,7 @@ Page({
     this.setData({ tmp: this.data.tmps[index], show: false })
   },
 
-  onRadioChange(e: any) {
-    
-  },
+  onRadioChange() {},
 
   /// 重量范围值更改
   syncNumRange(e: any) {

+ 1 - 1
GuangZuan/miniprogram/utils/util.ts

@@ -58,7 +58,7 @@ export const isnullstr = (str: string) => {
 }
 
 /// 截取两位小数位
-export const getDecimalNum = (number: string) => {
+export const getDecimalNum = (number: any) => {
   let amount = number
   let num = null
   // 小数点后最多只能输入两位