cm-order-control-nav.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view class="cm-order-control-nav">
  3. <view class="btn type2" v-if="btnState.share" @click.stop="handleClick('fightDetail')">拼团详情</view>
  4. <view class="btn type1" v-if="btnState.share" @click.stop="handleClick('share')">邀好友拼团</view>
  5. <view class="btn type2" v-if="btnState.cancel" @click.stop="handleClick('cancel')">取消订单</view>
  6. <view class="btn type2" v-if="btnState.delete" @click.stop="handleClick('delete')">删除订单</view>
  7. <view class="btn type2" v-if="btnState.query" @click.stop="handleClick('query')">查看物流</view>
  8. <view class="btn type1" v-if="btnState.pay" @click.stop="handleClick('pay')">付款</view>
  9. <view class="btn type1" v-if="btnState.again" @click.stop="handleClick('again')">再次购买</view>
  10. <!-- <view class="btn type1" @click="handleClick('again')">再次购买</view> -->
  11. <view class="btn type2" v-if="btnState.confirm" @click.stop="handleClick('confirm')">确认收货</view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. props: {
  17. orderInfo: {
  18. type: Object,
  19. default: () => {}
  20. }
  21. },
  22. data() {
  23. return {
  24. mapState: {
  25. fightDetail:[],
  26. share: [],
  27. query: [4, 5, 12, 13, 33, 22, 23, 32, 77],
  28. delete: [6],
  29. cancel: [0, 111],
  30. confirm: [33],
  31. again: [33],
  32. pay: [11, 12, 13, 21, 22, 23, 111]
  33. },
  34. buttonCount: 0
  35. }
  36. },
  37. computed: {
  38. btnState() {
  39. return this.initData()
  40. }
  41. },
  42. watch:{
  43. buttonCount(nVal){
  44. this.$emit('change', {
  45. count: nVal
  46. })
  47. }
  48. },
  49. methods: {
  50. /**
  51. * @分享按钮统一显示
  52. * @按钮根据状态显示
  53. * @(4、5、7、12、22、23、32)显示[查看物流]按钮,其他隐藏
  54. * @(6)显示[删除订单],其他隐藏
  55. * @(0、111)显示[取消订单],其他隐藏
  56. * @(21,31)只显示分享
  57. * @(13,33)显示[确认收货]和[查看物流]
  58. */
  59. initData(resVal) {
  60. const btnState = {}
  61. const orderStatus = parseInt(this.orderInfo.status)
  62. for (let key in this.mapState) {
  63. btnState[key] = this.mapState[key].includes(orderStatus)
  64. if(btnState[key]) {
  65. this.buttonCount ++
  66. }
  67. }
  68. return btnState
  69. },
  70. handleClick(type) {
  71. this.$emit('confirm', { type, order: this.orderInfo })
  72. }
  73. }
  74. }
  75. </script>
  76. <style lang="scss" scoped>
  77. .cm-order-control-nav {
  78. padding: 0 24rpx;
  79. text-align: right;
  80. .btn {
  81. display: inline-block;
  82. width: 160rpx;
  83. height: 56rpx;
  84. border-radius: 32rpx;
  85. margin-left: 24rpx;
  86. font-size: 26rpx;
  87. box-sizing: border-box;
  88. text-align: center;
  89. line-height: 54rpx;
  90. &.type1 {
  91. border: 1rpx solid #ff457b;
  92. color: #ff457b;
  93. }
  94. &.type2 {
  95. border: 1rpx solid #333;
  96. color: #333;
  97. }
  98. }
  99. }
  100. </style>