储能智慧云小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <wxs src="../common/utils.wxs" module="_" />
  2. <wxs src="./upload.wxs" module="this" />
  3. <wxs src="./drag.wxs" module="handler" />
  4. <view style="{{_._style([style, customStyle])}}" class="{{classPrefix}} class {{prefix}}-class">
  5. <t-grid
  6. gutter="{{gutter}}"
  7. border="{{false}}"
  8. align="center"
  9. column="{{column}}"
  10. style="{{draggable? 'overflow: visible' : ''}}"
  11. >
  12. <block wx:if="{{!dragLayout}}">
  13. <!-- 图片/视频 -->
  14. <t-grid-item
  15. wx:for="{{customFiles}}"
  16. wx:key="url"
  17. wx:for-item="file"
  18. t-class="{{classPrefix}}__grid {{classPrefix}}__grid-file"
  19. t-class-content="{{classPrefix}}__grid-content"
  20. aria-role="presentation"
  21. >
  22. <view
  23. class="{{classPrefix}}__wrapper {{disabled? classPrefix + '__wrapper--disabled' : '' }}"
  24. style="{{gridItemStyle}}"
  25. aria-role="{{ariaRole || this.getWrapperAriaRole(file)}}"
  26. aria-label="{{ariaLabel || this.getWrapperAriaLabel(file)}}"
  27. >
  28. <t-image
  29. wx:if="{{file.type !== 'video'}}"
  30. data-file="{{file}}"
  31. bind:tap="onProofTap"
  32. data-index="{{index}}"
  33. t-class="{{classPrefix}}__thumbnail"
  34. style="{{imageProps && imageProps.style || ''}}"
  35. src="{{ file.thumb || file.url }}"
  36. mode="{{imageProps && imageProps.mode || 'aspectFill'}}"
  37. error="{{imageProps && imageProps.error || 'default'}}"
  38. lazy="{{imageProps && imageProps.lazy || false}}"
  39. loading="{{imageProps && imageProps.loading || 'default'}}"
  40. shape="{{imageProps && imageProps.shape || 'round'}}"
  41. webp="{{imageProps && imageProps.webp || false}}"
  42. showMenuByLongpress="{{imageProps && imageProps.showMenuByLongpress || false}}"
  43. />
  44. <video
  45. data-file="{{file}}"
  46. bind:tap="onFileClick"
  47. wx:if="{{file.type === 'video'}}"
  48. class="{{classPrefix}}__thumbnail"
  49. src="{{file.url}}"
  50. poster="{{ file.thumb }}"
  51. controls
  52. autoplay="{{false}}"
  53. objectFit="contain"
  54. />
  55. <!-- 失败重试 -->
  56. <view
  57. data-index="{{index}}"
  58. wx:if="{{file.status && file.status != 'done'}}"
  59. class="{{classPrefix}}__progress-mask"
  60. data-file="{{file}}"
  61. bind:tap="onFileClick"
  62. >
  63. <block wx:if="{{file.status == 'loading'}}">
  64. <t-icon t-class="{{classPrefix}}__progress-loading" name="loading" size="24" aria-hidden />
  65. <view class="{{classPrefix}}__progress-text">{{file.percent ? file.percent + '%' : '上传中...'}}</view>
  66. </block>
  67. <t-icon wx:else name="{{file.status == 'reload' ? 'refresh' : 'close-circle'}}" size="24" aria-hidden />
  68. <view wx:if="{{file.status == 'reload' || file.status == 'failed'}}" class="{{classPrefix}}__progress-text">
  69. {{file.status == 'reload' ? '重新上传' : '上传失败'}}
  70. </view>
  71. </view>
  72. <!-- 删除 -->
  73. <view
  74. class="{{classPrefix}}__close-btn hotspot-expanded"
  75. bindtap="onDelete"
  76. data-index="{{index}}"
  77. aria-role="button"
  78. aria-label="删除"
  79. >
  80. <t-icon name="close" size="16" color="#fff" />
  81. </view>
  82. </view>
  83. </t-grid-item>
  84. <!-- 添加 -->
  85. <t-grid-item
  86. wx:if="{{customLimit > 0}}"
  87. t-class="{{classPrefix}}__grid"
  88. t-class-content="{{classPrefix}}__grid-content"
  89. bindclick="onAddTap"
  90. aria-label="上传"
  91. >
  92. <view class="{{classPrefix}}__wrapper" style="{{gridItemStyle}}">
  93. <slot name="add-content" />
  94. <block wx:if="{{addContent}}">{{addContent}}</block>
  95. <view wx:else class="{{classPrefix}}__add-icon {{disabled? classPrefix + '__add-icon--disabled' : '' }}">
  96. <t-icon name="add" />
  97. </view>
  98. </view>
  99. </t-grid-item>
  100. </block>
  101. <block wx:else>
  102. <view
  103. class="{{classPrefix}}__drag"
  104. list="{{dragList}}"
  105. style="{{dragWrapStyle}};"
  106. dragBaseData="{{dragBaseData}}"
  107. change:list="{{handler.listObserver}}"
  108. change:dragBaseData="{{handler.baseDataObserver}}"
  109. >
  110. <view
  111. class="{{classPrefix}}__drag-item"
  112. wx:for="{{customFiles}}"
  113. wx:key="url"
  114. wx:for-item="file"
  115. style="width: {{100 / column}}%; --td-upload-drag-transition-duration: {{transition.duration}}ms; --td-upload-drag-transition-timing-function: {{transition.timingFunction}}"
  116. bind:longpress="{{handler.longPress}}"
  117. catch:touchmove="{{dragging ? handler.touchMove : ''}}"
  118. catch:touchend="{{dragging ? handler.touchEnd : ''}}"
  119. data-index="{{index}}"
  120. >
  121. <!-- 图片/视频 -->
  122. <t-grid-item
  123. t-class="{{classPrefix}}__grid {{classPrefix}}__grid-file"
  124. t-class-content="{{classPrefix}}__grid-content"
  125. aria-role="presentation"
  126. style="width: 100%"
  127. >
  128. <view
  129. class="{{classPrefix}}__wrapper {{disabled? classPrefix + '__wrapper--disabled' : '' }}"
  130. style="{{gridItemStyle}};"
  131. aria-role="{{ariaRole || this.getWrapperAriaRole(file)}}"
  132. aria-label="{{ariaLabel || this.getWrapperAriaLabel(file)}}"
  133. >
  134. <t-image
  135. wx:if="{{file.type !== 'video'}}"
  136. data-file="{{file}}"
  137. bind:tap="onProofTap"
  138. data-index="{{index}}"
  139. t-class="{{classPrefix}}__thumbnail"
  140. style="{{imageProps && imageProps.style || ''}}"
  141. src="{{ file.thumb || file.url }}"
  142. mode="{{imageProps && imageProps.mode || 'aspectFill'}}"
  143. error="{{imageProps && imageProps.error || 'default'}}"
  144. lazy="{{imageProps && imageProps.lazy || false}}"
  145. loading="{{imageProps && imageProps.loading || 'default'}}"
  146. shape="{{imageProps && imageProps.shape || 'round'}}"
  147. webp="{{imageProps && imageProps.webp || false}}"
  148. showMenuByLongpress="{{imageProps && imageProps.showMenuByLongpress || false}}"
  149. />
  150. <video
  151. data-file="{{file}}"
  152. bind:tap="onFileClick"
  153. wx:if="{{file.type === 'video'}}"
  154. class="{{classPrefix}}__thumbnail"
  155. src="{{file.url}}"
  156. poster="{{ file.thumb }}"
  157. controls
  158. autoplay="{{false}}"
  159. objectFit="contain"
  160. />
  161. <!-- 失败重试 -->
  162. <view
  163. data-index="{{index}}"
  164. wx:if="{{file.status && file.status != 'done'}}"
  165. class="{{classPrefix}}__progress-mask"
  166. data-file="{{file}}"
  167. bind:tap="onFileClick"
  168. >
  169. <block wx:if="{{file.status == 'loading'}}">
  170. <t-icon t-class="{{classPrefix}}__progress-loading" name="loading" size="24" aria-hidden />
  171. <view class="{{classPrefix}}__progress-text"
  172. >{{file.percent ? file.percent + '%' : '上传中...'}}</view
  173. >
  174. </block>
  175. <t-icon wx:else name="{{file.status == 'reload' ? 'refresh' : 'close-circle'}}" size="24" aria-hidden />
  176. <view
  177. wx:if="{{file.status == 'reload' || file.status == 'failed'}}"
  178. class="{{classPrefix}}__progress-text"
  179. >
  180. {{file.status == 'reload' ? '重新上传' : '上传失败'}}
  181. </view>
  182. </view>
  183. <!-- 删除 -->
  184. <view
  185. class="{{classPrefix}}__close-btn hotspot-expanded"
  186. bindtap="onDelete"
  187. data-index="{{index}}"
  188. data-url="{{file.url}}"
  189. aria-role="button"
  190. aria-label="删除"
  191. >
  192. <t-icon name="close" size="16" color="#fff" />
  193. </view>
  194. </view>
  195. </t-grid-item>
  196. <!-- 添加 -->
  197. </view>
  198. <view class="{{classPrefix}}__drag-item" style="width: {{100 / column}}%" wx:if="{{customLimit > 0}}">
  199. <t-grid-item
  200. t-class="{{classPrefix}}__grid"
  201. t-class-content="{{classPrefix}}__grid-content"
  202. bindclick="onAddTap"
  203. aria-label="上传"
  204. style="width: 100%"
  205. >
  206. <view class="{{classPrefix}}__wrapper" style="{{gridItemStyle}}">
  207. <slot name="add-content" />
  208. <block wx:if="{{addContent}}">{{addContent}}</block>
  209. <view wx:else class="{{classPrefix}}__add-icon {{disabled? classPrefix + '__add-icon--disabled' : '' }}">
  210. <t-icon name="add" />
  211. </view>
  212. </view>
  213. </t-grid-item>
  214. </view>
  215. </view>
  216. </block>
  217. </t-grid>
  218. </view>