orderButton.vue 5.7 KB

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