<script setup>
import { reactive, ref, onMounted, computed } from 'vue';

const CACHE_KEY = 'score_center_info';

const data = reactive({
	form: {
		examYear: '2016',
		idNumber: '***********1234',
		name: '肖战',
		chinese: '113',
		math: '123',
		english: '116',
		comprehensive: '195'
	}
});

const total = computed(() => {
	const sum = Number(data.form.chinese || 0) + Number(data.form.math || 0) + Number(data.form.english || 0) + Number(data.form.comprehensive || 0);
	return sum || '';
});

const editDialog = reactive({
	show: false,
	data: {}
});

onMounted(() => {
	loadCache();
});

function loadCache() {
	const cache = uni.getStorageSync(CACHE_KEY);
	if (cache) {
		data.form = { ...data.form, ...cache };
	}
}

function saveCache() {
	uni.setStorageSync(CACHE_KEY, data.form);
}

function openEditDialog() {
	editDialog.data = JSON.parse(JSON.stringify(data.form));
	editDialog.show = true;
}

function saveEdit() {
	data.form = { ...data.form, ...editDialog.data };
	saveCache();
	editDialog.show = false;
	uni.showToast({
		title: '保存成功',
		icon: 'success'
	});
}

const editTotal = computed(() => {
	const sum = Number(editDialog.data.chinese || 0) + Number(editDialog.data.math || 0) + Number(editDialog.data.english || 0) + Number(editDialog.data.comprehensive || 0);
	return sum || '';
});
function back(){
	uni.navigateBack()
}
</script>

<template>
  <view class="div">
		<view v-if="$isVip()" >
			<watermark dark="light" source="uni_alipay_other_score" />
			<liu-drag-button :canDocking="false" @clickBtn="$goRechargePage('watermark', 'uni_alipay_other_score')">
				<c-lottie ref="cLottieRef" :src='$watermark()' width="94px" height='74px' :loop="true"></c-lottie>
			</liu-drag-button>
		</view>

		<view class="headerBox" :style="{'padding-top':$systemInfo.statusBarHeight+'px'}">
			<view class="header" >
				<view class="left" @click="back()">
					<image src="/static/image/other/score/center/home.png" mode=""></image>
				</view>
				<view class="center">
					查询专区
				</view>
				<view class="right">
					<image src="/static/image/other/score/center/rightBtn.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="" :style="{height:$systemInfo.statusBarHeight*2+88+'rpx'}">
			
		</view>
    <view class="flexcontainer" @click="openEditDialog">
      <view class="rectangle_23375">
        <text class="text_2"> 普通高考成绩查询 </text>
      </view>
      <view class="rectangle_23377">
        <view class="flexcontainer_1"><text class="text_3"> 考试年份: </text><text class="text_4"> {{data.form.examYear}} 年 </text></view>
        <view class="div_424"></view>
        <view class="flexcontainer_2"><text class="text_5"> 身份证号: </text><text class="text_6"> {{data.form.idNumber}} </text></view>
        <view class="div_425"></view>
        <view class="flexcontainer_3"><view class="text_7"> 姓 <text>名:</text> </view><text class="text_8"> {{data.form.name}} </text></view>
        <view class="div_426"></view>
        <text class="text_9"> 科目成绩: </text>
        <view class="group_48319">
          <text class="text_10"> 语文 </text>
          <view class="div_427"></view>
          <text class="text_11"> {{data.form.chinese}} </text>
        </view>
        <view class="group_48320">
          <text class="text_12"> 数学 </text>
          <view class="div_427_1"></view>
          <text class="text_13"> {{data.form.math}} </text>
        </view>
        <view class="group_48321">
          <text class="text_14"> 外语 </text>
          <view class="div_427_2"></view>
          <text class="text_15"> {{data.form.english}} </text>
        </view>
        <view class="group_48322">
          <text class="text_16"> 综合 </text>
          <view class="div_427_3"></view>
          <text class="text_17"> {{data.form.comprehensive}} </text>
        </view>
        <view class="group_48323">
          <text class="text_18"> 总分 </text>
          <view class="div_427_4"></view>
          <text class="text_19"> {{total}} </text>
        </view>
      </view>
    </view>
    <view class="group_48324">
      <text class="text_20"> 返回查询页 </text>
    </view>
    <view class="home">
      <view class="home_indicator"></view>
    </view>

    <!-- 编辑弹窗 -->
    <view v-if="editDialog.show" class="editDialog">
      <view class="editDialog_bg">
        <view class="editDialog_header">
          <text class="title">编辑成绩信息</text>
        </view>
        <view class="editDialog_body">
          <view class="formItem">
            <text>考试年份</text>
            <input v-model="editDialog.data.examYear" type="digit" placeholder="如: 2016" />
          </view>
          <view class="formItem">
            <text>身份证号</text>
            <input v-model="editDialog.data.idNumber" placeholder="如: ***********1234" />
          </view>
          <view class="formItem">
            <text>姓名</text>
            <input v-model="editDialog.data.name" placeholder="请输入姓名" />
          </view>
          <view class="formItem">
            <text>语文</text>
            <input v-model="editDialog.data.chinese" type="digit" placeholder="请输入语文成绩" />
          </view>
          <view class="formItem">
            <text>数学</text>
            <input v-model="editDialog.data.math" type="digit" placeholder="请输入数学成绩" />
          </view>
          <view class="formItem">
            <text>外语</text>
            <input v-model="editDialog.data.english" type="digit" placeholder="请输入外语成绩" />
          </view>
          <view class="formItem">
            <text>综合</text>
            <input v-model="editDialog.data.comprehensive" type="digit" placeholder="请输入综合成绩" />
          </view>
          <view class="formItem">
            <text>总分</text>
            <text style="flex:1;text-align:right;font-size:28rpx;color:#333;">{{editTotal}}</text>
          </view>
        </view>
        <view class="popup-footer">
          <view class="btn-cancel" @click="editDialog.show=false">取消</view>
          <view class="btn-save" @click="saveEdit">保存</view>
        </view>
      </view>
    </view>
  </view>
