<template>
  <view class="page" :style="themeColor" v-if="isLoading">
    <view class="flex benben-position-layout flex flex-wrap align-center ImmediatEevaluation_flex_0"
      :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
      <view class='flex flex-wrap align-center justify-between flex-sub ImmediatEevaluation_fd0_0'>
        <view class='flex flex-wrap align-center' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
          <text class='fu-iconfont2  ImmediatEevaluation_fd0_0_c0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">&#xE794;</text>
        </view>
        <view class='flex flex-wrap align-stretch justify-center flex-sub'>
          <text class='ImmediatEevaluation_fd0_0_c1_c0'>评价</text>
        </view>
        <view class='flex flex-wrap align-center ImmediatEevaluation_fd0_0_c2'>
        </view>
      </view>

    </view>
    <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
    <!---flex布局flex布局开始-->
    <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout ImmediatEevaluation_flex_1">
      <view class='flex flex-wrap align-center ImmediatEevaluation_fd1_0'>
        <image class='ImmediatEevaluation_fd1_0_c0' mode="aspectFill" :src='info.store_info.logo'></image>
        <text class='ImmediatEevaluation_fd1_0_c1'>{{info.store_info.store_name}}</text>
      </view>
      <view class='flex flex-direction flex-wrap align-stretch'>
        <view class='flex flex-wrap align-center ImmediatEevaluation_fd1_1_c0'>
          <text class='ImmediatEevaluation_fd1_1_c0_c0'>商家评分</text>
          <view class='flex flex-wrap align-center'>
            <template v-for="starNum in [1,2,3,4,5]">
              <image @tap="handleChooseStar('fd1_1_c0_c1', starNum)" v-if="fd1_1_c0_c1 >= starNum" :key="starNum" class='ImmediatEevaluation_star1fd1_1_c0_c1'
                mode="aspectFit" :src='STATIC_URL+"31.png"'></image>
              <image @tap="handleChooseStar('fd1_1_c0_c1', starNum)" v-else :key="starNum" class='ImmediatEevaluation_star1fd1_1_c0_c1' mode="aspectFit"
                :src='STATIC_URL+"164.png"'></image>
            </template>
          </view>
        </view>
        <view class='flex flex-wrap align-center ImmediatEevaluation_fd1_1_c1'>
          <text class='ImmediatEevaluation_fd1_1_c1_c0'>服务态度</text>
          <view class='flex flex-wrap align-center'>
            <template v-for="starNum in [1,2,3,4,5]">
              <image @tap="handleChooseStar('fd1_1_c1_c1', starNum)" v-if="fd1_1_c1_c1 >= starNum" :key="starNum" class='ImmediatEevaluation_star1fd1_1_c1_c1'
                mode="aspectFit" :src='STATIC_URL+"31.png"'></image>
              <image @tap="handleChooseStar('fd1_1_c1_c1', starNum)" v-else :key="starNum" class='ImmediatEevaluation_star1fd1_1_c1_c1' mode="aspectFit"
                :src='STATIC_URL+"164.png"'></image>
            </template>
          </view>
        </view>
        <view class='flex flex-wrap align-center ImmediatEevaluation_fd1_1_c2'>
          <text class='ImmediatEevaluation_fd1_1_c2_c0'>菜品口味</text>
          <view class='flex flex-wrap align-center'>
            <template v-for="starNum in [1,2,3,4,5]">
              <image @tap="handleChooseStar('fd1_1_c2_c1', starNum)" v-if="fd1_1_c2_c1 >= starNum" :key="starNum" class='ImmediatEevaluation_star1fd1_1_c2_c1'
                mode="aspectFit" :src='STATIC_URL+"31.png"'></image>
              <image @tap="handleChooseStar('fd1_1_c2_c1', starNum)" v-else :key="starNum" class='ImmediatEevaluation_star1fd1_1_c2_c1' mode="aspectFit"
                :src='STATIC_URL+"164.png"'></image>
            </template>
          </view>
        </view>
      </view>
      <view class='flex flex-wrap align-center'>
        <view class='flex flex-wrap ImmediatEevaluation_fd1_2_c0'>
          <textarea class='flex ImmediatEevaluation_input_fd1_2_c0' :placeholder="'请输入您的评价'" :maxlength="240"
            placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx" v-model="field" />

        </view>
      </view>
      <view class='flex flex-wrap align-center ImmediatEevaluation_fd1_3'>
        <text class='ImmediatEevaluation_fd1_3_c0'>添加照片</text>
        <text class='ImmediatEevaluation_fd1_3_c1'>最多可上传9张</text>
      </view>
      <view class='flex flex-wrap align-center'>
        <benben-images-upload ref="benbenImagesUploadfd1_4_c0" :img-list.sync="mastphoto_list" :img-ids.sync="mastphoto"
          :maxlength="9">
          <template #content="{ num, maxlength, isShow, imgList }">
            <view class="flex flex-wrap align-start flex ImmediatEevaluation_fd1_4_c0">

              <view v-for="(image, index) in imgList" :key="index"
                class='flex position-relative ImmediatEevaluation_fd1_4_c00'>
                <text class='fu-iconfont2 position-absolute ImmediatEevaluation_fd1_4_c000'
                  @tap.stop="$refs.benbenImagesUploadfd1_4_c0.delImage(index)">&#xE8E7;</text>
                <image class='ImmediatEevaluation_fd1_4_c001'
                  @tap.stop="$refs.benbenImagesUploadfd1_4_c0.previewImage(index)" mode="aspectFill" :src='image'>
                </image>
              </view>

              <image class='ImmediatEevaluation_fd1_4_c01'
                @tap.stop="$refs.benbenImagesUploadfd1_4_c0.manyChooseImage()" v-if="isShow" mode="aspectFill"
                :src='STATIC_URL+"81.png"'></image>

            </view>
          </template>
        </benben-images-upload>
      </view>
      <view class='flex flex-wrap align-center'>
        <benben-flex-switch-new class-name='flex flex' v-model="is_Anonymous" :disabled='false' :auto='true'>
          <template v-slot:checked>

            <view class='flex flex position-relative align-center'>
              <image class='ImmediatEevaluation_checkfd1_5_c0_c0_c0' mode="aspectFit" :src='STATIC_URL+"85.png"'>
              </image>
            </view>

          </template>
          <template v-slot:unchecked>

            <view class='flex flex position-relative justify-end align-center'>
              <image class='ImmediatEevaluation_noCheckfd1_5_c0_c1_c0' mode="aspectFit" :src='STATIC_URL+"123.png"'>
              </image>
            </view>

          </template>
        </benben-flex-switch-new>
        <text class='ImmediatEevaluation_fd1_5_c1'>匿名提交</text>
      </view>
    </view>

    <!---flex布局flex布局结束-->
    <view class="flex flex-direction flex-wrap align-center benben-position-layout flex ImmediatEevaluation_flex_2">
      <button class='ImmediatEevaluation_fd2_0' @tap.stop="submitEvaluationFunc()">提交</button>

    </view>
    <view :style="{height: '128rpx'}"></view>


  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "fd1_1_c0_c1": "5",
        "fd1_1_c1_c1": "5",
        "fd1_1_c2_c1": "5",
        "is_Anonymous": false,
        "field": "",
        "mastphoto_list": [],
        "mastphoto": "",
        sn: '',
        isLoading: false,
        info: {},
        isSubmit: false
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      this.sn = options.sn || '';
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {
      this.getOrderDetail();
    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      handleChooseStar(name, star) {
        this[name]= star;
      },
      /**
       * 获取订单详情
       */
      getOrderDetail() {
        this.$api.post(global.apiUrls.getOrderDetail, {
            order_sn: this.sn
          }).then(res => {
            if (res.data.code == 1) {
              this.isLoading = true
              this.info = res.data.data;
            }
          })
          .catch(err => {
            console.log(err);
          });
      },
      //提交评价
      submitEvaluationFunc() {
        if (!validate(this.field, 'require')) {
          this.$message.info('评价不能为空');
          return false;
        }
        // if (!(this.mastphoto_list.length != 0)) {
        //   this.$message.info('请上传图片');
        //   return false;
        // }
        if (this.isSubmit) return;
        this.isSubmit = true;
        uni.showLoading({
          title: '正在提交~',
          mask: true
        })
        let params = {
          order_sn: this.sn,
          score:  this.fd1_1_c0_c1,
          service_score: this.fd1_1_c1_c1,
          goods_score: this.fd1_1_c2_c1,
          images: this.mastphoto,
          content: this.field,
          is_anonymous: this.is_Anonymous ? 1 :0
        }
        this.$api.post(global.apiUrls.postAddOrderComment, params).then(res => {
          this.$message.info(res.data.msg);
          console.log(res);
          uni.hideLoading()
          if (res.data.code == 1) {
            // 提交成功返回上页面
            setTimeout(() => {
              this.$urouter.redirectTo(`/pages/dpxq/evaluateResults/evaluateResults`);
            }, 1200);
          } else {
            this.isSubmit = false;
          }
        });
        
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(255, 255, 255, 1);
    background-size: 100% auto !important;
  }

  .ImmediatEevaluation_flex_0 {
    background: rgba(255, 147, 0, 1);
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .ImmediatEevaluation_fd0_0_c2 {
    width: 32rpx;
    height: 32rpx;
  }

  .ImmediatEevaluation_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 500;
    color: rgba(255, 255, 255, 1);
    line-height: 88rpx;
  }

  .ImmediatEevaluation_fd0_0_c0_c0 {
    font-size: 32rpx;
    font-weight: 500;
    color: rgba(255, 255, 255, 1);
    line-height: 88rpx;
  }

  .ImmediatEevaluation_fd0_0 {
    margin: 0rpx 32rpx 0rpx 32rpx;
  }

  .ImmediatEevaluation_flex_1 {
    padding: 32rpx 32rpx 32rpx 32rpx;
  }

  .ImmediatEevaluation_fd1_5_c1 {
    margin: 0rpx 0rpx 0rpx 016rpx;
    color: #333333;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 24rpx;
  }

  .ImmediatEevaluation_noCheckfd1_5_c0_c1_c0 {
    border-radius: 24rpx 24rpx 24rpx 24rpx;
    width: 34rpx;
    height: 34rpx;
  }

  .ImmediatEevaluation_checkfd1_5_c0_c0_c0 {
    width: 34rpx;
    height: 34rpx;
    border-radius: 24rpx 24rpx 24rpx 24rpx;
  }

  .ImmediatEevaluation_fd1_4_c01 {
    width: 180rpx;
    height: 180rpx;
    margin: 0rpx 24rpx 24rpx 0rpx;
  }

  .ImmediatEevaluation_fd1_4_c001 {
    width: 180rpx;
    height: 180rpx;
  }

  .ImmediatEevaluation_fd1_4_c000 {
    top: 0rpx;
    right: 0rpx;
    z-index: 10;
    color: #ff5536;
  }

  .ImmediatEevaluation_fd1_4_c00 {
    margin: 0rpx 24rpx 24rpx 0rpx;
  }

  .ImmediatEevaluation_fd1_4_c0 {
    width: 750rpx;
    margin: 24rpx 0rpx 0rpx 0rpx;
  }

  .ImmediatEevaluation_fd1_3_c1 {
    color: #BFBFBF;
    font-size: 20rpx;
    font-weight: 400;
    line-height: 27rpx;
    margin: 0rpx 0rpx 0rpx 8rpx;
  }

  .ImmediatEevaluation_fd1_3_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 500;
    line-height: 27rpx;
  }

  .ImmediatEevaluation_fd1_3 {
    margin: 32rpx 0rpx 0rpx 0rpx;
  }

  .ImmediatEevaluation_input_fd1_2_c0 {
    width: 686%;
    height: 140rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #333;
    white-space: pre-wrap;
  }

  .ImmediatEevaluation_fd1_2_c0 {
    background: rgba(246, 247, 249, 1);
    width: 686rpx;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    padding: 24rpx 24rpx 24rpx 24rpx;
  }

  .ImmediatEevaluation_star1fd1_1_c2_c1 {
    height: 32rpx;
    margin: 0rpx 5rpx 0rpx 5rpx;
    width: 32rpx;
  }

  .ImmediatEevaluation_star1fd1_1_c2_c1 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 5rpx 0rpx 5rpx;
  }

  .ImmediatEevaluation_fd1_1_c2_c0 {
    margin: 0rpx 31rpx 0rpx 0rpx;
    color: #333333;
    font-size: 28rpx;
    font-weight: 500;
    line-height: 28rpx;
  }

  .ImmediatEevaluation_fd1_1_c2 {
    margin: 0rpx 0rpx 29rpx 0rpx;
  }

  .ImmediatEevaluation_star1fd1_1_c1_c1 {
    height: 32rpx;
    margin: 0rpx 5rpx 0rpx 5rpx;
    width: 32rpx;
  }

  .ImmediatEevaluation_star1fd1_1_c1_c1 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 5rpx 0rpx 5rpx;
  }

  .ImmediatEevaluation_fd1_1_c1_c0 {
    margin: 0rpx 31rpx 0rpx 0rpx;
    color: #333333;
    font-size: 28rpx;
    font-weight: 500;
    line-height: 28rpx;
  }

  .ImmediatEevaluation_fd1_1_c1 {
    margin: 0rpx 0rpx 29rpx 0rpx;
  }

  .ImmediatEevaluation_star1fd1_1_c0_c1 {
    height: 32rpx;
    margin: 0rpx 5rpx 0rpx 5rpx;
    width: 32rpx;
  }

  .ImmediatEevaluation_star1fd1_1_c0_c1 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 5rpx 0rpx 5rpx;
  }

  .ImmediatEevaluation_fd1_1_c0_c0 {
    margin: 0rpx 31rpx 0rpx 0rpx;
    color: #333333;
    font-size: 28rpx;
    font-weight: 500;
    line-height: 28rpx;
  }

  .ImmediatEevaluation_fd1_1_c0 {
    margin: 0rpx 0rpx 29rpx 0rpx;
  }

  .ImmediatEevaluation_fd1_0_c1 {
    color: #333333;
    font-size: 32rpx;
    font-weight: 600;
    line-height: 32rpx;
  }

  .ImmediatEevaluation_fd1_0_c0 {
    width: 80rpx;
    height: 80rpx;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    margin: 0rpx 24rpx 0rpx 0rpx;
  }

  .ImmediatEevaluation_fd1_0 {
    margin: 0rpx 0rpx 40rpx 0rpx;
  }

  .ImmediatEevaluation_flex_2 {
    width: 750rpx;
    height: 128rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(0rpx + var(--window-bottom));
  }

  .ImmediatEevaluation_fd2_0 {
    background: rgba(255, 147, 0, 1);
    border-radius: 44rpx 44rpx 44rpx 44rpx;
    font-size: 32rpx;
    color: #fff;
    width: 686rpx;
    height: 80rpx;
    line-height: 80rpx;
    font-weight: 400;
  }
</style>
