orderButton.vue 3.5 KB

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