Commit b97a3746 by 施宇

111

parent d1002dc1
// pages/form/bj/index.js
import {
getData,
tips
tips,
fourPoint
} from '../../../utils/util.js';
import {
apis
......@@ -49,19 +50,15 @@ Page({
} else if (isNaN(Number(obj.number.trim()))) {
tips('数量必须为数字');
return
} else if (!obj.price.trim().length) {
tips('请填写价格');
return
} else {
if (!fourPoint(obj.price)) {
return
}
if (obj.hq == 2) { //期货
if (!obj.day.trim().length) {
tips('请填写货期');
return
}
// else if (obj.day.trim().length > 3) {
// tips('货期不能大于3个字符');
// return
// }
}
}
this.postData(obj);
......
......@@ -2,7 +2,8 @@
import {
getData,
chooseImg,
tips
tips,
fourPoint
} from '../../../utils/util.js';
import {
apis
......@@ -112,22 +113,16 @@ Page({
} else if (isNaN(Number(obj.stock.trim()))) {
tips('库存必须为数字');
return
} else if (!obj.price.trim().length) {
tips('请填写价格');
return
} else {
}
else {
if (!fourPoint(obj.price)){
return
}
if (obj.hq == 2) { //期货
if (!obj.day.trim().length) {
tips('请填写货期');
return
}
// else if (isNaN(Number(obj.day.trim()))) {
// tips('货期必须为数字');
// return
// } else if (obj.day.trim().length > 3) {
// tips('货期不能大于3个字符');
// return
// }
}
}
this.postData(obj);
......
......@@ -2,7 +2,8 @@
import {
getData,
chooseImg,
tips
tips,
fourPoint
} from '../../../utils/util.js';
import {
apis
......@@ -46,22 +47,15 @@ Page({
} else if (isNaN(Number(obj.number.trim()))) {
tips('数量必须为数字');
return
} else if (!obj.price.trim().length) {
tips('请填写价格');
return
} else {
if (!fourPoint(obj.price)) {
return
}
if (obj.hq == 2) { //期货
if (!obj.day.trim().length) {
tips('请填写货期');
return
}
// else if (isNaN(Number(obj.day.trim()))) {
// tips('货期必须为数字');
// return
// } else if (obj.day.trim().length > 3) {
// tips('货期不能大于3个字符');
// return
// }
}
}
this.postData(obj);
......
......@@ -68,7 +68,7 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
typeof callBack == "function" && callBack(res.data, "");
}
}
if (tokenInvalid){
if (tokenInvalid) {
wx.removeStorageSync('access_token');
wx.removeStorageSync('user_id');
wx.removeStorageSync('company_name');
......@@ -324,21 +324,41 @@ const interval = (usedTime) => {
}
}
}
const fourPoint = (num) => { //检测价格是否是数字或者是四位小数点的小数
let price = num.trim();
if (!price.length) {
tips('请填写价格');
return false
} else {
if (isNaN(Number(price))) {
tips('价格必须为数字');
return false
} else {
let strArr = price.split('.');
if ((strArr.length == 1) || (strArr.length == 2 && strArr[1].length == 4)) {
return true
} else {
tips('价格只支持4位小数点');
return false
}
}
}
}
const matchReg = (str) => {
let reg = /<\/?.+?\/?>/g;
let newStr = str.replace(reg, '');
return newStr
}
const reloginIm = ()=>{
const reloginIm = () => {
wx.showModal({
title: '提示',
content: '您的聊天账号被迫下线!',
confirmText: "重新登录",
success: function (res) {
success: function(res) {
if (res.confirm) {
wx.showLoading();
getApp().conn.closed = true;
getApp().conn.reopen();
wx.showLoading();
getApp().conn.closed = true;
getApp().conn.reopen();
} else if (res.cancel) {
wx.switchTab({
url: '/pages/tab/home/home'
......@@ -356,5 +376,6 @@ module.exports = {
judgeToken: judgeToken,
interval: interval,
matchReg: matchReg,
reloginIm: reloginIm
reloginIm: reloginIm,
fourPoint: fourPoint
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment