123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349 |
- <template>
- <view class="contact">
- <view class="head">
- <view class="title">
- <image class="img-title" src="/static/img/contact/head_title.png" mode="aspectFill" />
- </view>
- <view class="tel">
- <image class="tel-img" src="/static/img/contact/icon_phone.png" mode="aspectFill" />
- </view>
- </view>
- <view class="form-warpper">
- <view class="input-content-wrapper">
- <form @submit="formSubmit" @reset="formReset">
- <view class="input-content">
- <view class="iconfont">
- <image class="image" src="/static/img/contact/icon_01.png" mode="aspectFill" />
- </view>
- <view class="flex align-center">
- <input class="uni-input" v-model="form.customer_name" name="customerName" placeholder="请输入您的姓名" />
- </view>
- </view>
- <view class="input-content">
- <view class="iconfont">
- <image class="image" src="/static/img/contact/icon_02.png" mode="aspectFill" />
- </view>
- <view class="flex align-center">
- <input class="uni-input" maxlength="11" v-model="form.mobile" name="mobile" placeholder="请输入联系方式" />
- </view>
- </view>
- <view class="input-content">
- <view class="iconfont">
- <image class="image" src="/static/img/contact/icon_03.png" mode="aspectFill" />
- </view>
- <view class="area flex align-center">
- <pick-regions name="regionCode" :defaultRegion="defaultRegionCode" @getRegion="handleGetRegion">
- <text :class="['regions', regionName ? '' : 'empty']" >{{ regionName || '请选择所在地区' }}</text>
- </pick-regions>
- <!-- <input class="uni-input" v-model="form.parentName" name="parentName" placeholder="请选择所在地区" /> -->
- <image class="arrow" src="/static/img/contact/down.png" mode="aspectFill" />
- </view>
- </view>
- <view class="input-content">
- <view class="iconfont">
- <image class="image" src="/static/img/contact/icon_04.png" mode="aspectFill" />
- </view>
- <view class="area flex align-center">
- <picker mode="selector" name="type" @change="typeChange" :value="typeIndex" :range="typeList" range-key="label">
- <view class="empty" v-if="typeIndex == -1">
- {{ '您的意向' }}
- </view>
- <view v-else>
- {{ typeList[typeIndex] }}
- </view>
- </picker>
- <!-- <input class="uni-input" v-model="form.parentName" name="parentName" placeholder="您的意向" /> -->
- <image class="arrow" src="/static/img/contact/down.png" mode="aspectFill" />
- </view>
- </view>
- <view class="submit-btn">
- <image src="/static/img/contact/submit.png" mode="aspectFill" />
- <button class="confirm-btn" :disabled="disabled" form-type="submit"></button>
- <button form-type="reset" ref="resrtBtn" style="display:none;">取消</button>
- </view>
- </form>
- </view>
- </view>
- <view class="adderss flex align-start">
- <view class="text">
- <view>
- 地址:北京市朝阳区高碑店乡西店记忆文创小镇E6号楼
- </view>
- <view>
- 一层102号
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import pickRegions from '@/components/pick-regions/pick-regions.vue';
- import { saveApply } from '@/api/apply';
- export default {
- data() {
- return {
- disabled:false,
- form: {
- customer_name: '',
- mobile: '',
- type: 0
- },
- region:[],
- defaultRegionCode: '110101',
- defaultRegion:['北京市','市辖区','东城区'],
- typeIndex: -1,
- typeList: ["教学渠道代理", "思维芯游戏教室渠道代理", "家庭版渠道代理", "HOME&PLUS渠道代理", "探索小镇渠道代理(TOWN)", "合作园所(北京地区园所)"],
- reqBody: {}
- }
- },
- computed: {
- regionName: {
- get: function() {
- return this.region.map(item=>item.name).join('/')
- },
- set: function(val) {
- if(val) {
- this.region = val.map(item => {
- return {
- name: item
- }
- })
- }
- return val;
- }
- },
- regionCode() {
- if (this.region.length > 0) {
- return this.region[this.region.length - 1].code;
- } else {
- return this.defaultRegionCode;
- }
- }
- },
- components: {
- pickRegions
- },
- methods: {
- formSubmit(e) {
- console.log(e.detail.value);
- console.log(this.typeIndex);
- // {
- // "entity": {
- // "customer_name": "李哈哈测试22",
- // "mobile": "13120373714",
- // "address": "xxxxx"
- // },
- // "field": [{
- // "fieldId": 135,
- // "fieldName": "代理商类型",
- // "value": "教学渠道代理",
- // }]
- // }
- let formData = e.detail.value;
- let rules = [
- { name: 'customerName', checkType: 'notnull', checkRule: '', errorMsg: '请填写姓名' },
- { name: 'customerName', checkType: 'string', checkRule: '2,8', errorMsg: '请输入2-8位姓名' },
- { name: 'type', checkType: 'in', checkRule: '0, 1, 2, 3, 4, 5', errorMsg: '意向不能为空' },
- { name: 'mobile', checkType: 'notnull', checkRule: '', errorMsg: '请填写联系方式'},
- { name: 'mobile', checkType: 'phoneno', checkRule: '', errorMsg: '联系方式不正确'},
- ]
- let regionRule = [
- { name: 'regionCode', checkType: 'notnull', checkRule: '', errorMsg: '请选择所在地区'},
- ];
- this.reqBody['regionCode'] = this.region;
- let checkRes = this.$mGraceChecker.check(formData, rules);
- if (!checkRes) {
- // this.disabled = true;
- this.$mHelper.toast(this.$mGraceChecker.error);
- return false;
- }
- let regionRes = this.$mGraceChecker.check(this.reqBody, regionRule)
- if (!regionRes) {
- this.$mHelper.toast(this.$mGraceChecker.error);
- return false;
- }
- if (this.typeIndex == -1) {
- this.$mHelper.toast('请选择您的意向');
- return false;
- }
- let entity = {
- customer_name: formData.customerName,
- mobile: formData.mobile,
- address: this.region.map(item=>item.name).join(',')
- };
- let field = [{
- fieldId: 135,
- name: "代理商类型",
- value: this.typeList[this.typeIndex]
- }];
- if (checkRes && regionRes && this.typeIndex != -1) {
- this.disabled = true;
- this.$http.post(saveApply, {
- entity,
- field
- }).then(res=> {
- this.$mHelper.toast('提交成功!我们会在在第一时间内联系您');
- this.$refs.resrtBtn.$dispatch('Form', 'uni-form-reset', {
- type: 'reset'
- })
- this.typeIndex = -1;
- this.region = [];
- this.disabled = false;
- }).catch(err => {
- this.disabled = false;
- console.log('err')
- })
- }
- },
- typeChange(e) {
- const index = e.detail.value;
- this.typeIndex = index;
- // this.form.sex = this.genderList[index].value;
- },
- // 获取选择的地区
- handleGetRegion(region){
- this.region = region
- }
- }
- }
- </script>
- <style lang="scss">
- .contact {
- padding: 86upx 0 120upx;
- background: url('@/static/img/contact/bg.png') no-repeat #01A2E8;
- background-size: cover;
- .title {
- text-align: center;
- .img-title {
- width: 598upx;
- height: 168upx;
- vertical-align: middle;
- }
- }
- .tel {
- margin-top: 36upx;
- .tel-img {
- width: 564upx;
- height: 134upx;
- vertical-align: middle;
- margin-left: 68upx;
- }
- }
- .form-warpper {
- margin-top: 52upx;
- padding: 0 96upx;
- }
- .input-content-wrapper {
- margin-bottom: 0upx
- }
- .input-content {
- display: flex;
- align-items: center;
- box-sizing: border-box;
- height: 100upx;
- border: 2upx solid #003F66;
- margin-bottom: 36upx;
- padding: 0 42upx 0 42upx;
- background: #FFFFFF;
- border-radius: 172upx;
- .iconfont {
- position: relative;
- margin-right: 52upx;
- &::after {
- content: "";
- width: 2upx;
- height: 34upx;
- background:#B9B9B9;
- border-radius: 4upx;
- position: absolute;
- top: 4upx;
- right: -26upx;
- }
- image {
- width: 40upx;
- height: 46upx;
- vertical-align: middle;
- }
- }
- .input-placeholder {
- color: #B9B9B9;
- line-height: 36px;
- font-size: 28upx;
- font-family: PingFangSC-Regular, PingFang SC;
- font-weight: 400;
- }
- .area {
- width: 100%;
- }
- uni-picker {
- width: 100%;
- }
- .regions {
- &.empty {
- color: #B9B9B9;
- line-height: 36px;
- font-size: 28upx;
- font-family: PingFangSC-Regular, PingFang SC;
- font-weight: 400;
- }
- }
- .empty {
- color: #B9B9B9;
- line-height: 36px;
- font-size: 28upx;
- font-family: PingFangSC-Regular, PingFang SC;
- font-weight: 400;
- }
- .picker {
- color: #B9B9B9;
- line-height: 36px;
- font-size: 28upx;
- font-family: PingFangSC-Regular, PingFang SC;
- font-weight: 400;
- }
- .arrow {
- width: 24upx;
- height: 12upx;
- vertical-align: middle;
- }
- }
- .submit-btn {
- position: relative;
- margin-top: 94upx;
- text-align: center;
- image {
- width: 334upx;
- height: 92upx;
- vertical-align: middle;
- }
- .confirm-btn {
- position: absolute;
- bottom: 0;
- left: 50%;
- transform: translateX(-50%);
- width: 334upx;
- height: 92upx;
- background: red;
- opacity: 0;
- }
- }
- .adderss {
- margin: 150upx 0 0 60upx;
- .text {
- font-size: 24upx;
- font-family: PingFangSC-Semibold, PingFang SC;
- font-weight: 600;
- color: #B2E8FF;
- line-height: 34upx;
- }
- }
- }
- </style>
|