8***@qq.com
8***@qq.com
  • 发布:2019-04-19 10:03
  • 更新:2019-04-19 10:37
  • 阅读:777

底部tabbar选项卡不应该显示的但是显示出来了

分类:uni-app

底部tabbar选项卡不应该显示的但是显示出来了而且样式错乱偶现的,怎么能不显示的?

2019-04-19 10:03 负责人:无 分享
已邀请:
DCloud_UNI_CHB

DCloud_UNI_CHB

这个要看你的页面是怎么实现的,最好有示例代码或项目,还需要说明有问题的平台、HBuilderX版本等关联信息,否则无法帮你分析。

  • 8***@qq.com (作者)

    <template>

    <view class="page">

    <view class="logo">

    <image src="../../../static/logo.png" mode=""></image>

    </view>

    <view class="content">

    <view class="input-group">

    <!-- <view v-if="weixinLogin=='fail'" class="input-row border">

    <view class="leftLabel">

    手机

    </view><input type="number" maxlength="11" placeholder-style="color:#9B9B9B" v-model="phone" placeholder="请输入手机号码">

    </view> -->

    <view class="input-row border">

    <view class="leftLabel">

    姓名

    </view>

    <input type="text" @input="noEmo()" maxlength="10" placeholder-style="color:#9B9B9B" v-model="name" placeholder="请输入您的姓名">

    </view>

    <view class="input-row border">

    <view class="leftLabel">类型</view>

    <radio-group class="uni-flex" name="gender" @change="radioChange">

    <label>

    <radio value="1" />小区</label>

    <label>

    <radio value="3" />学校</label>

    <label>

    <radio value="2" />单位</label>

    </radio-group>

    </view>

    <view class="input-row border">

    <view class="leftLabel uni-pull-left">

    区域

    </view>

    <view class="uni-pull-right input-row uni-list-cell-navigate uni-navigate-right cityContainer">

    <view class="viewPicker" @tap="showMulLinkageThreePicker">

    {{areaText}}

    </view>

    <mpvue-city-picker :themeColor="themeColor" ref="mpvueCityPicker" :pickerValueDefault="cityPickerValueDefault"

    @onCancel="onCancel" @onConfirm="onConfirm"></mpvue-city-picker>

    </view>

    </view>

    <view class="input-row border" v-show="radioType===1">

    <view class="leftLabel uni-pull-left">

    小区

    </view>

    <view class="uni-pull-right input-row uni-list-cell-navigate uni-navigate-right cityContainer">

    <view class="viewPicker" @tap="showSinglePicker">

    {{communityText}}

    </view>


                    </view>  
    </view>

    <view class="input-row border" v-show="radioType===3">
    <view class="leftLabel uni-pull-left">
    学校
    </view>
    <view class="uni-pull-right input-row uni-list-cell-navigate uni-navigate-right cityContainer">
    <view class="viewPicker" @tap="showSinglePicker">
    {{schoolText}}
    </view>
    </view>
    </view>
    <view class="input-row border" v-show="radioType===2">
    <view class="leftLabel uni-pull-left">
    单位
    </view>
    <view class="uni-pull-right input-row uni-list-cell-navigate uni-navigate-right cityContainer">
    <view class="viewPicker" @tap="showSinglePicker">
    {{unitText}}
    </view>
    </view>
    </view>
    <view class="input-row border">
    <view class="leftLabel uni-pull-left">
    详细地址
    </view>
    <view class="uni-pull-right input-row uni-list-cell-navigate uni-navigate-right cityContainer">
    <view class="viewPicker" @click="showBottomPopup">
    {{detailAddress}}
    </view>
    </view>
    </view>

    </view>
    <view class="btn-row">
    <button class="loginBtn" @tap="completeWxMessage">保存</button>
    </view>
    </view>
    <uni-popup :show="showPopupBottom" style="height: 200upx;" :type="popType" v-on:hidePopup="hidePopup">
    <view class="uni-popup-bottom">
    <view class="input-view">
    <uni-icon type="search" size="22" color="#666666"></uni-icon>
    <input confirm-type="search" maxlength="10" class="input" style="background: none;" :value="inputClearValue"
    @input="bindClearInput" type="text" />
    <view class="uni-icon uni-icon-clear" v-if="showClearIcon" @click="clearIcon"></view>
    </view>
    <view class="" v-show="searchResult">
    <view class="noresult">
    当前搜索无结果
    </view>
    <view class="">
    <button class="create" @tap="addHouseHold">创建当前搜索结果为您的详细住址</button>
    </view>
    </view>
    </view>
    </uni-popup>
    <mpvue-picker :themeColor="themeColor" ref="mpvuePicker" :mode="mode" :deepLength="deepLength" :pickerValueDefault="pickerValueDefault"
    @onConfirm="onConfirm" @onCancel="onCancel" :pickerValueArray="pickerValueArray"></mpvue-picker>
    </view>

    </template>

    <script>

    import mpvuePicker from '../../../components/mpvue-picker/mpvuePicker.vue';

    import mpvueCityPicker from '../../../components/mpvue-citypicker/mpvueCityPicker.vue'

    import cityData from '../../../common/city.data.js';

    import uniPopup from '../../../components/uni-popup.vue';

    import uniIcon from '../../../components/uni-icon.vue';

    import service from '../../../service.js';

    import {

    mapState,

    mapMutations

    } from 'vuex'

    var util = require('../../../common/util.js');

    var radioState = '';

    var district

    const path = service.path;

    export default {

    components: {

    mpvuePicker,

    mpvueCityPicker,

    uniIcon,

    uniPopup,

    },

    data() {

    return {

    cityPickerValueDefault: [0, 0, 1],

    themeColor: '#30CAB0',

    detailAddress: '支持搜索您的地址哦',

    areaText: '请选择区域',

    scene: '',

    name: '',

    radioType: '',

    mode: 'selector',

    deepLength: 0,

    pickerValueDefault: [],

    pickerValueArray: [],

    popType: 'bottom',

    showPopupBottom: false,

    inputValue: '',

    showClearIcon: false,

    inputClearValue: "",

    msg: '',

    pickerSingleArray: [],

    pickerDetailArray: [],

    communityText: '请选择小区',

    schoolText: '请选择学校',

    unitText: '请选择单位',

    detailState: false,

    searchResult: false,

    orgId: '',

    orgCode: '',

    phone: '',

    sid: '',

    register: '',

    unionId: '',

    avatarUrl: '',

    nickName: '',

    alid: '',

    weixinLogin: '',

    network: true

    }

    },

    onLoad(option) {

    this.register = option.register;

    this.weixinLogin = option.weixinLogin;

    // #ifdef H5

    this.unionId = option.hunionid ? option.hunionid : '';

    // #endif

    },

    onShow() {

    uni.getNetworkType({

    success: (res) => {

    if (res.networkType == 'none') {

    this.network = false;

    uni.showToast({

    title: '网络错误'

    })

    return;

    } else {

    this.network = true;

    }

    },

    })

    if (this.network == true) {

    var userInfo = service.getUsers();

    this.sid = service.getSid();

    this.phone = userInfo.phone;

    // #ifndef H5

    this.unionId = service.getInfo().unionId ? service.getInfo().unionId : '';

    // #endif

    this.alid = service.getInfo().alid ? service.getInfo().alid : '';

    this.nickName = userInfo.nickName ? userInfo.nickName : '';

    this.avatarUrl = userInfo.avatarUrl ? userInfo.avatarUrl : '';

    }

    },

    methods: {

    noEmo: function() {

    var reg =

    /[^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\n]/g;

    if (this.name.match(reg)) {

    this.name = this.name.replace(reg, '').trim();

    }

    },

    // 单列

    showSinglePicker() {

    if (this.tel == '' && this.weixinLogin == 'fail') {

    uni.showToast({

    icon: 'none',

    title: '手机号不能为空'

    });

    return;

    }

    if (this.name == '') {

    uni.showToast({

    title: '请输入姓名',

    icon: 'none'

    })

    return;

    }

    if (this.areaText == "请选择区域") {

    uni.showToast({

    title: '请先选择区域',

    icon: 'none'

    })

    return;

    }

    if (this.pickerSingleArray == '') {

    uni.showToast({

    title: '暂无信息',

    icon: 'none'

    })

    return;

    }

    this.pickerValueArray = this.pickerSingleArray;

    this.mode = 'selector'

    this.deepLength = 1

    this.pickerValueDefault = []

    this.$refs.mpvuePicker.show()

    this.detailState = false

    },

    showDetailPicker() {

    this.pickerValueArray = this.pickerDetailArray;

    this.mode = 'selector'

    this.deepLength = 1

    this.detailState = true

    this.pickerValueDefault = []

    this.$refs.mpvuePicker.show()

    },

    //统一的关闭popup方法

    hidePopup: function() {

    this.showPopupBottom = false;

    },

    // 三级联动选择

    showMulLinkageThreePicker() {

    if (this.phone == '' && this.weixinLogin == 'fail') {

    uni.showToast({

    icon: 'none',

    title: '手机号不能为空'

    });

    return;

    }

    if (this.name == '') {

    uni.showToast({

    title: '请输入姓名',

    icon: 'none'

    })

    return;

    }

    if (this.radioType == '') {

    uni.showToast({

    title: '请先选择小区/学校/单位',

    icon: 'none'

    })

    return;

    } else {

    this.deepLength = 3;

    this.$refs.mpvueCityPicker.show();

    }

    },

    //展示底部 popup

    showBottomPopup: function() {

    if (this.tel == '' && this.weixinLogin == 'fail') {

    uni.showToast({

    icon: 'none',

    title: '手机号不能为空'

    });

    return;

    }

    if (this.name == '') {

    uni.showToast({

    title: '请输入姓名',

    icon: 'none'

    })

    return;

    }

    if (this.radioType == '') {

    uni.showToast({

    icon: 'none',

    title: '请先选择小区/学校/单位'

    })

    return;

    }

    if (this.areaText == "请选择区域") {

    uni.showToast({

    title: '请先选择区域',

    icon: 'none'

    })

    return;

    }

    if (this.communityText == "请选择小区" && this.unitText == "请选择单位" && this.schoolText == "请选择学校") {

    uni.showToast({

    title: '请先选择小区/学校/单位',

    icon: 'none'

    })

    return;

    } else {

    this.hidePopup();

    this.popType = 'bottom';

    this.showPopupBottom = true;

    }

    },

    bindClearInput: function(e) {

    this.inputClearValue = e.target.value

    var reg =

    /[^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\n]/g;

    if (this.inputClearValue.match(reg)) {

    this.inputClearValue = this.inputClearValue.replace(reg, '').trim();

    }

    if (e.target.value.length > 0) {

    this.showClearIcon = true;

    } else {

    this.showClearIcon = false;

    }

    uni.request({

    url: path + '/smallwechart/wechat/wechatLoginApi/getHouseHold',

    method: 'POST',

    header: {

    'content-type': 'application/x-www-form-urlencoded'

    },

    data: {

    houserHoldName: this.inputClearValue,

    orgCode: this.orgCode,

    sid: this.sid

    },

    success: (res) => {

    if (res.data.code == '303') {

    uni.clearStorage();

    // #ifndef APP-PLUS

    uni.navigateTo({

    url: '/pages/mine/loading/loading'

    })

    // #endif

    // #ifdef APP-PLUS

    uni.navigateTo({

    url: '/pages/API/login/login'

    })

    // #endif

    }

    this.pickerDetailArray = [];

    if (res.data.data == '') {

    this.searchResult = true

    } else {

    this.searchResult = false;

    for (var i = 0; i < res.data.data.length; i++) {

    if (res.data.data[i].houserHoldName != "" || res.data.data[i].houserHoldName != undefined) {

    this.pickerDetailArray.push({

    label: res.data.data[i].houserHoldName,

    })

    }

    }

    if (this.pickerDetailArray != "" && this.inputClearValue != '') {

    this.showDetailPicker();

    }

    }

    }

    });

    },

    clearIcon: function() {

    this.inputClearValue = "";

    this.showClearIcon = false;

    },

    onConfirm(e) {

    if (this.deepLength == 3) {

    this.areaText = JSON.stringify(e.label).replace(/\"/g, "");

    }

    if (this.showPopupBottom == true && this.detailState == true) {

    this.detailAddress = JSON.stringify(e.label).replace(/\"/g, "");

    this.hidePopup()

    }


                if (this.areaText != '' && this.areaText != undefined) {  
    var obj = this.areaText;
    var index = obj.lastIndexOf("\-");
    district = obj.substring(index + 1, obj.length);
    this.getArea();
    }
    if (this.radioType == 1 && this.deepLength == 1 && this.detailState == false) {
    this.communityText = JSON.stringify(e.label).replace(/\"/g, "");
    this.orgCode = e.value[0][0];
    this.orgId = e.value[0][1];
    }
    if (this.radioType == 3 && this.deepLength == 1 && this.detailState == false) {
    this.schoolText = JSON.stringify(e.label).replace(/\"/g, "");
    this.orgCode = e.value[0][0];
    this.orgId = e.value[0][1];
    }
    if (this.radioType == 2 && this.deepLength == 1 && this.detailState == false) {
    this.unitText = JSON.stringify(e.label).replace(/\"/g, "");
    this.orgCode = e.value[0][0];
    this.orgId = e.value[0][1];
    }
    },
    onBackPress() {
    if (this.$refs.mpvuePicker.showPicker) {
    this.$refs.mpvuePicker.pickerCancel();
    return true;
    }
    if (this.$refs.mpvueCityPicker.showPicker) {
    this.$refs.mpvueCityPicker.pickerCancel();
    return true;
    }
    },
    onUnload() {
    if (this.$refs.mpvuePicker.showPicker) {
    this.$refs.mpvuePicker.pickerCancel()
    }
    if (this.$refs.mpvueCityPicker.showPicker) {
    this.$refs.mpvueCityPicker.pickerCancel()
    }
    },
    radioChange: function(e) {
    const current = e.detail.value;
    radioState = e.detail.value;
    if (current == 1) {
    this.radioType = 1;
    } else if (current == 2) {
    this.radioType = 2;
    } else if (current == 3) {
    this.radioType = 3;
    }
    this.getArea();

    },
    getArea: function() {
    if (district != '' && district != undefined && district != '请选择区域') {
    uni.request({
    url: path + '/sys/sceneOrg/get_list_weixin',
    method: 'GET',
    data: {
    scene: this.radioType,
    name: district,
    sid: this.sid
    },
    success: (res) => {
    if (res.data.code == '303') {
    uni.clearStorage();
    // #ifndef APP-PLUS
    uni.navigateTo({
    url: '/pages/mine/loading/loading'
    })
    // #endif
    // #ifdef APP-PLUS
    uni.navigateTo({
    url: '/pages/API/login/login'
    })
    // #endif
    }
    this.pickerSingleArray = [];
    for (var i = 0; i < res.data.length; i++) {
    this.pickerSingleArray.push({
    label: res.data[i].name,
    value: [res.data[i].internalCode, res.data[i].id]
    })
    }
    },
    complete: () => {
    this.loading = false
    }
    })
    }
    },
    addHouseHold: function() {
    uni.request({
    url: path + '/smallwechart/wechat/wechatLoginApi/addHouseHold',
    method: 'POST',
    header: {
    'content-type': 'application/x-www-form-urlencoded'
    },
    data: {
    phone: this.phone,
    houserHoldName: this.inputClearValue,
    orgId: this.orgId,
    orgCode: this.orgCode,
    sid: this.sid
    },
    success: (res) => {
    if (res.data.code == '303') {
    uni.clearStorage();
    // #ifndef APP-PLUS
    uni.navigateTo({
    url: '/pages/mine/loading/loading'
    })
    // #endif
    // #ifdef APP-PLUS
    uni.navigateTo({
    url: '/pages/API/login/login'
    })
    // #endif
    }
    if (res.data.success == true) {
    this.detailAddress = this.inputClearValue;
    this.completeWxMessage();
    } else {
    if (res.data.msg != undefined) {
    uni.showToast({
    title: res.data.msg,
    icon: 'none'
    })
    } else {
    uni.showToast({
    title: JSON.stringify(res),
    icon: 'none'
    })
    }
    }
    },
    complete: () => {
    this.loading = false
    }
    })
    },
    completeWxMessage: util.throttle(function(e) {
    // console.log(this.phone)
    // if (this.phone == '' && this.weixinLogin == 'fail') {
    // uni.showToast({
    // icon: 'none',
    // title: '手机号不能为空'
    // });
    // return;
    // }
    if (this.name == '') {
    uni.showToast({
    title: '请输入姓名',
    icon: 'none'
    })
    return;
    }
    if (this.radioType == '') {
    uni.showToast({
    title: '请选择类型',
    icon: 'none'
    })
    return;
    }
    if (this.detailAddress == '支持搜索您的地址哦') {
    uni.showToast({
    title: '请选择地址',
    icon: 'none'
    })
    return;
    }
    this.loading = true;
    // #ifndef MP-ALIPAY
    this.alid = ''
    // #endif
    uni.request({
    url: path + '/smallwechart/wechat/wechatLoginApi/completeMobileByPhone',
    method: 'POST',
    header: {
    'content-type': 'application/x-www-form-urlencoded'
    },
    data: {
    address: this.detailAddress,
    farmerName: this.name,
    scene: this.radioType,
    phone: this.phone,
    // #ifdef MP-WEIXIN || APP-PLUS || H5
    unionId: this.unionId,
    // #endif
    // #ifdef MP-ALIPAY
    alid: this.alid,
    // #endif
    wxHeard: this.avatarUrl,
    wxName: this.nickName,
    "org.id": this.orgId,
    "org.internalCode": this.orgCode,
    "sid": this.sid
    },
    success: (res) => {
    if (res.data.code == '303') {
    uni.clearStorage();
    // #ifndef APP-PLUS
    uni.navigateTo({
    url: '/pages/mine/loading/loading'
    })
    // #endif
    // #ifdef APP-PLUS
    uni.navigateTo({
    url: '/pages/API/login/login'
    })
    // #endif
    }
    if (res.data.code == '200') {
    this.sid = res.data.data.sid ? res.data.data.sid : this.sid;
    service.addSid(this.sid);
    if (this.register == "no") {
    console.log('0')
    const data = {
    orgId: this.orgId,
    orgCode: this.orgCode,
    scene: this.radioType
    }
    service.addFarmer(data);
    uni.navigateTo({
    url: '/pages/mine/progress/progress'
    })
    } else {
    const data = {
    orgId: this.orgId,
    orgCode: this.orgCode,
    scene: this.radioType
    }
    service.addFarmer(data);
    const userData = {
    phone: this.phone,
    avatarUrl: this.avatarUrl,
    nickName: this.nickName
    }
    service.addUser(userData);
    uni.reLaunch({
    url: '/pages/tabBar/component/component'
    })
    }
    } else {
    if (res.data.msg != undefined) {
    uni.showToast({
    title: res.data.msg,
    icon: 'none'
    })
    } else {
    uni.showToast({
    title: JSON.stringify(res),
    icon: 'none'
    })
    }
    }

    },
    complete: () => {
    this.loading = false
    }
    })
    }, 1000)
    }
    }

    </script>


    <style>

    .action-row {

    display: flex;

    flex-direction: row;

    justify-content: center;

    }


    .action-row navigator {  
    color: #007aff;
    padding: 0 20px;
    }

    .oauth-row {
    display: flex;
    flex-direction: row;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    }

    uni-page-body,
    .content,
    page {
    background: #FFFFFF;
    }

    .input-group::before {
    background: none;
    }

    .input-row {
    align-items: center;
    }

    .auth_text {
    width: 200upx;
    height: 60upx;
    line-height: 60upx;
    font-size: 24upx;
    color: #fff;
    background: #30CAB0;
    border-color: #30CAB0;
    border-radius: 30upx;
    }

    .loginBtn {
    color: #FFFFFF;
    background: #30CAB0;
    border-radius: 54upx;
    height: 106upx;
    line-height: 106upx;
    margin-bottom: 20upx;
    }

    .card-text {
    color: #9B9B9B;
    font-size: 24upx;
    }

    .input-row .card-input {
    padding: 0;
    }

    .btn-row {
    margin-top: 84upx;
    }

    .input-row.border::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 1px;
    content: '';
    -webkit-transform: scaleY(.5);
    -ms-transform: scaleY(.5);
    transform: scaleY(.5);
    background-color: #c8c7cc;
    }

    uni-input input {
    position: relative;
    border: none;
    height: inherit;
    width: 100%;
    background: rgba(0, 0, 0, 0);
    display: inherit;
    padding: 0;
    margin: 0;
    outline: none;
    vertical-align: middle;
    overflow: inherit;
    white-space: inherit;
    text-overflow: inherit;
    -webkit-tap-highlight-color: transparent;
    z-index: 2;
    }

    .content .input-row uni-input,
    .content radio-group,
    .content input {
    width: 100%;
    height: 50px;
    min-height: 50px;
    padding: 30upx 0 0 0;
    line-height: 50px;
    font-size: 28upx;
    }

    .input-row {
    display: flex;
    flex-direction: row;
    position: relative;
    }

    .content {
    display: flex;
    flex-direction: column;
    padding: 0 40upx;
    }

    uni-input div {
    position: relative;
    min-height: 1.4rem;
    text-overflow: inherit;
    border: none;
    height: inherit;
    width: inherit;
    font-size: inherit;
    font-weight: inherit;
    font-family: UICTFontTextStyleBody;
    color: inherit;
    background: inherit;
    padding: 0;
    margin: 0;
    outline: none;
    text-align: inherit;
    -webkit-tap-highlight-color: transparent;
    }

    .input-group {
    background-color: #ffffff;
    position: relative;
    }

    .input-group::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 1px;
    content: '';
    -webkit-transform: scaleY(.5);
    -ms-transform: scaleY(.5);
    transform: scaleY(.5);
    background-color: #c8c7cc;
    }

    .logo {
    height: 314upx;
    display: flex;
    align-items: center;
    justify-content: center;
    }

    /* #ifdef MP-ALIPAY */
    .logo image {
    background-size: cover;
    }

    /* #endif */
    image {
    width: 136upx;
    height: 136upx;
    }

    .leftLabel {
    width: 160upx;
    height: 50px;
    min-height: 50px;
    padding: 15px 0 0 0;
    line-height: 50px;
    font-size: 14px;
    color: #4A4A4A;
    }

    uni-radio .uni-radio-input {
    width: 28upx;
    height: 28upx;
    }

    picker {
    width: 100%;
    }

    .community,
    .communityContainer {
    padding-left: 0;
    }

    uni-radio-group {
    width: auto;
    }

    .city {
    width: 100%;
    padding: 0;
    }

    .uni-list-cell-navigate {
    padding: 15px 0 0 0;
    }

    .uni-pull-right,
    .uni-flex {
    color: #9B9B9B;
    }

    .cityContainer uni-view,
    .viewPicker {
    width: 100%;
    }

    .input-view .uni-icon {
    line-height: 30px !important;
    }

    .input-view .input {
    height: 30px;
    line-height: 30px;
    width: 94%;
    padding: 0 3%;
    }

    .input-view {
    width: 92%;
    display: flex;
    background-color: #e7e7e7;
    height: 30px;
    border-radius: 15px;
    padding: 0 4%;
    flex-wrap: nowrap;
    margin: 7px 0;
    line-height: 30px;
    }

    .input-view .uni-icon {
    line-height: 30px !important;
    }

    .input-view .input {
    height: 60upx;
    line-height: 60upx;
    width: 94%;
    padding: 0 3%;
    }

    .create {
    width: 90%;
    background: #30CAB0;
    color: #FFFFFF;
    font-size: 32upx;
    /* #ifdef MP-ALIPAY */
    margin: 0 auto;
    /* #endif */
    }

    .noresult {
    padding: 40upx;
    font-size: 32upx;
    }

    .uni-list-cell-navigate.uni-navigate-right:after {
    top: 68%;
    }

    /* #ifdef */
    shared-checkbox {
    top: 0.1rem;
    }

    /* #endif */

    </style>

    在app中偶现 HBuilderX版本:1.9.1

    2019-04-19 11:17

该问题目前已经被锁定, 无法添加新回复