<template>
  <view class="container">
    <navbar :config="config" backColor="#666"></navbar>
    <view class="top-state u-font24 u-00321E">
      <!--待付款-->
      <view class="obligation" v-if="payment_status == 0">
        <view class="u-flex-center u-flex1">
          <image class="timeImg" :src="imgUrl+'/time.png'"></image>
          <view class="u-flex1">
            <view class="u-font32 u-bold">{{
              close_mode == 0 ? "待付款" : "订单已关闭"
            }}</view>
            <view class="u-flex u-font26" v-if="close_mode == 0"
              >请在{{
                $mUtil.patTime(expired_pay_time)
              }}内完成支付，超时订单将自动关闭</view
            >
            <view class="u-flex u-font26" v-if="close_mode == 1"
              >原因：主动取消</view
            >
            <view class="u-flex u-font26" v-if="close_mode == 2"
              >原因：商家撤销关闭</view
            >
            <view class="u-flex u-font26" v-if="close_mode == 3"
              >原因：支付过期关闭</view
            >
          </view>
        </view>
      </view>

      <!--等待确认提货-->
      <view class="refund-underway obligation" v-if="payment_status == 3">
        <view class="u-flex-center u-flex1">
          <image class="timeImg" :src="imgUrl+'/time.png'"></image>
          <view class="u-flex1">
            <view class="u-font32 u-bold">待使用</view>
            <view class="u-flex u-font26" v-if="service_expire_time > 0"
              >您的商品，还剩{{
                $mUtil.patTime(service_expire_time)
              }}过期</view
            >
          </view>
        </view>
      </view>

      <!--交易成功-->
      <!-- <view class="refund-underway" v-if="payment_status==4">
				<view class="u-font28">交易成功</view>
			</view> -->
      <view class="obligation" v-if="payment_status == 4 && !end">
        <view class="u-flex-center u-flex1">
          <image class="timeImg" :src="imgUrl+'/time.png'"></image>
          <view class="u-flex1">
            <view class="u-font32 u-bold">待评价</view>
            <view class="u-flex u-font26"
              >您的订单已签收，请评价一下商品，剩{{
                $mUtil.patTime(last_comment_time)
              }}自动评价</view
            >
          </view>
        </view>
      </view>
      <!--待评价-->
      <view
        class="refund-underway obligation"
        v-if="payment_status == 4 && end"
      >
        <view class="u-flex-center u-flex1">
          <image class="timeImg" :src="imgUrl+'/time.png'"></image>
          <view class="u-flex1">
            <view class="u-font32 u-bold">已完成</view>
            <view class="u-flex u-font26">您的订单已完成，祝你购物愉快</view>
          </view>
        </view>
      </view>
      <view class="refund-underway obligation" v-if="payment_status == 5">
        <view class="u-flex-center u-flex1">
          <image class="timeImg" :src="imgUrl+'/time.png'"></image>
          <view class="u-flex1">
            <view class="u-font32 u-bold">已完成</view>
            <view class="u-flex u-font26">您的订单已完成，祝你购物愉快</view>
          </view>
        </view>
      </view>
      <view class="refund-underway obligation" v-if="payment_status == -1">
        <view class="u-flex-center u-flex1">
          <image class="timeImg" :src="imgUrl+'/time.png'"></image>
          <view class="u-flex1">
            <view class="u-font32 u-bold">退款中</view>
            <view class="u-flex u-font26">您的订单在退款中</view>
          </view>
        </view>
      </view>

      <view class="refund-underway obligation" v-if="payment_status == -2">
        <view class="u-flex-center u-flex1">
          <image class="timeImg" :src="imgUrl+'/time.png'"></image>
          <view class="u-flex1">
            <view class="u-font32 u-bold">退款完成</view>
            <view class="u-flex u-font26"
              >您的订单已完成退款，祝您生活愉快</view
            >
          </view>
        </view>
      </view>
      <view class="refund-underway obligation" v-if="payment_status == -3">
        <view class="u-flex-center u-flex1">
          <image class="timeImg" :src="imgUrl+'/time.png'"></image>
          <view class="u-flex1">
            <view class="u-font32 u-bold">退款退货维权中</view>
            <view class="u-flex u-font26">您的订单在退款退货维权中</view>
          </view>
        </view>
      </view>
      <view class="refund-underway obligation" v-if="payment_status == -4">
        <view class="u-flex-center u-flex1">
          <image class="timeImg" :src="imgUrl+'/time.png'"></image>
          <view class="u-flex1">
            <view class="u-font32 u-bold">退款退货完成</view>
            <view class="u-flex u-font26"
              >您的订单已完成退款退货完成，祝您生活愉快</view
            >
          </view>
        </view>
      </view>
    </view>

    <view class="u-flex-column-center u-bg-fff" v-if="payment_status == 3">
      <text class="u-font22 u-999 u-mt15">出示数字码向店长核销</text>
      <view class="u-flex-center u-ptb30">
        <text class="u-font40 u-333 u-bold">{{ pickCode }}</text>
        <text class="u-font28 u-666 u-ml20" @click="copy(pickCode)">复制</text>
      </view>
    </view>

    <view v-if="orderListPay.length > 0">
      <view class="pabox" v-for="item in orderListPay" :key="item.id">
        <ldshop
          :shopStatus="shopStatus"
          :value="item.source_shop_name"
          :proxy="item.proxy"
        ></ldshop>
        <view class="u-mt20"></view>
        <view v-for="items in item.child_order_list" :key="items.id">
          <ldgoods :value="items"></ldgoods>
        </view>
        <view class="u-font28 u-1A1A1A u-mt30 bg-fff">
          <view class="u-flex-center-sb u-border-one pt-pb25">
            <view>商品金额</view>
            <view class="u-999 u-font3"
              >¥ {{ item.original_goods_amount }}</view
            >
          </view>

          <view class="u-flex-center-sb u-border-one pt-pb25">
            <view>运费</view>
            <view class="u-999 u-font30">+¥{{ item.real_freight }} </view>
          </view>
          <view
            class="u-flex-center-sb u-border-one pt-pb25"
            v-if="item.first_order_reduced > 0"
          >
            <view>首单优惠 <text class="u-999 u-font24"></text> </view>
            <view class="u-999 u-font30"
              >-¥ {{ item.first_order_reduced }}</view
            >
          </view>

          <view class="u-flex-center-sb u-border-one pt-pb25">
            <view>服务商品优惠</view>
			<!-- {{ item.user_role_name }} -->

            <view class="u-999 u-font30">-¥ {{ item.discount_amount }}</view>
          </view>
          <view
            class="u-flex-center u-border-one pt-pb25"
            style="justify-content: flex-end"
          >
            <view class="">共{{ item.goods_number }}件商品，小计</view>
            <view class="u-bold u-FF0000"
              ><rich-text
                :nodes="$mUtil.priceBigSmall(item.total_amount)"
              ></rich-text
            ></view>
          </view>
          <view class="u-flex-column-start">
            <view style="margin-top: 20rpx;">购买备注</view>
            <view class="boxTextarea">{{
              item.user_remark ? item.user_remark : "无"
            }}</view>
          </view>
        </view>
      </view></view
    >

    <view class="pabox" v-if="orderList.length > 0 && service_card">
      <ldshop :shopStatus="shopStatus" :value="source_shop_name"></ldshop>
      <view class="u-mt20"></view>
      <view v-for="(item, index) in orderList" :key="item.id">
        <ldgoods
          :value="item"
          @parentevaluation="parentevaluation"
          :keys="index"
        ></ldgoods>
      </view>

      <view class="u-font28 u-1A1A1A u-mt30 bg-fff">
        <view class="u-flex-center-sb u-border-one pt-pb25">
          <view>商品金额</view>
          <view class="u-999 u-font3">¥ {{ original_goods_amount }}</view>
        </view>

        <view class="u-flex-center-sb u-border-one pt-pb25">
          <view>运费</view>
          <view class="u-999 u-font30">+¥{{ real_freight }} </view>
        </view>

        <view class="u-flex-center-sb u-border-one pt-pb25">
          <view v-if="marketing_type == 1">秒杀活动折扣</view>
          <view v-else>服务商品优惠</view>
          <view class="u-999 u-font30">-¥ {{ discount_amount }}</view>
        </view>
        <view
          class="u-flex-center-sb u-border-one pt-pb25"
          v-if="first_order_reduced > 0"
        >
          <view>首单优惠 <text class="u-999 u-font24"></text> </view>
          <view class="u-999 u-font30">-¥ {{ first_order_reduced }}</view>
        </view>
        <view
          class="u-flex-center u-border-one pt-pb25"
          style="justify-content: flex-end"
        >
          <view class="">共{{ goodNum }}件商品，小计</view>
          <view class="u-bold u-FF0000"
            ><rich-text :nodes="$mUtil.priceBigSmall(total_amount)"></rich-text
          ></view>
        </view>
        <view class="u-flex-column-start" style="padding-bottom: 20rpx">
          <view style="margin-top: 20rpx;">购买备注</view>
          <view class="boxTextarea">{{
            user_remark ? user_remark : "无"
          }}</view>
        </view>
      </view>
    </view>

    <view class="upb120">
      <view class="u-font28 u-1A1A1A u-mt30 bg-fff">
        <view class="u-flex-center-sb u-plr30 pt-pb25">
          <view>支付金额</view>
          <view class="u-FF0000 u-font32 u-bold"
            ><rich-text :nodes="$mUtil.priceBigSmall(total_amount)"></rich-text
          ></view>
        </view>
      </view>
      <view class="u-font28 u-1A1A1A u-mt30 bg-fff" v-if="service_card">
        <view class="u-plr30 pt-pb25">
          <view  class="u-flex-center-sb w100 pt-pb25">套餐内容</view></view
        >
        <view
          class="u-flex-center-sb u-plr30 pt-pb25"
          v-for="item in service_card.service_item_list"
          :key="item.id"
        >
          <view style="flex: 1;padding-right: 20rpx;">{{ item.item_name }}</view>
          <view class="u-999 u-font3"
            >¥ {{ item.item_price }} x {{ item.num }}</view
          >
        </view>
      </view>
      <view class="u-font28 u-1A1A1A u-mt30 bg-fff" v-if="service_card">
        <view class="u-flex-center-sb u-plr30 pt-pb25">
          <view >福利</view>
          <view class="u-999 u-font3" style="flex: 1;margin-left: 20rpx;">{{ service_card.welfare_items }}</view>
        </view>
        <view class="u-flex-center-sb u-plr30 pt-pb25">
          <view>服务次数</view>
          <view class="u-999 u-font3">{{ service_card.service_count }}次</view>
        </view>
        <view class="u-flex-center-sb u-plr30 pt-pb25">
          <view>已使用</view>
          <view class="u-999 u-font3">{{ service_card.use_count }} 次</view>
        </view>
        <view
          class="u-flex-center-sb u-plr30 pt-pb25"
          v-if="service_order_contacts"
        >
          <view>联系人</view>
          <view class="u-999 u-font3"
            >{{ service_order_contacts.contacts }}</view
          >
        </view>
        <view
          class="u-flex-center-sb u-plr30 pt-pb25"
          v-if="service_order_contacts"
        >
          <view>联系电话</view>
          <view class="u-999 u-font3">{{ service_order_contacts.mobile }}</view>
        </view>
      </view>
      <view
        class="u-font28 u-1A1A1A u-mt30 bg-fff"
        @click="goWriteOff"
      >
        <view class="u-flex-center-sb u-plr30 pt-pb25">
          <view>核销记录</view>
          <view class="u-999">查看</view>
        </view>
      </view>
      <view class="u-font28 u-1A1A1A u-mt30 bg-fff">
        <view class="u-plr30">
		  <div class="u-border-one u-flex-center-sb pt-pb25">
          <view>订单编号</view>
          <view class="u-999 u-font3">{{ order_code }} </view>
		  </div>
        </view>
        <view class="u-plr30 ">
			<div class="u-flex-center-sb u-border-one pt-pb25">
			  <view>下单时间</view>
			  <view class="u-999">{{ format_order_time }}</view>
		  </div>
        </view>
        <view
          class="u-flex-center-sb u-plr30 pt-pb25"
          v-if="payment_status >= 1 || payment_status < 0"
        >
			<div class="u-flex-center-sb w100 u-border-one pt-pb25">
				 <view>支付时间</view>
				 <view class="u-999">{{ format_pay_time }}</view>
			</div>
        </view>
        <view
          class="u-flex-center-sb u-plr30 pt-pb25"
          v-if="payment_status >= 1 || payment_status < 0"
        >
		<div class="u-flex-center-sb w100 u-border-one pt-pb25">
			 <view>支付方式</view>
			 <view class="u-999" v-if="pay_mode == 0">余额 </view>
			 <view class="u-999" v-if="pay_mode == 1">微信 </view>
			 <view class="u-999" v-if="pay_mode == 2">支付宝 </view>
		</div>
        </view>
        <view
          class="u-flex-center-sb u-plr30 pt-pb25"
          v-if="payment_status >= 2 && address"
        >
          <view>配送方式</view>
          <view class="u-999">{{ freighMoney }}</view>
        </view>

        <!-- <view class="u-flex-center-sb  u-plr30 pt-pb25" v-if="payment_status>=2">
				<view>发货时间</view>
				<view class="u-999">{{format_last_ship_time}}</view>
			</view> -->

        <!-- <view class="u-flex-center-sb  u-plr30 pt-pb25" v-if="payment_status>=4">
				<view>收货时间</view>
				<view class="u-999">{{format_last_receipt_time}}</view>
			</view> -->
        <!-- <view
          class="u-flex-center-sb u-plr30 pt-pb25"
          v-if="payment_status >= 4"
        >
          <view>获得积分</view>
          <view class="u-999">可获得{{ final_give_back_point }}积分</view>
        </view> -->
      </view>
    </view>
    <!--待付款-->
    <view
      class="bg-fff u-mt30 btn u-flex"
      v-if="payment_status == 0 && close_mode == 0 && !end"
    >
      <button class="cancel-btn u-br-999 u-999" @click="cancelOrder">
        取消订单
      </button>
      <button
        class="pay-btn bg-00321e u-FFF"
        @click="goPay(orderid, total_amount, expired_pay_time)"
      >
        去付款
      </button>
    </view>

    <!--待使用  已使用-->
    <view
      class="bg-fff u-mt30 u-plr30 ptb22 btn u-flex-column-end"
      v-if="payment_status == 3"
    >
      <view class="u-flex-center u-mr25">
        <button class="u-order-btn u-br-999 u-999" @click="goRefundType(1)">
          申请售后
        </button>
        <button class="u-order-btn u-br-999 u-999" @click="goPhone(mobile)">
          联系客服
        </button>
      </view>
    </view>

    <!--弹窗评价-->
    <uniPopup type="bottom" ref="uniPopup">
      <view class="popup">
        <view class="u-flex-sb u-plr30">
          <view class="u-flex">
            <image class="pic" :src="choseGoods.goods_img"></image>
            <view class="u-ml30 wt378">
              <view class="u-1A1A1A u-font28">{{
                choseGoods.goods_title
              }}</view>
              <view class="u-999 u-font22 u-mt10" v-if="choseGoods.sku_set_name"
                >规格：{{ choseGoods.sku_set_name }}</view
              >
              <view class="u-mt10 u-flex-center">
                <view class="u-FF0000 u-font32"
                  ><rich-text
                    :nodes="$mUtil.priceBigSmall(choseGoods.sale_price)"
                  ></rich-text
                ></view>
                <text class="u-ml10 u-999 u-font24"
                  >x {{ choseGoods.number }}</text
                >
              </view>
            </view>
          </view>
          <view class="iconfont u-999 closeIcon" @click="close">&#xe612;</view>
        </view>
        <view class="u-bg-fff u-plr30 u-mt5">
          <view class="pt-pb25 u-font28 u-flex-center">
            <text>总体评价：</text>
            <view>
              <text
                v-for="(item, index) in 5"
                :key="index"
                @click="startNum(index)"
                class="iconfont u-font34"
                :class="gradeNum >= item ? 'grade-active' : 'u-B3B3B3'"
                >&#xe624;</text
              >
            </view>
          </view>
          <view class="u-font26">
            <textarea
              class="u-font26"
              @input="textareaInput"
              :value="textareaVal"
              placeholder="请输入文字评价"
              placeholder-class="cccfont"
            ></textarea>
          </view>
          <view class="u-mt25 u-font30">添加图片</view>
          <view class="u-mt25">
            <uploadImg
              imgCount="6"
              :type="upimgtype"
              :imgArr="imgArray"
              url=""
              @result="resultUrl"
              @delImg="delImg"
            ></uploadImg>
          </view>
          <view class="evaluate-submit" @click="submitCom">
            <button class="u-btn-two">确认提交</button>
          </view>
        </view>
      </view>
    </uniPopup>
    <!--页面加载动画-->
    <ldLoading isFullScreen :active="loading"></ldLoading>
  </view>
