showModel.vue 7.7 KB

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