orderListButton.vue 6.0 KB

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