icon-items-list.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div class="icon-items-list" :class="'icon-items-list-'+type">
  3. <div class="icon-items-icons" :style="{width:itemWidth}" v-for="(item,index) in list" :key="item.id" @click="toPage(item,index)">
  4. <div class="icon-items-imgse" >
  5. <image class="imgs" v-if="type=='img'" :class="item.auth?'':'uni-img-gray'" :fade-show='true' :src="item.icon||'/static/def_imgs.png'"></image>
  6. <u-icon class="icons" v-if="type=='icon'" :color="item.color" :size="iconSize" :name="item.icon" custom-prefix="custom-icon"></u-icon>
  7. <u-badge class="tag" :absolute="false" type="error" v-if="item.nums" :count="item.nums"></u-badge>
  8. </div>
  9. <div class="icon-items-text">{{item.name}}</div>
  10. </div>
  11. <div class="nodata" v-if="list.length==0">
  12. <u-empty :text="noDataText" mode="list"></u-empty>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import { toAuthStore } from "@/utils/index.js"
  18. export default {
  19. name: "iconItemsList",
  20. props:{
  21. // 套餐服务项 或配件id
  22. list:{
  23. type: Array,
  24. default: function(){
  25. return []
  26. }
  27. },
  28. itemWidth: {
  29. type: String,
  30. default: '25%'
  31. },
  32. iconSize: {
  33. type: Number,
  34. default: 60
  35. },
  36. type: {
  37. type: String,
  38. default: 'icon'
  39. },
  40. noDataText: {
  41. type: String,
  42. default: '暂无数据'
  43. },
  44. isLogin: {
  45. type: Boolean,
  46. default: false
  47. },
  48. sysUserFlag: {
  49. type: String,
  50. default: '1'
  51. }
  52. },
  53. data() {
  54. return {
  55. datas: this.list
  56. }
  57. },
  58. methods: {
  59. toPage(item,index){
  60. if(this.isLogin){
  61. if(item.url&&item.url!=''){
  62. if(!item.ignoreAuth){
  63. // 游客去认证
  64. if(this.sysUserFlag == '0'){
  65. toAuthStore()
  66. return true
  67. }
  68. }
  69. if(item.target == 'page'){
  70. uni.navigateTo({
  71. url: item.url
  72. })
  73. }
  74. if(item.target == 'tabPage'){
  75. uni.switchTab({
  76. url: item.url
  77. })
  78. }
  79. if(item.target == 'fun'){
  80. this.$emit('callback',item)
  81. }
  82. }
  83. }else{
  84. uni.navigateTo({
  85. url: '/pages/login/login'
  86. })
  87. }
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="less">
  93. .icon-items-list{
  94. align-items: flex-start;
  95. display: flex;
  96. flex-wrap: wrap;
  97. .nodata{
  98. text-align: center;
  99. font-size: 24upx;
  100. width: 100%;
  101. color: #999999;
  102. }
  103. }
  104. .icon-items-list-img{
  105. .icon-items-icons{
  106. margin-bottom: 5px;
  107. }
  108. .icon-items-imgse{
  109. position: relative;
  110. width: 100upx;
  111. height: 100upx;
  112. margin-bottom: 6upx;
  113. display:flex;
  114. align-items: center;
  115. justify-content: center;
  116. .imgs{
  117. width: 90upx;
  118. height: 90upx;
  119. }
  120. .tag{
  121. position: absolute;
  122. top: -5upx;
  123. right: -5upx;
  124. }
  125. }
  126. }
  127. .icon-items-list-icon{
  128. .icon-items-imgse{
  129. position: relative;
  130. width: 100upx;
  131. margin-bottom: 6upx;
  132. display:flex;
  133. align-items: center;
  134. justify-content: center;
  135. .tag{
  136. position: absolute;
  137. top: -5upx;
  138. right: -5upx;
  139. }
  140. }
  141. .icon-items-text{
  142. font-size: 24upx;
  143. color: #333;
  144. }
  145. }
  146. .icon-items-icons{
  147. text-align: center;
  148. display: flex;
  149. align-items: center;
  150. flex-direction: column;
  151. justify-content: center;
  152. }
  153. </style>