orderButton.vue 4.6 KB

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