Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
mini-program
/
ai-card
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3e6796bf
authored
Oct 28, 2022
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
调整
1 parent
31a7273d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
52 deletions
components/CooperationApply/CooperationApply.js
components/CooperationApply/CooperationApply.wxml
pages/newEnergy/newEnergy.js
pages/newEnergy/newEnergy.json
pages/newEnergy/newEnergy.wxml
components/CooperationApply/CooperationApply.js
View file @
3e6796b
// components/CooperationApply/CooperationApply.js
// components/CooperationApply/CooperationApply.js
import
WxValidate
from
"../../utils/WxValidate"
import
WxValidate
from
"../../utils/WxValidate"
;
Component
({
Component
({
/**
/**
* 组件的属性列表
* 组件的属性列表
*/
*/
properties
:
{
properties
:
{},
},
/**
/**
* 组件的初始数据
* 组件的初始数据
*/
*/
data
:
{
data
:
{
tabData
:
[{
tabData
:
[
name
:
'门店合作申请'
,
{
value
:
0
name
:
"门店合作申请"
,
value
:
0
,
},
},
{
{
name
:
'代理商合作申请'
,
name
:
"代理商合作申请"
,
value
:
1
value
:
1
,
}
}
,
],
],
tabIndex
:
0
,
tabIndex
:
0
,
applyForm
:
{
applyForm
:
{
merchantName
:
''
,
merchantName
:
""
,
carModel
:
''
,
carModel
:
""
,
contactName
:
''
,
contactName
:
""
,
contactPhone
:
''
contactPhone
:
""
,
},
},
},
},
...
@@ -37,69 +36,76 @@ Component({
...
@@ -37,69 +36,76 @@ Component({
selectTab
(
e
)
{
selectTab
(
e
)
{
console
.
log
(
e
.
currentTarget
.
dataset
.
index
);
console
.
log
(
e
.
currentTarget
.
dataset
.
index
);
this
.
setData
({
this
.
setData
({
tabIndex
:
e
.
currentTarget
.
dataset
.
index
tabIndex
:
e
.
currentTarget
.
dataset
.
index
,
})
})
;
},
},
// 表单验证规则
// 表单验证规则
initValidate
()
{
initValidate
()
{
console
.
log
(
123123
);
console
.
log
(
123123
);
const
rules
=
{
const
rules
=
{
merchantName
:
{
merchantName
:
{
required
:
true
required
:
true
,
},
},
contactName
:
{
contactName
:
{
required
:
true
required
:
true
,
},
},
contactPhone
:
{
contactPhone
:
{
required
:
true
,
required
:
true
,
tel
:
true
tel
:
true
,
}
}
,
}
}
;
const
messages
=
{
const
messages
=
{
merchantName
:
{
merchantName
:
{
required
:
'请填写门店名称'
,
required
:
"请填写门店名称"
,
},
},
contactName
:
{
contactName
:
{
required
:
'请填写联系人'
required
:
"请填写联系人"
,
},
},
contactPhone
:
{
contactPhone
:
{
required
:
'请填写手机号'
required
:
"请填写手机号"
,
}
}
,
}
}
;
this
.
WxValidate
=
new
WxValidate
(
rules
,
messages
)
this
.
WxValidate
=
new
WxValidate
(
rules
,
messages
)
;
},
},
//报错
//报错
showModal
(
error
)
{
showModal
(
error
)
{
wx
.
showToast
({
wx
.
showToast
({
title
:
error
.
msg
,
title
:
error
.
msg
,
icon
:
'none'
,
icon
:
"none"
,
})
})
;
},
},
// 表单输入
// 表单输入
handleInput
(
e
)
{
handleInput
(
e
)
{
let
name
=
e
.
currentTarget
.
dataset
.
name
let
name
=
e
.
currentTarget
.
dataset
.
name
;
let
val
=
e
.
detail
.
value
let
val
=
e
.
detail
.
value
;
const
form
=
`applyForm.
${
name
}
`
const
form
=
`applyForm.
${
name
}
`
;
this
.
setData
({
this
.
setData
({
[
form
]:
val
[
form
]:
val
,
})
})
;
},
},
// 校验表单
// 校验表单
validateForm
()
{
validateForm
()
{
let
params
=
this
.
data
.
applyForm
let
params
=
this
.
data
.
applyForm
;
// 校验表单
// 校验表单
if
(
!
this
.
WxValidate
.
checkForm
(
params
))
{
if
(
!
this
.
WxValidate
.
checkForm
(
params
))
{
const
error
=
this
.
WxValidate
.
errorList
[
0
]
const
error
=
this
.
WxValidate
.
errorList
[
0
]
;
this
.
showModal
(
error
)
this
.
showModal
(
error
)
;
wx
.
hideLoading
()
wx
.
hideLoading
()
;
return
false
return
false
;
}
else
{
}
else
{
return
[
params
,
this
.
data
.
tabIndex
]
return
[
params
,
this
.
data
.
tabIndex
]
;
}
}
}
},
// 设置手机号
setPhone
(
phone
)
{
this
.
setData
({
[
applyForm
.
contactPhone
]:
phone
,
});
},
},
},
// 组件页面生周期
// 组件页面生周期
...
@@ -107,8 +113,8 @@ Component({
...
@@ -107,8 +113,8 @@ Component({
created
:
function
()
{
created
:
function
()
{
// 在组件实例刚刚被创建时执行
// 在组件实例刚刚被创建时执行
// 初始化验证规则函数
// 初始化验证规则函数
console
.
log
(
'created'
);
console
.
log
(
"created"
);
this
.
initValidate
()
this
.
initValidate
()
;
},
},
}
})
\ No newline at end of file
\ No newline at end of file
},
});
components/CooperationApply/CooperationApply.wxml
View file @
3e6796b
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
手机号
手机号
<text class="require">*</text>
<text class="require">*</text>
</text>
</text>
<input name="bussinessName" type='text' placeholder-style='font-size:28rpx;color: #9E9EA8;' placeholder='请输入手机号' value="{{applyForm.contactPhone}}" bindinput="handleInput" data-name="contactPhone"></input>
<input name="bussinessName" type='text'
maxlength="11"
placeholder-style='font-size:28rpx;color: #9E9EA8;' placeholder='请输入手机号' value="{{applyForm.contactPhone}}" bindinput="handleInput" data-name="contactPhone"></input>
</view>
</view>
</view>
</view>
</form>
</form>
...
...
pages/newEnergy/newEnergy.js
View file @
3e6796b
...
@@ -5,13 +5,15 @@
...
@@ -5,13 +5,15 @@
import
{
import
{
entmicroApi
entmicroApi
}
from
"../../api/api"
}
from
"../../api/api"
import
Util
from
"../../utils/util"
;
Page
({
Page
({
/**
/**
* 页面的初始数据
* 页面的初始数据
*/
*/
data
:
{
data
:
{
applyShow
:
false
applyShow
:
false
,
hasPhoneNumber
:
false
},
},
toSuccess
()
{
toSuccess
()
{
...
@@ -23,6 +25,17 @@ Page({
...
@@ -23,6 +25,17 @@ Page({
applyShow
:
!
this
.
data
.
applyShow
applyShow
:
!
this
.
data
.
applyShow
})
})
},
},
// 授权手机号
updatePhoneNumber
(
e
)
{
console
.
log
(
e
);
if
(
e
.
detail
)
{
this
.
setData
({
applyShow
:
!
this
.
data
.
applyShow
,
});
this
.
selectComponent
(
'#applyForm'
).
setPhone
(
e
.
detail
)
}
},
// 提交申请
// 提交申请
submitApply
()
{
submitApply
()
{
wx
.
$util
.
showLoading
(
'提交中...'
)
wx
.
$util
.
showLoading
(
'提交中...'
)
...
@@ -58,10 +71,20 @@ Page({
...
@@ -58,10 +71,20 @@ Page({
})
})
},
},
getPhone
()
{
console
.
log
(
Util
.
getUserInfo
())
if
(
Util
.
getUserInfo
()
&&
Util
.
getUserInfo
().
phone
)
{
this
.
setData
({
hasPhoneNumber
:
true
});
}
},
/**
/**
* 生命周期函数--监听页面加载
* 生命周期函数--监听页面加载
*/
*/
onLoad
(
options
)
{
onLoad
(
options
)
{
this
.
getPhone
()
wx
.
hideShareMenu
({
wx
.
hideShareMenu
({
menus
:
[
'shareAppMessage'
,
'shareTimeline'
]
menus
:
[
'shareAppMessage'
,
'shareTimeline'
]
})
})
...
...
pages/newEnergy/newEnergy.json
View file @
3e6796b
{
{
"usingComponents"
:
{
"usingComponents"
:
{
"apply-content"
:
"../../components/CooperationApply/CooperationApply"
"apply-content"
:
"../../components/CooperationApply/CooperationApply"
,
"phone-number"
:
"../../components/PhoneNumber/PhoneNumber"
},
},
"navigationBarTitleText"
:
"数字化+新能源汽车"
"navigationBarTitleText"
:
"数字化+新能源汽车"
}
}
\ No newline at end of file
\ No newline at end of file
pages/newEnergy/newEnergy.wxml
View file @
3e6796b
<!--
pages/newEnergy/newEnergy.wxml
-->
<!--
pages/newEnergy/newEnergy.wxml
-->
<view class="wrapper-bg">
<view class="wrapper-bg">
<image class="newenergy-img newenergy-img1" mode="widthFix" webp src="{{IMGURL}}home/newenergy1.png?v={{img_version}}"></image>
<image class="newenergy-img newenergy-img1" mode="widthFix" webp src="{{IMGURL}}home/newenergy1.png?v={{img_version}}"></image>
<image class="newenergy-img newenergy-img2" mode="widthFix" webp src="{{IMGURL}}home/newenergy2.png?v={{img_version}}"></image>
<image class="newenergy-img newenergy-img2" mode="widthFix" webp src="{{IMGURL}}home/newenergy2.png?v={{img_version}}"></image>
...
@@ -7,10 +7,12 @@
...
@@ -7,10 +7,12 @@
<view class="apply-box" wx:if="{{applyShow}}">
<view class="apply-box" wx:if="{{applyShow}}">
<image class="apply-bg" mode="widthFix" webp src="{{IMGURL}}home/apply_bg.png?v={{img_version}}"></image>
<image class="apply-bg" mode="widthFix" webp src="{{IMGURL}}home/apply_bg.png?v={{img_version}}"></image>
<view>
<view>
<apply-content id="applyForm" class="apply-content"></apply-content>
<apply-content id="applyForm" class="apply-content"></apply-content>
<button class="btn-apply submit-btn" bindtap="submitApply">提交申请</button>
<button class="btn-apply submit-btn" bindtap="submitApply">提交申请</button>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="btn-box" wx:if="{{!applyShow}}">
<view class="btn-box" wx:if="{{!applyShow}}">
<button class="btn-apply" bindtap="toApply">合作申请</button></view>
\ No newline at end of file
\ No newline at end of file
<phone-number wx:if="{{!hasPhoneNumber}}" bind:updatePhoneNumber="updatePhoneNumber" showIcon="{{false}}" phoneText="合作申请"></phone-number>
<button wx:else class="btn-apply" bindtap="toApply">合作申请</button>
</view>
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment