App.vue 11 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
<script setup lang="ts">
import {onHide, onLaunch, onLoad, onShow} from "@dcloudio/uni-app";
import axios from "axios";
import mpAdapter from "axios-miniprogram-adapter";
import store from "@/store";

onLaunch(() => {
    console.log("App Launch");
    getLocationFn();
});
onLoad(() => {
    console.log("App onLoad");

});
onShow(() => {
    console.log("App Show");
});
onHide(() => {
    console.log("App Hide");
});

const getLocationFn = () => {
    let currentCity = uni.getStorageSync("CURRENT_CITY");
    if (currentCity) {
        store.commit('changeCity', currentCity);
    } else {
        uni.getLocation({
            type: 'gcj02', // 中国标准坐标系
            accuracy: 'best', // 高精度定位模式
            timeout: 10000, // 超时时间10秒
            highAccuracyExpireTime: 60000, // 高精度定位有效期60秒
            geocode: true, // 直接获取经纬度对应的地址信息
            success: (res) => {
                const axiosInstance = axios.create({
                    timeout: 1000 * 60, baseURL: 'https://api.map.baidu.com', headers: {},
                    // @ts-ignore
                    adapter: mpAdapter
                });
                axiosInstance.get('reverse_geocoding/v3', {
                    params: {
                        ak: 'RrBC6n7W9373y3I5U4ZQgsyvpyRaz5EK', coordtype: 'gcj02ll', output: 'json',
                        location: res.longitude + ',' + res.latitude
                    }
                }).then(res => {
                    console.log(res.data.result);
                    if (res.data?.result?.addressComponent) {
                        const address = res.data.result.addressComponent;
                        const cityCode = address.adcode.slice(0, 4) + "00";
                        store.commit('changeCity', {code: cityCode, name: address.city, value: ""});
                    }
                });
            },
            fail(err) {
                console.error('获取位置失败', err);
                if (err?.errMsg?.indexOf('deny') !== -1) {
                    uni.showModal({
                        title: '权限提示',
                        content: '您拒绝了位置权限,是否去设置中开启?',
                        success: (res) => {
                            if (res.confirm) {
                                uni.openSetting({
                                    success: (res) => {
                                        if (res.authSetting['scope.userLocation']) {
                                            // this.navigateToScenicSpot();
                                        }
                                    }
                                });
                            }
                        }
                    });
                } else {
                    // uni.showToast({title: '获取位置失败,请稍后重试', icon: 'none'});
                }
            }
        });
    }
}
</script>
<style lang="scss">
/* #ifdef MP-WEIXIN */
@import "wxcomponents/vant/weapp/common/index.wxss";
/* #endif */
@import "uview-plus/index.scss";
@import "components/uni-plate-input/uni-plate-input.css";
//@import "@vant/weapp/dist/common/index.wxss";
/* 页面根元素背景色(覆盖内容区域) */
page {
    //background-image: url('~@/static/background.jpg');
    //background-color: #ffffff;
    min-height: 100%;
    background-color: transparent; /* 让页面根节点背景透明 */

    .van-button--primary {
        //font-size: 20px;
        background-color: rgba(24, 94, 254, 1);
        border: none;
    }

    .van-button--info {
        //font-size: 20px;
        background-color: rgba(24, 94, 254, 1);
        border: none;
    }

    .van-sidebar-item {
        padding: 12px 12px 12px 8px;
    }

    .van-sidebar-item--selected {
        border-color: transparent;
    }

    /* 修改外层容器背景色 */
    .van-dropdown-menu {
        background-color: transparent;
        /* 移除阴影 */
        box-shadow: none !important;
        //background-color: #f5f7fa;
        //padding: 0 16px;
        height: 40px; /* 调整高度 */
    }

    /* 修改触发器容器高度和边框 */
    .van-dropdown-menu__bar {
        //height: 40px; /* 调整高度 */
        //border-bottom: 1px solid #eee;
    }

    /* 修改触发器文字样式 */
    .van-dropdown-menu__title {
        color: #000; /* 文字颜色 */
        font-size: 12px; /* 文字大小 */
        font-weight: 400;
    }

    /* 修改触发器箭头颜色和大小 */
    .van-dropdown-menu__icon {
        color: #000; /* 箭头颜色 */
        font-size: 18px; /* 箭头大小 */
    }

    /* 修改下拉菜单容器样式(弹出层) */
    .van-dropdown-menu__content {
        //border-radius: 8px; /* 圆角 */
        //box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1); /* 阴影 */
        /* 背景透明 */
        background-color: transparent !important;
        /* 移除阴影 */
        box-shadow: none !important;
        /* 可选:移除边框(如果有的话) */
        border: none !important;
        margin-top: 1px; /* 与触发器的间距 */
    }

    /* 修改下拉选项样式 */
    .van-dropdown-item__option {
        height: 40px; /* 选项高度 */
        font-size: 15px; /* 选项文字大小 */
    }

    /* 选项激活(选中)状态 */
    .van-dropdown-item__option--active {
        color: #185EFE; /* 选中文字颜色 */
        background-color: #e8f3ff; /* 选中背景色 */
    }


    .van-index-anchor {
        background-color: #F7F9FC;
    }

    .van-checkbox__icon--checked {
        background-color: #185EFE;
        border-color: #185EFE;
    }

    .brand-active .van-cell {
        background: #F8F9FCFF;
    }

    .small-cell .van-cell {
        padding: 2px 12px;
    }

    .small-cell .van-cell__title {
        font-size: 14px;
        font-weight: 400;
        color: #999999;
    }

    .small-cell .van-cell__value {
        font-size: 14px;
        font-weight: 400;
        color: #333333;
    }


    .red-cell .van-cell__value {
        font-size: 15px;
        font-weight: 400;
        color: #EE3140;
    }

    .orange-cell .van-cell__value {
        font-size: 14px;
        font-weight: 400;
        color: #FF4800;
    }

    .small-field .van-cell {
        padding-left: 2px;
    }

    .blue-button .van-button {
        border: 1px solid #185EFE;
        color: #185EFE;
    }

    .search-empty .van-empty {
        padding-bottom: 0;
        padding-top: 1px;
    }

    .search-empty .van-empty__image {
        width: 120px;
        height: 120px;
    }

    .search-empty .van-empty__image__img {
        width: 120px;
        height: 120px;
    }

    .red-count-down .van-count-down {
        color: #EE3140;
    }

    .red-auction-count-down .van-count-down {
        font-size: 20px;
        font-weight: 500;
        color: #EE3140;
    }

    .blue-count-down .van-count-down {
        color: #185EFE;
    }

    .blue-small-count-down .van-count-down {
        color: #185EFE;
        font-size: 12px;
    }

    .red-small-count-down .van-count-down {
        color: #EE3140;
        font-size: 10px;
    }

    .white-small-count-down .van-count-down {
        color: #FFFFFF;
        font-size: 10px;
    }

    .brand-cell .van-cell {
        justify-content: space-between;
    }

    .brand-cell .van-cell__value {
        flex: none !important;
    }


    .page-container {
        min-height: 100vh;
        /* 避免内容被顶部导航栏遮挡(可选) */
        //padding-top: var(--status-bar-height);
        //box-sizing: border-box;
    }

    .bg-image {
        position: fixed;
        /* 覆盖全屏 */
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-size: 100%; /*设置了背景图铺满整个容器*/
        background-repeat: no-repeat; /*设置不重复平铺*/
        background-position: top center; /*设置了背景图在容器中的位置为居中*/
        background-attachment: fixed; /* 将背景图固定不动 */
        z-index: 0;
    }

    /* 顶部导航样式 */
    .header {
        width: 100%;
        //margin: 0 12px;
        //padding: 2px 1px 10px 10px;
        //box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
        position: fixed;
        top: 44px;
        z-index: 99;
    }

    .upload-placeholder {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: #F9F9F9;
    }

    .upload-text {
        margin-top: 12rpx;
        font-size: 12px;
        font-weight: 400;
        color: #999999;
    }

    .slider-button {
        margin-top: 32px;
        width: 16px;
        height: 16px;
        border-radius: 4px;
        background: #185EFE;
    }

    .slider-button .arrow-down {
        width: 0;
        height: 0;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-bottom: 8px solid #185EFE;
        position: absolute;
        top: 26px;
        left: 50%;
        transform: translateX(-50%);
    }

    .slider-ranges {
        display: flex;
        align-items: center;
        justify-content: space-between;
        font-size: 12px;
        font-weight: 400;
        color: #999999;
        margin-bottom: 6px;
    }

    .bid-amount .uni-easyinput__content-input {
        font-size: 20px;
    }

    //.active::part(uni-table-td) {
    //    background-color: #FFF9ED !important; /* 表头背景色(蓝色示例) */
    //}

    .state-segmented .segmented-control {
        padding-bottom: 4px;
        white-space: nowrap !important; /* 禁止组件内部选项换行 */
        min-width: max-content !important; /* 最小宽度 = 所有选项总宽度(关键!) */
        /* 可选:给选项加固定宽度,确保每个选项不收缩 */
        .uni-segmented-control__item {
            min-width: 120rpx !important; /* 每个选项最小宽度(按需调整) */
            padding: 0 10rpx !important;
        }
    }

    /* 限定自定义类名下的样式 */
    .state-segmented ::v-deep(.segmented-control__text) {
        font-size: 15px !important; /* 非激活 */
        color: #666666 !important;
        padding-right: 12px;
    }

    .state-segmented .segmented-control__item--text {
        font-size: 17px !important; /* 激活 */
        font-weight: 500 !important;
        color: #333333 !important;
        //border-bottom: 4px solid #185EFE !important;
        border-bottom: none !important;
    }

    //.state-segmented .segmented-control__text.uni-segmented-control-item-active {
    //    font-size: 17px !important;; /* 激活 */
    //}

    .state-segmented .segmented-control__item--text::after {
        content: '';
        position: absolute;
        bottom: -3px;
        left: 21px;
        //margin: 0 auto; /* 水平居中关键 */
        width: 20px;
        height: 4px;
        border-radius: 2px;
        background-color: #185EFE;
    }

    .empty-tip {
        text-align: center;
        font-size: 12px;
        font-weight: 400;
        color: #999999;
    }
}
</style>