uni-popup-share.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 {
  23. initVueI18n
  24. } from '@dcloudio/uni-i18n'
  25. import messages from '../uni-popup/i18n/index.js'
  26. const {t} = initVueI18n(messages)
  27. export default {
  28. name: 'UniPopupShare',
  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: '微信',
  45. icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/c2b17470-50be-11eb-b680-7980c8a877b8.png',
  46. name: 'wx'
  47. },
  48. {
  49. text: '支付宝',
  50. icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/d684ae40-50be-11eb-8ff1-d5dcf8779628.png',
  51. name: 'wx'
  52. },
  53. {
  54. text: 'QQ',
  55. icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/e7a79520-50be-11eb-b997-9918a5dda011.png',
  56. name: 'qq'
  57. },
  58. {
  59. text: '新浪',
  60. icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/0dacdbe0-50bf-11eb-8ff1-d5dcf8779628.png',
  61. name: 'sina'
  62. },
  63. // {
  64. // text: '百度',
  65. // icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/1ec6e920-50bf-11eb-8a36-ebb87efcf8c0.png',
  66. // name: 'copy'
  67. // },
  68. // {
  69. // text: '其他',
  70. // icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/2e0fdfe0-50bf-11eb-b997-9918a5dda011.png',
  71. // name: 'more'
  72. // }
  73. ]
  74. }
  75. },
  76. created() {
  77. },
  78. computed: {
  79. cancelText() {
  80. return t("uni-popup.cancel")
  81. },
  82. shareTitleText() {
  83. return this.title || t("uni-popup.shareTitle")
  84. }
  85. },
  86. methods: {
  87. /**
  88. * 选择内容
  89. */
  90. select(item, index) {
  91. this.$emit('select', {
  92. item,
  93. index
  94. })
  95. this.close()
  96. },
  97. /**
  98. * 关闭窗口
  99. */
  100. close() {
  101. if (this.beforeClose) return
  102. this.popup.close()
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss">
  108. .uni-popup-share {
  109. background-color: #fff;
  110. border-top-left-radius: 11px;
  111. border-top-right-radius: 11px;
  112. }
  113. .uni-share-title {
  114. /* #ifndef APP-NVUE */
  115. display: flex;
  116. /* #endif */
  117. flex-direction: row;
  118. align-items: center;
  119. justify-content: center;
  120. height: 40px;
  121. }
  122. .uni-share-title-text {
  123. font-size: 14px;
  124. color: #666;
  125. }
  126. .uni-share-content {
  127. /* #ifndef APP-NVUE */
  128. display: flex;
  129. /* #endif */
  130. flex-direction: row;
  131. justify-content: center;
  132. padding-top: 10px;
  133. }
  134. .uni-share-content-box {
  135. /* #ifndef APP-NVUE */
  136. display: flex;
  137. /* #endif */
  138. flex-direction: row;
  139. flex-wrap: wrap;
  140. width: 360px;
  141. }
  142. .uni-share-content-item {
  143. width: 90px;
  144. /* #ifndef APP-NVUE */
  145. display: flex;
  146. /* #endif */
  147. flex-direction: column;
  148. justify-content: center;
  149. padding: 10px 0;
  150. align-items: center;
  151. }
  152. .uni-share-content-item:active {
  153. background-color: #f5f5f5;
  154. }
  155. .uni-share-image {
  156. width: 30px;
  157. height: 30px;
  158. }
  159. .uni-share-text {
  160. margin-top: 10px;
  161. font-size: 14px;
  162. color: #3B4144;
  163. }
  164. .uni-share-button-box {
  165. /* #ifndef APP-NVUE */
  166. display: flex;
  167. /* #endif */
  168. flex-direction: row;
  169. padding: 10px 15px;
  170. }
  171. .uni-share-button {
  172. flex: 1;
  173. border-radius: 50px;
  174. color: #666;
  175. font-size: 16px;
  176. }
  177. .uni-share-button::after {
  178. border-radius: 50px;
  179. }
  180. </style>