Commit b97a3746 by 施宇

111

parent d1002dc1
// pages/form/bj/index.js // pages/form/bj/index.js
import { import {
getData, getData,
tips tips,
fourPoint
} from '../../../utils/util.js'; } from '../../../utils/util.js';
import { import {
apis apis
...@@ -49,19 +50,15 @@ Page({ ...@@ -49,19 +50,15 @@ Page({
} else if (isNaN(Number(obj.number.trim()))) { } else if (isNaN(Number(obj.number.trim()))) {
tips('数量必须为数字'); tips('数量必须为数字');
return return
} else if (!obj.price.trim().length) {
tips('请填写价格');
return
} else { } else {
if (!fourPoint(obj.price)) {
return
}
if (obj.hq == 2) { //期货 if (obj.hq == 2) { //期货
if (!obj.day.trim().length) { if (!obj.day.trim().length) {
tips('请填写货期'); tips('请填写货期');
return return
} }
// else if (obj.day.trim().length > 3) {
// tips('货期不能大于3个字符');
// return
// }
} }
} }
this.postData(obj); this.postData(obj);
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
import { import {
getData, getData,
chooseImg, chooseImg,
tips tips,
fourPoint
} from '../../../utils/util.js'; } from '../../../utils/util.js';
import { import {
apis apis
...@@ -112,22 +113,16 @@ Page({ ...@@ -112,22 +113,16 @@ Page({
} else if (isNaN(Number(obj.stock.trim()))) { } else if (isNaN(Number(obj.stock.trim()))) {
tips('库存必须为数字'); tips('库存必须为数字');
return return
} else if (!obj.price.trim().length) { }
tips('请填写价格'); else {
return if (!fourPoint(obj.price)){
} else { return
}
if (obj.hq == 2) { //期货 if (obj.hq == 2) { //期货
if (!obj.day.trim().length) { if (!obj.day.trim().length) {
tips('请填写货期'); tips('请填写货期');
return return
} }
// else if (isNaN(Number(obj.day.trim()))) {
// tips('货期必须为数字');
// return
// } else if (obj.day.trim().length > 3) {
// tips('货期不能大于3个字符');
// return
// }
} }
} }
this.postData(obj); this.postData(obj);
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
import { import {
getData, getData,
chooseImg, chooseImg,
tips tips,
fourPoint
} from '../../../utils/util.js'; } from '../../../utils/util.js';
import { import {
apis apis
...@@ -46,22 +47,15 @@ Page({ ...@@ -46,22 +47,15 @@ Page({
} else if (isNaN(Number(obj.number.trim()))) { } else if (isNaN(Number(obj.number.trim()))) {
tips('数量必须为数字'); tips('数量必须为数字');
return return
} else if (!obj.price.trim().length) {
tips('请填写价格');
return
} else { } else {
if (!fourPoint(obj.price)) {
return
}
if (obj.hq == 2) { //期货 if (obj.hq == 2) { //期货
if (!obj.day.trim().length) { if (!obj.day.trim().length) {
tips('请填写货期'); tips('请填写货期');
return return
} }
// else if (isNaN(Number(obj.day.trim()))) {
// tips('货期必须为数字');
// return
// } else if (obj.day.trim().length > 3) {
// tips('货期不能大于3个字符');
// return
// }
} }
} }
this.postData(obj); this.postData(obj);
......
...@@ -68,7 +68,7 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => { ...@@ -68,7 +68,7 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
typeof callBack == "function" && callBack(res.data, ""); typeof callBack == "function" && callBack(res.data, "");
} }
} }
if (tokenInvalid){ if (tokenInvalid) {
wx.removeStorageSync('access_token'); wx.removeStorageSync('access_token');
wx.removeStorageSync('user_id'); wx.removeStorageSync('user_id');
wx.removeStorageSync('company_name'); wx.removeStorageSync('company_name');
...@@ -324,21 +324,41 @@ const interval = (usedTime) => { ...@@ -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) => { const matchReg = (str) => {
let reg = /<\/?.+?\/?>/g; let reg = /<\/?.+?\/?>/g;
let newStr = str.replace(reg, ''); let newStr = str.replace(reg, '');
return newStr return newStr
} }
const reloginIm = ()=>{ const reloginIm = () => {
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
content: '您的聊天账号被迫下线!', content: '您的聊天账号被迫下线!',
confirmText: "重新登录", confirmText: "重新登录",
success: function (res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
wx.showLoading(); wx.showLoading();
getApp().conn.closed = true; getApp().conn.closed = true;
getApp().conn.reopen(); getApp().conn.reopen();
} else if (res.cancel) { } else if (res.cancel) {
wx.switchTab({ wx.switchTab({
url: '/pages/tab/home/home' url: '/pages/tab/home/home'
...@@ -356,5 +376,6 @@ module.exports = { ...@@ -356,5 +376,6 @@ module.exports = {
judgeToken: judgeToken, judgeToken: judgeToken,
interval: interval, interval: interval,
matchReg: matchReg, 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