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