Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
施宇
/
icsalesProgram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
91b55198
authored
Aug 14, 2019
by
施宇
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
表单校验
parent
9c9dc943
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
48 deletions
pages/form/bj/index.js
pages/form/good/index.js
pages/form/xj/index.js
pages/form/bj/index.js
View file @
91b55198
...
...
@@ -18,23 +18,38 @@ Page({
},
formSubmit
:
function
(
e
)
{
let
obj
=
e
.
detail
.
value
;
if
(
!
obj
.
goods_name
)
{
if
(
!
obj
.
goods_name
.
trim
().
length
)
{
tips
(
'请填写型号'
);
return
}
else
if
(
!
obj
.
brand_name
)
{
}
else
if
(
obj
.
goods_name
.
trim
().
length
<
3
)
{
tips
(
'型号不能小于3个字符'
);
return
}
else
if
(
!
obj
.
brand_name
.
trim
().
length
)
{
tips
(
'请填写品牌'
);
return
}
else
if
(
!
obj
.
number
)
{
}
else
if
(
obj
.
brand_name
.
trim
().
length
<
2
)
{
tips
(
'品牌不能小于2个字符'
);
return
}
else
if
(
!
obj
.
number
.
trim
().
length
)
{
tips
(
'请填写数量'
);
return
}
else
if
(
!
obj
.
price
)
{
}
else
if
(
isNaN
(
Number
(
obj
.
number
.
trim
())))
{
tips
(
'数量必须为数字'
);
return
}
else
if
(
!
obj
.
price
.
trim
().
length
)
{
tips
(
'请填写价格'
);
return
}
else
{
if
(
obj
.
hq
==
2
)
{
//期货
if
(
!
obj
.
day
)
{
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
}
}
}
...
...
pages/form/good/index.js
View file @
91b55198
...
...
@@ -19,7 +19,7 @@ Page({
price
:
""
,
day
:
""
,
goodId
:
""
,
hq
:
"1"
,
hq
:
"1"
,
isShowTip
:
true
},
...
...
@@ -40,7 +40,7 @@ Page({
title
:
'新增商品'
})
}
},
getGoodData
:
function
()
{
let
me
=
this
;
...
...
@@ -65,44 +65,59 @@ Page({
},
renderForm
:
function
(
infoObj
)
{
this
.
setData
({
goodsName
:
infoObj
.
goods_name
,
goodsName
:
infoObj
.
goods_name
,
brandName
:
infoObj
.
brand_name
,
encap
:
infoObj
.
encap
,
stock
:
infoObj
.
stock
,
price
:
infoObj
.
price
,
currency
:
infoObj
.
currency
,
imgUrl
:
infoObj
.
goods_images
imgUrl
:
infoObj
.
goods_images
});
if
(
infoObj
.
delivery_time
!==
'现货'
)
{
let
day
=
infoObj
.
delivery_time
.
replace
(
'天'
,
''
);
if
(
infoObj
.
delivery_time
!==
'现货'
)
{
let
day
=
infoObj
.
delivery_time
.
replace
(
'天'
,
''
);
console
.
log
(
day
)
this
.
setData
({
isShowTime
:
2
,
hq
:
2
,
day
:
day
});
this
.
setData
({
isShowTime
:
2
,
hq
:
2
,
day
:
day
});
}
},
formSubmit
:
function
(
e
)
{
let
obj
=
e
.
detail
.
value
;
if
(
!
obj
.
goods_name
)
{
if
(
!
obj
.
goods_name
.
trim
().
length
)
{
tips
(
'请填写型号'
);
return
}
else
if
(
!
obj
.
brand_name
)
{
}
else
if
(
obj
.
goods_name
.
trim
().
length
<
3
)
{
tips
(
'型号不能小于3个字符'
);
return
}
else
if
(
!
obj
.
brand_name
.
trim
().
length
)
{
tips
(
'请填写品牌'
);
return
}
else
if
(
!
obj
.
stock
)
{
}
else
if
(
obj
.
brand_name
.
trim
().
length
<
2
)
{
tips
(
'品牌不能小于2个字符'
);
return
}
else
if
(
!
obj
.
stock
.
trim
().
length
)
{
tips
(
'请填写库存'
);
return
}
else
if
(
!
obj
.
price
)
{
}
else
if
(
isNaN
(
Number
(
obj
.
stock
.
trim
())))
{
tips
(
'库存必须为数字'
);
return
}
else
if
(
!
obj
.
price
.
trim
().
length
)
{
tips
(
'请填写价格'
);
return
}
else
{
if
(
obj
.
hq
==
2
)
{
//期货
if
(
!
obj
.
day
)
{
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
}
}
}
...
...
@@ -152,7 +167,7 @@ Page({
let
val
=
e
.
detail
.
value
;
this
.
setData
({
isShowTime
:
val
==
1
?
false
:
true
,
hq
:
val
hq
:
val
})
},
...
...
@@ -170,7 +185,7 @@ Page({
imgUrl
:
null
})
},
deleteGood
:
function
()
{
deleteGood
:
function
()
{
},
/**
...
...
pages/form/xj/index.js
View file @
91b55198
// pages/form/xj/index.js
import
{
getData
,
chooseImg
,
tips
}
from
'../../../utils/util.js'
;
import
{
apis
}
from
'../../../utils/api.js'
;
import
{
getData
,
chooseImg
,
tips
}
from
'../../../utils/util.js'
;
import
{
apis
}
from
'../../../utils/api.js'
;
Page
({
/**
...
...
@@ -14,31 +20,46 @@ Page({
isClick
:
true
,
isShowTip
:
true
},
formSubmit
:
function
(
e
)
{
formSubmit
:
function
(
e
)
{
let
obj
=
e
.
detail
.
value
;
if
(
!
obj
.
goods_name
)
{
if
(
!
obj
.
goods_name
.
trim
().
length
)
{
tips
(
'请填写型号'
);
return
}
else
if
(
!
obj
.
brand_name
)
{
}
else
if
(
obj
.
goods_name
.
trim
().
length
<
3
)
{
tips
(
'型号不能小于3个字符'
);
return
}
else
if
(
!
obj
.
brand_name
.
trim
().
length
)
{
tips
(
'请填写品牌'
);
return
}
else
if
(
!
obj
.
number
)
{
}
else
if
(
obj
.
brand_name
.
trim
().
length
<
2
)
{
tips
(
'品牌不能小于2个字符'
);
return
}
else
if
(
!
obj
.
number
.
trim
().
length
)
{
tips
(
'请填写数量'
);
return
}
else
if
(
!
obj
.
price
)
{
}
else
if
(
isNaN
(
Number
(
obj
.
number
.
trim
())))
{
tips
(
'数量必须为数字'
);
return
}
else
if
(
!
obj
.
price
.
trim
().
length
)
{
tips
(
'请填写价格'
);
return
}
else
{
if
(
obj
.
hq
==
2
)
{
//期货
if
(
!
obj
.
day
)
{
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
);
},
postData
:
function
(
obj
)
{
postData
:
function
(
obj
)
{
let
me
=
this
;
let
token
=
wx
.
getStorageSync
(
'access_token'
);
obj
.
hq
==
1
?
obj
.
delivery_time
=
'现货'
:
obj
.
delivery_time
=
obj
.
day
+
'天'
;
...
...
@@ -51,7 +72,7 @@ Page({
me
.
setData
({
isClick
:
false
})
getData
(
apis
.
inquiryadd
,
'get'
,
obj
,
function
(
res
)
{
getData
(
apis
.
inquiryadd
,
'get'
,
obj
,
function
(
res
)
{
if
(
res
.
errcode
==
0
)
{
tips
(
'发布成功'
)
me
.
setData
({
...
...
@@ -75,16 +96,16 @@ Page({
})
},
uploadImg
:
function
()
{
uploadImg
:
function
()
{
let
me
=
this
;
chooseImg
(
apis
.
ossupload
,
1
,
function
(
url
)
{
chooseImg
(
apis
.
ossupload
,
1
,
function
(
url
)
{
me
.
setData
({
imgUrl
:
url
})
})
},
deleteImg
:
function
()
{
deleteImg
:
function
()
{
this
.
setData
({
imgUrl
:
null
})
...
...
@@ -92,71 +113,71 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad
:
function
(
options
)
{
onLoad
:
function
(
options
)
{
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady
:
function
()
{
onReady
:
function
()
{
},
/**
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
onShow
:
function
()
{
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide
:
function
()
{
onHide
:
function
()
{
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload
:
function
()
{
onUnload
:
function
()
{
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh
:
function
()
{
onPullDownRefresh
:
function
()
{
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom
:
function
()
{
onReachBottom
:
function
()
{
},
/**
* 用户点击右上角分享
*/
onShareAppMessage
:
function
()
{
onShareAppMessage
:
function
()
{
},
changePrice
:
function
(
e
)
{
changePrice
:
function
(
e
)
{
let
type
=
e
.
target
.
dataset
.
pricetype
;
this
.
setData
({
currency
:
type
,
isShowSwitch
:
false
})
},
switchPrice
:
function
()
{
switchPrice
:
function
()
{
this
.
setData
({
isShowSwitch
:
!
this
.
data
.
isShowSwitch
})
},
closeTip
:
function
()
{
closeTip
:
function
()
{
this
.
setData
({
isShowTip
:
false
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment