多租户商城-商户小程序端
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.

381 lines
6.4 KiB

2 years ago
2 years ago
  1. <template>
  2. <view @touchmove.stop.prevent>
  3. <view class="tui-modal-box" :style="{width:width,padding:padding,borderRadius:radius}" :class="[(fadein || show)?'tui-modal-normal':'tui-modal-scale',show?'tui-modal-show':'']">
  4. <view v-if="!custom">
  5. <view class="tui-modal-title" v-if="title">{{title}}</view>
  6. <view class="tui-modal-content" :class="[title?'':'tui-mtop']" :style="{color:color,fontSize:size+'rpx'}">{{content}}</view>
  7. <view class="tui-modalBtn-box" :class="[button.length!=2?'tui-flex-column':'']">
  8. <block v-for="(item,index) in button" :key="index">
  9. <button class="tui-modal-btn" :class="['tui-'+(item.type || 'primary')+(item.plain?'-outline':''),button.length!=2?'tui-btn-width':'',button.length>2?'tui-mbtm':'',shape=='circle'?'tui-circle-btn':'']"
  10. :hover-class="'tui-'+(item.plain?'outline':(item.type || 'primary'))+'-hover'" :data-index="index" @tap="handleClick">{{item.text || "确定"}}</button>
  11. </block>
  12. </view>
  13. </view>
  14. <view v-else>
  15. <view class="flex-end-plus" @tap="handleClickCancel">
  16. <!-- <image class="img" src="http://36.138.125.206:8081/ceres-local-file/static/close@3x.png" mode=""></image> -->
  17. </view>
  18. <slot></slot>
  19. </view>
  20. </view>
  21. <view class="tui-modal-mask" :class="[show?'tui-mask-show':'']" @tap="handleClickCancel"></view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. name: "tuiModal",
  27. props: {
  28. //是否显示
  29. show: {
  30. type: Boolean,
  31. default: false
  32. },
  33. width: {
  34. type: String,
  35. default: "80%"
  36. },
  37. padding: {
  38. type: String,
  39. default: "40rpx 40rpx"
  40. },
  41. radius: {
  42. type: String,
  43. default: "10rpx"
  44. },
  45. //标题
  46. title: {
  47. type: String,
  48. default: ""
  49. },
  50. //内容
  51. content: {
  52. type: String,
  53. default: ""
  54. },
  55. //内容字体颜色
  56. color: {
  57. type: String,
  58. default: "#000"
  59. },
  60. //内容字体大小 rpx
  61. size: {
  62. type: Number,
  63. default: 28
  64. },
  65. //形状 circle, square
  66. shape: {
  67. type: String,
  68. default: 'square'
  69. },
  70. button: {
  71. type: Array,
  72. default: function() {
  73. return [{
  74. text: "取消",
  75. type: "red",
  76. plain: true //是否空心
  77. }, {
  78. text: "确定",
  79. type: "red",
  80. plain: false
  81. }]
  82. }
  83. },
  84. //点击遮罩 是否可关闭
  85. maskClosable: {
  86. type: Boolean,
  87. default: true
  88. },
  89. //自定义弹窗内容
  90. custom: {
  91. type: Boolean,
  92. default: false
  93. },
  94. //淡入效果,自定义弹框插入input输入框时传true
  95. fadein: {
  96. type: Boolean,
  97. default: false
  98. }
  99. },
  100. data() {
  101. return {
  102. };
  103. },
  104. methods: {
  105. handleClick(e) {
  106. if (!this.show) return;
  107. const dataset = e.currentTarget.dataset;
  108. this.$emit('click', {
  109. index: Number(dataset.index)
  110. });
  111. },
  112. handleClickCancel() {
  113. if (!this.maskClosable) return;
  114. this.$emit('cancel');
  115. }
  116. }
  117. }
  118. </script>
  119. <style>
  120. .tui-modal-box {
  121. position: fixed;
  122. left: 50%;
  123. top: 50%;
  124. margin: auto;
  125. background-color: #FFFFFF;
  126. z-index: 10000;
  127. transition: all 0.3s ease-in-out;
  128. opacity: 0;
  129. box-sizing: border-box;
  130. visibility: hidden;
  131. }
  132. .tui-modal-scale {
  133. transform: translate(-50%, -50%) scale(0);
  134. }
  135. .tui-modal-normal {
  136. transform: translate(-50%, -50%) scale(1);
  137. }
  138. .tui-modal-show {
  139. opacity: 1;
  140. visibility: visible;
  141. }
  142. .tui-modal-mask {
  143. position: fixed;
  144. top: 0;
  145. left: 0;
  146. right: 0;
  147. bottom: 0;
  148. background: rgb(0,0,0,0.5);
  149. z-index: 9999;
  150. transition: all 0.3s ease-in-out;
  151. opacity: 0;
  152. visibility: hidden;
  153. }
  154. .tui-mask-show {
  155. visibility: visible;
  156. opacity: 1;
  157. }
  158. .tui-modal-title {
  159. text-align: center;
  160. font-size: 34rpx;
  161. color: #333;
  162. padding-top: 20rpx;
  163. font-weight: bold;
  164. }
  165. .tui-modal-content {
  166. text-align: center;
  167. color: #999;
  168. font-size: 28rpx;
  169. padding-top: 20rpx;
  170. padding-bottom: 60rpx;
  171. }
  172. .tui-mtop {
  173. margin-top: 30rpx;
  174. }
  175. .tui-mbtm {
  176. margin-bottom: 30rpx;
  177. }
  178. .tui-modalBtn-box {
  179. width: 100%;
  180. display: flex;
  181. align-items: center;
  182. justify-content: space-between
  183. }
  184. .tui-flex-column {
  185. flex-direction: column;
  186. }
  187. .tui-modal-btn {
  188. width: 46%;
  189. height: 68rpx;
  190. line-height: 68rpx;
  191. position: relative;
  192. border-radius: 10rpx;
  193. font-size: 24rpx;
  194. overflow: visible;
  195. margin-left: 0;
  196. margin-right: 0;
  197. }
  198. .tui-modal-btn::after {
  199. content: "";
  200. position: absolute;
  201. width: 200%;
  202. height: 200%;
  203. -webkit-transform-origin: 0 0;
  204. transform-origin: 0 0;
  205. -webkit-transform: scale(0.5, 0.5);
  206. transform: scale(0.5, 0.5);
  207. left: 0;
  208. top: 0;
  209. border-radius: 20rpx;
  210. }
  211. .tui-btn-width {
  212. width: 80% !important;
  213. }
  214. .tui-primary {
  215. background: #5677fc;
  216. color: #fff;
  217. }
  218. .tui-primary-hover {
  219. background: #4a67d6;
  220. color: #e5e5e5;
  221. }
  222. .tui-primary-outline {
  223. color: #5677fc;
  224. background: none;
  225. }
  226. .tui-primary-outline::after {
  227. border: 1px solid #5677fc;
  228. }
  229. .tui-danger {
  230. background: #ed3f14;
  231. color: #fff;
  232. }
  233. .tui-danger-hover {
  234. background: #d53912;
  235. color: #e5e5e5;
  236. }
  237. .tui-danger-outline {
  238. color: #ed3f14;
  239. background: none;
  240. }
  241. .tui-danger-outline::after {
  242. border: 1px solid #ed3f14;
  243. }
  244. .tui-red {
  245. background: #e41f19;
  246. color: #fff;
  247. }
  248. .tui-red-hover {
  249. background: #c51a15;
  250. color: #e5e5e5;
  251. }
  252. .tui-red-outline {
  253. color: #e41f19;
  254. background: none;
  255. }
  256. .tui-red-outline::after {
  257. border: 1px solid #e41f19;
  258. }
  259. .tui-warning {
  260. background: #ff7900;
  261. color: #fff;
  262. }
  263. .tui-warning-hover {
  264. background: #e56d00;
  265. color: #e5e5e5;
  266. }
  267. .tui-warning-outline {
  268. color: #ff7900;
  269. background: none;
  270. }
  271. .tui-warning-outline::after {
  272. border: 1px solid #ff7900;
  273. }
  274. .tui-green {
  275. background: #19be6b;
  276. color: #fff;
  277. }
  278. .tui-green-hover {
  279. background: #16ab60;
  280. color: #e5e5e5;
  281. }
  282. .tui-green-outline {
  283. color: #19be6b;
  284. background: none;
  285. }
  286. .tui-green-outline::after {
  287. border: 1px solid #19be6b;
  288. }
  289. .tui-white {
  290. background: #fff;
  291. color: #333;
  292. }
  293. .tui-white-hover {
  294. background: #f7f7f9;
  295. color: #666;
  296. }
  297. .tui-white-outline {
  298. color: #333;
  299. background: none;
  300. }
  301. .tui-white-outline::after {
  302. border: 1px solid #333;
  303. }
  304. .tui-gray {
  305. background: #ededed;
  306. color: #999;
  307. }
  308. .tui-gray-hover {
  309. background: #d5d5d5;
  310. color: #898989;
  311. }
  312. .tui-gray-outline {
  313. color: #999;
  314. background: none;
  315. }
  316. .tui-gray-outline::after {
  317. border: 1px solid #999;
  318. }
  319. .tui-outline-hover {
  320. opacity: 0.6;
  321. }
  322. .tui-circle-btn {
  323. border-radius: 40rpx !important;
  324. }
  325. .tui-circle-btn::after {
  326. border-radius: 80rpx !important;
  327. }
  328. .img{
  329. width: 30upx;
  330. height: 30upx;
  331. }
  332. </style>