orderListButton.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. // console.log(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. * @(11)显示[取消订单],其他隐藏
  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. isShare: true,
  80. isConfirmation:false,
  81. }
  82. return btnState
  83. },
  84. getShareCode(code){
  85. this.shareCode = code
  86. },
  87. onShareCode(orderId){
  88. this.$parent.isShareModal = true
  89. this.$parent.btnoRderID = orderId
  90. this.$emit('shareConfirm')
  91. },
  92. btnConfirm(type,id){
  93. let data = {
  94. type:type,
  95. orderId:id
  96. }
  97. this.$emit('buttonConfirm',data)
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss">
  103. .button-template{
  104. width: 100%;
  105. height: auto;
  106. float: left;
  107. background: #FFFFFF;
  108. .button-content{
  109. width: 702rpx;
  110. height: auto;
  111. float: left;
  112. position: relative;
  113. .share-code{
  114. width: 200rpx;
  115. height: 64rpx;
  116. line-height: 64rpx;
  117. color: #2A45FF;
  118. text-align: left;
  119. position: absolute;
  120. font-size: $font-size-28;
  121. font-weight: bold;
  122. left: 24rpx;
  123. top: 24rpx;
  124. }
  125. .btn{
  126. width: 160rpx;
  127. height: 64rpx;
  128. margin:22rpx;
  129. line-height: 64rpx;
  130. font-size:$font-size-26;
  131. color: #FFFFFF;
  132. text-align: center;
  133. border-radius: 10rpx;
  134. float: right;
  135. }
  136. .btn-cancel{
  137. background:linear-gradient(135deg,rgba(104,104,104,1) 0%,rgba(181,181,181,1) 100%);
  138. }
  139. .btn-delete{
  140. background:linear-gradient(315deg,rgba(255,163,3,1) 0%,rgba(255,53,1,1) 100%);
  141. }
  142. .btn-query{
  143. background:linear-gradient(135deg,rgba(255,212,129,1) 0%,rgba(198,129,0,1) 100%);
  144. }
  145. .btn-confirm{
  146. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  147. }
  148. .btn-share{
  149. background:linear-gradient(315deg,rgba(0,212,150,1) 0%,rgba(126,243,174,1) 100%);
  150. margin-right: 0;
  151. position: relative;
  152. .tips{
  153. width: 160rpx;
  154. height: 34rpx;
  155. padding: 10rpx 10rpx;
  156. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  157. box-shadow:0px 2px 4px 0px rgba(0,0,0,0.2);
  158. border-radius: 8rpx;
  159. position: absolute;
  160. color: #FFFFFF;
  161. line-height: 34rpx;
  162. font-size: $font-size-24;
  163. text-align: left;
  164. right: 0;
  165. top: -65rpx;
  166. &:before{
  167. content: "";
  168. width: 25rpx;
  169. height: 25rpx;
  170. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  171. position: absolute;
  172. bottom: -8rpx;
  173. right: 30rpx;
  174. z-index: -1;
  175. transform:rotate(45deg);
  176. }
  177. }
  178. }
  179. }
  180. }
  181. </style>