c-confirm-sign.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view class="mask" :class="maskState===0 ? 'none' : maskState===1 ? 'show' : ''" >
  3. <view class="mask-content" @click.stop.prevent="stopPrevent">
  4. <view class="title" v-if="defautlOptions.title" v-html="defautlOptions.title"></view>
  5. <div class="divider"></div>
  6. <view class="desc" v-if="defautlOptions.content" v-html="defautlOptions.content"></view>
  7. <view class="info-name">打卡方式</view>
  8. <view class="info" v-if="defautlOptions.info" v-html="defautlOptions.info"></view>
  9. <view class="action-content">
  10. <u-button type="primary"
  11. style="margin-bottom: 30rpx;"
  12. class="c-button"
  13. @click="confirm">
  14. <image style="width: 32rpx;height: 32rpx;" src="@/static/app/daka.png" mode="aspectFill"></image>
  15. <text style="font-size: 32rpx;font-weight: 500;margin-left: 20rpx;">
  16. {{defautlOptions.confirmText}}
  17. </text>
  18. </u-button>
  19. <view class="cancel-btn" @click="cancel">{{defautlOptions.cancelText}}</view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. name:"c-confrim-sign",
  27. data() {
  28. return {
  29. maskState: 0,
  30. defautlOptions: {
  31. title: '',
  32. content: '',
  33. info: '',
  34. confirmText: '打卡',
  35. confirmClass: 'text-red',
  36. cancelText: '我再想想',
  37. cancelClass: 'text-black'
  38. }
  39. };
  40. },
  41. methods: {
  42. stopPrevent(){
  43. },
  44. toggleMask(type){
  45. let timer = type === 'show' ? 10 : 0;
  46. let state = type === 'show' ? 1 : 0;
  47. this.maskState = 2;
  48. setTimeout(()=>{
  49. this.maskState = state;
  50. }, timer)
  51. },
  52. /**
  53. * @description 确认
  54. * @param {Object} title: String desc: String
  55. */
  56. $confirm(options = {}){
  57. // 继承原来的
  58. this.defautlOptions = Object.assign(this.defautlOptions, options);
  59. return new Promise((resolve,reject)=> {
  60. this.toggleMask('show')
  61. this._confirm = () => {
  62. resolve(1)
  63. this._confirm = null;
  64. }
  65. this._cancel = () => {
  66. resolve(0)
  67. this._cancel = null;
  68. }
  69. })
  70. },
  71. confirm() {
  72. if(this._confirm){
  73. this._confirm()
  74. this.toggleMask();
  75. }
  76. },
  77. cancel() {
  78. if(this._cancel){
  79. this._cancel()
  80. this.toggleMask();
  81. }
  82. }
  83. },
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. .mask{
  88. display: flex;
  89. align-items: center;
  90. justify-content: center;
  91. position: fixed;
  92. left: 0;
  93. top: var(--window-top);
  94. bottom: 0;
  95. width: 100vw;
  96. background: rgba(0,0,0,0);
  97. z-index: 10001;
  98. transition: .6s;
  99. .mask-content{
  100. padding-top: 0rpx;
  101. display: flex;
  102. flex-direction: column;
  103. width: 630rpx;
  104. background: #fff;
  105. border-radius: 3px;
  106. transition: transform .1s opacity 0.1s;
  107. transform: scale(1.2);
  108. transition-timing-function: ease-out;
  109. opacity: 0.3;
  110. }
  111. &.none{
  112. display: none;
  113. }
  114. &.show{
  115. background: rgba(0,0,0,0);
  116. .mask-content{
  117. transition: transform .3s;
  118. opacity: 1;
  119. transform: scale(1);
  120. }
  121. }
  122. .title{
  123. display: flex;
  124. justify-content: center;
  125. align-items: center;
  126. height: 90rpx;
  127. font-size: 30rpx;
  128. font-family: PingFang SC;
  129. font-weight: bold;
  130. color: #FD8701;
  131. text-align: justify;
  132. }
  133. .divider{
  134. height: 14rpx;
  135. background: #F3F3F3;
  136. }
  137. .desc {
  138. padding: 31rpx 29rpx 20rpx;
  139. font-size: 26rpx;
  140. font-family: PingFang SC;
  141. font-weight: 400;
  142. color: #333333;
  143. line-height: 36rpx;
  144. text-indent: 2em;
  145. text-align: justify;
  146. }
  147. .info-name{
  148. font-size: 26rpx;
  149. font-family: PingFang SC;
  150. font-weight: bold;
  151. color: #333333;
  152. padding-left: 30rpx;
  153. }
  154. .info{
  155. font-size: 26rpx;
  156. font-family: PingFang SC;
  157. font-weight: 400;
  158. color: #333333;
  159. line-height: 36rpx;
  160. padding: 10rpx 30rpx;
  161. text-align: justify;
  162. text-indent: 2em;
  163. }
  164. .action-content{
  165. padding: 81rpx 50rpx 30rpx;
  166. .cancel-btn{
  167. display: flex;
  168. align-items: center;
  169. justify-content: center;
  170. font-size: 26rpx;
  171. font-family: PingFang SC;
  172. font-weight: 400;
  173. text-decoration: underline;
  174. color: #999999;
  175. line-height: 40rpx;
  176. }
  177. }
  178. }
  179. .icon-wrap{
  180. position: absolute;
  181. top: -60rpx;
  182. right: -5rpx;
  183. }
  184. </style>