orderListButton.vue 5.0 KB

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