</template>

<script>
import ldgoods from "../../../components/ld-goods/ld-goods.vue";
import ldAddress from "../../../components/ld-address/ld-address.vue";
import ldAddresszt from "../../../components/ld-address/ld-addresszt.vue";
import uniPopup from "../../../components/uni-popup/uni-popup.vue";
import uploadImg from "../../../components/uploadImg/imgUpload.vue";
import ldshop from "../../../components/ld-shop/ld-shop.vue";
export default {
  components: {
    ldAddress,
    ldAddresszt,
    uniPopup,
    uploadImg,
    ldgoods,
    ldshop,
  },
  data() {
    return {
      upimgtype: "comment",
      final_give_back_point: 0,
      payment_status: null, //0:待付款,1:待发货
      expired_pay_time: null, //订单剩余支付时间
      total_amount: null, //总金额
      orderid: null,
      goods_amount: null, //商品价格
      first_order_reduced: 0, //首单优惠多少
      real_freight: null, //配送费
      discount_amount: null, //商品会员折扣
      pay_mode: null, //（0余额，1微信，2支付宝）
      order_code: null, //订单编号
      format_order_time: null, //下单时间
      format_pay_time: null, //支付时间
      format_last_ship_time: null, //发货时间
      format_last_receipt_time: null, //收货时间
      receipt_expire_time: "", //自提包裹时间
      freighMoney: null, //物流公司
      goodNum: null, //数量
      shipment_mode: 0,
      pickCode: "", //核销码
      original_goods_amount: null, //原价
      total_reduced: null, //vip优惠
      vipcode: "",
      shopStatus: false,
      loading: true,
      config: {
     	back: true, //false是tolbar页面 是则不写
					title: '订单详情',
					color: '#1A1A1A',
					//背景颜色;参数一：透明度（0-1）;参数二：背景颜色（array则为线性渐变，string为单色背景）
					backgroundColor: [1, "#FFFFFF"],
					statusBarFontColor: '#1A1A1A'
      },
      isSubmit: false,
      index: 0,
      mobile: "",
      end: false,
      logImg: "", //物流图片
      address: null,
      addresszt: null,
      last_ship_time: 0, //发货时间
      last_receipt_time: 0, //收货时间
      orderList: [],
      orderListPay: [],
      source_shop_name: "",
      user_remark: "", //备注
      payStatus: "",
      goodsid: null, //评价商品的id
      choseGoods: {},
      textareaVal: "",
      upimg: [],
      imgArray: [],
      gradeNum: 0,
      close_mode: 0, //0未关闭,1用户撤销关闭,2商家撤销关闭,3支付过期关闭,4退货成功,5退款成功,6支付成功,但条件已经不允许购买,发生自动退款关闭,7自提过期
      marketing_type: null, //折扣类型
      service_card: null, //服务卡
      service_expire_time: null,
      service_order_contacts: null,
	  imgUrl: this.$mConfig.staticUrl
    };
  },
  onLoad(options) {
    if (options.id) {
      this.orderid = options.id;
      this.payStatus = options.status;
      if (options.status == "pay") {
        this.orderDetail(options.id);
      }
      if (options.status == "waitpay") {
        this.orderDetailPay(options.id);
      }
    }
    //
  },

  methods: {
    goWriteOff() {
      uni.navigateTo({
        url: "./log?id=" + this.orderid + "&childId=" + this.orderList[0].id,
      });
    },

    //复制
    copy(code) {
      uni.setClipboardData({
        data: code,
        success: () => {
          uni.showToast({
            title: "复制成功",
          });
        },
      });
    },
    goPhone(phone) {
      if (phone) {
        uni.makePhoneCall({
          phoneNumber: phone, //仅为示例
        });
      }
    },
    restCom() {
      this.textareaVal = "";
      this.gradeNum = 0;
    },
    //提交评价
    submitCom() {
      if (this.gradeNum == 0) {
        this.$mUtil.toast("请评价星星");
      } else if (this.textareaVal == "") {
        this.$mUtil.toast("请输入文字评价");
      } else {
        let imgs = "";
        if (this.upimg.length > 0) {
          imgs = this.upimg.join(",");
        } else {
          imgs = "";
        }
        let data = {
          chlid_order_id: this.goodsid,
          order_id: this.orderid,
          level: this.gradeNum,
          content: this.textareaVal,
          img: imgs,
        };
        this.$http
          .post("/comment/orderGoods/saveservicegoods", data)
          .then((res) => {
            if (res && res.code == 200) {
              this.$mUtil.toast("评价成功");
              this.$refs.uniPopup.close();
              setTimeout(() => {
                uni.reLaunch({
                  url: "/pages/order/orderList/serviceOrder",
                });
              }, 1000);
            }
          });
      }
    },
    textareaInput(e) {
      this.textareaVal = e.detail.value;
    },
    resultUrl(e) {
      if (e) {
        this.upimg = e;
      }
    },
    delImg(e) {
      if (e) {
        this.upimg = e;
      }
    },
    startNum(index) {
      this.gradeNum = index * 1 + 1;
    },
    //评价
    parentevaluation(data) {
      this.choseGoods = this.orderList[data.keys];
      this.goodsid = data.id;
      this.$refs.uniPopup.open();
    },
    //确认收货
    sureGetOrder() {
      uni.showModal({
        title: "提示",
        content: "确定已经收到了该商品？",
        success: (res) => {
          if (res.confirm) {
            this.$http
              .post("/order/receipt", { order_id: this.orderid })
              .then((res) => {
                if (res && res.code == 200) {
                  this.$mUtil.toast("收货成功");
                  setTimeout(() => {
                    uni.reLaunch({
                      url: "/pages/order/orderList/orderList",
                    });
                  }, 1000);
                }
              });
          } else if (res.cancel) {
          }
        },
      });
    },
    //选完地址回选
    otherFun(object) {
      if (!!object) {
        console.log(object.addressid);
        this.$http
          .put("/order/update-receipt/" + this.orderid + "/" + object.addressid)
          .then((res) => {
            if (res && res.code == 200) {
              this.$mUtil.toast("修改成功");
              this.orderDetail(this.orderid);
            }
          });
      }
    },

    //取消订单
    cancelOrder() {
      uni.showModal({
        title: "提示",
        content: "确定取消该订单吗？",
        success: (res) => {
          if (res.confirm) {
            this.$http.post("/order/cancel-pay/" + this.orderid).then((res) => {
              if (res && res.code == 200) {
                this.$mUtil.toast("取消成功");
                setTimeout(() => {
                  uni.reLaunch({
                    url: "/pages/order/orderList/orderList",
                  });
                }, 1000);
              }
            });
          } else if (res.cancel) {
          }
        },
      });
    },
    orderDetail(id) {
      this.$http.get("/order/info/" + id).then((res) => {
        this.loading = false;
        if (res && res.code == 200) {
          let target = res.data;
          this.mobile = target.shop.customer_service_phone;
          this.final_give_back_point = target.final_give_back_point;
          this.address = target.receipt;
          this.addresszt = target.shop;
          this.orderList = target.child_order_list;
          this.source_shop_name = target.source_shop_name;
          this.user_remark = target.user_remark;
          this.total_amount = target.total_amount;
          this.vipcode = target.user_role_name; //vipcode
          this.goods_amount = target.goods_amount; //商品价格
          this.original_goods_amount = target.original_goods_amount; //商品原价价格
          this.total_reduced = target.total_reduced; //vip优惠
          this.first_order_reduced = target.first_order_reduced; //首单优惠多少
          this.real_freight = target.real_freight; //配送费
          this.discount_amount = target.discount_amount; //商品会员折扣
          this.pay_mode = target.pay_mode; //（0余额，1微信，2支付宝）
          this.order_code = target.order_code; //订单编号
          this.format_order_time = target.format_order_time; //下单时间
          this.format_pay_time = target.format_pay_time; //支付时间

          this.format_last_ship_time = target.format_last_ship_time; //发货时间
          this.format_last_receipt_time = target.format_last_receipt_time; //收货时间
          this.last_ship_time = target.last_ship_time; //发货时间
          this.last_receipt_time = target.last_receipt_time; //收货时间
          this.goodNum = target.goods_number; //数量
          this.logImg = target.child_order_list[0].goods_img;
          this.last_comment_time = target.child_order_list[0].last_comment_time; //评价时间
          this.shipment_mode = target.shipment_mode;
          this.end = target.end;
          this.marketing_type = target.marketing_type;
          if (target.child_order_list[0].service_card.verification_code) {
            this.service_expire_time =
              target.child_order_list[0].service_card.expired_use_time;
			  
			  
            this.pickCode =
              target.child_order_list[0].service_card.verification_code;
            this.service_card = target.child_order_list[0].service_card;
            this.service_order_contacts = target.service_order_contacts;
          }
          if (target.order_package) {
            this.receipt_expire_time = target.order_package.receipt_expire_time;
            if (target.order_package.express) {
              this.freighMoney = target.order_package.express.express_name; //物流公司
            }
          }
          if (target.rights_type == 0 && target.rights_status == 0) {
            if (target.use_status == 0 || target.use_status) {
              //待使用  部分使用
              this.payment_status = 3;
            }

            if (target.transaction_status == 5 && target.comment_status == 0) {
              //交易完成未评价
              this.payment_status = 4;
              this.service_card = target.child_order_list[0].service_card;
            }

            if (target.transaction_status == 5 && target.end) {
              //交易完成已评价
              this.payment_status = 5;
              this.service_card = target.child_order_list[0].service_card;
            }
          }

          if (target.transaction_status == 6) {
            //关闭
            this.payment_status = 6;
          }
          //rights_type:0没有，1仅退款,2退款退货,rights_status:（0没有，1维权中，2完成）
          if (target.rights_type == 1 && target.rights_status == 1) {
            //退款维权中
            this.payment_status = -1;
          }
          if (target.rights_type == 1 && target.rights_status == 2) {
            //退款完成
            this.payment_status = -2;
          }
          if (target.rights_type == 2 && target.rights_status == 1) {
            //退款退货维权中
            this.payment_status = -3;
          }
          if (target.rights_type == 2 && target.rights_status == 2) {
            //退款退货完成
            this.payment_status = -4;
          }
        }
      });
    },
    orderDetailPay(id) {
      this.$http.get("/pay/order/sale-detail/" + id).then((res) => {
        this.loading = false;
        if (res && res.code == 200) {
          let target = res.page.order_list[0];
          this.address = res.page.receipt;
          this.addresszt = res.page.self_take_shop;
          this.orderListPay = res.page.order_list;
          if (res.page.pay_order.payment_status != 5) {
            this.payment_status = 0;
          } else {
            this.payment_status = res.page.pay_order.payment_status;
          }

          this.expired_pay_time = res.page.pay_order.expired_pay_time;
          this.total_amount = res.page.pay_order.total_amount;
          this.close_mode = res.page.pay_order.close_mode;
          this.user_remark = target.user_remark;

          // this.goods_amount=target.goods_amount//商品价格
          // this.first_order_reduced=target.first_order_reduced//首单优惠多少
          // this.real_freight=target.real_freight//配送费
          this.pay_mode = target.pay_mode; //（0余额，1微信，2支付宝）
          this.order_code = target.order_code; //订单编号
          this.format_order_time = target.format_order_time; //下单时间
          this.format_pay_time = target.format_pay_time; //支付时间
          this.format_last_ship_time = target.format_last_ship_time; //发货时间
          this.format_last_receipt_time = target.format_last_receipt_time; //收货时间
        }
      });
    },
    close() {
      this.$refs.uniPopup.close();
      this.restCom();
    },
    //支付页

    goPay(id, total_amount, expired_pay_time) {
      uni.navigateTo({
        url:
          "../../order/pay?id=" +
          id +
          "&total_amount=" +
          total_amount +
          "&expired_pay_time=" +
          expired_pay_time +
          "&type=service",
      });
    },
    //申请售后
    goRefundType(i) {
      //i:1未发货，退款，2收到货退款/退货
      uni.setStorageSync("blackgoodsList", this.orderList);
      if (i == 1) {
        uni.navigateTo({
          url:
            "applicationDrawback?keystatus=" +
            i +
            "&title=申请退款" +
            "&orderid=" +
            this.orderid+"&type=service",
        });
      } else {
        uni.navigateTo({
          url:
            "refundType?order_code=" +
            this.order_code +
            "&format_order_time=" +
            this.format_order_time +
            "&keystatus=" +
            i +
            "&orderid=" +
            this.orderid,
        });
      }
    },
    //查看物流
    goLogistics() {
      uni.navigateTo({
        url:
          "../logistics?id=" +
          this.orderid +
          "&num=" +
          this.goodNum +
          "&img=" +
          this.logImg +
          "&type=1",
      });
    },
    //填写物流信息
    logisticsOpen() {
      this.$refs.logisticsOpen.open();
    },
    //选择快递
    deliveryPicker(e) {
      this.index = e.target.value;
    },
    //提交表单物流信息
    logisticsSubmit(e) {
      let target = e.detail.value;
      console.log(target);
      if (!target.deliveryOdd) {
        this.$mUtil.toast("请输入快递单号");
        return false;
      }
    },
  },
};
</script>

