sellerOrderButton.vue 4.3 KB

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