sellerOrderButton.vue 4.9 KB

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