tm-shareSheet.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="tm-shareSheet">
  3. <tm-poup :black="black_tmeme" @change="toogle" ref="pop" v-model="showpop" height="auto" >
  4. <view class="tm-shareSheet-title pa-32 pb-32 relative" :class="[black_tmeme?'grey-darken-5':'white']">
  5. <view class="text-size-s text-align-center text-grey-lighten-1">{{title}}</view>
  6. <view class="tm-shareSheet-close rounded flex-center absolute" :class="black_tmeme?'grey-darken-3':'grey-lighten-3'">
  7. <tm-icons @click="close" name="icon-times" size="24" :color="black_tmeme?'white':'grey'"></tm-icons>
  8. </view>
  9. </view>
  10. <block v-for="(item2,index2) in actions" :key="index2">
  11. <view class="py-32 pa-32">
  12. <scroll-view scroll-x class="tm-shareSheet-wk flex-start">
  13. <view @click="onclick(index,item)" v-for="(item,index) in item2" :key="index" class="tm-shareSheet-zuti ">
  14. <view class="tm-shareSheet-zuti-img flex-center rounded" :style="{
  15. background:black_tmeme?'#424242':item.bgcolor
  16. }">
  17. <tm-icons :black="black_tmeme" :name="item.icon" size="45" :color="black_tmeme?'white':item.color"></tm-icons>
  18. </view>
  19. <view class="tm-shareSheet-zuti-text text-size-xs my-10 text-grey">{{item.name}}</view>
  20. </view>
  21. </scroll-view>
  22. </view>
  23. <view v-if="(index2+1)%2!=0&&actions.length>1" class="my-5 mx-32" >
  24. <view class=" border-b-1" :class="[black_tmeme?'bk':'']"></view>
  25. </view>
  26. </block>
  27. <view class="safe--hei"></view>
  28. </tm-poup>
  29. </view>
  30. </template>
  31. <script>
  32. /**
  33. * 分享面板
  34. * @description 动作面板,从底部弹出的操作菜单。
  35. * @property {Boolean} black = [true|false] 默认:false,暗黑模式
  36. * @property {Boolean} click-close = [true|false] 默认:true,点击图标后是否立即关闭弹层。
  37. * @property {Boolean} value = [true|false] 默认:false,显示菜单,推荐使用v-model,使用value.sync达到双向绑定。
  38. * @property {String} title = [] 默认:'请操作',弹出层的标题。
  39. * @property {Array} actions = [] 默认:[],格式见文档,操作数组。{name:"微信",bgcolor:"#07c160",icon:"icon-weixin",color:"white"}
  40. * @property {Function} change 点击项目时触发,返回:{index:项目索引,data:actions的对象数据}
  41. * @property {Function} input 弹层显示和隐藏时,将会触发。
  42. * @example <tm-shareSheet ></tm-shareSheet>
  43. */
  44. import tmIcons from "@/tm-vuetify/components/tm-icons/tm-icons.vue"
  45. import tmPoup from "@/tm-vuetify/components/tm-poup/tm-poup.vue"
  46. export default {
  47. components:{tmIcons,tmPoup},
  48. name:"tm-shareSheet",
  49. model:{
  50. prop:'value',
  51. event:'input'
  52. },
  53. props:{
  54. value:{
  55. type:Boolean,
  56. default:false
  57. },
  58. black:{
  59. type:Boolean,
  60. default:null
  61. },
  62. clickClose:{
  63. type:Boolean,
  64. default:true
  65. },
  66. title:{
  67. type:String,
  68. default:'立即分享给好友吧'
  69. },
  70. actions:{
  71. type:Array,
  72. default:()=>{
  73. return [
  74. [
  75. {name:"微信",bgcolor:"#07c160",icon:"icon-weixin",color:"white"},
  76. {name:"朋友圈",bgcolor:"#04c887",icon:"icon-pengyouquan",color:"white"},
  77. {name:"微博",bgcolor:"#e91e38",icon:"icon-weibo",color:"white"},
  78. {name:"QQ",bgcolor:"#1dc0fd",icon:"icon-QQ",color:"white"},
  79. {name:"小程序",bgcolor:"#1893fd",icon:"icon-xiaochengxu",color:"white"},
  80. ],
  81. [
  82. {name:"复制链接",bgcolor:"#f5f5f5",icon:"icon-connection",color:"grey-darken-1"},
  83. {name:"分享海报",bgcolor:"#f5f5f5",icon:"icon-picture",color:"grey-darken-1"},
  84. {name:"二维码",bgcolor:"#f5f5f5",icon:"icon-qrcode",color:"grey-darken-1"},
  85. {name:"分享",bgcolor:"#f5f5f5",icon:"icon-share1",color:"grey-darken-1"}
  86. ]
  87. ]
  88. }
  89. }
  90. },
  91. watch:{
  92. value:function(){
  93. this.showpop = this.value;
  94. }
  95. },
  96. data() {
  97. return {
  98. showpop:false,
  99. };
  100. },
  101. computed: {
  102. black_tmeme: function() {
  103. if (this.black !== null) return this.black;
  104. return this.$tm.vx.state().tmVuetify.black;
  105. }
  106. },
  107. mounted() {
  108. this.showpop = this.value;
  109. },
  110. methods: {
  111. close(){
  112. this.$refs.pop.close();
  113. },
  114. toogle(e){
  115. let t = this;
  116. if(e){
  117. this.$nextTick(function(){
  118. if(this.dataValue != this.defaultValue){
  119. this.dataValue = this.defaultValue;
  120. }
  121. })
  122. }
  123. this.$emit('input',e);
  124. this.$emit('update:value',e);
  125. },
  126. onclick(index,item){
  127. this.$emit('change',{index:index,data:item})
  128. if(this.clickClose === true){
  129. this.$refs.pop.close();
  130. }
  131. }
  132. },
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .tm-shareSheet-title {
  137. .tm-shareSheet-close {
  138. top: 32upx;
  139. right: 32upx;
  140. width: 50upx;
  141. height: 50upx;
  142. }
  143. }
  144. .tm-shareSheet-wk{
  145. white-space: nowrap;
  146. width: 100%;
  147. .tm-shareSheet-zuti{
  148. width: 140upx;
  149. flex-shrink: 0;
  150. text-align: center;
  151. display: inline-block;
  152. .tm-shareSheet-zuti-img{
  153. margin: auto;
  154. width: 100upx;
  155. height: 100upx;
  156. }
  157. }
  158. }
  159. </style>