orderListButton.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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',order)">付款</view>
  6. <view class="btn btn-share" @click.stop="onShareCode(order.orderID)">分享订单</view>
  7. <view class="btn btn-cancel" v-if="btnState.isCancel" @click.stop="btnConfirm('cancel',order)">取消订单</view>
  8. <view class="btn btn-delete" v-if="btnState.isDelete" @click.stop="btnConfirm('delete',order)">删除订单</view>
  9. <view class="btn btn-query" v-if="btnState.isQuery && order.secondHandOrderFlag!=1" @click.stop="btnConfirm('query',order)">查看物流</view>
  10. <view class="btn " v-if="btnState.isConfirm" @click.stop="btnConfirm('confirm',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. },
  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:'isPay',val:[11,12,13,21,22,23,111],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. }
  80. return btnState
  81. },
  82. getShareCode(code){
  83. this.shareCode = code
  84. },
  85. onShareCode(orderId){
  86. this.$parent.isShareModal = true
  87. this.$parent.btnoRderID = orderId
  88. this.$emit('shareConfirm')
  89. },
  90. btnConfirm(type,order){
  91. let data = {
  92. type:type,
  93. orderId:order.orderID,
  94. order:order
  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. height: auto;
  109. float: right;
  110. position: relative;
  111. .share-code{
  112. width: 200rpx;
  113. height: 64rpx;
  114. line-height: 64rpx;
  115. color: #2A45FF;
  116. text-align: left;
  117. position: absolute;
  118. font-size: $font-size-28;
  119. font-weight: bold;
  120. left: 24rpx;
  121. top: 24rpx;
  122. }
  123. .btn{
  124. width: 160rpx;
  125. height: 64rpx;
  126. margin: 22rpx 0 20rpx 20rpx;
  127. line-height: 64rpx;
  128. font-size:$font-size-26;
  129. color: #999999;
  130. text-align: center;
  131. float: right;
  132. border-radius: 34rpx;
  133. border: 2rpx solid #999999;
  134. &.btn-payment{
  135. line-height: 38rpx;
  136. font-size: 24rpx;
  137. background: #f9a94b;
  138. color: #fff;
  139. border: 2rpx solid #f9a94b;
  140. text{
  141. display: block;
  142. line-height: 15rpx;
  143. }
  144. }
  145. }
  146. .btn-color{
  147. background: $btn-confirm;
  148. // margin: 22rpx 0 22rpx 22rpx;
  149. }
  150. .btn-cancel{
  151. // background:#FFFFFF;
  152. // color: #999999;
  153. // float: left;
  154. // margin: 22rpx 0;
  155. text-align: center;
  156. }
  157. // .btn-delete{
  158. // background:linear-gradient(315deg,rgba(255,163,3,1) 0%,rgba(255,53,1,1) 100%);
  159. // }
  160. // .btn-query{
  161. // background:linear-gradient(135deg,rgba(255,212,129,1) 0%,rgba(198,129,0,1) 100%);
  162. // }
  163. .btn-confirm{
  164. background:#ff7a51;
  165. border-color:#ff7a51;
  166. color: #FFFFFF;
  167. }
  168. .btn-share{
  169. // background:linear-gradient(315deg,rgba(0,212,150,1) 0%,rgba(126,243,174,1) 100%);
  170. position: relative;
  171. .tips{
  172. width: 160rpx;
  173. height: 34rpx;
  174. padding: 10rpx 10rpx;
  175. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  176. box-shadow:0px 2px 4px 0px rgba(0,0,0,0.2);
  177. border-radius: 8rpx;
  178. position: absolute;
  179. color: #FFFFFF;
  180. line-height: 34rpx;
  181. font-size: $font-size-24;
  182. text-align: left;
  183. right: 0;
  184. top: -65rpx;
  185. &:before{
  186. content: "";
  187. width: 25rpx;
  188. height: 25rpx;
  189. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  190. position: absolute;
  191. bottom: -8rpx;
  192. right: 30rpx;
  193. z-index: -1;
  194. transform:rotate(45deg);
  195. }
  196. }
  197. }
  198. }
  199. }
  200. </style>