Commit 3e6796bf by 前端

调整

1 parent 31a7273d
// components/CooperationApply/CooperationApply.js
import WxValidate from "../../utils/WxValidate"
import WxValidate from "../../utils/WxValidate";
Component({
/**
* 组件的属性列表
*/
properties: {
},
properties: {},
/**
* 组件的初始数据
*/
data: {
tabData: [{
name: '门店合作申请',
value: 0
tabData: [
{
name: "门店合作申请",
value: 0,
},
{
name: '代理商合作申请',
value: 1
}
name: "代理商合作申请",
value: 1,
},
],
tabIndex: 0,
applyForm: {
merchantName: '',
carModel: '',
contactName: '',
contactPhone: ''
merchantName: "",
carModel: "",
contactName: "",
contactPhone: "",
},
},
......@@ -37,69 +36,76 @@ Component({
selectTab(e) {
console.log(e.currentTarget.dataset.index);
this.setData({
tabIndex: e.currentTarget.dataset.index
})
tabIndex: e.currentTarget.dataset.index,
});
},
// 表单验证规则
initValidate() {
console.log(123123);
const rules = {
merchantName: {
required: true
required: true,
},
contactName: {
required: true
required: true,
},
contactPhone: {
required: true,
tel: true
}
}
tel: true,
},
};
const messages = {
merchantName: {
required: '请填写门店名称',
required: "请填写门店名称",
},
contactName: {
required: '请填写联系人'
required: "请填写联系人",
},
contactPhone: {
required: '请填写手机号'
}
}
this.WxValidate = new WxValidate(rules, messages)
required: "请填写手机号",
},
};
this.WxValidate = new WxValidate(rules, messages);
},
//报错
showModal(error) {
wx.showToast({
title: error.msg,
icon: 'none',
})
icon: "none",
});
},
// 表单输入
handleInput(e) {
let name = e.currentTarget.dataset.name
let val = e.detail.value
const form = `applyForm.${name}`
let name = e.currentTarget.dataset.name;
let val = e.detail.value;
const form = `applyForm.${name}`;
this.setData({
[form]: val
})
[form]: val,
});
},
// 校验表单
validateForm() {
let params = this.data.applyForm
let params = this.data.applyForm;
// 校验表单
if (!this.WxValidate.checkForm(params)) {
const error = this.WxValidate.errorList[0]
this.showModal(error)
wx.hideLoading()
return false
const error = this.WxValidate.errorList[0];
this.showModal(error);
wx.hideLoading();
return false;
} else {
return [params, this.data.tabIndex]
return [params, this.data.tabIndex];
}
}
},
// 设置手机号
setPhone(phone) {
this.setData({
[applyForm.contactPhone]: phone,
});
},
},
// 组件页面生周期
......@@ -107,8 +113,8 @@ Component({
created: function () {
// 在组件实例刚刚被创建时执行
// 初始化验证规则函数
console.log('created');
this.initValidate()
console.log("created");
this.initValidate();
},
}
})
\ No newline at end of file
},
});
......@@ -30,7 +30,7 @@
手机号
<text class="require">*</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>
</form>
......
......@@ -5,13 +5,15 @@
import {
entmicroApi
} from "../../api/api"
import Util from "../../utils/util";
Page({
/**
* 页面的初始数据
*/
data: {
applyShow: false
applyShow: false,
hasPhoneNumber: false
},
toSuccess() {
......@@ -23,6 +25,17 @@ Page({
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() {
wx.$util.showLoading('提交中...')
......@@ -58,10 +71,20 @@ Page({
})
},
getPhone() {
console.log(Util.getUserInfo())
if (Util.getUserInfo() && Util.getUserInfo().phone) {
this.setData({
hasPhoneNumber: true
});
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getPhone()
wx.hideShareMenu({
menus: ['shareAppMessage', 'shareTimeline']
})
......
{
"usingComponents": {
"apply-content": "../../components/CooperationApply/CooperationApply"
"apply-content": "../../components/CooperationApply/CooperationApply",
"phone-number": "../../components/PhoneNumber/PhoneNumber"
},
"navigationBarTitleText": "数字化+新能源汽车"
}
\ No newline at end of file
<!--pages/newEnergy/newEnergy.wxml-->
<!-- pages/newEnergy/newEnergy.wxml -->
<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-img2" mode="widthFix" webp src="{{IMGURL}}home/newenergy2.png?v={{img_version}}"></image>
......@@ -7,10 +7,12 @@
<view class="apply-box" wx:if="{{applyShow}}">
<image class="apply-bg" mode="widthFix" webp src="{{IMGURL}}home/apply_bg.png?v={{img_version}}"></image>
<view>
<apply-content id="applyForm" class="apply-content"></apply-content>
<button class="btn-apply submit-btn" bindtap="submitApply">提交申请</button>
<apply-content id="applyForm" class="apply-content"></apply-content>
<button class="btn-apply submit-btn" bindtap="submitApply">提交申请</button>
</view>
</view>
</view>
<view class="btn-box" wx:if="{{!applyShow}}">
<button class="btn-apply" bindtap="toApply">合作申请</button></view>
\ 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
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!