orderListButton.vue 3.2 KB

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