You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
3.7 KiB

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