orderListButton.vue 5.9 KB

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