<template>
	<view class="container">
		<navBar title="推荐奖励" :back="true" color="#333333" background="#FFFFFF" />

		<view class="outerBox" :style="{'background-image':`url(${picBase+'jl_bg2.png'})`}">
			<view class="addPd">
				<view class="countBox" :style="{'background-image':`url(${picBase+'jl_c_bg.png'})`}">
					<view class="left">
						<view class="num">
							{{jiangli.currentDiamondCount}}
						</view>
						<view class="tip">
							剩余次数
						</view>
					</view>
					<view class="right">
						<view class="num">
							{{jiangli.shareDiamondCount}}
						</view>
						<view class="tip">
							推荐奖励次数
						</view>
					</view>
				</view>
			</view>


			<!-- <view class="mianContent" :style="{'background-image':`url(${picBase+'my_b_bg.png'})`}"> -->
			<!-- <view class="mianContent" :style="{'background-image':`url(../../../static/other/bg_9.png)`}"> -->
			<view class="mianContent" :style="">
				<!-- 	<view class="sanjiaoxing">
				</view> -->
				<view class="pPos">

				</view>

				<view class="tipBox">
					<view class="top">
						<!-- <view class="tag">
							TIPS
						</view> -->
						<image :src="picBase+'hb_tips.png'" mode="" class="tag"></image>
						推荐奖励说明
					</view>
					<view class="bot">
						<!-- 推荐新用户，新用户成功注册后，将奖励推荐次数5次。推荐越多，奖励将会越多哦！ -->

						{{sm}}
					</view>
				</view>

				<view class="titleBox">
					<image :src="picBase+'s_star.png'" mode="heightFix" class="starIcon" @click=""></image>
					推荐奖励明细
				</view>
				<view class="list">
					<view class="empty" style="margin-top: 5%;" v-if="jiangli.data.length==0">
						<u-empty mode="data" />
					</view>

					<view class="" v-else>
						<view class="item" v-for="(item,index) in jiangli.data">
							<view class="left">
								<image :src="item.user.avatar?item.user.avatar:picBase+'defaultAvatar.png'" mode=""
									class="avatar"></image>
								<view class="des">
									<view class="name">
										{{item.user.name?item.user.name:'默认用户'}}
									</view>
									<view class="time">
										{{item.updated_at}}
									</view>
								</view>
							</view>
							<view class="right">
								奖励次数：{{item.diamond}}
							</view>
						</view>
					</view>
				</view>


			</view>
		</view>
		<view class="btnBox">
			<!-- <view class="btn" @click="toTuijian">
				立即推荐
			</view> -->
			<button open-type="share" class="btn">
				立即推荐
			</button>
		</view>

		<!-- <view class="" style="height: 800px;">

		</view> -->
	</view>
</template>

<script>
	import {
		getTuijian,
		getPosterBg
	} from '@/api/index/index.js'
	// import navBar from '@/components/navBar/index.vue'
	export default {
		// components: {
		// 	navBar
		// },
		data() {
			return {
				picBase: this.$picBase2,
				jiangli: {
					data: []
				},
				shareTitle: null,
				shareImg: '',

				sm: ''
			}
		},
		onLoad() {
			this.getTuijian()
			this.getShare()

		},
		onShareAppMessage(params) {
			if (params.from === 'button' || params.from === 'menu') {
				return {
					title: this.shareTitle,
					imageUrl: this.$ossBaseUrl + this.shareImg,
					path: '/pages/index/index?scene=' + uni.getStorageSync('userInfo').id || '',
					mpId: this.$appId,
					type: this.$shareType,
				}
			}
		},
		methods: {
			async getShare() {
				let res1 = await getPosterBg({
					key: 'share_title'
				})
				console.log('分享信息返回值--------1', res1);
				if (res1.code == 0) {
					this.shareTitle = res1.data.value
				} else {
					this.$toast(res1.message)
				}

				let res2 = await getPosterBg({
					key: 'share_image'
				})
				console.log('分享信息返回值--------2', res2);
				if (res2.code == 0) {
					this.shareImg = res2.data.value
				} else {
					this.$toast(res2.message)
				}

				let res3 = await getPosterBg({
					key: 'push_promotion'
				})
				console.log('奖励说明返回值--------2', res3);
				if (res3.code == 0) {
					this.sm = res3.data.value
				} else {
					this.$toast(res3.message)
				}


				// 
			},


			toTuijian() {



				// uni.navigateTo({
				// 	url: '/pages/my/tuiguangDashi/index'
				// })
			},
			async getTuijian() {
				let res1 = await getTuijian()
				console.log('推荐奖励返回值--------2', res1);
				if (res1.code == 0) {
					this.jiangli = res1.data
				} else {
					this.$toast(res1.message)
				}
			},
		}
	}
</script>

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