lin
2026-04-17 7ad48ddf4ca20d0f1f894cbfe4946b2a8d7041ab
pages/web/index.vue
@@ -1,35 +1,41 @@
<template>
  <web-view class="web-view" :webview-styles="webviewStyles" :src="url" :style="{width: windowW + 'px', height: windowH + 'px'}"></web-view>
</template>
<script>
export default {
  name: "index",
  data() {
    return {
      windowH: 0,
      windowW: 0,
      webviewUrl: `${this.$rongbeiUrl}/?appId=${uni.getStorageSync('userAppId')}&phone=${uni.getStorageSync('phone')}&appName=rongyouxuan`, // 默认地址
      webviewStyles: {
        progress: {
          color: 'transparent'
        }
      },
      url: ''
      }
    }
  },
  onLoad(option) {
    if(option.webUel) this.url = decodeURIComponent(option.webUel);
    // 蚂蚁智能客服场景参数
    if(option.scene) this.url += `&scene=${option.scene}`;
    uni.setNavigationBarTitle({
      title: option.title
    })
    try {
      const res = uni.getSystemInfoSync();
      this.windowW = res.windowWidth;
      this.windowH = res.windowHeight;
    } catch (e) {
      // error
    // 如果页面传了参数,可以拼接到 url
    if (option && option.path) {
      this.webviewUrl = `${this.webviewUrl}${option.path}`;
    }
  }
}
</script>
<template>
  <view class="container">
    <web-view
        :webview-styles="webviewStyles"
        :src="webviewUrl"
    />
  </view>
</template>
<style scoped lang="scss">
.container {
  width: 100%;
  height: 100vh;
  display: flex;
}
web-view {
  flex: 1; // 自适应填满
}
</style>