<!--pages/orders/order-detail.wxml-->
<view class="container">
  <navigation-bar title="{{ statusList[status].title }}"></navigation-bar>

  <scroll-view class="record-list" type="list" scroll-y bindscrolltolower="loadMore">
    <!-- <view class="order-status" wx:if="{{statusList[status]}}">
      <view class="status">
        <image src="{{ statusList[status].logo }}"></image>
        <text>{{ statusList[status].title }}</text>
      </view>
      <view class="tips" wx:if="{{ statusList[status].content }}">{{ statusList[status].content }}</view>
    </view> -->

    <view class="goods-content" wx:if="{{ goodsInfo.goods && goodsInfo.goods.length > 0 }}">
      <view class="item-content" wx:for="{{ goodsInfo.goods }}" wx:key="index">
        <image class='goods-icon' src="{{ item.goodsUrl }}" mode="" />
        <view class="goods-desc">
          <view class="goodsInfo">
            <view class="goods-name">{{ item.goodsName }}</view>
            <view class="goods-price">¥ <text>{{ item.originalPrice }}</text></view>
          </view>
          <view class="goods-type">
            <view class="goods-card">{{ item.typeName }}</view>
            <view class="goods-num">x{{ item.goodsNum }}</view>
          </view>
        </view>
      </view>
    </view>

    <view class="order-time">
      <view class="order-item">
        <view class="title">订单编号</view>
        <view class="value">
          {{ goodsInfo.orderNo }}
          <view class="copy" bind:tap="onCopy" data-orderno="{{goodsInfo.orderNo}}">复制</view>
        </view>
      </view>
      <view class="order-item">
        <view class="title">下单时间</view>
        <view class="value">{{ goodsInfo.createTime }}</view>
      </view>
    </view>
    <view class="order-content" wx:if="{{ (goodsInfo.wechatStatus == 'PAID' || goodsInfo.wechatStatus == 'WAIT_USE') && showCanvas }}">
      <view class="qrcode-title" >{{ goodsInfo.wechatStatus == 'WAIT_USE' ? '请扫码激活' : '激活码已使用' }}</view>
      <view class="qrcode-line"></view>
      <view class="qrcode-section">
        <view class="qrcode-text" wx:if="{{goodsInfo.wechatStatus == 'WAIT_USE'}}">请<text>扫描下方二维码</text>激活</view>
        <view class="qrcode-text used" wx:else>登录「音乐数字课堂」APP,开启AI学练之旅~</view>
        <view class="qrcode-block">
          <view class="left-text">{{goodsInfo.wechatStatus == 'WAIT_USE' ? '待使用' : '已使用'}}</view>
          <view class="qrcode-wrap">
            <image src="{{canvasImg}}" mode="scaleToFill" class='my_draw_canvas' style="opacity: {{ goodsInfo.wechatStatus == 'PAID' ? 0.5 : 1 }};" show-menu-by-longpress="true"></image>
            <view class="loader" wx:if="{{!canvasImg}}"></view>
          </view>
        </view>
      </view>
    </view>

    <view class="order-time" wx:if="{{ goodsInfo.wechatStatus == 'REFUNDED' || goodsInfo.wechatStatus == 'REFUNDING' }}">
      <view class="order-item">
        <view class="title">{{ goodsInfo.wechatStatus == 'REFUNDED' ? '退款时间' : '申请退款时间' }}</view>
        <view class="value">{{ goodsInfo.refundTime || '' }}</view>
      </view>
      <view class="order-item">
        <view class="title">退款金额</view>
        <view class="value">¥{{ goodsInfo.refundAmount }}</view>
      </view>
      <view class="order-item" wx:if="{{goodsInfo.wechatStatus != 'REFUNDING'}}">
        <view class="title">退款路径</view>
        <view class="value">{{ goodsInfo.refundStyleStr }}</view>
      </view>
    </view>
  </scroll-view>

  <canvas class='my_draw_canvas only_canvas' data-type="image" canvas-id='canvasCode' id="canvasCode"></canvas>

  <view class="order-btn" wx:if="{{ goodsInfo.wechatStatus != 'WAIT_PAY' }}">
    <button type="primary" bind:tap="useRefound" wx:if="{{ goodsInfo.wechatStatus == 'WAIT_USE' && tabIdx == 5 }}">申请退款</button>
    <block wx:else>
      <button type="primary" bind:tap="cancelRefound" wx:if="{{ goodsInfo.wechatStatus == 'REFUNDING' }}">取消退款</button>
      <button type="primary" wx:else bind:tap="onSubmit">再次购买</button>
    </block>
  </view>
  <!-- 客服 -->
  <service wx:if="{{serviceShow}}"></service>
  <!-- 退费 -->
  <apply-refound refoundStatus="{{ refoundStatus }}" goodsInfo="{{goodsInfo}}" bind:changeRefoundStatus="changeRefoundStatus" bind:onConfirm="onRefoundComfirm"></apply-refound>
</view>