<template>
	<view class="">
		<u-navbar :border-bottom="false" back-icon-size="35"  title-size="32" :background="background"
			:back-text-style="hhyanm" title-color="#ffffff" back-icon-color="#ffffff"></u-navbar>

		<view class="fzctob mywoddt" style="padding-bottom:30rpx;">
			<image :src="jsinfo.img"
				style="width: 152rpx;height: 152rpx;border-radius:160rpx;min-width:152rpx;margin-right: 24rpx;" mode="">
			</image>
			<view class="flztoa" style="width: 100%;">
				<view class="fsxto">
					<text class="letxtfy">{{jsinfo.title}}</text>
					<view class="fzctob letxtfya">
						<text v-for="item in jsinfo.tag">{{item}}</text>
					</view>
				</view>
			</view>
		</view>
		
		<view class="flztoa shiddwe">
			<view class="flztoa shiufh">
				<view class="fzddrew">
					<text>{{question_num}}</text>
					<text class="shiufhtx">获赞</text>
				</view>
				<view class="fzddrew">
					<text>{{lecturer_follow}}</text>
					<text class="shiufhtx">粉丝</text>
				</view>
			</view>
			<view style="width: 120upx;height: 65upx;color: #ffffff;display: flex;align-items: center;justify-content: center;background: #F54E43;border-radius: 50upx;" @click="guanzhu(jsinfo.id)">
				{{jsinfo.is_follow == 0?'关注':'已关注'}}
			</view>
		</view>
		
		<view class="shiwdmmt">
			<view class="indhuyr">
				<view class="indjbrr"></view>
				<text>动态</text>
			</view>
			
			<view class="shidongt" v-for="(item,index) in question" :key="index">
				<view class="shibbert">
					<text>{{item.content}}</text>
				<view class="flztoa" style="margin-top: 46rpx;">
					<view class="fzctob">
						<image  @click="like(item.id)" :src="item.is_like == 1?'/static/index/w1.png':'/static/index/w2.png'" style="width: 48rpx;height: 48rpx;min-width: 48rpx;" mode=""></image>
						<text class="shitxty">{{item.like_num}}</text>
						<view style="margin-left: 40rpx;" @click="toDetail(item.id)">
							<image src="/static/index/w3.png" style="width: 48rpx;height: 48rpx;min-width: 48rpx;" mode=""></image>
						</view>
					</view>
					<view class="">
						<text class="shitxtya">{{$u.timeFormat(item.create_time, 'yyyy:mm:dd  hh:MM:ss')}}</text>
					</view>
				</view>
				</view>
			</view>
		</view>
		<view class="fzjtod shitoob" v-if="type == 1">
			<view class="shitoobtxt" style="margin-bottom: 20rpx;" @click="pay">
				<text>找他倾诉/¥{{jsinfo.price}}</text>
			</view>
		</view>
	</view>
</template>
<style>
	page {
		background: #FAFAFA;
	}
</style>
<script>
	export default {
		data() {
			return {
				type:1,
				xqaxuye:false,
				background: {
					backgroundColor: '#374B6E',
				},
				hhyanm: {
					color: '#FFFFFF',
				},
				jsinfo:{},
				question:[],
				question_num:0,
				lecturer_follow:0,
				id:'',//讲师id
				user_id:'',//当前用户id
				deviceType:'wxapp'
				
			}
		},
		onLoad(e) {
			// #ifdef APP-PLUS
				this.deviceType = 'wxh5'
			// #endif
			// #ifdef MP-WEIXIN
				this.deviceType = 'wxapp'
			// #endif
			this.id = e.id;
			this.user_id = uni.getStorageSync('id');
			this.getinfo(this.user_id,this.id);
			if(e.type){
				this.type = e.type
			}
			
		},
		methods:{
			toDetail(id){
				uni.navigateTo({
					url:'./jiehuo-pl?id=' + id + '&user_id=' + uni.getStorageSync('id')
				})
			},
			//获取讲师详情信息
			getinfo(user_id,id) {
				this.$post({
					data: {
						do: 'LecturerIndex',
						data:{
							user_id:user_id,
							id:id
						}
					}
				}).then(res => {
					this.jsinfo = res.data.lecturer
					this.question = res.data.question
					this.question_num = res.data.question_num
					this.lecturer_follow = res.data.lecturer_follow
				})
			},
			//点赞
			like(id){
				let that = this;
				console.log(id,that.user_id)
				that.$post({
					data: {
						do: 'QuestionLike',
						data: {
							question_id: id,
							user_id: that.user_id
						}
					}
				}).then(res => {
					that.getinfo(this.user_id,this.id);
				})
			},
			//关注
			guanzhu(id){
				let that = this;
				that.$post({
					data: {
						do: 'LecturerFollow',
						data: {
							id: id,
							user_id: that.user_id
						}
					}
				}).then(res => {
					that.getinfo(this.user_id,this.id);
				})
			},
			//找他倾诉
			pay(){
				let that = this;
				that.$post({
					data: {
						do: 'Course',
						data: {
							vip_pay: '0',
							course_id:that.jsinfo.id,
							user_id: that.user_id,
							good_type:'2',
							pw:'375',
							cdkey:'',
							is_luck:'',
							luck_id:''
						},
						deviceType:this.deviceType
					}
				}).then(res => {
					that.wechatpay(res.data);
					
				})
			},
			wechatpay(pay){
				var that = this
				// #ifdef APP-PLUS
				uni.requestPayment({
					provider: 'wxpay',
					orderInfo:pay.orderinfo,
					success() {
						uni.showToast({
							title: '支付成功'
						})
					},
					fail(res) {
						console.log(res)
						uni.showToast({
							title: '支付失败',
							icon: 'error'
						})
					}
				})
				// #endif
				// #ifdef MP-WEIXIN
				uni.requestPayment({
					provider: 'wxpay',
					timeStamp: pay.timeStamp,
					nonceStr: pay.nonceStr,
					package: pay.package,
					signType: 'MD5',
					paySign: pay.paySign,
					success() {
						uni.showToast({
							title: '支付成功'
						})
					},
					fail(res) {
						console.log(res)
						uni.showToast({
							title: '支付失败',
							icon: 'error'
						})
					}
				})
				// #endif
			
			}
		}
	}
</script>

<style lang="scss" scoped>
	 

</style>
