sellerDetaileButton.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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-cancel" v-if="btnState.isCancel" @click.stop="btnConfirm('cancel',order)">取消订单</view>
  6. <view class="btn btn-cancel" v-if="btnState.isDelete" @click.stop="btnConfirm('delete',order)">删除订单</view>
  7. <view class="btn btn-color" @click.stop="onShareCode">
  8. <view class="tips" v-if="shareCode">分享码:{{shareCode}}</view>
  9. 分享订单
  10. </view>
  11. <view class="btn btn-color" v-if="btnState.isConfirm" @click.stop="btnConfirm('confirm',order)">确认订单</view>
  12. <view class="btn btn-color" v-if="btnState.isPay && ableUserMoney > 0" @click.stop="btnConfirm('balance',order)">余额抵扣</view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default{
  18. name:"button",
  19. props:{
  20. status:{
  21. type:Number
  22. },
  23. order: {
  24. type:Object
  25. },
  26. ableUserMoney:{
  27. type:Number
  28. },
  29. shareCode:{
  30. type:String
  31. }
  32. },
  33. watch:{
  34. status:{
  35. handler:function(val){
  36. this.initData(val)
  37. },
  38. deep:true//对象内部的属性监听,也叫深度监听
  39. }
  40. },
  41. data() {
  42. return{
  43. btnState:this.initStatus(),
  44. isIphoneX:this.$store.state.isIphoneX,
  45. mapStateArr:[
  46. {label:'isDelete',val:[6],status: true},
  47. {label:'isCancel',val:[0,111],status: true},
  48. {label:'isConfirm',val:[0],status: true},
  49. {label:'isPay',val:[11,12,13,21,22,23,111],status: true},
  50. ]
  51. }
  52. },
  53. created(){
  54. this.initData(this.status)
  55. },
  56. computed: {
  57. },
  58. methods:{
  59. initData(resVal) {
  60. /**
  61. * @分享按钮统一显示
  62. * @按钮根据状态显示
  63. * @(4、5、7、12、22、23、32)显示[查看物流]按钮,其他隐藏
  64. * @(6)显示[删除订单],其他隐藏
  65. * @(0、111)显示[取消订单],其他隐藏
  66. * @(21,31)只显示分享
  67. * @(13,33)显示[确认收货]和[查看物流]
  68. */
  69. this.btnState = this.initStatus()
  70. this.mapStateArr.forEach(el => {
  71. el.val.forEach(value => {
  72. if(resVal === value){
  73. this.btnState[el.label] = el.status
  74. //console.log(this.btnState[el.label]);
  75. }
  76. })
  77. })
  78. },
  79. initStatus(){
  80. let btnState= {
  81. isQuery: false,
  82. isDelete: false,
  83. isCancel: false,
  84. isConfirm: false,
  85. isPay: 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: 10rpx;
  142. float: right;
  143. }
  144. .btn-color{
  145. background: $btn-confirm;
  146. margin: 20rpx 0 20rpx 20rpx;
  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-share{
  191. background:linear-gradient(315deg,rgba(0,212,150,1) 0%,rgba(126,243,174,1) 100%);
  192. margin-right: 0;
  193. position: relative;
  194. .tips{
  195. width: 160rpx;
  196. height: 34rpx;
  197. padding: 10rpx 10rpx;
  198. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  199. box-shadow:0px 2px 4px 0px rgba(0,0,0,0.2);
  200. border-radius: 8rpx;
  201. position: absolute;
  202. color: #FFFFFF;
  203. line-height: 34rpx;
  204. font-size: $font-size-24;
  205. text-align: left;
  206. right: 0;
  207. top: -65rpx;
  208. &:before{
  209. content: "";
  210. width: 25rpx;
  211. height: 25rpx;
  212. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  213. position: absolute;
  214. bottom: -8rpx;
  215. right: 30rpx;
  216. z-index: -1;
  217. transform:rotate(45deg);
  218. }
  219. }
  220. }
  221. }
  222. }
  223. </style>