t-rt-popup1.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view>
  3. <tui-bubble-popup :show="popupShow" @close="toggle" :maskBgColor="maskBgColor" right="8px" :top="popupTop" triangleRight="16px" triangleTop="-22rpx" width="90px">
  4. <view @tap="scan" class="tui-popup-item tui-start" hover-class="tui-item-active" :hover-stay-time="150">
  5. <tui-icon name="sweep" color="#fff" :size="20"></tui-icon>
  6. <text class="tui-bubble-popup_title">扫一扫</text>
  7. </view>
  8. <view @tap="configure" class="tui-popup-item tui-start" hover-class="tui-item-active" :hover-stay-time="150">
  9. <tui-icon name="setup" color="#fff" :size="20"></tui-icon>
  10. <text class="tui-bubble-popup_title">系统设置</text>
  11. </view>
  12. <view @tap="settings" class="tui-popup-item tui-start" hover-class="tui-item-active" :hover-stay-time="150">
  13. <tui-icon name="camera-add" color="#fff" :size="20"></tui-icon>
  14. <text class="tui-bubble-popup_title">管理设置</text>
  15. </view>
  16. </tui-bubble-popup>
  17. </view>
  18. </template>
  19. <script>
  20. import tuiIcon from '@/components/thorui/tui-icon/tui-icon';
  21. import tuiBubblePopup from '@/components/thorui/tui-bubble-popup/tui-bubble-popup';
  22. //右上角气泡弹层
  23. export default {
  24. components: {
  25. tuiIcon,
  26. tuiBubblePopup
  27. },
  28. name: 'tRtPopup',
  29. props: {
  30. //如果图标是image,则icon传入图片地址
  31. itemList: {
  32. type: Array,
  33. default: () => {
  34. return [
  35. {
  36. title: '关闭',
  37. icon: 'close'
  38. }
  39. ];
  40. }
  41. },
  42. //遮罩背景色
  43. maskBgColor: {
  44. type: String,
  45. default: 'transparent'
  46. },
  47. //图标是否为图片
  48. isImage:{
  49. type: Boolean,
  50. default: false
  51. },
  52. //图标宽度
  53. width:{
  54. type: String,
  55. default: '40rpx'
  56. },
  57. //图标高度
  58. height:{
  59. type: String,
  60. default: '40rpx'
  61. }
  62. },
  63. created() {
  64. this.popupTop = 0 + uni.upx2px(12) + 'px';
  65. // #ifdef H5
  66. this.popupTop = 44 + uni.upx2px(12) + 'px';
  67. // #endif
  68. },
  69. data() {
  70. return {
  71. popupShow: false,
  72. popupTop: '12rpx'
  73. };
  74. },
  75. methods: {
  76. settings: function() {
  77. uni.navigateTo({
  78. url: './settings'
  79. });
  80. },
  81. scan: function() {
  82. uni.scanCode({
  83.      onlyFromCamera: true, //为true只允许相机扫码,不加允许相册扫码
  84. success: function(res) {
  85. console.log('条码类型:' + res.scanType);
  86. console.log(res.scanType + ':' + res.result);
  87. }
  88. })
  89. },
  90. configure: function() {
  91. uni.navigateTo({
  92. url: '../main/configure/configure'
  93. });
  94. },
  95. handleClick(index) {
  96. this.$emit('click', { index: index });
  97. this.toggle()
  98. },
  99. toggle() {
  100. this.popupShow = !this.popupShow;
  101. }
  102. }
  103. };
  104. </script>
  105. <style lang="scss" scoped>
  106. .tui-popup-item {
  107. padding: 10rpx;
  108. display: flex;
  109. align-items: center;
  110. font-size: 24rpx;
  111. position: relative;
  112. &::after {
  113. content: '';
  114. position: absolute;
  115. border-bottom: 1rpx solid #888;
  116. -webkit-transform: scaleY(0.5);
  117. transform: sc8aleY(0.5);
  118. bottom: 0;
  119. right: 0;
  120. left: 38rpx;
  121. }
  122. .tui-bubble-popup_title {
  123. padding-left: $uni-spacing-row-base;
  124. }
  125. }
  126. .tui-start {
  127. border-top-left-radius: 8rpx;
  128. border-top-right-radius: 8rpx;
  129. }
  130. .tui-last {
  131. border-bottom-left-radius: 8rpx;
  132. border-bottom-right-radius: 8rpx;
  133. &::after {
  134. border-bottom: 0 !important;
  135. }
  136. }
  137. .tui-item-active {
  138. background-color: #444;
  139. }
  140. </style>