orderButton.vue 5.6 KB

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