<style lang="scss">
page {
  background-color: #f5f5f5;
}
.cccfont {
  font-size: 26rpx;
  color: #eee;
}
.grade-active {
  color: #ff5112;
}
.u-B3B3B3 {
  color: #b3b3b3;
}
.user_remark {
  background-color: #fff;
  padding: 30rpx;
  border-top: 1px solid #eee;
}
.boxTextarea {
  width: 686rpx;
  border: 1px solid #ededed;
  border-radius: 20rpx;
  background-color: #fafafa;
  padding: 20rpx;
  box-sizing: border-box;
  margin-top: 20rpx;
}
.pabox {
  background-color: #fff;
  padding: 0 30rpx 0;
  // margin-top: 30rpx;
}
.upb120 {
  padding-bottom: 140rpx;
}
.bg-fff {
  background-color: #ffffff;
}
.ptb22 {
  padding-top: 22rpx;
  padding-bottom: 22rpx;
}
.pt-pb25 {
  // padding-top: 25rpx;
  // padding-bottom: 25rpx;
  height: 90rpx;
}
.pt28-pb24 {
  padding-top: 28rpx;
  padding-bottom: 24rpx;
}
.iconfont58 {
  font-size: 58rpx;
}
.mt44 {
  margin-top: 44rpx;
}
.ml38 {
  margin-left: 38rpx;
}
.ml82 {
  margin-left: 82rpx;
}
.wt378 {
  width: 378rpx;
}
.wt504 {
  width: 504rpx;
}
.u-br-999 {
  border: 1px solid #999999;
}
.u-br-f00 {
  border: 1px solid #ff0000;
}
.bg-00321e {
  background: #0B844A;
}
.account-paid {
  padding: 44rpx 0rpx;
}
.account-paid image {
  width: 202rpx;
  height: 124rpx;
}
.btn {
  width: 100%;
  position: fixed;
  bottom: 0rpx;
  padding: 22rpx 0rpx;
}
.cancel-btn {
  margin-left: auto;
}
.cancel-btn,
.pay-btn {
  width: 202rpx;
  height: 70rpx;
  line-height: 70rpx;
  border-radius: 35px;
  font-size: 28rpx;
  margin-right: 30rpx;
}
.top-state {
	background-color: #d9f9dd;
	color: #139145;
	padding: 35rpx 30rpx;
	// 待支付
	.obligation {
		display: flex;
		justify-content: space-between;
		.timeImg {
			display: none;
			width: 70rpx;
			height: 54rpx;
			margin-right: 40rpx;
		}
	}
}
.address {
  background-color: #ffffff;
  padding-top: 72rpx;
  .linkman {
    padding-bottom: 34rpx;
  }
  .remark {
    padding: 35rpx 0rpx 35rpx 50rpx;
  }
}

