orderButton.vue 3.7 KB

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