<template>
  <view class="page">
    <h3>配送方式</h3>
    <div class="appraise" @click="showPicker = true">
      <div>{{ detailData.orderState }}</div>
      <div class="flex appraise-right">
        <u-icon name="arrow-right" size="12" />
      </div>
    </div>
    <div class="cont">
      <div class="top-source m-8">订单来源: {{ detailData.orderSource }}</div>
      <div class="flex justify-between m-8">
        <div class="flex align-center">
          <div>{{ detailData.canteenName }}</div>
          <div class="tag">{{ detailData.canteenType }}</div>
        </div>
        <div>就餐日期: {{ detailData.diningTime }}</div>
      </div>
      <div class="img-cont m-8">
        <div class="img-list m-8" v-for="(item, index) in detailData.addFood" :key="index">
          <div class="flex align-center">
            <u-image :src="item.imageUrl" width="80px" height="80px" />
            <div class="name-num">
              <div style="margin-bottom: 10px">{{ item.mealName }}</div>
              <div>x{{ item.restrictNum }}</div>
            </div>
          </div>
          <div>￥{{ item.salePrice }}</div>
        </div>
      </div>
      <div class="flex justify-between m-8 bt">
        配送费
        <div>{{ detailData.deliveryFee }}</div>
      </div>
      <div class="flex justify-between m-8 bt">
        包装费
        <div>{{ detailData.packingFee }}</div>
      </div>
      <div class="flex justify-between align-center m-8 bt">
        备注
        <u-input v-model="detailData.remark" placeholder="请填写备注信息" border="none" inputAlign="right"></u-input>
      </div>
      <u-line />
      <div class="flex justify-between m-8 realAmount">
        小计
        <div>￥{{ detailData.realAmount || 12 }}</div>
      </div>
    </div>
    <div class="order">
      <div class="m-8 bt" style="font-weight: 800">支付方式</div>
      <div class="flex justify-between align-center m-8">
        <div class="flex justify-between align-center">
          <u-icon name="/static/images/remaining-sum.png" size="36" />
          <div style="margin-left: 10px">
            <div>钱包支付</div>
            <div style="font-size: 12px; color: rgba(15, 39, 75, 0.6)">推荐使用</div>
          </div>
        </div>
        <u-icon name="/static/images/active-circle.png" size="20" />
      </div>
    </div>

    <div style="height: 60px"></div>
    <div class="shop-car">
      <div class="car-cont">
        <div class="flex align-center">
          <span class="money">
            <span style="font-size: 13px">实付款￥</span>
            {{ detailData.totalPrice }}
          </span>
        </div>

        <div>
          <u-button shape="circle" color="#FF6816" style="width: 79px; height: 28px" @click="handleOrder">
            结算
          </u-button>
        </div>
      </div>
    </div>

    <u-picker
      :show="showPicker"
      :columns="columns"
      keyName="label"
      @cancel="showPicker = false"
      @confirm="confirm"
    ></u-picker>
  </view>
</template>

<script>
export default {
  props: {},
  data() {
    return {
      // 详情页数据
      detailData: {
        // 订单状态
        orderState: '堂食',
        // 订单来源
        orderSource: '设备下线消费',
        // 餐厅名称
        canteenName: '',
        // 餐次
        canteenType: '',
        // 就餐时间
        diningTime: '',
        // 菜品
        addFood: [],
        remark: '', // 备注
        // 支付方式
        payType: '小程序二维码支付'
      },
      showPicker: false, // 是否显示选择器
      // 选择器数据
      columns: [
        [
          {
            label: '自取外带',
            value: '1'
          },
          {
            label: '堂食',
            value: '2'
          }
        ]
      ]
    }
  },
  onLoad(opt) {
    opt = JSON.parse(opt.params)
    this.detailData = {
      ...this.detailData,
      ...opt
    }
  },
  methods: {
    confirm(e) {
      console.log('🚀 ~ confirm ~ value:', e)
      this.showPicker = false
      this.detailData.orderState = e.value[0].label
    },
  }
}
</script>

<style lang="scss" scoped>
.page {
  background: #f9fbff;
  padding: 16px;
  min-height: 100vh;
  color: #0f274b;
}
.appraise {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin: 8px 0 20px;
  .appraise-right {
    color: #ff6816;
  }
}
.m-8 {
  margin: 0 8px;
}
.bt {
  margin-bottom: 16px;
}
.cont {
  background: #fff;
  border-radius: 8px;
  padding: 8px 0;
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
  .top-source {
    font-weight: 800;
    margin-bottom: 12px;
  }
  .tag {
    margin-left: 5px;
    width: 32px;
    border-radius: 1px 1px 1px 1px;
    border: 1px solid #ff6816;
    color: #ff6816;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .img-cont {
    margin: 20px 0;
    .img-list {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 10px;
      .name-num {
        margin-left: 10px;
      }
    }
  }
  .realAmount {
    margin-top: 16px;
    font-size: 16px;
    font-weight: 800;
  }
}
.order {
  margin-top: 16px;
  padding: 8px 0;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
}
.shop-car {
  height: 60px;
  background: #fff;
  box-shadow: 0px -1px 4px 0px rgba(0, 102, 204, 0.1);
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;

  .car-cont {
    margin: 15px 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .money {
      margin-left: 8px;
      font-weight: 600;
      font-size: 18px;
      color: #0f274b;
    }
  }
}
</style>
