Browse Source

feat: mobile test

jiangzixin 1 năm trước cách đây
mục cha
commit
7f17fe53ce
2 tập tin đã thay đổi với 204 bổ sung45 xóa
  1. 202 43
      uniapp/pages/policy/index.vue
  2. 2 2
      uniapp/pages/policy/search.vue

+ 202 - 43
uniapp/pages/policy/index.vue

@@ -10,13 +10,70 @@
             :current="currentTab" @change="changeTab" />
         <!-- 我是人才 -->
         <view class="p-70 p-t-40 talent-tab" v-if="currentTab == 0">
-            <view class="flex-col col-center">
+            <view class="flex-col col-center" v-if="currentTab == 2">
                 <view class="title">您所从事的行业:</view>
-                <router-link :to="{ path: '/pages/policy/talent', query: { type: item.type, title: item.title }}" class="m-t-40"
-                    v-for="(item,index) in talentTypeList">
+                <router-link :to="{ path: '/pages/policy/talent', query: { type: item.type, title: item.title }}"
+                    class="m-t-40" v-for="(item,index) in talentTypeList">
                     <image :src="item.image" mode="widthFix"></image>
                 </router-link>
             </view>
+            <view class="huodong-details">
+
+                <view class="p-30 ">
+                    <!-- <view class="detail-title">
+                        {{ title }}
+                    </view> -->
+                    <view class="content-box bg-white m-t-30">
+                        <view class="detail-cell row-between u-border-bottom" v-for="(item, index) in surveyList"
+                            @tap="pickerShow(item.name)" v-if="item.type != 'array'">
+                            <view class="width75">
+                                {{item.description}}
+                            </view>
+                            <view class="text-right flex-1" v-if="item.type == 'radio' || item.type == 'select'">
+                                <text class="muted">{{survey[item.name]}}</text>
+                                <u-icon name="arrow-right" size="28" color="#B8B8B8"
+                                    :label="survey[item.name]!= undefined ? '' :'请选择'" label-pos="left"></u-icon>
+                                <u-picker v-model="show[item.name]" mode="selector" :range="item.value"
+                                    @confirm="pickerConfirm(index, $event)" @cancel="pickerCancel(index)"></u-picker>
+                            </view>
+                            <view class="text-right flex-1" v-if="item.type == 'checkbox'">
+                                <u-checkbox-group shape="circle" active-color="#DD4250" :name="item.name"
+                                    @change="groupChange(index, $event)">
+                                    <u-checkbox :name="value" v-for="(value, key) in item.value" :key="key"
+                                        v-model="item.checked[key]">
+                                        {{value}}
+                                    </u-checkbox>
+                                </u-checkbox-group>
+                            </view>
+
+                            <view class="text-right flex-1" v-if="item.type == 'text'">
+                                <cus-selects :data="item.value" v-model="survey[item.name]" :clearable='true'
+                                    :filterable='true' :searchType='1' arrLeft='300' placeholder='输入搜索'></cus-selects>
+                            </view>
+                        </view>
+
+
+                        <view class="detail-cell row-between u-border-bottom">
+                            <view class="bold">
+                                验证码
+                            </view>
+                            <view class="text-right flex-1 flex row-right">
+                                <input type="text" v-model="survey.code" placeholder="请输入">
+                                <image :src="captchaImg" mode="heightFix" style="height: 54rpx;" class="m-l-10"
+                                    @tap="refreshCaptcha"></image>
+                            </view>
+                        </view>
+
+
+                    </view>
+                </view>
+
+                <view class="footer">
+                    <button class="white btn lg" @click="handleConsult">提交</button>
+                </view>
+
+            </view>
+
         </view>
         <!-- 我是企业 -->
         <view v-if="currentTab == 1">
@@ -202,7 +259,8 @@
                             </view>
                             <view class="text-right flex-1 flex row-right">
                                 <input type="text" v-model="info.code" placeholder="请输入">
-                                <image :src="captchaImg" mode="heightFix" style="height: 54rpx;" class="m-l-10" @tap="refreshCaptcha"></image>
+                                <image :src="captchaImg" mode="heightFix" style="height: 54rpx;" class="m-l-10"
+                                    @tap="refreshCaptcha"></image>
                             </view>
                         </view>
 
@@ -220,21 +278,29 @@
 </template>
 
 <script>
