cm-order-control-nav.vue 3.7 KB

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