cm-order-control-nav.vue 3.1 KB

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