orderListButton.vue 4.8 KB

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