c-share-model.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="mask" :class="maskState===0 ? 'none' : maskState===1 ? 'show' : ''" >
  3. <view class="content">
  4. <view class="arrow-wrap">
  5. <image style="width: 150rpx;height: 141rpx;" src="/static/app/share/share-arrow.png" mode="aspectFit"></image>
  6. </view>
  7. <view class="arrow-content">
  8. <view class="text">点击更多,可以转发</view>
  9. <view class="text">给朋友和分享到朋友圈哦!</view>
  10. </view>
  11. <view class="button-wrap">
  12. <u-button type="primary"
  13. style="margin-bottom: 30rpx;width: 280rpx;"
  14. shape="circle"
  15. class="c-button"
  16. :text="defautlOptions.confirmText"
  17. @click="confirm">
  18. </u-button>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. name:"c-share-model",
  26. data() {
  27. return {
  28. maskState: 0,
  29. defautlOptions: {
  30. title: '',
  31. content: '',
  32. confirmText: '知道了',
  33. confirmClass: 'text-red',
  34. cancelText: '我在想想',
  35. cancelClass: 'text-black'
  36. }
  37. };
  38. },
  39. methods: {
  40. stopPrevent(){
  41. },
  42. toggleMask(type){
  43. let timer = type === 'show' ? 10 : 0;
  44. let state = type === 'show' ? 1 : 0;
  45. this.maskState = 2;
  46. setTimeout(()=>{
  47. this.maskState = state;
  48. }, timer)
  49. },
  50. /**
  51. * @description 确认
  52. * @param {Object} title: String desc: String
  53. */
  54. $confirm(options = {}){
  55. // 继承原来的
  56. this.defautlOptions = Object.assign(this.defautlOptions, options);
  57. return new Promise((resolve,reject)=> {
  58. this.toggleMask('show')
  59. this._confirm = () => {
  60. resolve(1)
  61. this._confirm = null;
  62. }
  63. this._cancel = () => {
  64. resolve(0)
  65. this._cancel = null;
  66. }
  67. })
  68. },
  69. confirm() {
  70. if(this._confirm){
  71. this._confirm()
  72. this.toggleMask();
  73. }else{
  74. this.toggleMask();
  75. }
  76. },
  77. cancel() {
  78. if(this._cancel){
  79. this._cancel()
  80. this.toggleMask();
  81. }else{
  82. this.toggleMask();
  83. }
  84. }
  85. },
  86. }
  87. </script>
  88. <style lang="scss" scoped>
  89. .mask{
  90. display: flex;
  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. &.none{
  100. display: none;
  101. }
  102. &.show{
  103. background: rgba(0,0,0,.6);
  104. .mask-content{
  105. transition: transform .3s;
  106. opacity: 1;
  107. transform: scale(1);
  108. }
  109. }
  110. }
  111. .content{
  112. width: 100%;
  113. align-self: stretch;
  114. .arrow-wrap{
  115. padding-top: 42rpx;
  116. padding-right: 36rpx;
  117. width: 100%;
  118. display: flex;
  119. justify-content: flex-end;
  120. box-sizing: border-box;
  121. }
  122. .arrow-content{
  123. padding-left: 40vw;
  124. .text{
  125. text-align: left;
  126. font-size: 28rpx;
  127. font-family: NSimSun;
  128. font-weight: 400;
  129. color: #FFFFFF;
  130. line-height: 1.2;
  131. }
  132. }
  133. .button-wrap{
  134. padding-top: 60rpx;
  135. }
  136. }
  137. </style>