gui-face-group.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <view class="gui-face-group"
  3. :style="{height:(size + borderWidth * 2 ) +'rpx'}">
  4. <view class="gui-face-items"
  5. v-for="(item, index) in items" :key="index"
  6. :style="{'z-index':startIndex + index,
  7. left:isAddBtn ? (space * (index)) + 'rpx' : (space * index) + 'rpx',
  8. borderWidth:borderWidth + 'rpx', borderStyle :'solid ', borderColor:borderColor,
  9. width:size+'rpx', height:size+'rpx'}">
  10. <image :src="item" mode="widthFix" class="gui-face-image"
  11. :style="{width:size+'rpx', height:size+'rpx'}"></image>
  12. </view>
  13. <view class="gui-face-items" v-if="isAddBtn"
  14. :style="{
  15. 'z-index':zindex,
  16. width:size+'rpx',
  17. height:size+'rpx',
  18. borderWidth:borderWidth + 'rpx', borderStyle :'solid ', borderColor:borderColor,
  19. left : isAddBtn ? (space * Number(this.items.length)) + 'rpx' : 0,
  20. }" @tap.stop="addBtnClick">
  21. <slot></slot>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default{
  27. name : "gui-face-group",
  28. props : {
  29. items : { type : Array, default : function () { return new Array() } },
  30. size : { type : Number, default : 80 },
  31. space : { type : Number, default : 50 },
  32. borderWidth : { type : Number, default : 4 },
  33. borderColor : { type : String, default : '#F5F5F5' },
  34. isAddBtn : { type : Boolean, default : false },
  35. startIndex : { type : Number, default : 100}
  36. },
  37. data() {
  38. return {
  39. zindex : 100,
  40. }
  41. },
  42. created:function(){
  43. this.zindex = this.startIndex + this.items.length + 1;
  44. },
  45. watch:{
  46. items : function (v) {
  47. this.zindex = this.startIndex + this.items.length + 1;
  48. }
  49. },
  50. methods:{
  51. addBtnClick : function (){
  52. this.$emit('addBtnClicked');
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped>
  58. .gui-face-group{position:relative;}
  59. .gui-face-items{position:absolute; overflow:hidden; border-radius:200rpx; font-size:0;}
  60. .gui-face-image{border-radius:200rpx;}
  61. </style>