</template>

<style lang="scss">
* {
  box-sizing: border-box;
}
.flex-row {
  display: flex;
  flex-direction: row;
}
.flex-col {
  display: flex;
  flex-direction: column;
}
.justify-start {
  display: flex;
  justify-content: flex-start;
}
.justify-center {
  display: flex;
  justify-content: center;
}
.justify-end {
  display: flex;
  justify-content: flex-end;
}
.justify-between {
  display: flex;
  justify-content: space-between;
}
.items-start {
  display: flex;
  align-items: flex-start;
}
.items-end {
  display: flex;
  align-items: flex-end;
}
.items-center {
  display: flex;
  align-items: center;
}
.no-shrink {
  flex-shrink: 0;
}

/* 编辑弹窗样式 */
.editDialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.editDialog_bg {
  width: 680rpx;
  max-height: 80vh;
  background-color: #ffffff;
  border-radius: 20rpx;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editDialog_header {
  padding: 30rpx;
  border-bottom: 1rpx solid #eee;
  text-align: center;

  .title {
    font-size: 32rpx;
    font-weight: bold;
    color: #333;
  }
}

.editDialog_body {
  padding: 20rpx 30rpx;
  overflow-y: auto;
  max-height: 60vh;
}

.formItem {
  display: flex;
  align-items: center;
  padding: 20rpx 0;
  border-bottom: 1rpx solid #f5f5f5;

  text {
    width: 200rpx;
    font-size: 28rpx;
    color: #666;
    flex-shrink: 0;
  }

  input {
    flex: 1;
    font-size: 28rpx;
    color: #333;
    text-align: right;
  }
}

.popup-footer {
  display: flex;
  padding: 20rpx 30rpx;
  border-top: 1rpx solid #eee;
  gap: 20rpx;

  .btn-cancel,
  .btn-save {
    flex: 1;
    height: 80rpx;
    line-height: 80rpx;
    text-align: center;
    border-radius: 10rpx;
    font-size: 28rpx;
  }

  .btn-cancel {
    background-color: #f5f5f5;
    color: #666;
  }

  .btn-save {
    background-color: #187AFF;
    color: #fff;
  }
}
</style>
<style lang="scss" scoped>
/* 查询中心 */
.div {
  position: relative;
  width: 750rpx;
  // height: 1624rpx;
  overflow: hidden;
  background-color: #f4f7fb;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  isolation: isolate;
	.headerBox{
		position: fixed;
		left: 0;
		top: 0;
		background-color: #fff;
		z-index: 999 !important;
		width: 100%;
	}
	.header{
		min-height: 88rpx;
		width: 100%;
	
		display: flex;
		align-items: center;
		justify-content: space-between;
		.center{
			font-weight: bold;
			font-size: 17px;
			color: #1A1A1A;
		}
		.left,.right{
			width: 200rpx;
			display: flex;
			align-items: center;
		}
		.left{
			margin-left: 30rpx;
			image{
				width: 42rpx;
				height: 42rpx;
			}
		}
		.right{
			margin-right: 30rpx;
			image{
				width: 200rpx;
				height: 66rpx;
			}
		}
	}


  /* flexContainer */
  .flexcontainer {
    position: relative;
    display: flex;
    width: 750rpx;
    height: 1222rpx;
    flex-direction: column;
    align-items: flex-start;
    isolation: isolate;
    z-index: 2;
    margin-top: 0;
    margin-left: 0;

    /* 矩形 23375 */
    .rectangle_23375 {
      position: relative;
      width: 750rpx;
      height: 260rpx;
      background-color: #1a92ef;
      margin-left: auto;
      margin-right: auto;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      z-index: 0;
      margin-top: 0;
			border-radius: 0 0 24rpx 24rpx;
      /* 消息类型设置 */
      .text_2 {
        position: relative;
        text-align: center;
        font-size: 36rpx;
        font-family: 'PingFang SC';
        font-weight: 400;
        line-height: 50rpx;
        color: #ffffff;
        white-space: pre;
        height: 50rpx;
        margin-top: 24rpx;
        margin-bottom: -7rpx;
        width: max-content;
        margin-left: auto;
        margin-right: auto;
      }
    }

    /* 矩形 23377 */
    .rectangle_23377 {
      position: relative;
      width: 688rpx;
      height: 1056rpx;
      border-radius: 20rpx;
      background-color: #ffffff;
      margin-left: auto;
      margin-right: auto;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      isolation: isolate;
      z-index: 2;
      margin-top: -94rpx;

      /* flexContainer */
      .flexcontainer_1 {
        position: relative;
        display: flex;
        width: 344rpx;
        height: 32rpx;
        flex-direction: row;
        align-items: flex-start;
        z-index: 0;
        margin-top: 32rpx;
        margin-left: 30rpx;

        /* 考试年份: */
        .text_3 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          letter-spacing: 0.34em;
          color: #6f6f6f;
          white-space: pre;
          height: 44rpx;
          margin-top: 0;
          margin-bottom: -6rpx;
          position: relative;
          margin-left: 0;
        }

        /* 2016 年 */
        .text_4 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          color: #333333;
          white-space: pre;
          height: 44rpx;
          margin-top: 0;
          margin-bottom: -6rpx;
          position: relative;
          margin-left: 42rpx;
        }
      }

      /* 直线 424 */
      .div_424 {
        width: 626rpx;
        height: 0;
        border: 1rpx solid #f1f1f1;
        z-index: 4;
        position: relative;
        margin-top: 46rpx;
        margin-left: 30rpx;
      }

      /* flexContainer */
      .flexcontainer_2 {
        position: relative;
        display: flex;
        width: 482rpx;
        height: 32rpx;
        flex-direction: row;
        align-items: flex-start;
        z-index: 1;
        margin-top: 32rpx;
        margin-left: 30rpx;

        /* 身份证号: */
        .text_5 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          letter-spacing: 0.34em;
          color: #6f6f6f;
          white-space: pre;
          height: 44rpx;
          margin-top: 0;
          margin-bottom: -6rpx;
          position: relative;
          margin-left: 0;
        }

        /* ***********1234 */
        .text_6 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          color: #333333;
          white-space: pre;
          height: 44rpx;
          margin-top: 0;
          margin-bottom: -6rpx;
          position: relative;
          margin-left: 42rpx;
        }
      }

      /* 直线 425 */
      .div_425 {
        width: 626rpx;
        height: 0;
        border: 1rpx solid #f1f1f1;
        z-index: 5;
        position: relative;
        margin-top: 46rpx;
        margin-left: 30rpx;
      }

      /* flexContainer */
      .flexcontainer_3 {
        position: relative;
        display: flex;
        // width: 288rpx;
        height: 32rpx;
        flex-direction: row;
        align-items: flex-start;
        z-index: 3;
        margin-top: 34rpx;
        margin-left: 30rpx;

        /* 姓 名: */
        .text_7 {
					width: 210rpx;
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          letter-spacing: 0.34em;
          color: #6f6f6f;
          white-space: pre;
          height: 44rpx;
          margin-top: 0;
          margin-bottom: -6rpx;
          position: relative;
          margin-left: 0;
					display: flex;
					justify-content: space-between;
        }

        /* 肖战 */
        .text_8 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          color: #333333;
          white-space: pre;
          height: 44rpx;
          margin-top: 0;
          margin-bottom: -6rpx;
          position: relative;
          margin-left: 42rpx;
        }
      }

      /* 直线 426 */
      .div_426 {
        width: 626rpx;
        height: 0;
        border: 1rpx solid #f1f1f1;
        z-index: 6;
        position: relative;
        margin-top: 46rpx;
        margin-left: 30rpx;
      }

      /* 科目成绩: */
      .text_9 {
        font-size: 32rpx;
        font-family: 'PingFang SC';
        font-weight: 400;
        line-height: 44rpx;
        letter-spacing: 0.34em;
        color: #6f6f6f;
        white-space: pre;
        height: 44rpx;
        margin-top: 32rpx;
        margin-bottom: -6rpx;
        z-index: 2;
        position: relative;
        margin-left: 30rpx;
      }

      /* 组 48319 */
      .group_48319 {
        width: 626rpx;
        height: 90rpx;
        position: relative;
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        z-index: 7;
        margin-top: 48rpx;
        margin-left: 30rpx;
        border-radius: 16rpx;
        background-color: #f4f7f9;
        isolation: isolate;

        /* 语文 */
        .text_10 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          color: #6f6f6f;
          white-space: pre;
          height: 44rpx;
          margin-top: 26rpx;
          margin-bottom: -6rpx;
          z-index: 0;
          position: relative;
          margin-left: 128rpx;
        }

        /* 直线 427 */
        .div_427 {
          width: 40rpx;
          height: 0;
          transform: rotate(90deg);
          border: 1rpx solid #e5e8ea;
          z-index: 2;
          position: relative;
          margin-left: 84rpx;
          margin-top: 44rpx;
        }

        /* 113 */
        .text_11 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          letter-spacing: -0.04em;
          color: #0087cf;
          white-space: pre;
          height: 44rpx;
          margin-top: 26rpx;
          margin-bottom: -6rpx;
          z-index: 1;
          position: relative;
          margin-left: 122rpx;
        }
      }

      /* 组 48320 */
      .group_48320 {
        width: 626rpx;
        height: 90rpx;
        position: relative;
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        z-index: 9;
        margin-top: 32rpx;
        margin-left: 30rpx;
        border-radius: 16rpx;
        background-color: #f4f7f9;
        isolation: isolate;

        /* 数学 */
        .text_12 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          color: #6f6f6f;
          white-space: pre;
          height: 44rpx;
          margin-top: 26rpx;
          margin-bottom: -6rpx;
          z-index: 0;
          position: relative;
          margin-left: 128rpx;
        }

        /* 直线 427 */
        .div_427_1 {
          width: 40rpx;
          height: 0;
          transform: rotate(90deg);
          border: 1rpx solid #e5e8ea;
          z-index: 2;
          position: relative;
          margin-left: 84rpx;
          margin-top: 44rpx;
        }

        /* 123 */
        .text_13 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          letter-spacing: -0.04em;
          color: #0087cf;
          white-space: pre;
          height: 44rpx;
          margin-top: 26rpx;
          margin-bottom: -6rpx;
          z-index: 1;
          position: relative;
          margin-left: 122rpx;
        }
      }

      /* 组 48321 */
      .group_48321 {
        width: 626rpx;
        height: 90rpx;
        position: relative;
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        z-index: 8;
        margin-top: 32rpx;
        margin-left: 30rpx;
        border-radius: 16rpx;
        background-color: #f4f7f9;
        isolation: isolate;

        /* 外语 */
        .text_14 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          color: #6f6f6f;
          white-space: pre;
          height: 44rpx;
          margin-top: 26rpx;
          margin-bottom: -6rpx;
          z-index: 0;
          position: relative;
          margin-left: 128rpx;
        }

        /* 直线 427 */
        .div_427_2 {
          width: 40rpx;
          height: 0;
          transform: rotate(90deg);
          border: 1rpx solid #e5e8ea;
          z-index: 2;
          position: relative;
          margin-left: 84rpx;
          margin-top: 44rpx;
        }

        /* 116 */
        .text_15 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          letter-spacing: -0.04em;
          color: #0087cf;
          white-space: pre;
          height: 44rpx;
          margin-top: 26rpx;
          margin-bottom: -6rpx;
          z-index: 1;
          position: relative;
          margin-left: 122rpx;
        }
      }

      /* 组 48322 */
      .group_48322 {
        width: 626rpx;
        height: 90rpx;
        position: relative;
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        z-index: 10;
        margin-top: 32rpx;
        margin-left: 30rpx;
        border-radius: 16rpx;
        background-color: #f4f7f9;
        isolation: isolate;

        /* 综合 */
        .text_16 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          color: #6f6f6f;
          white-space: pre;
          height: 44rpx;
          margin-top: 26rpx;
          margin-bottom: -6rpx;
          z-index: 0;
          position: relative;
          margin-left: 128rpx;
        }

        /* 直线 427 */
        .div_427_3 {
          width: 40rpx;
          height: 0;
          transform: rotate(90deg);
          border: 1rpx solid #e5e8ea;
          z-index: 2;
          position: relative;
          margin-left: 84rpx;
          margin-top: 44rpx;
        }

        /* 195 */
        .text_17 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          letter-spacing: -0.04em;
          color: #0087cf;
          white-space: pre;
          height: 44rpx;
          margin-top: 26rpx;
          margin-bottom: -6rpx;
          z-index: 1;
          position: relative;
          margin-left: 122rpx;
        }
      }

      /* 组 48323 */
      .group_48323 {
        width: 626rpx;
        height: 90rpx;
        position: relative;
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        z-index: 11;
        margin-top: 32rpx;
        margin-left: 30rpx;
        border-radius: 16rpx;
        background-color: #f4f7f9;
        isolation: isolate;

        /* 总分 */
        .text_18 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          color: #6f6f6f;
          white-space: pre;
          height: 44rpx;
          margin-top: 26rpx;
          margin-bottom: -6rpx;
          z-index: 0;
          position: relative;
          margin-left: 128rpx;
        }

        /* 直线 427 */
        .div_427_4 {
          width: 40rpx;
          height: 0;
          transform: rotate(90deg);
          border: 1rpx solid #e5e8ea;
          z-index: 2;
          position: relative;
          margin-left: 84rpx;
          margin-top: 44rpx;
        }

        /* 549 */
        .text_19 {
          font-size: 32rpx;
          font-family: 'PingFang SC';
          font-weight: 400;
          line-height: 44rpx;
          letter-spacing: -0.04em;
          color: #0087cf;
          white-space: pre;
          height: 44rpx;
          margin-top: 26rpx;
          margin-bottom: -6rpx;
          z-index: 1;
          position: relative;
          margin-left: 122rpx;
        }
      }
    }


  }

  /* 组 48324 */
  .group_48324 {
    width: 688rpx;
    height: 90rpx;
    position: relative;
    font-size: 28rpx;
    font-family: 'PingFang SC';
    font-weight: 400;
    line-height: 40rpx;
    color: #ffffff;
    white-space: pre;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    z-index: 3;
    margin-top: 48rpx;
    margin-left: 32rpx;
    border-radius: 298rpx;
    background-color: #1689f9;

    /* 返回查询页 */
    .text_20 {
      height: 40rpx;
      margin-top: 32rpx;
      margin-bottom: -6rpx;
      position: relative;
      margin-left: 274rpx;
    }
  }

  /* home */
  .home {
    position: absolute;
    width: 750rpx;
    height: 68rpx;
    top: auto;
    left: 0;
    background-color: rgba(255, 255, 255, 0);
    right: 0;
    margin-left: auto;
    margin-right: auto;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;

    .home_indicator {}
  }
}
</style>