sellerOrderButton.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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="btnagainConfirm('again',orderID,serviceProviderId)">再来一单</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. btnagainConfirm(type,id,serviceid){
  101. let data = {
  102. type:type,
  103. orderId:id,
  104. serviceProviderId:serviceid,
  105. }
  106. this.$emit('buttonConfirm',data)
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss">
  112. .button-template{
  113. width: 100%;
  114. height: auto;
  115. float: left;
  116. background: #FFFFFF;
  117. .button-content{
  118. // width: 702rpx;
  119. height: auto;
  120. float: right;
  121. position: relative;
  122. margin: 20rpx 0;
  123. .share-code{
  124. width: 200rpx;
  125. height: 64rpx;
  126. line-height: 64rpx;
  127. color: #2A45FF;
  128. text-align: left;
  129. position: absolute;
  130. font-size: $font-size-28;
  131. font-weight: bold;
  132. left: 24rpx;
  133. top: 24rpx;
  134. }
  135. .btn{
  136. width: 160rpx;
  137. height: 64rpx;
  138. line-height: 64rpx;
  139. font-size:$font-size-26;
  140. color: #FFFFFF;
  141. text-align: center;
  142. border-radius:32rpx;
  143. // float: right;
  144. display: inline-block;
  145. }
  146. .btn-color{
  147. background: $btn-confirm;
  148. // margin: 22rpx 0 22rpx 22rpx;
  149. }
  150. .btn-cancel{
  151. border: 2rpx solid #999999;
  152. background:#FFFFFF;
  153. color: #666666;
  154. // float: left;
  155. margin-right: 15rpx;
  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:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  165. }
  166. .btn-share{
  167. background:linear-gradient(315deg,rgba(0,212,150,1) 0%,rgba(126,243,174,1) 100%);
  168. margin-right: 0;
  169. position: relative;
  170. .tips{
  171. width: 160rpx;
  172. height: 34rpx;
  173. padding: 10rpx 10rpx;
  174. background:#E15616;
  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:#E15616;
  188. position: absolute;
  189. bottom: -8rpx;
  190. left: 30rpx;
  191. z-index: -1;
  192. transform:rotate(45deg);
  193. }
  194. }
  195. }
  196. }
  197. }
  198. </style>