orderButton.vue 5.3 KB

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