<template>
  <view class="rule-main">
    <network-error />
    <view class="u-font-32 line-44 bold color-212121">符合活动的评价要求，需满足：</view>
    <view class="u-m-t-16 u-font-28 line-20 color-333">{{detail.requirement}}</view>
  </view>
</template>

<script>
import { getActivityDetail } from '@/api/activityApi'
export default {
  data () {
    return {
      activityId: '',
      detail: {}
    }
  },
  onLoad (options) {
    this.activityId = options.id
    this.getDetailData()
  },
  methods: {
    // 获取用户经纬度
    getLocation () {
      return new Promise((resolve, reject) => {
        uni.getLocation({
          type: 'gcj02',
          success: (res) => {
            resolve(res)
          },
          fail: () => {
            resolve(false)
          }
        })
      })
    },
    // 获取活动详情
    async getDetailData () {
      const location = await this.getLocation()
      if (!location) { return }
      const params = {
        id: this.activityId,
        lng: location.longitude,
        lat: location.latitude
      }
      const { code, data } = await getActivityDetail(params)
      if (code === 200) {
        this.detail = data
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  .rule-main {
    box-sizing: border-box;
    padding: 48px 32px 0;
    height: 100vh;
    background-color: #fff;
    .color-212121 {
      color: #212121;
    }
    .color-333 {
      color: #333;
    }
  }
</style>
