cm-details-button.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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-confirm" v-if="btnState.isConfirmation" @click.stop="btnConfirm('confirmation',order)">确认订单</view>
  6. <view class="btn btn-pay" v-if="btnState.isPay" @click.stop="btnConfirm('pay',order)">付款</view>
  7. <view class="btn btn-cancel" v-if="order.checkFlag === 2" @click.stop="btnConfirm('upload',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" @click.stop="btnConfirm('query',order)">查看物流</view>
  15. <view class="btn btn-firm" v-if="btnState.isConfirm" @click.stop="btnConfirm('confirm',order)">
  16. 确认收货
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default{
  23. name:'button',
  24. props:{
  25. status:{
  26. type:Number
  27. },
  28. order: {
  29. type:Object
  30. },
  31. shareCode:{
  32. type:String
  33. },
  34. },
  35. watch:{
  36. status:{
  37. handler:function(val){
  38. this.initData(val)
  39. },
  40. deep:true//对象内部的属性监听,也叫深度监听
  41. }
  42. },
  43. data() {
  44. return{
  45. btnState:this.initStatus(),
  46. isIphoneX:this.$store.state.isIphoneX,
  47. mapStateArr:[
  48. { label: 'isQuery', val: [2, 3, 5, 6, 12, 13, 22, 23, 32, 33], status: true },
  49. { label: 'isDelete', val: [4], status: true },
  50. { label: 'isCancel', val: [0, 11], status: true },
  51. { label: 'isConfirm', val: [33], status: true },
  52. { label: 'isConfirmation', val: [0], status: true },
  53. { label: 'isPay', val: [11, 12, 13, 21, 22, 23], status: true }
  54. ]
  55. }
  56. },
  57. created(){
  58. this.initData(this.status)
  59. },
  60. computed: {
  61. },
  62. methods:{
  63. initData(resVal) {
  64. /**
  65. * @分享按钮统一显示
  66. * @按钮根据状态显示
  67. * @(4、5、7、12、22、23、32)显示[查看物流]按钮,其他隐藏
  68. * @(6)显示[删除订单],其他隐藏
  69. * @(0、111)显示[取消订单],其他隐藏
  70. * @(21,31)只显示分享
  71. * @(13,33)显示[确认收货]和[查看物流]
  72. */
  73. this.btnState = this.initStatus()
  74. this.mapStateArr.forEach(el => {
  75. el.val.forEach(value => {
  76. if(resVal === value){
  77. this.btnState[el.label] = el.status
  78. }
  79. })
  80. })
  81. },
  82. initStatus(){
  83. let btnState= {
  84. isQuery: false,
  85. isDelete: false,
  86. isCancel: false,
  87. isConfirm: false,
  88. isConfirmation:false,
  89. }
  90. return btnState
  91. },
  92. getShareCode(code){
  93. this.shareCode = code
  94. },
  95. onShareCode(){
  96. this.$parent.isShareModal = true
  97. this.$emit('shareConfirm')
  98. },
  99. btnConfirm(type,order){
  100. let data = {
  101. type:type,
  102. shopOrderId:order.shopOrderId,
  103. order:order
  104. }
  105. this.$emit('buttonConfirm',data)
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss">
  111. .button-template{
  112. width: 100%;
  113. height: auto;
  114. position: fixed;
  115. bottom: 0;
  116. left: 0;
  117. background: #FFFFFF;
  118. // z-index: 99999;
  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: 150rpx;
  138. height: 64rpx;
  139. margin:22rpx 15rpx 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>