<template>
	<view class="app">
		<view class="content">
			<image src="/static/index.png" mode=""></image>
			<!-- <image :src="baseurl+ '/profile/weChatPicture/mainPage.png'" mode=""></image> -->

		</view>
		<view class="center">
			<view class="health">
				常用功能
			</view>
			<view class="contentcenter">

				<view class="home" @tap="goonline">
					<image src="@/static/appointmen.png" mode=""></image>
					<view class="name">
						我的随访
					</view>
				</view>
				<view class="home" @tap="review">
					<image src="@/static/follows.png" mode=""></image>
					<view class="name">
						我的复查
					</view>
				</view>
				<view class="home" @tap="goappoint">
					<image src="@/static/drug.png" mode=""></image>
					<view class="name">
						我的用药
					</view>
				</view>
				<view class="home" @tap="HealthCalendar">
					<image src="@/static/serveappoint.png" mode=""></image>
					<view class="name">
						健康日历
					</view>
				</view>
				<view class="home" @tap="Satisfaction">
					<image src="@/static/qianyue.png" mode=""></image>
					<view class="name">
						满意度调查
					</view>
				</view>
				<view class="home" @tap="Satisfactions">
					<image src="@/static/push.png" mode=""></image>
					<view class="name">
						推送记录
					</view>
				</view>
			</view>
		</view>
		<view class="Healthknowledge">
			<view class="title">
				医护常识
			</view>
			<view class="more" @tap='gohealth'>
				<view class="title">
					查看更多
				</view>
				<image src="@/static/huijiantou.png" mode=""></image>
			</view>
			<view class="lists">
				<view class="item" v-for="(item,index) in informationCategoryVOList" :key="index"
					@tap='goMedical(item)'>
					<view class="text">
						{{item.infoTitle}}
					</view>
					<view class="author"></view>
					<image :src="item.infoLargePictureUrl" mode=""></image>
				</view>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {
		getHeathHousingList
	} from '@/api/homepage/homepage.js'
	import {
		mapActions
	} from "vuex";
	import baseurl from '@/api/baseurl.js'
	export default {
		data() {
			return {
				informationCategoryVOList: [], //咨询信息
				informationCategorytotal: 0,
				pageNum: 1,
				pageSize: 5,
				baseurl: undefined,
			}
		},
		onLoad() {},
		onShow() {
			this.baseurl = baseurl
			if (uni.getStorageSync('patientId') && uni.getStorageSync('openid')) {
				this.getHeathHousing();
			}
		},
		methods: {
			getHeathHousing() {
				getHeathHousingList(this.pageNum, this.pageSize).then(res => {
					if (res.rows) {
						res.rows.forEach(e => {
							e.infoLargePictureUrl = baseurl + e.infoLargePictureUrl
						})
					}
					this.informationCategoryVOList = res.rows
					this.informationCategorytotal = res.total
				})
			},
			Loggedin(url) {
				if (uni.getStorageSync('patientId') && uni.getStorageSync('openid')) {
					this.message()
					uni.navigateTo({
						url: url
					})
				} else {
					this.gologin()
				}
			},
			// 查看更多
			gohealth() {
				this.Loggedin('/pages/Healthknowledge/Healthknowledge')
			},
			message() {
				wx.requestSubscribeMessage({
					tmplIds: [
						'YNeOOaRXbtLFJ1H7HRb9Ot6HADnKO_mg2uLFrqYOhCw',
					],
					success(res) {
						console.log(res)
					},
					fail(err) {
						console.log(err)
					},
					complete(scc) {}
				})
			},
			// 未登录
			gologin() {
				this.$refs.uToast.show({
					title: '请前往个人中心页面登录',
					type: 'error',
				})
			},
			// 我的随访
			goonline() {
				this.Loggedin('/pages/follow/follow')
			},
			// 健康日历
			HealthCalendar() {
				this.Loggedin('/pages/HealthCalendar/HealthCalendar')
			},
			// 推送消息
			Satisfactions() {
				this.Loggedin('/pages/Messagepush/Messagepush')
			},
			// 满意度调查
			Satisfaction() {
				this.Loggedin('/pages/Satisfaction/Satisfaction')
			},
			//医护常识
			goMedical(item) {
				this.Loggedin(`/pages/Medicalknowledge/Medicalknowledge?item=${encodeURIComponent(JSON.stringify(item))}`)
			},
			// 复查
			review() {
				this.Loggedin('/pages/Myreview/Myreview')
			},
			// 我的用药
			goappoint() {
				this.Loggedin('/pages/medication/medication')
			},
		}
	}
</script>

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