+    import cusSelects from '@/components/cus-selects-fan/cus-selects-fan.vue'
     import {
         mapGetters,
         mapActions
     } from 'vuex'
     import {
-        submitSurveyEnterprise
+        submitSurveyEnterprise,
+        getSurvey,
+        submitSurvey
     } from '@/api/app';
     import {
         getCaptcha
     } from '@/utils/tools'
     const app = getApp()
     export default {
+        components: {
+            cusSelects
+        },
         data() {
             return {
                 show: {},
+                survey: {},
+                surveyList: [],
                 propertyModeList: [{
                     value: 1,
                     label: '自主研发'
@@ -300,6 +366,7 @@
                     name: '我是企业',
                 }],
                 currentTab: 0,
+                type: 'industry', //默认类型
                 talentTypeList: [{
                     'image': '/static/images/type-1.png',
                     type: 'industry',
@@ -363,12 +430,13 @@
             this.isStandard = this.isStandardList[0]
             this.info.propertyMode = this.propertyMode.value
             this.info.isStandard = this.isStandard.value
-            
-             this.captchaImg = getCaptcha()
+
+            this.captchaImg = getCaptcha()
         },
         onShow() {
             // this.getHomeFun();
             // this.getUser();
+             this.getSurvey();
         },
         onHide() {},
         onPullDownRefresh() {
@@ -377,11 +445,15 @@
             // })
         },
         methods: {
-            refreshCaptcha(){
+            refreshCaptcha() {
                 this.captchaImg = getCaptcha()
-                 this.$forceUpdate();
+                this.$forceUpdate();
             },
             // ...mapActions(['getUser']),
+            groupChange(index, detail) {
+                let item = this.surveyList[index]
+                this.survey[item.name] = detail
+            },
             // 改变当前的Tabs位置
             changeTab(index) {
                 this.currentTab = index;
@@ -394,53 +466,119 @@
                 this.$forceUpdate();
             },
             pickerConfirm(index, obj) {
-                //日期
-                if (index == 'estdate') {
-                    this.info[index] = obj['year'] + '-' + obj['month'] + '-' + obj['day']
+                //人才
+                if (this.currentTab == 0) {
+                    let item = this.surveyList[index]
+                    this.survey[item.name] = item.value[obj[0]]
+                    this.show[item.name] = false
                 } else {
-                    //单选框
-                    this[index] = obj[0]
-                    this.info[index] = obj[0].value
+                    //企业
+                    //日期
+                    if (index == 'estdate') {
+                        this.info[index] = obj['year'] + '-' + obj['month'] + '-' + obj['day']
+                    } else {
+                        //单选框
+                        this[index] = obj[0]
+                        this.info[index] = obj[0].value
+                    }
                 }
                 this.$forceUpdate();
+
             },
             pickerCancel(index, obj) {
-                this.show[index] = false
+                if (this.currentTab == 0) {
+                    let item = this.surveyList[index]
+                    this.show[item.name] = false
+                } else {
+                    this.show[index] = false
+                }
                 this.$forceUpdate();
             },
             async handleConsult() {
-                console.log(this.info)
-                //表单必填验证
-                try {
-                    Object.keys(this.infoValidate).forEach((key, index) => {
-                        if (this.info[key] == '') {
-                            throw new Error('请输入' + this.infoValidate[key])
-                        }
-                    })
-                } catch (e) {
-                    this.$toast({
-                        title: e.message
-                    })
-                    return false;
+                if (this.currentTab == 0) {
+                    if (!this.survey.code) {
+                        this.$toast({
+                            title: '请输入验证码'
+                        })
+                        return false;
+                    }
+                    const {
+                        status,
+                        data,
+                        cengci,
+                        msg
+                    } = await submitSurvey(this.info);
+                    if (status == 1) {
+                        uni.setStorageSync('policyList', data);
+                        uni.setStorageSync('policyCengci', cengci);
+                        uni.navigateTo({
+                            url: '/pages/policy/list',
+                        })
+                    }
+                } else {
+                    //表单必填验证
+                    try {
+                        Object.keys(this.infoValidate).forEach((key, index) => {
+                            if (this.info[key] == '') {
+                                throw new Error('请输入' + this.infoValidate[key])
+                            }
+                        })
+                    } catch (e) {
+                        this.$toast({
+                            title: e.message
+                        })
+                        return false;
+                    }
+                    const {
+                        status,
+                        data,
+                        msg
+                    } = await submitSurveyEnterprise(this.info);
+
+                    if (status == 1) {
+                        uni.setStorageSync('enterpriseScore', data);
+                        uni.navigateTo({
+                            url: '/pages/policy/score'
+                        })
+                    }
                 }
-                //todo API验证码
-                // if (this.captcha == '' || this.captcha != 'abcd') {
-                //     this.$toast({
-                //         title: '验证码错误'
-                //     })
-                //     return false;
-                // }
+            },
 
+            //获取动态表单
+            async getSurvey() {
                 const {
                     status,
-                    data,
-                    msg
-                } = await submitSurveyEnterprise(this.info);
-
+                    data
+                } = await getSurvey({
+                    type: this.type
+                });
                 if (status == 1) {
-                    uni.setStorageSync('enterpriseScore', data);
-                    uni.navigateTo({
-                        url: '/pages/policy/score'
+                    this.surveyList = data
+
+                    this.surveyList.map((item, index) => {
+                        // this.show[item.name] = false;
+                        //初始化radio的info
+                        if (item.type == 'radio' || item.type == 'select') {
+                            this.survey[item.name] = item.value[0]
+                        }
+                        //初始化模糊搜索框
+                        if (item.type == 'text') {
+                            item.value.forEach((value, key) => {
+                                item.value[key] = {
+                                    label: key + 1 + '、' + value,
+                                    value: value
+                                }
+                            })
+                        }
+
+                        //checkbox多选判断,初始化checked状态
+                        if (item.type == 'checkbox') {
+                            item.checked = []
+                            item.value.forEach((value, key) => {
+                                item.checked[key] = false
+                            })
+                            return item;
+                        }
                     })
                 }
             },
@@ -578,4 +716,25 @@
             color: #333333;
         }
     }
+    /deep/ .select_input {
+        border: none !important;
+    }
+     /deep/ .select_modal_con {
+            position: sticky;
+            // left: -100px;
+            margin-left: -200rpx;
+            width: 700rpx;
+            
+        .select_modal {
+            height: 100%;
+        }
+        .select_content_li {
+            text-align: left !important;
+            white-space: normal !important;
+            overflow: auto !important;
+            height: auto !important;
+            line-height: normal !important;
+            margin-bottom: 16rpx !important;
+        }
+    }
 </style>

+ 2 - 2
uniapp/pages/policy/search.vue

@@ -205,8 +205,8 @@
                 let pageNum = page.num; // 页码, 默认从1开始
                 let pageSize = page.size; // 页长, 默认每页10条
                 let params = {
-                    // page_size: pageSize,
-                    // page_no: pageNum
+                    page_size: pageSize,
+                    page_no: pageNum
                 }
                 this.categoryList.forEach((item, index) => {
                 	if (item.activeIndex) {