modal.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-gradual-pink" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content">模态窗口</block>
  6. </cu-custom>
  7. <view class="cu-bar bg-white margin-top">
  8. <view class="action">
  9. <text class="cuIcon-title text-orange "></text> 普通窗口
  10. </view>
  11. <view class="action">
  12. <button class="cu-btn bg-green shadow" @tap="showModal" data-target="Modal">Modal</button>
  13. </view>
  14. </view>
  15. <view class="cu-modal" :class="modalName=='Modal'?'show':''">
  16. <view class="cu-dialog">
  17. <view class="cu-bar bg-white justify-end">
  18. <view class="content">Modal标题</view>
  19. <view class="action" @tap="hideModal">
  20. <text class="cuIcon-close text-red"></text>
  21. </view>
  22. </view>
  23. <view class="padding-xl">
  24. Modal 内容。
  25. </view>
  26. </view>
  27. </view>
  28. <view class="cu-bar bg-white margin-top">
  29. <view class="action">
  30. <text class="cuIcon-title text-orange "></text> 底部窗口
  31. </view>
  32. <view class="action">
  33. <button class="cu-btn bg-green shadow" @tap="showModal" data-target="bottomModal">Bottom</button>
  34. </view>
  35. </view>
  36. <view class="cu-modal bottom-modal" :class="modalName=='bottomModal'?'show':''">
  37. <view class="cu-dialog">
  38. <view class="cu-bar bg-white">
  39. <view class="action text-green">确定</view>
  40. <view class="action text-blue" @tap="hideModal">取消</view>
  41. </view>
  42. <view class="padding-xl">
  43. Modal 内容。
  44. </view>
  45. </view>
  46. </view>
  47. <view class="cu-bar bg-white margin-top">
  48. <view class="action">
  49. <text class="cuIcon-title text-orange "></text> 对话窗口
  50. </view>
  51. <view class="action">
  52. <button class="cu-btn bg-green shadow" @tap="showModal" data-target="DialogModal1">Dialog</button>
  53. <button class="cu-btn bg-blue shadow margin-left" @tap="showModal" data-target="DialogModal2">Dialog</button>
  54. </view>
  55. </view>
  56. <view class="cu-modal" :class="modalName=='DialogModal1'?'show':''">
  57. <view class="cu-dialog">
  58. <view class="cu-bar bg-white justify-end">
  59. <view class="content">Modal标题</view>
  60. <view class="action" @tap="hideModal">
  61. <text class="cuIcon-close text-red"></text>
  62. </view>
  63. </view>
  64. <view class="padding-xl">
  65. Modal 内容。
  66. </view>
  67. <view class="cu-bar bg-white justify-end">
  68. <view class="action">
  69. <button class="cu-btn line-green text-green" @tap="hideModal">取消</button>
  70. <button class="cu-btn bg-green margin-left" @tap="hideModal">确定</button>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="cu-modal" :class="modalName=='DialogModal2'?'show':''">
  76. <view class="cu-dialog">
  77. <view class="cu-bar bg-white justify-end">
  78. <view class="content">Modal标题</view>
  79. <view class="action" @tap="hideModal">
  80. <text class="cuIcon-close text-red"></text>
  81. </view>
  82. </view>
  83. <view class="padding-xl">
  84. Modal 内容。
  85. </view>
  86. <view class="cu-bar bg-white">
  87. <view class="action margin-0 flex-sub text-green " @tap="hideModal">
  88. <text class="cuIcon-moneybag"></text>微信支付</view>
  89. <view class="action margin-0 flex-sub text-green solid-left" @tap="hideModal">取消</view>
  90. <view class="action margin-0 flex-sub solid-left" @tap="hideModal">确定</view>
  91. </view>
  92. </view>
  93. </view>
  94. <view class="cu-bar bg-white margin-top">
  95. <view class="action">
  96. <text class="cuIcon-title text-orange "></text> 图片窗口
  97. </view>
  98. <view class="action">
  99. <button class="cu-btn bg-green shadow" @tap="showModal" data-target="Image">Image</button>
  100. </view>
  101. </view>
  102. <view class="cu-modal" :class="modalName=='Image'?'show':''">
  103. <view class="cu-dialog">
  104. <view class="bg-img" style="background-image: url('https://ossweb-img.qq.com/images/lol/web201310/skin/big91012.jpg');height:200px;">
  105. <view class="cu-bar justify-end text-white">
  106. <view class="action" @tap="hideModal">
  107. <text class="cuIcon-close "></text>
  108. </view>
  109. </view>
  110. </view>
  111. <view class="cu-bar bg-white">
  112. <view class="action margin-0 flex-sub solid-left" @tap="hideModal">我知道了</view>
  113. </view>
  114. </view>
  115. </view>
  116. <view class="cu-bar bg-white margin-top">
  117. <view class="action">
  118. <text class="cuIcon-title text-orange "></text> 单选窗口
  119. </view>
  120. <view class="action">
  121. <button class="cu-btn bg-green shadow" @tap="showModal" data-target="RadioModal">Radio</button>
  122. </view>
  123. </view>
  124. <view class="cu-modal" :class="modalName=='RadioModal'?'show':''" @tap="hideModal">
  125. <view class="cu-dialog" @tap.stop="">
  126. <radio-group class="block" @change="RadioChange">
  127. <view class="cu-list menu text-left">
  128. <view class="cu-item" v-for="(item,index) in 5" :key="index">
  129. <label class="flex justify-between align-center flex-sub">
  130. <view class="flex-sub">Item {{index +1}}</view>
  131. <radio class="round" :class="radio=='radio' + index?'checked':''" :checked="radio=='radio' + index?true:false"
  132. :value="'radio' + index"></radio>
  133. </label>
  134. </view>
  135. </view>
  136. </radio-group>
  137. </view>
  138. </view>
  139. <view class="cu-bar bg-white margin-top">
  140. <view class="action">
  141. <text class="cuIcon-title text-orange "></text> 多选窗口
  142. </view>
  143. <view class="action">
  144. <button class="cu-btn bg-green shadow" @tap="showModal" data-target="ChooseModal">Choose</button>
  145. </view>
  146. </view>
  147. <view class="cu-modal bottom-modal" :class="modalName=='ChooseModal'?'show':''" @tap="hideModal">
  148. <view class="cu-dialog" @tap.stop="">
  149. <view class="cu-bar bg-white">
  150. <view class="action text-blue" @tap="hideModal">取消</view>
  151. <view class="action text-green" @tap="hideModal">确定</view>
  152. </view>
  153. <view class="grid col-3 padding-sm">
  154. <view v-for="(item,index) in checkbox" class="padding-xs" :key="index">
  155. <button class="cu-btn orange lg block" :class="item.checked?'bg-orange':'line-orange'" @tap="ChooseCheckbox"
  156. :data-value="item.value"> {{item.name}}
  157. <view class="cu-tag sm round" :class="item.checked?'bg-white text-orange':'bg-orange'" v-if="item.hot">HOT</view>
  158. </button>
  159. </view>
  160. </view>
  161. </view>
  162. </view>
  163. <view class="cu-bar bg-white margin-top">
  164. <view class="action">
  165. <text class="cuIcon-title text-orange "></text> 侧边抽屉
  166. </view>
  167. <view class="action">
  168. <button class="cu-btn bg-green shadow" @tap="showModal" data-target="DrawerModalL">Left</button>
  169. <button class="cu-btn bg-blue shadow margin-left" @tap="showModal" data-target="DrawerModalR">Right</button>
  170. </view>
  171. </view>
  172. <view class="cu-modal drawer-modal justify-start" :class="modalName=='DrawerModalL'?'show':''" @tap="hideModal">
  173. <view class="cu-dialog basis-lg" @tap.stop="" :style="[{top:CustomBar+'px',height:'calc(100vh - ' + CustomBar + 'px)'}]">
  174. <view class="cu-list menu text-left">
  175. <view class="cu-item arrow" v-for="(item,index) in 5" :key="index">
  176. <view class="content">
  177. <view>Item {{index +1}}</view>
  178. </view>
  179. </view>
  180. </view>
  181. </view>
  182. </view>
  183. <view class="cu-modal drawer-modal justify-end" :class="modalName=='DrawerModalR'?'show':''" @tap="hideModal">
  184. <view class="cu-dialog basis-lg" @tap.stop="" :style="[{top:CustomBar+'px',height:'calc(100vh - ' + CustomBar + 'px)'}]">
  185. <view class="cu-list menu text-left">
  186. <view class="cu-item arrow" v-for="(item,index) in 5" :key="index">
  187. <view class="content">
  188. <view>Item {{index +1}}</view>
  189. </view>
  190. </view>
  191. </view>
  192. </view>
  193. </view>
  194. </view>
  195. </template>
  196. <script>
  197. export default {
  198. data() {
  199. return {
  200. CustomBar: this.CustomBar,
  201. modalName: null,
  202. radio: 'radio1',
  203. checkbox: [{
  204. value: 0,
  205. name: '10元',
  206. checked: false,
  207. hot: false,
  208. }, {
  209. value: 1,
  210. name: '20元',
  211. checked: true,
  212. hot: false,
  213. }, {
  214. value: 2,
  215. name: '30元',
  216. checked: true,
  217. hot: true,
  218. }, {
  219. value: 3,
  220. name: '60元',
  221. checked: false,
  222. hot: true,
  223. }, {
  224. value: 4,
  225. name: '80元',
  226. checked: false,
  227. hot: false,
  228. }, {
  229. value: 5,
  230. name: '100元',
  231. checked: false,
  232. hot: false,
  233. }]
  234. };
  235. },
  236. methods: {
  237. showModal(e) {
  238. this.modalName = e.currentTarget.dataset.target
  239. },
  240. hideModal(e) {
  241. this.modalName = null
  242. },
  243. RadioChange(e) {
  244. this.radio = e.detail.value
  245. },
  246. ChooseCheckbox(e) {
  247. let items = this.checkbox;
  248. let values = e.currentTarget.dataset.value;
  249. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  250. if (items[i].value == values) {
  251. items[i].checked = !items[i].checked;
  252. break
  253. }
  254. }
  255. }
  256. }
  257. }
  258. </script>
  259. <style>
  260. button .cu-tag {
  261. position: absolute;
  262. top: 8upx;
  263. right: 8upx;
  264. }
  265. </style>