showModel.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <view class="showModel" v-show="disjunctor">
  3. <view class="showModel__wrap">
  4. <view class="showModel__header" v-if="title">
  5. {{ title }}
  6. <text v-if="operate.know == '知道了' && timerFlag">({{ time }})</text>
  7. </view>
  8. <view class="showModel__article" :class="{ p0: textareaFlag }">
  9. <text
  10. v-if="icon"
  11. class="showModel__icon icon_transport"
  12. :class="[
  13. 'showModel__icon--' + icon,
  14. { 'transport-duigou': icon === 'success' },
  15. { 'transport-shibai': icon === 'error' },
  16. { 'transport-wenhao': icon === 'warn' },
  17. ]"
  18. ></text>
  19. <view v-if="content" class="showModel__content" @click="tel()" v-html="content"></view>
  20. <view v-if="info" class="showModel__info">{{ info }}</view>
  21. <view class="specialCloseFlag" v-if="textareaFlag">
  22. <textarea
  23. style="width: 100%"
  24. placeholder="请输入10~100个文字方可提交!"
  25. maxlength="100"
  26. @input="textareaInput"
  27. />
  28. </view>
  29. <view class="radio-wrap" v-if="radioItem.length">
  30. <radio-group @change="radioChange">
  31. <view v-for="(item, index) in radioItem" :key="item.qrcode" class="radio-item">
  32. <label>
  33. <radio :value="item.qrcode" :checked="index === 0" />
  34. <text>{{ item.deptName }}</text>
  35. </label>
  36. </view>
  37. </radio-group>
  38. </view>
  39. </view>
  40. <view class="showModel__footer">
  41. <view
  42. v-if="operate.ok"
  43. class="showModel__ok"
  44. @click="ok"
  45. hover-class="seimin-btn-hover"
  46. >{{ operate.ok || "" }}</view
  47. >
  48. <view
  49. v-if="operate.cancel"
  50. class="showModel__cancel"
  51. @click="cancel"
  52. hover-class="seimin-btn-hover"
  53. >{{ operate.cancel || "" }}</view
  54. >
  55. <view
  56. v-if="operate.know"
  57. class="showModel__know"
  58. @click="know"
  59. hover-class="seimin-btn-hover"
  60. >{{ operate.know || "" }}</view
  61. >
  62. <view
  63. v-if="operate.know && timerFlag"
  64. class="showModel__know"
  65. @click="cancelTimer"
  66. hover-class="seimin-btn-hover"
  67. >取消自动关闭</view
  68. >
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. export default {
  75. data() {
  76. return {
  77. time: 5, //5秒后自动关闭
  78. timer: null, //5秒后自动关闭,定时器
  79. timerFlag: true, //是否显示取消自动关闭按钮
  80. };
  81. },
  82. watch: {
  83. disjunctor(newValue) {
  84. if (newValue && this.operate.know == "知道了") {
  85. this.time = 5;
  86. this.timer = setInterval(() => {
  87. this.time--;
  88. if (this.time <= 0) {
  89. clearInterval(this.timer);
  90. this.know();
  91. }
  92. }, 1000);
  93. }
  94. },
  95. },
  96. props: {
  97. // 显示隐藏
  98. disjunctor: {
  99. type: Boolean,
  100. default: false,
  101. },
  102. // 标题
  103. title: {
  104. type: String,
  105. default: "提示",
  106. },
  107. // 图标
  108. icon: {
  109. type: String,
  110. default: "success",
  111. },
  112. // 内容
  113. content: {
  114. type: String,
  115. default: "",
  116. },
  117. // 说明
  118. info: {
  119. type: String,
  120. default: "",
  121. },
  122. // 拨打电话
  123. phone: {
  124. type: String,
  125. default: "",
  126. },
  127. // 特殊情况关闭原因
  128. textareaFlag: {
  129. type: Boolean,
  130. default: false,
  131. },
  132. // 单选框选项
  133. radioItem: {
  134. type: Array,
  135. default: () => {
  136. return [];
  137. },
  138. },
  139. // 操作按钮文字
  140. operate: {
  141. type: Object,
  142. default: () => {
  143. return {
  144. know: "知道了",
  145. };
  146. },
  147. },
  148. },
  149. methods: {
  150. // 单选框选中
  151. radioChange(item){
  152. this.$emit('radioChange',item.target.value)
  153. },
  154. // 输入文字
  155. textareaInput(e) {
  156. this.$emit("textareaInput", e.detail.value);
  157. },
  158. // 确定
  159. ok() {
  160. this.$emit("ok");
  161. },
  162. // 取消
  163. cancel() {
  164. this.$emit("cancel");
  165. },
  166. // 知道了
  167. know() {
  168. clearInterval(this.timer);
  169. this.$emit("know");
  170. },
  171. // 取消自动关闭
  172. cancelTimer() {
  173. this.timerFlag = false;
  174. clearInterval(this.timer);
  175. },
  176. // 拨打电话
  177. tel() {
  178. if (this.phone) {
  179. uni.makePhoneCall({
  180. phoneNumber: this.phone,
  181. });
  182. }
  183. },
  184. },
  185. };
  186. </script>
  187. <style lang="less">
  188. .showModel {
  189. position: fixed;
  190. left: 0;
  191. right: 0;
  192. top: 0;
  193. bottom: 0;
  194. background-color: rgba(0, 0, 0, 0.2);
  195. z-index: 999999;
  196. .showModel__wrap {
  197. width: 560rpx;
  198. position: absolute;
  199. left: 50%;
  200. top: 50%;
  201. transform: translate(-50%, -50%);
  202. background-color: #fff;
  203. border-radius: 12rpx;
  204. .showModel__header {
  205. font-size: 36rpx;
  206. color: 000;
  207. height: 84rpx;
  208. display: flex;
  209. justify-content: center;
  210. align-items: center;
  211. }
  212. .showModel__article {
  213. margin: 40rpx auto 25rpx;
  214. width: 488rpx;
  215. padding: 60rpx 0;
  216. background-color: rgb(249, 250, 251);
  217. border: 2rpx solid rgb(229, 233, 237);
  218. border-radius: 12rpx;
  219. box-sizing: border-box;
  220. display: flex;
  221. flex-direction: column;
  222. justify-content: center;
  223. align-items: center;
  224. &.p0 {
  225. padding: 0;
  226. }
  227. .showModel__icon {
  228. font-size: 138rpx;
  229. margin-bottom: 32rpx;
  230. &.showModel__icon--success {
  231. color: rgb(52, 179, 73);
  232. }
  233. &.showModel__icon--warn {
  234. color: rgb(245, 165, 35);
  235. }
  236. &.showModel__icon--error {
  237. color: rgb(255, 58, 82);
  238. }
  239. }
  240. .showModel__content {
  241. font-size: 36rpx;
  242. }
  243. .showModel__info {
  244. font-size: 32rpx;
  245. color: rgb(102, 102, 102);
  246. }
  247. .specialCloseFlag {
  248. width: 90%;
  249. height: 100%;
  250. padding: 16rpx;
  251. }
  252. .radio-wrap{
  253. .radio-item{
  254. margin-top: 16rpx;
  255. /deep/ .uni-radio-input-checked{
  256. background-color: #49b856!important;
  257. border-color: #49b856!important;
  258. }
  259. }
  260. }
  261. }
  262. .showModel__footer {
  263. box-sizing: border-box;
  264. height: 100rpx;
  265. border-top: 2rpx solid rgb(229, 233, 237);
  266. display: flex;
  267. align-items: center;
  268. view {
  269. height: 100%;
  270. display: flex;
  271. align-items: center;
  272. justify-content: center;
  273. font-size: 36rpx;
  274. color: rgb(102, 102, 102);
  275. position: relative;
  276. &:nth-of-type(2)::before {
  277. content: "";
  278. position: absolute;
  279. left: 0;
  280. bottom: 0;
  281. width: 2rpx;
  282. height: 87rpx;
  283. background-color: rgb(229, 233, 237);
  284. }
  285. }
  286. .showModel__ok {
  287. flex: 1;
  288. color: rgb(73, 184, 86);
  289. }
  290. .showModel__cancel {
  291. flex: 1;
  292. }
  293. .showModel__know {
  294. flex: 1;
  295. color: rgb(73, 184, 86);
  296. }
  297. }
  298. }
  299. }
  300. </style>