orderButton.vue 5.5 KB

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