orderListButton.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template name="button">
  2. <view class="button-template">
  3. <!-- 底部按钮 v-if="btnState.isConfirm"-->
  4. <view class="button-content">
  5. <view class="btn btn-pay" v-if="btnState.isPay" @click.stop="btnConfirm('pay',order)">付款</view>
  6. <view class="btn btn-pay" v-if="btnState.isConfirm" @click.stop="btnConfirm('confirm',order)">确认收货</view>
  7. <view class="btn btn-pay" v-if="btnState.isAgain" @click.stop="btnConfirm('again',order)">再次购买</view>
  8. <view class="btn btn-cancel" v-if="btnState.isCancel" @click.stop="btnConfirm('cancel',order)">取消订单</view>
  9. <view class="btn btn-cancel" v-if="btnState.isDelete" @click.stop="btnConfirm('delete',order)">删除订单</view>
  10. <view class="btn btn-cancel" v-if="btnState.isQuery" @click.stop="btnConfirm('query',order)">查看物流</view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default{
  16. name:"button",
  17. props:{
  18. status: {
  19. type:Number
  20. },
  21. order: {
  22. type:Object
  23. },
  24. },
  25. data() {
  26. return{
  27. isShare:true,
  28. shareCode:'',
  29. btnState:this.initStatus(),
  30. mapStateArr:[
  31. {label:'isQuery',val:[4,5,12,13,33,22,23,32,77],status: true},
  32. {label:'isDelete',val:[6],status: true},
  33. {label:'isCancel',val:[0,111],status: true},
  34. {label:'isConfirm',val:[33],status: true},
  35. {label:'isAgain',val:[33],status: true},
  36. {label:'isPay',val:[11,12,13,21,22,23,111],status: true},
  37. ]
  38. }
  39. },
  40. created(){
  41. this.initData(this.status)
  42. },
  43. computed: {
  44. },
  45. watch:{
  46. status:{
  47. handler:function(val){
  48. this.initData(val)
  49. },
  50. deep:true//对象内部的属性监听,也叫深度监听
  51. }
  52. },
  53. methods:{
  54. initData(resVal) {
  55. /**
  56. * @分享按钮统一显示
  57. * @按钮根据状态显示
  58. * @(4、5、7、12、22、23、32)显示[查看物流]按钮,其他隐藏
  59. * @(6)显示[删除订单],其他隐藏
  60. * @(0、111)显示[取消订单],其他隐藏
  61. * @(21,31)只显示分享
  62. * @(13,33)显示[确认收货]和[查看物流]
  63. */
  64. this.btnState = this.initStatus()
  65. this.mapStateArr.forEach(el => {
  66. el.val.forEach(value => {
  67. if(resVal === value){
  68. this.btnState[el.label] = el.status
  69. }
  70. })
  71. })
  72. },
  73. initStatus(){
  74. let btnState= {
  75. isQuery: false,
  76. isDelete: false,
  77. isCancel: false,
  78. isConfirm: false,
  79. isAgain: false,
  80. }
  81. return btnState
  82. },
  83. getShareCode(code){
  84. this.shareCode = code
  85. },
  86. btnConfirm(type,order){
  87. let data = {
  88. type:type,
  89. orderId:order.orderId,
  90. order:order
  91. }
  92. this.$emit('buttonConfirm',data)
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss">
  98. .button-template{
  99. width: 100%;
  100. height: auto;
  101. float: left;
  102. background: #FFFFFF;
  103. .button-content{
  104. height: auto;
  105. float: right;
  106. position: relative;
  107. .share-code{
  108. width: 200rpx;
  109. height: 64rpx;
  110. line-height: 64rpx;
  111. color: #2A45FF;
  112. text-align: left;
  113. position: absolute;
  114. font-size: $font-size-28;
  115. font-weight: bold;
  116. left: 24rpx;
  117. top: 24rpx;
  118. }
  119. .btn{
  120. width: 160rpx;
  121. height: 64rpx;
  122. margin: 22rpx 0 20rpx 20rpx;
  123. line-height: 64rpx;
  124. font-size:$font-size-26;
  125. color: #333333;
  126. text-align: center;
  127. float: right;
  128. border-radius: 34rpx;
  129. border: 2rpx solid #333333;
  130. &.btn-pay{
  131. border-color: $color-system;
  132. color: $color-system;
  133. }
  134. &.btn-cancel{
  135. text-align: center;
  136. }
  137. }
  138. }
  139. }
  140. </style>