uni-popup-share.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="uni-popup-share">
  3. <view class="uni-share-title">
  4. <text class="uni-share-title-text">{{ shareTitleText }}</text>
  5. </view>
  6. <view class="uni-share-content">
  7. <view class="uni-share-content-box">
  8. <view v-for="(item,index) in bottomData" :key="index" class="uni-share-content-item"
  9. @click.stop="select(item,index)">
  10. <image :src="item.icon" class="uni-share-image" mode="aspectFill"></image>
  11. <text class="uni-share-text">{{ item.text }}</text>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="uni-share-button-box">
  16. <button class="uni-share-button" @click="close">{{ cancelText }}</button>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import popup from '../uni-popup/popup.js'
  22. import {initVueI18n} 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. text: '微信',
  43. icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/c2b17470-50be-11eb-b680-7980c8a877b8.png',
  44. name: 'wx'
  45. },
  46. {
  47. text: '支付宝',
  48. icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/d684ae40-50be-11eb-8ff1-d5dcf8779628.png',
  49. name: 'wx'
  50. },
  51. {
  52. text: 'QQ',
  53. icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/e7a79520-50be-11eb-b997-9918a5dda011.png',
  54. name: 'qq'
  55. },
  56. {
  57. text: '新浪',
  58. icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/0dacdbe0-50bf-11eb-8ff1-d5dcf8779628.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. },
  76. computed: {
  77. cancelText() {
  78. return t("uni-popup.cancel")
  79. },
  80. shareTitleText() {
  81. return this.title || t("uni-popup.shareTitle")
  82. }
  83. },
  84. methods: {
  85. /**
  86. * 选择内容
  87. */
  88. select(item, index) {
  89. this.$emit('select', {
  90. item,
  91. index
  92. })
  93. this.close()
  94. },
  95. /**
  96. * 关闭窗口
  97. */
  98. close() {
  99. if (this.beforeClose) return
  100. this.popup.close()
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss">
  106. .uni-popup-share {
  107. background-color: #fff;
  108. border-top-left-radius: 11px;
  109. border-top-right-radius: 11px;
  110. }
  111. .uni-share-title {
  112. /* #ifndef APP-NVUE */
  113. display: flex;
  114. /* #endif */
  115. flex-direction: row;
  116. align-items: center;
  117. justify-content: center;
  118. height: 40px;
  119. }
  120. .uni-share-title-text {
  121. font-size: 14px;
  122. color: #666;
  123. }
  124. .uni-share-content {
  125. /* #ifndef APP-NVUE */
  126. display: flex;
  127. /* #endif */
  128. flex-direction: row;
  129. justify-content: center;
  130. padding-top: 10px;
  131. }
  132. .uni-share-content-box {
  133. /* #ifndef APP-NVUE */
  134. display: flex;
  135. /* #endif */
  136. flex-direction: row;
  137. flex-wrap: wrap;
  138. width: 360px;
  139. }
  140. .uni-share-content-item {
  141. width: 90px;
  142. /* #ifndef APP-NVUE */
  143. display: flex;
  144. /* #endif */
  145. flex-direction: column;
  146. justify-content: center;
  147. padding: 10px 0;
  148. align-items: center;
  149. }
  150. .uni-share-content-item:active {
  151. background-color: #f5f5f5;
  152. }
  153. .uni-share-image {
  154. width: 30px;
  155. height: 30px;
  156. }
  157. .uni-share-text {
  158. margin-top: 10px;
  159. font-size: 14px;
  160. color: #3B4144;
  161. }
  162. .uni-share-button-box {
  163. /* #ifndef APP-NVUE */
  164. display: flex;
  165. /* #endif */
  166. flex-direction: row;
  167. padding: 10px 15px;
  168. }
  169. .uni-share-button {
  170. flex: 1;
  171. border-radius: 50px;
  172. color: #666;
  173. font-size: 16px;
  174. }
  175. .uni-share-button::after {
  176. border-radius: 50px;
  177. }
  178. </style>