modal.vue 8.7 KB

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