step-one.vue 5.22 KB
<template>
    <view class="pageBox">
        <view class="width-calc">
            <view class="content-title">
                经营模式<span class="validate">*</span>
            </view>
            <view class="select-list">
                <view v-for="(item, index) in operateArr" :key="index"
                    :class="{ 'select-but': true, 'ml-12': index === 1, 'pitchOn': pageData.businessModel === item.value }"
                    @click="selectOperate(item.value)">
                    {{ item.label }}
                    <view v-if="pageData.businessModel === item.value" class="pitchOn-img"></view>
                </view>
            </view>
            <view class="tip-head">
                <view class="tips-img-box">
                    <image src="https://img02.glsx.com.cn/aus/images/preference/tips.png" class="tips-img"></image>
                </view>
                <view class="tip-box">
                    <text class="tip">批发商模式优先推荐“高周转车型”,</text>
                    <text class="tip">零售模式优先推荐“高利润车型”。</text>
                </view>
            </view>
            <view class="content-title mt-16" style="height: 28px; line-height: 28px;">
                注册地区<span class="validate">*</span>
            </view>
            <view class="reason-select" @click="openChangeCity()">
                <text v-if="pageData.cityName">{{ pageData.cityName }}</text>
                <text v-else class="placeholder">请选择注册城市</text>
                <uni-icons type="right" size="14" color="#999999" />
            </view>
        </view>
    </view>
</template>

<script lang="ts">
import { Component, Vue, Watch } from 'vue-facing-decorator';


@Component({})
export default class stepOne extends Vue {

    //页面数据
    pageData = {
        businessModel: '1',
        cityCode: '',
        cityName: '',
        cityCn: ''
    }

    //经营模式
    operateArr = [
        { label: '批发', value: '1' },
        { label: '零售', value: '2' }
    ]

    //初始化数据
    initData(data: any) {
        this.pageData.businessModel = data.businessModel || '';
        this.pageData.cityCode = data.cityCode || '';
        this.pageData.cityName = data.cityName || '';
        this.pageData.cityCn = data.cityCn || '';
    }

    //选择经营模式
    selectOperate(value: string) {
        this.pageData.businessModel = value;
    }

    openChangeCity(): void {
        const that = this;
        uni.navigateTo({
            url: '/pages/LocationCityPage', events: {
                onReturnData: function (city: any) {
                    if (city) {
                        that.pageData.cityCode = city.code || '';
                        that.pageData.cityName = city.name || '';
                        that.pageData.cityCn = city.value || '';
                    }
                }
            },
        });
    }

    // 深度监听整个pageData对象
    @Watch('pageData', { deep: true, immediate: true })
    watchPageData(newVal: any, oldVal: any) {
        this.$emit('oneData', newVal);
    }
}
</script>

<style scoped lang="scss">
.pageBox {
    width: 100%;
    background: #fff;
    float: left;
}

.width-calc {
    width: -webkit-calc(100% - 40px);
    width: -moz-calc(100% - 40px);
    width: calc(100% - 40px);
    float: left;
    margin: 0 20px;
    padding-bottom: 20px;
}

.content-title {
    width: 100%;
    height: 50px;
    line-height: 50px;
    float: left;
    color: #141e34;
    font-size: 16px;
    font-weight: 中黑体;
    font-family: "苹方-简";
}

.validate {
    color: #ee3040;
    font-size: 16px;
    padding-left: 2px;
}

.select-but {
    width: -webkit-calc(50% - 6px);
    width: -moz-calc(50% - 6px);
    width: calc(50% - 6px);
    height: 40px;
    line-height: 40px;
    border-radius: 4px;
    background: #f5f9ff;
    color: #333333;
    font-size: 14px;
    font-family: "苹方-简";
    text-align: center;
    float: left;
    cursor: pointer;
    position: relative;
}

.pitchOn {
    background: #f5f9ff !important;
    color: #185efe !important;
}

.pitchOn-img {
    position: absolute;
    top: 0;
    right: 0;
    width: 16px;
    height: 16px;
    z-index: 99;
    background-image: url("https://img02.glsx.com.cn/aus/images/preference/pitchOn.png");
    background-repeat: no-repeat;
    background-size: 100%;
}

.ml-12 {
    margin-left: 12px;
}

.mt-16 {
    margin-top: 16px;
}

.tip-head {
    width: 100%;
    float: left;
    margin-top: 16px;
}

.tips-img-box {
    width: 14px;
    height: 36px;
    float: left;
}

.tip-box {
    width: -webkit-calc(100% - 18px);
    width: -moz-calc(100% - 18px);
    width: calc(100% - 18px);
    height: 36px;
    float: left;
    margin-left: 4px;
}

.tips-img {
    width: 14px;
    height: 14px;
    z-index: -1;
}

.tip {
    width: 100%;
    height: 18px;
    float: left;
    line-height: 18px;
    color: #666666;
    font-size: 12px;
}

.reason-select {
    width: 100%;
    height: 52px;
    line-height: 52px;
    float: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    border-bottom: 1px solid #e6ebf5;
    cursor: pointer;
    color: #333333;
}

.placeholder {
    color: #999999;
    font-size: 14px;
}
</style>