uni-swipe-action.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class="uni-swipe">
  3. <!-- #ifndef APP-PLUS || MP-WEIXIN || H5 -->
  4. <view class="uni-swipe_content">
  5. <view ref="selector-button-hock" class="uni-swipe_button-group selector-query-hock move-hock">
  6. <view v-for="(item,index) in options" :data-button="btn" :key="index" :style="{
  7. backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
  8. fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
  9. }" class="uni-swipe_button button-hock" @click.stop="onClick(index,item)">
  10. <!-- <text class="uni-swipe_button-text" :style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text> -->
  11. <block v-if="item.bShowDeleteIcon">
  12. <view style="width: 100rpx;">
  13. <view class="cuIcon-delete text-white text-center"></view>
  14. </view>
  15. </block>
  16. <block v-else>
  17. <text class="uni-swipe_button-text" :style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text>
  18. </block>
  19. </view>
  20. </view>
  21. <view ref='selector-content-hock' class="selector-query-hock" @touchstart="touchstart" @touchmove="touchmove" @touchend="touchend">
  22. <view class="uni-swipe_move-box" :class="{'ani':uniShow}" :style="{transform:moveLeft}">
  23. <view class="uni-swipe_box">
  24. <slot />
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- #endif -->
  30. <!-- #ifdef APP-VUE|| MP-WEIXIN||H5 -->
  31. <view class="uni-swipe_content">
  32. <view :data-disabled="disabled" :data-position="pos" :change:prop="swipe.sizeReady" :prop="pos" class="uni-swipe_move-box selector-query-hock move-hock" @touchstart="swipe.touchstart" @touchmove="swipe.touchmove" @touchend="swipe.touchend" @change="change">
  33. <view class="uni-swipe_box">
  34. <slot />
  35. </view>
  36. <view ref="selector-button-hock" class="uni-swipe_button-group selector-query-hock move-hock">
  37. <view v-for="(item,index) in options" :data-button="btn" :key="index" :style="{
  38. backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
  39. fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
  40. }" class="uni-swipe_button button-hock" @click.stop="onClick(index,item)">
  41. <block v-if="item.bShowDeleteIcon">
  42. <view style="width: 100rpx;">
  43. <view class="cuIcon-delete text-white text-center"></view>
  44. </view>
  45. </block>
  46. <block v-else>
  47. <text class="uni-swipe_button-text" :style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text>
  48. </block>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- #endif -->
  54. <!-- #ifdef APP-NVUE -->
  55. <view ref="selector-box-hock" class="uni-swipe_content" @horizontalpan="touchstart" @touchend="touchend">
  56. <view ref="selector-button-hock" class="uni-swipe_button-group selector-query-hock move-hock" :style="{width:right+'px'}">
  57. <view ref="button-hock" v-for="(item,index) in options" :key="index" :style="{
  58. backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
  59. fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px',left: right+'px'
  60. }" class="uni-swipe_button " @click.stop="onClick(index,item)">
  61. <!-- <text class="uni-swipe_button-text" :style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text> -->
  62. <block v-if="item.bShowDeleteIcon">
  63. <view style="width: 100rpx;">
  64. <view class="cuIcon-delete text-white text-center"></view>
  65. </view>
  66. </block>
  67. <block v-else>
  68. <text class="uni-swipe_button-text" :style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text>
  69. </block>
  70. </view>
  71. </view>
  72. <view ref='selector-content-hock' class="uni-swipe_move-box selector-query-hock">
  73. <view class="uni-swipe_box">
  74. <slot />
  75. </view>
  76. </view>
  77. </view>
  78. <!-- #endif -->
  79. </view>
  80. </template>
  81. <script src="./index.wxs" module="swipe" lang="wxs"></script>
  82. <script>
  83. // #ifndef APP-PLUS|| MP-WEIXIN || H5
  84. import mixins from './mpother'
  85. // #endif
  86. // #ifdef APP-VUE|| MP-WEIXIN||H5
  87. import mp from './mp'
  88. // #endif
  89. // #ifdef APP-NVUE
  90. import bindingx from './bindingx.js'
  91. // #endif
  92. export default {
  93. // #ifdef APP-VUE|| MP-WEIXIN||H5
  94. mixins: [mp],
  95. // #endif
  96. // #ifdef APP-NVUE
  97. mixins: [bindingx],
  98. // #endif
  99. // #ifndef APP-PLUS|| MP-WEIXIN || H5
  100. mixins: [mixins],
  101. // #endif
  102. props: {
  103. /**
  104. * 按钮内容
  105. */
  106. options: {
  107. type: Array,
  108. default () {
  109. return []
  110. }
  111. },
  112. /**
  113. * 禁用
  114. */
  115. disabled: {
  116. type: Boolean,
  117. default: false
  118. },
  119. /**
  120. * 变量控制开关
  121. */
  122. show: {
  123. type: Boolean,
  124. default: false
  125. },
  126. /**
  127. * 是否自动关闭
  128. */
  129. autoClose: {
  130. type: Boolean,
  131. default: true
  132. }
  133. }
  134. }
  135. </script>
  136. <style scoped>
  137. .uni-swipe {
  138. overflow: hidden;
  139. }
  140. .uni-swipe_content {
  141. flex: 1;
  142. position: relative;
  143. }
  144. .uni-swipe_move-box {
  145. /* #ifndef APP-NVUE */
  146. display: flex;
  147. /* #endif */
  148. position: relative;
  149. flex-direction: row;
  150. }
  151. .uni-swipe_box {
  152. /* #ifndef APP-NVUE */
  153. width: 100%;
  154. flex-shrink: 0;
  155. /* #endif */
  156. /* #ifdef APP-NVUE */
  157. flex: 1;
  158. /* #endif */
  159. font-size: 14px;
  160. /* background-color: #fff; */
  161. }
  162. .uni-swipe_button-group {
  163. /* #ifndef APP-VUE|| MP-WEIXIN||H5 */
  164. position: absolute;
  165. top: 0;
  166. right: 0;
  167. bottom: 0;
  168. z-index: 0;
  169. /* #endif */
  170. /* #ifndef APP-NVUE */
  171. display: flex;
  172. flex-shrink: 0;
  173. /* #endif */
  174. flex-direction: row;
  175. }
  176. .uni-swipe_button {
  177. /* #ifdef APP-NVUE */
  178. position: absolute;
  179. left: 0;
  180. top: 0;
  181. bottom: 0;
  182. /* #endif */
  183. /* #ifndef APP-NVUE */
  184. display: flex;
  185. /* #endif */
  186. flex-direction: row;
  187. justify-content: center;
  188. align-items: center;
  189. padding: 0 20px;
  190. }
  191. .uni-swipe_button-text {
  192. /* #ifndef APP-NVUE */
  193. flex-shrink: 0;
  194. /* #endif */
  195. font-size: 14px;
  196. }
  197. .ani {
  198. transition-property: transform;
  199. transition-duration: 0.3s;
  200. transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
  201. }
  202. </style>