123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <template>
- <div class="layout">
- <div style="height: 12.2666666667vw" v-if="isShowNavBar">
- <van-nav-bar
- title="0元购机,尽情享受"
- left-arrow
- fixed
- @click-left="goBackFun"
- />
- </div>
- <div class="layout-container" :style="containerStyle">
- <slot></slot>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: 'layout',
- props: {
- // 是否显示头部
- isNavBar: {
- type: Boolean,
- default: false,
- },
- // 背景图片
- bgImgName: {
- type: String,
- default: 'bg-1',
- },
- // 背景图片高度
- bgHeight: {
- type: [Number, String],
- default: 300,
- },
- bgColor: {
- type: String,
- default: '#F3F4F6',
- },
- },
- data() {
- return {};
- },
- mounted() {},
- computed: {
- containerStyle() {
- return {
- backgroundImage: `url(${require(`@/assets/image/claimCloudPhone/${this.bgImgName}.png`)})`,
- backgroundRepeat: 'no-repeat',
- backgroundSize: `100% ${this.bgHeight}px`,
- backgroundColor: this.bgColor,
- backgroundPosition: '0 0',
- };
- },
- isShowNavBar() {
- // 是否是APP
- const isApp = this.$userAgent.isSzx || this.$userAgent.isSzxBrowser;
- const isAndroid = this.$userAgent.isAndroid;
- const isIos = this.$userAgent.isIos;
- const isWx = this.$userAgent.isWx;
- // 如果是App并且是安卓,就不显示头部, ios显示
- // 如果微信小程序环境的,也不显示头部
- // 如果是h5 就显示头部
- let bool = false;
- bool = isApp ? (isAndroid ? !isAndroid : isIos) : (isWx ? !isWx : !isWx);
- return bool;
- },
- },
- methods: {
- goBackFun() {
- if (this.$listeners.goBack) {
- this.$emit('goBack');
- return;
- }
- this.$router.go(-1);
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .layout {
- height: 100%;
- display: flex;
- flex-direction: column;
- .layout-container {
- flex: 1;
- overflow-y: auto;
- padding: 16px;
- }
- ::v-deep .van-nav-bar__arrow {
- color: #000000;
- font-size: 24px;
- }
- ::v-deep .van-nav-bar__title {
- font-weight: bold !important;
- font-size: 17px !important;
- color: #0a132b !important;
- line-height: 24px !important;
- }
- .van-nav-bar {
- z-index: 1000;
- }
- }
- </style>
|