orderButton.vue 4.5 KB

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