123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <template>
- <view class="cm-order-control-nav">
- <view class="btn type2" v-if="btnState.cancel" @click.stop="handleClick('cancel')">取消订单</view>
- <view class="btn type2" v-if="btnState.fightDetail" @click.stop="handleClick('fightDetail')">拼团详情</view>
- <!-- <button
- class="btn type1"
- id="fightShare"
- v-if="btnState.fightShare"
- @click.stop="handleClick('fightShare')"
- open-type="share"
- :data-share="orderInfo"
- >
- 邀好友拼团
- </button> -->
- <view class="btn type1" v-if="btnState.fightShare" @click.stop="handleClick('fightShare')">邀好友拼团</view>
- <view class="btn type2" v-if="btnState.delete" @click.stop="handleClick('delete')">删除订单</view>
- <view class="btn type2" v-if="btnState.query" @click.stop="handleClick('query')">查看物流</view>
- <view class="btn type1" v-if="btnState.pay" @click.stop="handleClick('pay')">付款</view>
- <view class="btn type1" v-if="btnState.again" @click.stop="handleClick('again')">再次购买</view>
- <!-- <view class="btn type1" @click="handleClick('again')">再次购买</view> -->
- <view class="btn type2" v-if="btnState.confirm" @click.stop="handleClick('confirm')">确认收货</view>
- </view>
- </template>
- <script>
- export default {
- props: {
- orderInfo: {
- type: Object,
- default: () => {}
- },
- hasBottom: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- mapState: {
- fightDetail: [82, 83],
- fightShare: [81],
- query: [4, 5, 12, 13, 33, 22, 23, 32, 77, 83],
- delete: [6],
- cancel: [0, 111],
- confirm: [33, 83],
- again: [33],
- pay: [11, 12, 13, 21, 22, 23, 111]
- },
- buttonCount: 0
- }
- },
- computed: {
- btnState() {
- return this.initData()
- }
- },
- watch: {
- buttonCount(nVal) {
- this.$emit('change', {
- count: nVal
- })
- }
- },
- methods: {
- /**
- * @分享按钮统一显示
- * @按钮根据状态显示
- * @(4、5、7、12、22、23、32)显示[查看物流]按钮,其他隐藏
- * @(6)显示[删除订单],其他隐藏
- * @(0、111)显示[取消订单],其他隐藏
- * @(21,31)只显示分享
- * @(13,33)显示[确认收货]和[查看物流]
- */
- initData(resVal) {
- const btnState = {}
- const orderStatus = parseInt(this.orderInfo.status)
- for (let key in this.mapState) {
- btnState[key] = this.mapState[key].includes(orderStatus)
- if (btnState[key]) {
- this.buttonCount++
- }
- }
- return btnState
- },
- handleClick(type) {
- this.$emit('confirm', { type, order: this.orderInfo })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .cm-order-control-nav {
- padding: 0 24rpx;
- text-align: right;
- // background: #fff;
- .btn {
- display: inline-block;
- width: 160rpx;
- height: 56rpx;
- border-radius: 32rpx;
- margin-left: 24rpx;
- font-size: 26rpx;
- box-sizing: border-box;
- text-align: center;
- line-height: 54rpx;
- vertical-align: middle;
- &.type1 {
- border: 1rpx solid #ff457b;
- color: #ff457b;
- }
- &.type2 {
- border: 1rpx solid #333;
- color: #333;
- }
- }
- }
- </style>
|