orderButton.vue 5.6 KB

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