uni-popup-share.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. <view class="uni-share-content-item" v-for="(item,index) in bottomData" :key="index" @click.stop="select(item,index)">
  7. <image class="uni-share-image" :src="item.icon" mode="aspectFill"></image>
  8. <text class="uni-share-text">{{item.text}}</text>
  9. </view>
  10. </view>
  11. </view>
  12. <view class="uni-share-button-box">
  13. <button class="uni-share-button" @click="close">{{cancelText}}</button>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import popup from '../uni-popup/popup.js'
  19. import {
  20. initVueI18n
  21. } from '@dcloudio/uni-i18n'
  22. import messages from '../uni-popup/i18n/index.js'
  23. const { t } = initVueI18n(messages)
  24. export default {
  25. name: 'UniPopupShare',
  26. mixins:[popup],
  27. emits:['select'],
  28. props: {
  29. title: {
  30. type: String,
  31. default: ''
  32. },
  33. beforeClose: {
  34. type: Boolean,
  35. default: false
  36. }
  37. },
  38. data() {
  39. return {
  40. // TODO 替换为自己的图标
  41. bottomData: [{
  42. text: '微信',
  43. icon: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
  44. name: 'wx'
  45. },
  46. {
  47. text: '支付宝',
  48. icon: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
  49. name: 'ali'
  50. },
  51. {
  52. text: 'QQ',
  53. icon: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
  54. name: 'qq'
  55. },
  56. {
  57. text: '新浪',
  58. icon: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
  59. name: 'sina'
  60. },
  61. // {
  62. // text: '百度',
  63. // icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/1ec6e920-50bf-11eb-8a36-ebb87efcf8c0.png',
  64. // name: 'copy'
  65. // },
  66. // {
  67. // text: '其他',
  68. // icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/2e0fdfe0-50bf-11eb-b997-9918a5dda011.png',
  69. // name: 'more'
  70. // }
  71. ]
  72. }
  73. },
  74. created() {},
  75. computed: {
  76. cancelText() {
  77. return t("uni-popup.cancel")
  78. },
  79. shareTitleText() {
  80. return this.title || t("uni-popup.shareTitle")
  81. }
  82. },
  83. methods: {
  84. /**
  85. * 选择内容
  86. */
  87. select(item, index) {
  88. this.$emit('select', {
  89. item,
  90. index
  91. })
  92. this.close()
  93. },
  94. /**
  95. * 关闭窗口
  96. */
  97. close() {
  98. if(this.beforeClose) return
  99. this.popup.close()
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss" >
  105. .uni-popup-share {
  106. background-color: #fff;
  107. border-top-left-radius: 11px;
  108. border-top-right-radius: 11px;
  109. }
  110. .uni-share-title {
  111. /* #ifndef APP-NVUE */
  112. display: flex;
  113. /* #endif */
  114. flex-direction: row;
  115. align-items: center;
  116. justify-content: center;
  117. height: 40px;
  118. }
  119. .uni-share-title-text {
  120. font-size: 14px;
  121. color: #666;
  122. }
  123. .uni-share-content {
  124. /* #ifndef APP-NVUE */
  125. display: flex;
  126. /* #endif */
  127. flex-direction: row;
  128. justify-content: center;
  129. padding-top: 10px;
  130. }
  131. .uni-share-content-box {
  132. /* #ifndef APP-NVUE */
  133. display: flex;
  134. /* #endif */
  135. flex-direction: row;
  136. flex-wrap: wrap;
  137. width: 360px;
  138. }
  139. .uni-share-content-item {
  140. width: 90px;
  141. /* #ifndef APP-NVUE */
  142. display: flex;
  143. /* #endif */
  144. flex-direction: column;
  145. justify-content: center;
  146. padding: 10px 0;
  147. align-items: center;
  148. }
  149. .uni-share-content-item:active {
  150. background-color: #f5f5f5;
  151. }
  152. .uni-share-image {
  153. width: 30px;
  154. height: 30px;
  155. }
  156. .uni-share-text {
  157. margin-top: 10px;
  158. font-size: 14px;
  159. color: #3B4144;
  160. }
  161. .uni-share-button-box {
  162. /* #ifndef APP-NVUE */
  163. display: flex;
  164. /* #endif */
  165. flex-direction: row;
  166. padding: 10px 15px;
  167. }
  168. .uni-share-button {
  169. flex: 1;
  170. border-radius: 50px;
  171. color: #666;
  172. font-size: 16px;
  173. }
  174. .uni-share-button::after {
  175. border-radius: 50px;
  176. }
  177. </style>