sellerDetaileButton.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 && !rechargeGoods" @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. rechargeGoods:{
  30. type:Boolean
  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:'isDelete',val:[6],status: true},
  50. {label:'isCancel',val:[0,111],status: true},
  51. {label:'isConfirm',val:[0],status: true},
  52. {label:'isPay',val:[11,12,13,21,22,23,111],status: true},
  53. ]
  54. }
  55. },
  56. created(){
  57. console.log(this.rechargeGoods);
  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. //console.log(this.btnState[el.label]);
  79. }
  80. })
  81. })
  82. },
  83. initStatus(){
  84. let btnState= {
  85. isQuery: false,
  86. isDelete: false,
  87. isCancel: false,
  88. isConfirm: false,
  89. isPay: 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. width: 702rpx;
  121. padding:0 24rpx;
  122. height: auto;
  123. float: left;
  124. position: relative;
  125. .share-code{
  126. width: 200rpx;
  127. height: 64rpx;
  128. line-height: 64rpx;
  129. color: #2A45FF;
  130. text-align: left;
  131. position: absolute;
  132. font-size: $font-size-28;
  133. font-weight: bold;
  134. left: 24rpx;
  135. top: 24rpx;
  136. }
  137. .btn{
  138. width: 160rpx;
  139. height: 64rpx;
  140. margin:22rpx;
  141. line-height: 64rpx;
  142. font-size:$font-size-26;
  143. color: #FFFFFF;
  144. text-align: center;
  145. border-radius: 6rpx;
  146. float: right;
  147. }
  148. .btn-color{
  149. background: $btn-confirm;
  150. margin: 20rpx 0 20rpx 20rpx;
  151. .tips{
  152. width: 160rpx;
  153. height: 34rpx;
  154. padding: 10rpx 10rpx;
  155. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  156. box-shadow:0px 2px 4px 0px rgba(0,0,0,0.2);
  157. border-radius: 8rpx;
  158. position: absolute;
  159. color: #FFFFFF;
  160. line-height: 34rpx;
  161. font-size: $font-size-24;
  162. text-align: left;
  163. right: 24rpx;
  164. top: -45rpx;
  165. &:before{
  166. content: "";
  167. width: 25rpx;
  168. height: 25rpx;
  169. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  170. position: absolute;
  171. bottom: -8rpx;
  172. right: 30rpx;
  173. z-index: -1;
  174. transform:rotate(45deg);
  175. }
  176. }
  177. }
  178. .btn-cancel{
  179. background:#FFFFFF;
  180. color: #999999;
  181. float: left;
  182. margin: 22rpx 0;
  183. text-align: left;
  184. }
  185. .btn-delete{
  186. background:linear-gradient(315deg,rgba(255,163,3,1) 0%,rgba(255,53,1,1) 100%);
  187. }
  188. .btn-query{
  189. background:linear-gradient(135deg,rgba(255,212,129,1) 0%,rgba(198,129,0,1) 100%);
  190. }
  191. .btn-confirm{
  192. background:linear-gradient(315deg,rgba(231,0,0,1) 0%,rgba(255,104,1,1) 100%);
  193. }
  194. .btn-share{
  195. background:linear-gradient(315deg,rgba(0,212,150,1) 0%,rgba(126,243,174,1) 100%);
  196. margin-right: 0;
  197. position: relative;
  198. .tips{
  199. width: 160rpx;
  200. height: 34rpx;
  201. padding: 10rpx 10rpx;
  202. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  203. box-shadow:0px 2px 4px 0px rgba(0,0,0,0.2);
  204. border-radius: 8rpx;
  205. position: absolute;
  206. color: #FFFFFF;
  207. line-height: 34rpx;
  208. font-size: $font-size-24;
  209. text-align: left;
  210. right: 0;
  211. top: -65rpx;
  212. &:before{
  213. content: "";
  214. width: 25rpx;
  215. height: 25rpx;
  216. background:linear-gradient(45deg,rgba(0,0,0,1) 0%,rgba(87,87,87,1) 100%);
  217. position: absolute;
  218. bottom: -8rpx;
  219. right: 30rpx;
  220. z-index: -1;
  221. transform:rotate(45deg);
  222. }
  223. }
  224. }
  225. }
  226. }
  227. </style>