<template>
	<view class="container">
		<navBar title="推广大使" :back="true" color="#333333" background="#FFFFFF" />

		<view class="topBox">
			<view class="addBg" :style="{'background-image':`url(${picBase+'tgds_bg.png'})`}">
				<view class="top">
					<view class="en">
						<image :src="picBase+'star_w.png'" mode="heightFix" class="starIcon"></image>
						PROMOTION AND RECRUITMENT
					</view>
					<view class="zh">
						推广大使招募
					</view>
				</view>
				<view class="bot2">
					<!-- 入驻说明，加入分销商需要沟通买399年卡会员，联系客服开通 -->
					{{sm}}
				</view>
			</view>

		</view>

		<view class="form" :style="{'background-image':`url(${picBase+'my_b_bg.png'})`}">
			<!-- <view class="sanjiaoxing">
			</view> -->
			<view class="titleBox">
				<image :src="picBase+'s_star.png'" mode="heightFix" class="starIcon"></image>
				推荐奖励明细
			</view>
			<view class="inputbox">
				<input type="text" class="name" placeholder="输入姓名" v-model="formData.name" />
				<input type="text" class="phone" placeholder="输入手机号" v-model="formData.phone" />
			</view>
			<view class="tipBox">
				<!-- <image src="../../../static/tabbar/my.png" mode="" class="info"></image> -->

				<!-- <u-radio-group v-model="value">
					<u-radio value="" :customStyle="{}" @change="radioChange" />
				</u-radio-group> -->
				<!-- <view class="radio">
					<radio :checked="value" style="width: 10rpx;" @click="value=!value" color="#017CFF" size="12" />
				</view> -->
				<u-icon name="checkmark-circle-fill" @click="value=!value" :color="value?'#207CF7':'#ededed'"
					size="16"></u-icon>
				<text style="margin-left: 5rpx;">我已阅读并同意以上规则以及</text>
				<text class="t2" @click="toProtocol"> 推广员功能服务协议</text>
			</view>
		</view>


		<view class="btnBox">
			<view class="btn" @click="apply">
				申请成为推广大使
			</view>
		</view>
	</view>
</template>

<script>
	// import navBar from '@/components/navBar/index.vue'
	import {
		postZhaomu,

		getPosterBg
	} from '@/api/index/index.js'
	export default {
		// components: {
		// 	navBar
		// },
		data() {
			return {
				picBase: this.$picBase2,
				formData: {
					name: '',
					phone: ''
				},
				value: true,

				sm: ''
			}
		},
		onLoad() {
			this.tuiguangSm()
		},
		methods: {
			async tuiguangSm() {
				let res1 = await getPosterBg({
					key: 'desc_share'
				})
				console.log('推广说明返回值--------2', res1);
				if (res1.code == 0) {
					this.sm = res1.data.value

				} else {
					this.$toast(res1.message)
				}
			},

			async apply() {
				let phoneReg = /^[1][3,4,5,7,8,9][0-9]{9}$/
				if (!this.formData.name) {
					return this.$toast('请输入姓名')
				}

				if (!this.formData.phone) {
					return this.$toast('请输入手机号')
				}

				if (!phoneReg.test(this.formData.phone)) {
					return this.$toast('请输入合法的手机号')
				}
				if (!this.value) {
					return this.$toast('请同意协议')
				}


				// console.log('form', this.formData);
				let p = {
					name: this.formData.name,
					phone: this.formData.phone,
				}

				this.formData.name = ''
				this.formData.phone = ''

				let res1 = await postZhaomu(p)


				console.log('申请推广大使返回值--------2', res1);
				this.$toast('申请成功', 'success')
				if (res1.code == 0) {
					this.$toast('申请成功', 'success')
					setTimeout(() => {
						uni.reLaunch({
							url: '/pages/my/index'
						})
					}, 1500)
				} else {
					this.$toast(res1.message)
				}
			},

			toProtocol() {
				uni.navigateTo({
					url: '/pages/my/protocol/index?type=' + 3
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "./index.scss";
</style>