sellerOrderButton.vue 4.3 KB

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