rf-swipe-action-item.vue 7.2 KB

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