uni-popup-share.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view class="uni-popup-share">
  3. <view class="uni-share-title"><text class="uni-share-title-text">{{shareTitleText}}</text></view>
  4. <view class="uni-share-content">
  5. <view class="uni-share-content-box">
  6. <slot></slot>
  7. <!-- <view class="uni-share-content-item" v-for="(item,index) in bottomData" :key="index" @click.stop="select(item,index)">
  8. <image class="uni-share-image" :src="item.icon" mode="aspectFill"></image>
  9. <text class="uni-share-text">{{item.text}}</text>
  10. </view> -->
  11. </view>
  12. </view>
  13. <view class="uni-share-button-box">
  14. <button class="uni-share-button" @click="close">{{cancelText}}</button>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import popup from '../uni-popup/popup.js'
  20. import {
  21. initVueI18n
  22. } from '@dcloudio/uni-i18n'
  23. import messages from '../uni-popup/i18n/index.js'
  24. const { t } = initVueI18n(messages)
  25. export default {
  26. name: 'UniPopupShare',
  27. mixins:[popup],
  28. emits:['select'],
  29. props: {
  30. title: {
  31. type: String,
  32. default: ''
  33. },
  34. beforeClose: {
  35. type: Boolean,
  36. default: false
  37. }
  38. },
  39. data() {
  40. return {
  41. bottomData: []
  42. }
  43. },
  44. created() {},
  45. computed: {
  46. cancelText() {
  47. return t("uni-popup.cancel")
  48. },
  49. shareTitleText() {
  50. return this.title || t("uni-popup.shareTitle")
  51. }
  52. },
  53. methods: {
  54. /**
  55. * 选择内容
  56. */
  57. select(item, index) {
  58. this.$emit('select', {
  59. item,
  60. index
  61. })
  62. this.close()
  63. },
  64. /**
  65. * 关闭窗口
  66. */
  67. close() {
  68. if(this.beforeClose) return
  69. this.popup.close()
  70. }
  71. }
  72. }
  73. </script>
  74. <style lang="scss" >
  75. .uni-popup-share {
  76. background-color: #fff;
  77. border-top-left-radius: 11px;
  78. border-top-right-radius: 11px;
  79. }
  80. .uni-share-title {
  81. /* #ifndef APP-NVUE */
  82. display: flex;
  83. /* #endif */
  84. flex-direction: row;
  85. align-items: center;
  86. justify-content: center;
  87. height: 40px;
  88. }
  89. .uni-share-title-text {
  90. font-size: 14px;
  91. color: #666;
  92. }
  93. .uni-share-content {
  94. /* #ifndef APP-NVUE */
  95. display: flex;
  96. /* #endif */
  97. flex-direction: row;
  98. justify-content: center;
  99. padding-top: 10px;
  100. }
  101. .uni-share-content-box {
  102. /* #ifndef APP-NVUE */
  103. display: flex;
  104. justify-content: space-around;
  105. /* #endif */
  106. flex-direction: row;
  107. flex-wrap: wrap;
  108. width: 100%;
  109. }
  110. .uni-share-content-item {
  111. width: 90px;
  112. /* #ifndef APP-NVUE */
  113. display: flex;
  114. /* #endif */
  115. flex-direction: column;
  116. justify-content: center;
  117. padding: 10px 0;
  118. align-items: center;
  119. }
  120. .uni-share-content-item:active {
  121. background-color: #f5f5f5;
  122. }
  123. .uni-share-image {
  124. width: 30px;
  125. height: 30px;
  126. }
  127. .uni-share-text {
  128. margin-top: 10px;
  129. font-size: 14px;
  130. color: #3B4144;
  131. }
  132. .uni-share-button-box {
  133. /* #ifndef APP-NVUE */
  134. display: flex;
  135. /* #endif */
  136. flex-direction: row;
  137. padding: 10px 15px;
  138. }
  139. .uni-share-button {
  140. flex: 1;
  141. border-radius: 50px;
  142. color: #666;
  143. font-size: 16px;
  144. }
  145. .uni-share-button::after {
  146. border-radius: 50px;
  147. }
  148. </style>