riku
2024-08-13 1a0e4972f80278bfa9e53283374b745b6c968341
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<wxs src="../common/utils.wxs" module="_" />
<wxs src="./upload.wxs" module="this" />
 
<view style="{{_._style([style, customStyle])}}" class="{{classPrefix}} class {{prefix}}-class">
  <t-grid gutter="{{gutter}}" border="{{false}}" align="center" column="{{column}}">
    <!-- 图片/视频 -->
    <t-grid-item
      wx:for="{{customFiles}}"
      wx:key="index"
      wx:for-item="file"
      t-class="{{classPrefix}}__grid {{classPrefix}}__grid-file"
      t-class-content="{{classPrefix}}__grid-content"
      aria-role="presentation"
    >
      <view
        class="{{classPrefix}}__wrapper"
        style="{{gridItemStyle}}"
        aria-role="{{ariaRole || this.getWrapperAriaRole(file)}}"
        aria-label="{{ariaLabel || this.getWrapperAriaLabel(file)}}"
      >
        <t-image
          wx:if="{{file.type !== 'video'}}"
          data-file="{{file}}"
          bind:tap="onProofTap"
          data-index="{{index}}"
          t-class="{{classPrefix}}__thumbnail"
          style="{{imageProps.style || ''}}"
          src="{{file.url}}"
          mode="{{imageProps.mode || 'aspectFill'}}"
          error="{{imageProps.error || 'default'}}"
          lazy="{{imageProps.lazy || false}}"
          loading="{{imageProps.loading || 'default'}}"
          shape="{{imageProps.shape || 'round'}}"
          webp="{{imageProps.webp || false}}"
          showMenuByLongpress="{{imageProps.showMenuByLongpress || false}}"
        />
        <video
          data-file="{{file}}"
          bind:tap="onFileClick"
          wx:if="{{file.type === 'video'}}"
          class="{{classPrefix}}__thumbnail"
          src="{{file.url}}"
          controls
          autoplay="{{false}}"
          objectFit="contain"
        />
        <!-- 失败重试 -->
        <view
          data-index="{{index}}"
          wx:if="{{file.status && file.status != 'done'}}"
          class="{{classPrefix}}__progress-mask"
          data-file="{{file}}"
          bind:tap="onFileClick"
        >
          <block wx:if="{{file.status == 'loading'}}">
            <t-icon t-class="{{classPrefix}}__progress-loading" name="loading" size="24" aria-hidden />
            <view class="{{classPrefix}}__progress-text">{{file.percent ? file.percent + '%' : '上传中...'}}</view>
          </block>
          <t-icon wx:else name="{{file.status == 'reload' ? 'refresh' : 'close-circle'}}" size="24" aria-hidden />
          <view wx:if="{{file.status == 'reload' || file.status == 'failed'}}" class="{{classPrefix}}__progress-text">
            {{file.status == 'reload' ? '重新上传' : '上传失败'}}
          </view>
        </view>
      </view>
 
      <!-- 删除 -->
      <view
        class="{{classPrefix}}__close-btn hotspot-expanded"
        bindtap="onDelete"
        data-index="{{index}}"
        aria-role="button"
        aria-label="删除"
      >
        <t-icon name="close" size="16" color="#fff" />
      </view>
    </t-grid-item>
 
    <!-- 添加 -->
    <t-grid-item
      wx:if="{{customLimit > 0}}"
      t-class="{{classPrefix}}__grid"
      t-class-content="{{classPrefix}}__grid-content"
      bindclick="onAddTap"
      aria-label="上传"
    >
      <view class="{{classPrefix}}__wrapper" style="{{gridItemStyle}}">
        <slot name="add-content" />
        <block wx:if="{{addContent}}">{{addContent}}</block>
        <view wx:else class="{{classPrefix}}__add-icon">
          <t-icon name="add" />
        </view>
      </view>
    </t-grid-item>
  </t-grid>
</view>