orderButton.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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 btn-confirm" 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: #FFFFFF;
  140. text-align: center;
  141. border-radius: 6rpx;
  142. float: right;
  143. }
  144. .btn-color{
  145. background: $btn-confirm;
  146. margin: 22rpx 0 22rpx 22rpx;
  147. .tips{
  148. width: 160rpx;
  149. height: 34rpx;
  150. padding: 10rpx 10rpx;
  151. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  152. box-shadow:0px 2px 4px 0px rgba(0,0,0,0.2);
  153. border-radius: 8rpx;
  154. position: absolute;
  155. color: #FFFFFF;
  156. line-height: 34rpx;
  157. font-size: $font-size-24;
  158. text-align: left;
  159. right: 24rpx;
  160. top: -45rpx;
  161. &:before{
  162. content: "";
  163. width: 25rpx;
  164. height: 25rpx;
  165. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  166. position: absolute;
  167. bottom: -8rpx;
  168. right: 30rpx;
  169. z-index: -1;
  170. transform:rotate(45deg);
  171. }
  172. }
  173. }
  174. .btn-cancel{
  175. background:#FFFFFF;
  176. color: #999999;
  177. float: left;
  178. margin: 22rpx 0;
  179. text-align: left;
  180. }
  181. .btn-delete{
  182. background:linear-gradient(315deg,rgba(255,163,3,1) 0%,rgba(255,53,1,1) 100%);
  183. }
  184. .btn-query{
  185. background:linear-gradient(135deg,rgba(255,212,129,1) 0%,rgba(198,129,0,1) 100%);
  186. }
  187. .btn-confirm{
  188. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  189. }
  190. .btn-pay{
  191. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  192. margin-right: 0;
  193. }
  194. .btn-share{
  195. background:linear-gradient(315deg,rgba(0,212,150,1) 0%,rgba(126,243,174,1) 100%);
  196. position: relative;
  197. .tips{
  198. width: 160rpx;
  199. height: 34rpx;
  200. padding: 10rpx 10rpx;
  201. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  202. box-shadow:0px 2px 4px 0px rgba(0,0,0,0.2);
  203. border-radius: 8rpx;
  204. position: absolute;
  205. color: #FFFFFF;
  206. line-height: 34rpx;
  207. font-size: $font-size-24;
  208. text-align: left;
  209. right: 0;
  210. top: -65rpx;
  211. &:before{
  212. content: "";
  213. width: 25rpx;
  214. height: 25rpx;
  215. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  216. position: absolute;
  217. bottom: -8rpx;
  218. right: 30rpx;
  219. z-index: -1;
  220. transform:rotate(45deg);
  221. }
  222. }
  223. }
  224. }
  225. }
  226. </style>