orderButton.vue 5.1 KB

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