<template>
  <view class="page-wrap">
    <image class="bg" src="https://ld.726p.com/ldyx_static/imgs/tjkf_bg.png" mode="widthFix" />
    <image class="kf-img" :src="kfImg" :show-menu-by-longpress="true" />
  </view>
</template>

<script>
const app = getApp()

export default {
  data() {
    return {
      params: {},
      kfImg: '',
      kfImgDefault: 'https://ld.726p.com/ldyx_static/imgs/lhkf_default.png',
    }
  },
  onLoad(options) {
    console.log('options => ', options)
    this.params = {...options}
    this.handleGetKfImg()
  },
  methods: {
    async handleGetKfImg () {
      try {
        const url = this.$api.lh_getUserQrcode;
        const params = {
          ...this.params
        }
        uni.showLoading({ title: '加载中...', mask: true })
        const { data: res = {} } = await this.$get(url, params);
        if (res && res.errno == 0) {
          this.kfImg = res.rst.qrcode_url || this.kfImgDefault
        } else {
          uni.showToast({ title: res.err || '加载失败', icon: 'none' })
        }
      } catch (error) {
        uni.showToast({ title: '服务器错误', icon: 'none' })
      } finally {
        uni.hideLoading()
      }
    },
  },
}
</script>

<style scoped lang="scss">
.page-wrap {
  position: relative;
  min-height: 100vh;
  background-color: #fff;
  .bg {
    width: 100vw;
  }
  .kf-img {
    position: absolute;
    top: 600rpx;
    left: 155rpx;
    width: 440rpx;
    height: 440rpx;
  }
}
</style>
