orderListButton.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template name="button">
  2. <view class="button-template">
  3. <!-- 底部按钮 -->
  4. <view class="button-content">
  5. <view class="btn btn-share" @click.stop="onShareCode(orderID)">分享订单</view>
  6. <view class="btn btn-confirm" v-if="btnState.isConfirmation" @click.stop="btnConfirm('confirmation',orderID)">确认订单</view>
  7. <view class="btn btn-cancel" v-if="btnState.isCancel" @click.stop="btnConfirm('cancel',orderID)">取消订单</view>
  8. <view class="btn btn-delete" v-if="btnState.isDelete" @click.stop="btnConfirm('delete',orderID)">删除订单</view>
  9. <view class="btn btn-query" v-if="btnState.isQuery" @click.stop="btnConfirm('query',orderID)">查看物流</view>
  10. <view class="btn btn-confirm" v-if="btnState.isConfirm" @click.stop="btnConfirm('confirm',orderID)">确认收货</view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default{
  16. name:"button",
  17. props:{
  18. status: {
  19. type:Number
  20. },
  21. orderID: {
  22. type:Number
  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:'isConfirmation',val:[0],status: true},
  36. ]
  37. }
  38. },
  39. created(){
  40. this.initData(this.status)
  41. },
  42. computed: {
  43. },
  44. watch:{
  45. status:{
  46. handler:function(val){
  47. this.initData(val)
  48. },
  49. deep:true//对象内部的属性监听,也叫深度监听
  50. }
  51. },
  52. methods:{
  53. initData(resVal) {
  54. /**
  55. * @分享按钮统一显示
  56. * @按钮根据状态显示
  57. * @(4、5、7、12、22、23、32)显示[查看物流]按钮,其他隐藏
  58. * @(6)显示[删除订单],其他隐藏
  59. * @(0、111)显示[取消订单],其他隐藏
  60. * @(21,31)只显示分享
  61. * @(13,33)显示[确认收货]和[查看物流]
  62. */
  63. this.btnState = this.initStatus()
  64. this.mapStateArr.forEach(el => {
  65. el.val.forEach(value => {
  66. if(resVal === value){
  67. this.btnState[el.label] = el.status
  68. }
  69. })
  70. })
  71. },
  72. initStatus(){
  73. let btnState= {
  74. isQuery: false,
  75. isDelete: false,
  76. isCancel: false,
  77. isConfirm: false,
  78. isShare: true,
  79. isConfirmation:false,
  80. }
  81. return btnState
  82. },
  83. getShareCode(code){
  84. this.shareCode = code
  85. },
  86. onShareCode(orderId){
  87. this.$parent.isShareModal = true
  88. this.$parent.btnoRderID = orderId
  89. this.$emit('shareConfirm')
  90. },
  91. btnConfirm(type,id){
  92. let data = {
  93. type:type,
  94. orderId:id
  95. }
  96. this.$emit('buttonConfirm',data)
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss">
  102. .button-template{
  103. width: 100%;
  104. height: auto;
  105. float: left;
  106. background: #FFFFFF;
  107. .button-content{
  108. width: 702rpx;
  109. height: auto;
  110. float: left;
  111. position: relative;
  112. .share-code{
  113. width: 200rpx;
  114. height: 64rpx;
  115. line-height: 64rpx;
  116. color: #2A45FF;
  117. text-align: left;
  118. position: absolute;
  119. font-size: $font-size-28;
  120. font-weight: bold;
  121. left: 24rpx;
  122. top: 24rpx;
  123. }
  124. .btn{
  125. width: 160rpx;
  126. height: 64rpx;
  127. margin:22rpx;
  128. line-height: 64rpx;
  129. font-size:$font-size-26;
  130. color: #FFFFFF;
  131. text-align: center;
  132. border-radius: 10rpx;
  133. float: right;
  134. }
  135. .btn-cancel{
  136. background:linear-gradient(135deg,rgba(104,104,104,1) 0%,rgba(181,181,181,1) 100%);
  137. }
  138. .btn-delete{
  139. background:linear-gradient(315deg,rgba(255,163,3,1) 0%,rgba(255,53,1,1) 100%);
  140. }
  141. .btn-query{
  142. background:linear-gradient(135deg,rgba(255,212,129,1) 0%,rgba(198,129,0,1) 100%);
  143. }
  144. .btn-confirm{
  145. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  146. }
  147. .btn-share{
  148. background:linear-gradient(315deg,rgba(0,212,150,1) 0%,rgba(126,243,174,1) 100%);
  149. margin-right: 0;
  150. position: relative;
  151. .tips{
  152. width: 160rpx;
  153. height: 34rpx;
  154. padding: 10rpx 10rpx;
  155. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  156. box-shadow:0px 2px 4px 0px rgba(0,0,0,0.2);
  157. border-radius: 8rpx;
  158. position: absolute;
  159. color: #FFFFFF;
  160. line-height: 34rpx;
  161. font-size: $font-size-24;
  162. text-align: left;
  163. right: 0;
  164. top: -65rpx;
  165. &:before{
  166. content: "";
  167. width: 25rpx;
  168. height: 25rpx;
  169. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  170. position: absolute;
  171. bottom: -8rpx;
  172. right: 30rpx;
  173. z-index: -1;
  174. transform:rotate(45deg);
  175. }
  176. }
  177. }
  178. }
  179. }
  180. </style>