IndexOrderItem.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="div order-item" @click="onclick()">
  3. <view>
  4. <image mode="aspectFit" class="img order-item-icon" :src="src" />
  5. </view>
  6. <label class="item-title order-item-title">{{title}}</label>
  7. <text class="span number" v-if="orderNumber == 0 ? '': orderNumber && isEmpty == false ? '': orderNumber">{{ orderNumber }}</text>
  8. </view>
  9. </template>
  10. <script>
  11. import { urlencode } from '@/util/common'
  12. import { mapState, mapMutations } from 'vuex'
  13. export default {
  14. props: {
  15. src: {
  16. type: String
  17. },
  18. title: {
  19. type: String
  20. },
  21. testAttr: {
  22. type: String
  23. },
  24. state: {
  25. default: ''
  26. },
  27. orderNumber: {
  28. type: Number,
  29. default: 0
  30. }
  31. },
  32. data () {
  33. return {
  34. isEmpty: false
  35. }
  36. },
  37. computed: mapState({
  38. isOnline: state => state.member.isOnline
  39. }),
  40. created () {
  41. this.isSignin()
  42. },
  43. methods: {
  44. ...mapMutations({
  45. changeStatus: 'changeStatus'
  46. }),
  47. onclick () {
  48. if (this.isOnline) {
  49. uni.navigateTo({ url: this.testAttr+'?'+urlencode( { state: this.state } )})
  50. } else {
  51. uni.navigateTo({ url: 'signin' })
  52. }
  53. },
  54. // 是否登录
  55. isSignin () {
  56. if (this.isOnline) {
  57. this.isEmpty = true
  58. } else {
  59. this.isEmpty = false
  60. }
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .order-item {
  67. display: flex;
  68. flex-direction: column;
  69. justify-content: flex-start;
  70. align-items: center;
  71. }
  72. .item-title {
  73. font-size: $fontSize;
  74. color: $descTextColor;
  75. }
  76. .order-item-icon {
  77. width: 1.4rem;
  78. height: 1.4rem;
  79. font-size:1.3rem;
  80. margin-top:0.8rem;
  81. }
  82. .order-item-title {
  83. margin-top:0.4rem;
  84. }
  85. .span.number {
  86. width:0.8rem;
  87. height:0.8rem;
  88. line-height:0.8rem;
  89. margin-top:-3rem;
  90. margin-left:1rem;
  91. background: $primaryColor;
  92. border-radius:50%;
  93. font-size:$h6;
  94. text-align: center;
  95. color: RGBA(255, 255, 255, 1);
  96. font-weight: normal;
  97. position: relative;
  98. z-index: 2;
  99. }
  100. </style>