123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <template name="button">
- <view class="button-template">
- <!-- 底部按钮 -->
- <view class="button-content">
- <view class="btn btn-cancel" v-if="btnState.isCancel" @click.stop="btnConfirm('cancel',orderInfo)">关闭订单</view>
- <view class="btn btn-delete" v-if="btnState.isDelete" @click.stop="btnConfirm('delete',orderInfo)">删除订单</view>
- <view class="btn btn-query" v-if="btnState.isRefund" @click.stop="btnConfirm('refund',orderInfo)">订单发货</view>
- <view class="btn btn-confirm" v-if="btnState.isQuery" @click.stop="btnConfirm('query',orderInfo)">订单跟踪</view>
- </view>
- </view>
- </template>
- <script>
- export default{
- name:"button",
- props:{
- status: {
- type:Number
- },
- orderInfo:{
- type:Object
- }
- },
- data() {
- return{
- isShare:true,
- shareCode:'',
- btnState:this.initStatus(),
- mapStateArr:[
- {label:'isCancel',val:[0],status: true},
- {label:'isDelete',val:[4],status: true},
- {label:'isQuery',val:[2,3],status: true},
- {label:'isRefund',val:[1],status: true},
- ]
- }
- },
- created(){
- this.initData(this.status)
- },
- computed: {
-
- },
- watch:{
- status:{
- handler:function(val){
- this.initData(val)
- },
- deep:true//对象内部的属性监听,也叫深度监听
- }
- },
- methods:{
- initData(resVal) {
- /**
- * @分享按钮统一显示
- * @按钮根据状态显示
- * @(4、5、7、12、22、23、32)显示[查看物流]按钮,其他隐藏
- * @(6)显示[删除订单],其他隐藏
- * @(0、111)显示[取消订单],其他隐藏
- * @(21,31)只显示分享
- * @(13,33)显示[确认收货]和[查看物流]
- */
- this.btnState = this.initStatus()
- this.mapStateArr.forEach(el => {
- el.val.forEach(value => {
- if(resVal === value){
- this.btnState[el.label] = el.status
- }
- })
- })
- },
- initStatus(){
- let btnState= {
- isQuery: false,
- isDelete: false,
- isCancel: false,
- isConfirm: false,
- isRefund: false,
- isReturned: false,
- isConfirmation:false,
- }
- return btnState
- },
- btnConfirm(type,order){
- let data = {
- type:type,
- order:order
- }
- this.$emit('buttonConfirm',data)
- }
- }
- }
- </script>
- <style lang="scss">
- .button-template{
- width: 100%;
- height: auto;
- float: left;
- background: #FFFFFF;
- .button-content{
- width: 100%;
- height: auto;
- float: left;
- position: relative;
- padding:0 20rpx;
- .share-code{
- width: 200rpx;
- height: 64rpx;
- line-height: 64rpx;
- color: #2A45FF;
- text-align: left;
- position: absolute;
- font-size: $font-size-28;
- font-weight: bold;
- left: 24rpx;
- top: 24rpx;
- }
- .btn{
- width: 160rpx;
- height: 64rpx;
- margin:22rpx;
- line-height: 64rpx;
- font-size:$font-size-26;
- text-align: center;
- border-radius: 6rpx;
- float: right;
-
- }
- .btn-cancel{
- background-color:#f6f6f6;
- color: #333333;
- }
- .btn-delete{
- background-color:#f6f6f6;
- color: #333333;
- }
- .btn-query{
- background-color:#FF5000;
- color: #FFFFFF;
- }
- .btn-confirm{
- background-color:#4688fa;
- color: #FFFFFF;
- }
- .btn-pay{
- background-color:#4688fa;
- color: #FFFFFF;
- margin-right: 0;
- }
- }
- }
- </style>
|