//弹窗填写物流信息
.logisticsPopup {
  background-color: #ffffff;
  width: 100%;
  border-radius: 20rpx;
  .pd {
    padding: 15rpx 98rpx 68rpx;
  }
  input {
    height: 70rpx;
    line-height: 70rpx;
    border: 1rpx solid #cccccc;
    border-radius: 15rpx;
    padding-left: 8rpx;
    color: #999999;
  }
  .icon {
    margin-top: -65rpx;
  }
  .pl-pr {
    padding-left: 74rpx;
  }
  button {
    margin-top: 66rpx;
    background-color: #01331f;
    width: 345rpx;
  }
}

// 弹窗评价
.popup {
  background-color: #f5f5f5;
  width: 100%;
  border-radius: 18rpx 18rpx 0px 0px;
}
.u-flex-sb {
  display: flex;
  justify-content: space-between;
  padding-top: 30rpx;
  padding-bottom: 30rpx;
  background-color: #ffffff;
  border-radius: 18rpx 18rpx 0px 0px;
  .pic {
    width: 155rpx;
    height: 155rpx;
	border-radius: 15rpx;
  }
}
textarea {
  width: 100%;
  height: 210rpx;
  opacity: 0.66;
  border: 1rpx solid #e6e6e6;
  border-radius: 8rpx;
  padding-left: 22rpx;
  padding-top: 14rpx;
  box-sizing: border-box;
}
.evaluate-submit {
  margin-top: 58rpx;
  padding-bottom: 25rpx;
}
.evaluate-submit button {
  background-color: #0B844A;
  color: #ffffff;
}
.w100 {
	width: 100%;
}
</style>
