uni-popup-share.vue 3.7 KB

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