showModel.vue 8.0 KB

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