import React, { Component } from 'react' import Taro, { getCurrentInstance } from '@tarojs/taro' import { View, ScrollView, RichText } from '@tarojs/components' import { SpNavBar, SpHtmlContent, SpHtml, SpPage } from '@/components' import { withPager } from '@/hocs' import api from '@/api' import './reg-rule.scss' @withPager export default class RegRule extends Component { $instance = getCurrentInstance() constructor(props) { super(props) this.state = { info: null } } componentDidMount () { this.fetch() } async fetch () { let data = '' let navBarTitle = '协议' const { type } = this.$instance.router.params Taro.showLoading({ title: '' }) if (type === '1') { // 充值协议 const { content, title = '充值协议' } = await api.member.depositPayRule() data = content navBarTitle = title } else if (type === 'privacyAndregister') { // 隐私和注册协议 const { content: registerContent, title: registerTitle } = await api.shop.getRuleInfo({ type: 'member_register' }) const { content: privacyContent, title: privactTitle } = await api.shop.getRuleInfo({ type: 'privacy' }) data = registerContent + privacyContent navBarTitle = `${registerTitle}和${privactTitle}` } else if (type) { // 隐私政策 const { content, title = '充值协议' } = await api.shop.getRuleInfo({ type }) data = content navBarTitle = title } else { // 注册协议 const { content, title = '注册协议' } = await api.user.regRule() data = content navBarTitle = title } Taro.hideLoading() Taro.setNavigationBarTitle({ title: navBarTitle }) this.setState({ info: data, title: navBarTitle }) } render () { const { info, title } = this.state return ( {info && ( )} ) } }