captain-ui
Version:
有赞vue wap业务组件库
192 lines (170 loc) • 5.77 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import "vant/es/tag/style";
import _Tag from "vant/es/tag";
import "vant/es/card/style";
import _Card from "vant/es/card";
import urlHelper from '@youzan/utils/url/helper';
import ActionBtns from './action_btns';
import { btns } from './config';
export default {
render: function render() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c('div', {
staticClass: "cap-order-item",
on: {
"click": _vm.onItemClick
}
}, [_c('div', {
staticClass: "cap-order-item__head"
}, [_c('div', [_vm._v("\n " + _vm._s(_vm.order.team_name) + "\n "), _c('span', {
staticClass: "cap-order-item__state"
}, [_vm._v("\n " + _vm._s(_vm.order.order_state_str) + "\n ")])]), _c('div', {
staticClass: "cap-order-item__order-no"
}, [_vm._v("\n 订单编号:" + _vm._s(_vm.order.order_no) + "\n ")])]), _c('div', {
staticClass: "cap-order-item__body"
}, [_c('van-card', {
attrs: {
"thumb": _vm.imgUrl
}
}, [_c('div', {
staticClass: "van-card__row",
attrs: {
"slot": "title"
},
slot: "title"
}, [_c('h4', {
staticClass: "van-card__title"
}, [_vm._v(_vm._s(_vm.firstGoods.title))]), _c('span', {
staticClass: "van-card__price"
}, [_vm._v("¥ " + _vm._s(_vm.firstGoods.pay_price))])]), _c('div', {
staticClass: "van-card__row",
attrs: {
"slot": "desc"
},
slot: "desc"
}, [_c('h4', {
staticClass: "van-card__desc"
}, [_vm._v(_vm._s(_vm.firstGoodsSKU))]), _c('span', {
staticClass: "van-card__num"
}, [_vm._v("x " + _vm._s(_vm.firstGoods.num))])]), _c('div', {
staticClass: "van-card__row",
attrs: {
"slot": "tags"
},
slot: "tags"
}, [_vm.order.order_type_str ? _c('van-tag', {
attrs: {
"type": "danger"
}
}, [_vm._v("\n " + _vm._s(_vm.order.order_type_str) + "\n ")]) : _vm._e()], 1), _c('div', {
attrs: {
"slot": "footer"
},
slot: "footer"
})])], 1), _c('div', {
staticClass: "cap-order-item__footer"
}, [_vm.order.items.length > 1 ? _c('div', {
staticClass: "cap-order-item__more"
}, [_vm._v("\n 查看全部" + _vm._s(_vm.order.items.length) + "件商品\n ")]) : _vm._e(), _c('div', {
staticClass: "cap-order-item__total-price"
}, [_vm._v("\n 合计:"), _c('span', [_vm._v("¥ " + _vm._s(_vm.order.real_pay))])]), !_vm.$slots.btns && _vm.actionBtns.length > 0 ? _c('cap-order-btns', {
attrs: {
"action-btns": _vm.actionBtns
},
on: {
"click": _vm.onBtnClick
}
}) : _vm._t("btns")], 2)]);
},
name: 'cap-order-list-item',
components: {
'van-card': _Card,
'van-tag': _Tag,
'cap-order-btns': ActionBtns
},
props: {
order: Object
},
computed: {
firstGoods: function firstGoods() {
var firstItemData = this.order.items[0];
return firstItemData;
},
firstGoodsSKU: function firstGoodsSKU() {
// 如果直接有描述语,就不需要再计算
if (this.firstGoods.sku_str) {
return this.firstGoods.sku_str;
}
var sku = this.firstGoods.sku || {};
var skuStr = '';
sku.forEach(function (item) {
skuStr += " " + (item.v || item.value);
});
return skuStr;
},
imgUrl: function imgUrl() {
return urlHelper.getCdnImageUrl(this.firstGoods.image_url, '!200x0.jpg');
},
orderTypeStr: function orderTypeStr() {
// 如果有btns的slot,就返回,不再需要计算
if (this.$slots.btns) {
return;
}
var orderTypeStr = this.order.order_state; // 代付未支付
if (+this.order.buy_way === 7) {
orderTypeStr = 'peerpay';
} // 送礼
if (this.order.gift_url) {
orderTypeStr = 'gift';
} // 收银台
// '6', '7', '8', '51', '52' 为收银台的订单类型,如有变动需要后端确认
if (['6', '7', '8', '51', '52'].indexOf(this.order.order_type) > -1) {
orderTypeStr = 'cashier_sign';
} // 酒店商品商家接单,不显示物流
if (+this.order.order_type === 35 && (orderTypeStr === 'send' || orderTypeStr === 'sign')) {
orderTypeStr = 'receive_order';
}
return orderTypeStr;
},
actionBtns: function actionBtns() {
// 如果有btns的slot,就返回,不再需要计算
if (this.$slots.btns) {
return;
}
var actionBtns = btns[this.orderTypeStr] || [];
var isShowReview = +this.order.is_show_review === 1;
actionBtns = actionBtns.slice();
if (isShowReview) {
actionBtns.push(this.order.has_all_reviewed ? 'reviewed' : 'review');
} // isAllowLaterReceive 为1, 可以显示延迟发货
if (+this.order.isAllowLaterReceive === 1) {
actionBtns.push('extend-receive');
}
if (+this.order.isAllowConfirmReceive === 1) {
actionBtns.push('confirm-receive');
}
if (+this.order.isAllowBuyAgain === 1) {
actionBtns.push('buy-again');
} // 单人代付未付款可取消。
if (+this.order.buy_way === 7 && this.order.pay_strategy === 1 && this.order.state < 5) {
actionBtns.unshift('cancel');
}
return actionBtns;
}
},
methods: {
onBtnClick: function onBtnClick(event) {
this.$emit('btnclick', {
type: event,
order: _extends({}, this.order)
});
},
onItemClick: function onItemClick() {
this.$emit('itemclick', {
order: _extends({}, this.order)
});
}
}
};