<template>
	<view class="app">
		<view class="prescription">
			<view class="record" @tap="recorddata()">
				处方记录
			</view>
			<view class="recorditem">
				<u-collapse :item-style="itemStyle" :accordion='false' :arrow="false">
					<u-collapse-item :title="item.tempName" v-for="(item, index) in lastrecodedata.ptList" :key="index"
						@change='tapcollapse(item)' :class="item.check?'headcollapse':''">
						<view class="itemtext">
							<view class="collapse_top" v-for="uitem in item.ptValList">
								<u-icon name="star-fill" color="#000" size="28"
									v-if="uitem.itemType=='1' || uitem.itemType=='2' ||uitem.itemType=='3'"></u-icon>
								<span style="margin-left: 10rpx;" v-if="uitem.itemType=='1'">健康生活方式 </span>
								<span style="margin-left: 10rpx;" v-if="uitem.itemType=='2'">治疗与康复</span>
								<span style="margin-left: 10rpx;" v-if="uitem.itemType=='3'">急症处理</span>
								<view class="itemsdata">
									<view class="itemword" v-if="uitem.val=='true'">
										<u-checkbox active-color="#26A888" v-model="checked"> {{uitem.content}}</u-checkbox>
									</view>
									<view class="itemword" v-if="uitem.val==null || uitem.val=='false'">
										<u-checkbox active-color="#26A888" v-model="checkedfalse">{{uitem.content}}</u-checkbox>
									</view>
								</view>
							</view>

						</view>
					</u-collapse-item>
				</u-collapse>
			</view>
		</view>
		<u-loading :show="show" mode="flower" size="40"></u-loading>
	</view>
</template>

<script>
	import {
		lastrecode
	} from "@/api/pagesB/threeHundredAndSixty/threeHundredAndSixty.js"
	export default {
		data() {
			return {
				show: true,
				checked: true,
				lastrecodedata: null,
				cardNo: '',
				itemList: [],

			}
		},
		mounted() {
			this.lastrecodelist()

		},
		methods: {
			tapcollapse(item) {
				item.check = !item.check
			},
			lastrecodelist() {
				if (uni.getStorageSync("userinfo").cardNo) {
					// this.cardNo=uni.getStorageSync("userinfo").cardNo
					this.cardNo = '370522196411282177'
					lastrecode(this.cardNo).then(res => {
						this.lastrecodedata = res.data
						this.show = false
					})
				}
			},
			// 处方记录
			recorddata() {
				uni.navigateTo({
					url: "/pagesB/Prescriptionrecords/Prescriptionrecords"
				})


			},

		}
	}
</script>


<style lang="scss">
	.app {
		height: 100vh;
		background-color: #fff;
		// padding: 100rpx 40rpx;
		text-align: center;
		font-size: 36rpx;
		

		// 健康处方
		.prescription {
			::v-deep .u-collapse-title {
				font-size: 30rpx;
				font-weight: 600;
				padding-left: 10rpx;
			}

			.headcollapse {
				::v-deep .u-collapse-head {
					border-bottom: 2rpx solid #E6E6E6;
					text-align: center !important;
				}

				::v-deep .u-collapse-title {
					color: #26A888;
				}
			}
			::v-deep .u-icon--right {
				color: #26A888 !important;
			}


			::v-deep .u-collapse-head {
				width: 96%;
				margin: 0 auto;
				background: #26A888 !important;
				text-align: center;
				color: #fff;
			}

			.record {
				color: #fff;
				width: 250rpx;
				height: 70rpx;
				line-height: 70rpx;
				border-radius: 10rpx;
				text-align: center;
				margin-left: auto;
				background: #26A888;
				font-size: 27rpx;

			}

			.recorditem {
				margin-top: 39rpx;

			

				.itemtext {
					.collapse_top {
						font-size: 30rpx;
						font-weight: 500;
						color: #000;
						width: 94%;
						line-height: 40rpx;
						margin: 0 auto;
						padding: 20rpx 20rpx;

						.itemsdata {
							width: 100%;

							.itemword {
								margin: 15rpx;


							}

						}

					}
				}

			}

		}
	}
</style>