orderListButton.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template name="button">
  2. <view class="button-template">
  3. <!-- 底部按钮 -->
  4. <view class="button-content">
  5. <view class="btn btn-cancel" v-if="btnState.isCancel" @click.stop="btnConfirm('cancel',orderID)">取消订单</view>
  6. <view class="btn btn-cancel" v-if="btnState.isDelete" @click.stop="btnConfirm('delete',orderID)">删除订单</view>
  7. <view class="btn btn-color" @click.stop="onShareCode(orderID)">分享订单</view>
  8. <view class="btn btn-color" v-if="btnState.isConfirmation" @click.stop="btnConfirm('confirmation',orderID)">确认订单</view>
  9. <view class="btn btn-color" v-if="btnState.isQuery" @click.stop="btnConfirm('query',orderID)">查看物流</view>
  10. <view class="btn btn-color" 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-color{
  136. background: $btn-confirm;
  137. margin: 22rpx 0 22rpx 22rpx;
  138. }
  139. .btn-cancel{
  140. background:#FFFFFF;
  141. color: #999999;
  142. float: left;
  143. margin: 22rpx 0;
  144. text-align: left;
  145. }
  146. .btn-delete{
  147. background:linear-gradient(315deg,rgba(255,163,3,1) 0%,rgba(255,53,1,1) 100%);
  148. }
  149. .btn-query{
  150. background:linear-gradient(135deg,rgba(255,212,129,1) 0%,rgba(198,129,0,1) 100%);
  151. }
  152. .btn-confirm{
  153. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  154. }
  155. .btn-share{
  156. background:linear-gradient(315deg,rgba(0,212,150,1) 0%,rgba(126,243,174,1) 100%);
  157. margin-right: 0;
  158. position: relative;
  159. .tips{
  160. width: 160rpx;
  161. height: 34rpx;
  162. padding: 10rpx 10rpx;
  163. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  164. box-shadow:0px 2px 4px 0px rgba(0,0,0,0.2);
  165. border-radius: 8rpx;
  166. position: absolute;
  167. color: #FFFFFF;
  168. line-height: 34rpx;
  169. font-size: $font-size-24;
  170. text-align: left;
  171. right: 0;
  172. top: -65rpx;
  173. &:before{
  174. content: "";
  175. width: 25rpx;
  176. height: 25rpx;
  177. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  178. position: absolute;
  179. bottom: -8rpx;
  180. right: 30rpx;
  181. z-index: -1;
  182. transform:rotate(45deg);
  183. }
  184. }
  185. }
  186. }
  187. }
  188. </style>