Authored by shuaiguo

Merge remote-tracking branch 'refs/remotes/origin/feature/saler_coupon' into develop

... ... @@ -4,4 +4,9 @@ export default [
path: '/xianyu/home/coupon.html',
component: () => import(/* webpackChunkName: "home.coupon" */ './list'),
},
{
name: 'SalerCoupon',
path: '/xianyu/home/salerCoupon.html',
component: () => import(/* webpackChunkName: "home.coupon" */ './saler-list'),
},
];
... ...
... ... @@ -55,6 +55,10 @@
<div class="couponErrorPageImage"></div>
暂无优惠券
</div>
<div class="saler-wrapper" @click="jumpToSalerList">
<div class="saler-img"></div>
<div class="saler-text">卖家劵</div>
</div>
</LayoutApp>
</template>
... ... @@ -70,12 +74,12 @@ export default {
components: {EmptyList},
activated: function() {
this.type = 'unused';
this.fetchCouponList({type: 'unused', isReset: true}).then(r=>{
this.fetchCouponList({type: 'unused', userType: this.userType, isReset: true}).then(r=>{
this.list = r;
this.showEmpty = !(r && r.length);
});
this.fetchCouponList({type: 'used', isReset: true});
this.fetchCouponList({type: 'overtime', isReset: true});
this.fetchCouponList({type: 'used', userType: this.userType, isReset: true});
this.fetchCouponList({type: 'overtime', userType: this.userType, isReset: true});
},
data() {
return {
... ... @@ -87,6 +91,7 @@ export default {
pullDownRefresh: false
},
type: 'unused',
userType: 0, // 0:全部 1:买家 2:卖家
list: [],
showEmpty: false
};
... ... @@ -114,7 +119,7 @@ export default {
},
async onPullingUp() {
this.list = await this.fetchCouponList({type: this.type});
this.list = await this.fetchCouponList({type: this.type, userType: this.userType});
this.showEmpty = this[this.type].isEmpty;
},
... ... @@ -126,6 +131,12 @@ export default {
type: 8
}
});
},
jumpToSalerList() {
this.$router.push({
name: 'SalerCoupon',
});
}
},
computed: {
... ... @@ -342,6 +353,37 @@ export default {
}
}
.saler-wrapper {
background: #002B47;
width: 160px;
height: 60px;
border-top-left-radius: 45px;
border-bottom-left-radius: 45px;
position: absolute;
right: 0;
bottom: 80px;
display: flex;
flex-direction: row;
align-items: center;
.saler-img {
background: url(~statics/image/coupon/mjq_ic@3x.png) no-repeat;
background-size: contain;
width: 36px;
height: 24px;
margin-left: 26px;
}
.saler-text {
font-size: 24px;
line-height: 60px;
color: #FFFFFF;
letter-spacing: 0;
margin-left: 10px;
text-align: center;
}
}
.empty-wrapper {
width: 100%;
margin: auto 0;
... ...
<template>
<LayoutApp title="卖家优惠券">
<div class="tab">
<div class="item right-line" :class="type ==='unused' ? 'item-selected' : 'item-default'"
@click="onChangeList('unused')">未使用{{unused.total && '('+ unused.total + ')' || null}}
</div>
<div class="item right-line" :class="type ==='used' ? 'item-selected' : 'item-default'"
@click="onChangeList('used')">已使用{{used.total && '('+ used.total + ')' || null}}
</div>
<div class="item" :class="type ==='overtime' ? 'item-selected' : 'item-default'"
@click="onChangeList('overtime')">已失效{{overtime.total && '('+ overtime.total + ')' || null}}
</div>
</div>
<LayoutScroll ref="couponlist"
class="coupon-list"
:loading="loadingOptions"
@pulling-up="onPullingUp" v-show="!showEmpty">
<div class="item" v-for="(item,index) in list">
<div :class="type === 'unused' ? 'item-bg' : 'item-gray-bg'">
<div class="item-left">
<div class="item-price" :class="type !== 'unused' && 'gray'">{{item.coupon_value}}</div>
<div class="item-rule" v-if="item.use_rule" :class="type !== 'unused' && 'gray'">{{item.use_rule}}</div>
</div>
<div class="item-right">
<div class="item-name" :class="type !== 'unused' && 'gray'">
<span class="item-type" :class="type !== 'unused' && 'gray'">[{{item.coupon_type_name}}]</span>
{{item.coupon_name}}
</div>
<div class="item-time" :class="type !== 'unused' && 'gray'">{{item.coupon_validity}}</div>
<div class="item-desc-btn" :class="type !== 'unused' && 'gray'" @click="handleShowNotice(item,index)">
使用说明
<div class="down" :class="item.showNotice && 'up'"></div>
</div>
<div class="time-up" v-if="type ==='unused' && item.is_expired_soon === 'Y'"></div>
<div class="item-used-flag" v-if="type === 'used'"></div>
<div class="item-use" v-if="type === 'unused'" @click="goUseList(item.coupon_token)">
立即使用
</div>
<div class="item-overtime-flag" v-if="type === 'overtime'"></div>
</div>
</div>
<div class="notice" v-show="item.showNotice">
<div class="shadow"></div>
<div v-for="no in item.notes" class="row">
<div class="mr10">•</div>
<div class="no-text">{{no}}</div>
</div>
</div>
</div>
</LayoutScroll>
<div
class="empty-wrapper"
v-show="showEmpty"
>
<div class="couponErrorPageImage"></div>
暂无优惠券
</div>
</LayoutApp>
</template>
<script>
import {createNamespacedHelpers} from 'vuex';
import EmptyList from '../../../components/ufo-no-item';
const {mapState, mapActions} = createNamespacedHelpers('home/salerCoupon');
export default {
name: 'Coupon',
components: {EmptyList},
activated: function() {
this.type = 'unused';
this.fetchSalerCouponList({type: 'unused', userType: this.userType, isReset: true}).then(r=>{
this.list = r;
this.showEmpty = !(r && r.length);
});
this.fetchSalerCouponList({type: 'used', userType: this.userType, isReset: true});
this.fetchSalerCouponList({type: 'overtime', userType: this.userType, isReset: true});
},
data() {
return {
scrollOptions: {
bounce: {
top: false
},
pullUpLoad: true,
pullDownRefresh: false
},
type: 'unused',
userType: 2, // 0:全部 1:买家 2:卖家
list: [],
showEmpty: false
};
},
methods: {
...mapActions(['fetchSalerCouponList']),
onChangeList(type) {
// 切换tab
this.type = type;
// 切换list
this.list = this[type].list;
this.showEmpty = this[type].isEmpty;
this.$refs.couponlist.scrollTo(0, 0);
},
handleShowNotice(item, index) {
if (item.showNotice !== void(0)) {
item.showNotice = !item.showNotice;
} else {
item.showNotice = true;
}
this.$set(this.list, index, item);
},
async onPullingUp() {
this.list = await this.fetchSalerCouponList({type: this.type, userType: this.userType});
this.showEmpty = this[this.type].isEmpty;
},
goUseList(coupon_token) {
return this.$router.push({
name: 'List',
query: {
coupon_token,
type: 8
}
});
}
},
computed: {
...mapState(['unused', 'used', 'overtime']),
loadingOptions() {
let info = this[this.type];
return {
hide: !this.list || !this.list.length,
noMore: info && info.reachedEnd
}
}
},
};
</script>
<style lang="scss" scoped>
.tab {
position: relative;
display: flex;
width: 100%;
height: 88px;
padding: 14px 0;
align-items: center;
z-index: 9999;
background: #fff;
.item {
font-size: 28px;
flex: 1;
height: 60px;
text-align: center;
line-height: 60px;
}
.right-line {
border-right: 1px solid #E0E0E0;
}
.item-default {
color: #B0B0B0;
}
.item-selected {
color: #444444;
}
}
.coupon-list {
background: #f5f5f5;
.item {
width: 100%;
margin-top: 20px;
}
.item-bg {
background: url(~statics/image/coupon/bg@3x.png) no-repeat;
width: 710px;
height: 200px;
background-size: cover;
margin: 0 auto;
display: flex;
position: relative;
z-index: 10;
}
.down {
transform: rotate(0deg);
background: url(~statics/image/coupon/down@3x.png) no-repeat;
background-size: contain;
width: 20px;
height: 20px;
margin-left: 10px;
margin-top: 4px;
}
.up {
margin-top: -8px !important;
transform: rotate(180deg);
}
.shadow {
opacity: 0.7;
background: #fff;
position: absolute;
top: 0;
left: 0;
height: 2px;
width: 702px;
box-shadow: #ddd 0 1px 10px 10px;
}
.item-left {
width: 230px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.item-price {
font-size: 72px;
font-weight: bold;
color: #002B47;
}
.item-rule {
font-size: 24px;
margin-top: 4px;
color: #002B47;
}
}
.item-right {
margin-left: 6px;
.item-name {
font-size: 24px;
color: #222;
margin-top: 22px;
width: 320px;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
height: 60px;
}
.item-type {
color: #002B47;
}
.item-time {
margin-top: 10px;
font-size: 22px;
color: #999;
}
.item-desc-btn {
margin-top: 26px;
font-size: 22px;
color: #999;
display: flex;
align-items: center;
}
.time-up {
background: url(~statics/image/coupon/time-up@3x.png) no-repeat;
background-size: cover;
position: absolute;
top: 0;
right: 0;
width: 80px;
height: 80px;
}
.item-used-flag {
background: url(~statics/image/coupon/used@3x.png) no-repeat;
background-size: cover;
position: absolute;
right: 30px;
width: 130px;
height: 130px;
top: 30px;
}
.item-overtime-flag {
background: url(~statics/image/coupon/overtime@3x.png) no-repeat;
background-size: cover;
position: absolute;
right: 30px;
width: 130px;
height: 130px;
top: 30px;
}
}
.gray {
color: #ccc !important;
}
.item-gray-bg {
background: url(~statics/image/coupon/bg-gray@3x.png) no-repeat;
width: 710px;
height: 200px;
background-size: cover;
margin: 0 auto;
display: flex;
position: relative;
z-index: 10;
}
.notice {
opacity: 0.7;
background: #fff;
margin: -10px 20px 0 20px;
padding: 36px 26px 26px 26px;
position: relative;
.mr10 {
margin-right: 10px;
}
.row {
display: flex;
margin-bottom: 8px;
}
.no-text {
font-size: 22px;
color: #444;
}
}
}
.empty-wrapper {
width: 100%;
margin: auto 0;
position: absolute;
top: 0;
bottom: 0;
background: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
font-size: 28px;
color: #b0b0b0;
}
.couponErrorPageImage {
background: url(~statics/image/coupon/no_coupon.png) no-repeat;
background-size: cover;
width: 208px;
height: 130px;
margin-bottom: 30px;
}
.item-use {
position: absolute;
right: 20px;
bottom: 20px;
width: 130px;
height: 50px;
border: 1px solid #444;
border-radius: 25px;
justify-content: center;
align-items: center;
font-size: 20px;
color: #444;
display: flex;
}
</style>
... ...
... ... @@ -39,6 +39,29 @@
<span class="iconfont iconwarn"></span>
<p>{{ stateCenterAddress.deliverDesc }}</p>
</div>
<!-- 新增价格信息 -->
<div class="coupon-wrapper" v-if="orderFeeInfo.couponInfo" @click="onCouponClick">
<div class="title">优惠券<span class="desc">{{orderFeeInfo.couponInfo.desc || ''}}</span></div>
<div><span class="price">{{orderFeeInfo.couponInfo.coupon_amount_str || '¥0'}}</span><i class="iconfont iconright icon-right"></i></div>
</div>
<div class="price-info item-wrapper" v-if="orderFeeInfo.platformFee">
<p class="platform-fee">
<span class="label"
>平台费用:</span>
<span>{{orderFeeInfo.platformFee.amount || '¥0'}}</span>
</p>
<p class="delivery-fee">
<span class="label">银行转账费(1%):</span>
<span>{{orderFeeInfo.bankTransferFee || '¥0'}}</span>
</p>
<p>
<span class="label">实收入:</span>
<span class="pay-price">{{orderFeeInfo.income || '¥0'}}</span>
</p>
</div>
<div class="submit-warp">
<div class="contract-check">
<i
... ... @@ -69,46 +92,43 @@
</template>
<script>
import { get } from "lodash";
import { Button, Input } from "cube-ui";
import { createNamespacedHelpers } from "vuex";
import { get } from 'lodash';
import { Button, Input } from 'cube-ui';
import { createNamespacedHelpers } from 'vuex';
const { mapState, mapActions } = createNamespacedHelpers("order/orderDeliver");
const { mapState, mapActions } = createNamespacedHelpers('order/orderDeliver');
export default {
name: "OrderDeliver",
name: 'OrderDeliver',
data() {
return {
canCopy: false,
canScan: false,
centerAddress: {},
expressCode: "",
readContract: false
expressCode: '',
readContract: false,
};
},
components: {
CubeButton: Button,
CubeInput: Input
},
created() {
let { skup, code } = this.$route.params || {};
this.orderCode = code;
if (process.env.VUE_ENV !== "server") {
if (process.env.VUE_ENV !== 'server') {
this.fetchAppraiseAddress({
skup,
orderCode: code
});
}
},
computed: {
...mapState(["appraiseAddress"]),
stateCenterAddress() {
if (!this.centerAddress.address) {
this.centerAddress = get(this.appraiseAddress, this.orderCode) || {};
}
return this.centerAddress;
},
deliverDisable() {
return !(this.expressCode && this.readContract);
}
// 第一次进入发货页面,获取费用
this.computeWithCoupon({
orderCode: code,
couponCode: ''
});
},
mounted() {
if (this.$yoho.isAliApp) {
... ... @@ -120,24 +140,24 @@ export default {
this.fetchAppraiseAddressChangeNotice({ orderCode: this.orderCode }).then(
res => {
let isChanged = get(res, "data.isChanged");
let isForceShow = get(res, "data.isForceShow");
let isChanged = get(res, 'data.isChanged');
let isForceShow = get(res, 'data.isForceShow');
if (!isChanged && !isForceShow) {
return;
}
let {
title = "",
title = '',
tips,
alert_address_name,
alert_address,
alert_mobile
} = res.data || {};
let info = [
alert_address_name || "",
alert_address || "",
alert_mobile || ""
alert_address_name || '',
alert_address || '',
alert_mobile || ''
];
if (isChanged && tips) {
... ... @@ -146,41 +166,40 @@ export default {
this.$createDialog(
{
type: "alert",
type: 'alert',
confirmBtn: {
text: "我知道了"
text: '我知道了'
},
onConfirm() {
// Todo report()
console.log("Todo Report", res.data);
console.log('Todo Report', res.data);
}
},
createElement => {
return [
createElement(
"div",
'div',
{
class: {
"dg-notice-content": true
'dg-notice-content': true
},
slot: "content"
slot: 'content'
},
[
createElement(
"div",
'div',
{
class: {
"dg-notice-content-title": true
'dg-notice-content-title': true
}
},
isChanged ? "仓库调整公告" : title
isChanged ? '仓库调整公告' : title
),
...info.map(val => {
return createElement(
"p",
'p',
{
class: {
"dg-notice-content-info": true
'dg-notice-content-info': true
}
},
val
... ... @@ -194,17 +213,68 @@ export default {
}
);
},
computed: {
...mapState(['appraiseAddress', 'orderFeeInfo', 'selectCouponCode']),
stateCenterAddress() {
if (!this.centerAddress.address) {
this.centerAddress = get(this.appraiseAddress, this.orderCode) || {};
}
return this.centerAddress;
},
deliverDisable() {
return !(this.expressCode && this.readContract);
}
},
methods: {
...mapActions([
"fetchAppraiseAddress",
"fetchAppraiseAddressChangeNotice",
"deliverOrderToDepot"
'fetchAppraiseAddress',
'fetchAppraiseAddressChangeNotice',
'deliverOrderToDepot',
'computeWithCoupon',
'changeSelectCouponList'
]),
onCouponClick() {
let vm = this;
this.couponListActionSheet = this.$createOrderCouponList({
$props: {
data: this.orderFeeInfo.couponList,
},
onItemClickAction(item) {
vm.onCouponItemClick(item);
},
onConfirmAction() {
vm.couponListActionSheet.hide();
vm.compute();
},
onCloseAction() {
vm.compute();
}
}).show();
},
onCouponItemClick(item) {
this.changeSelectCouponList(item);
},
compute() {
return this.computeWithCoupon({
orderCode: this.orderCode,
couponCode: this.selectCouponCode
}).then(result => {
if (result.code !== 200) {
this.$createToast({
time: 1500,
txt: result.message,
type: 'txt'
}).show();
}
});
},
toast(msg, time = 1500) {
this.$createToast &&
this.$createToast({
txt: msg,
type: "txt",
type: 'txt',
time
}).show();
},
... ... @@ -221,7 +291,7 @@ export default {
},
scanCode() {
if (window && window.WindVane) {
window.WindVane.call("Scancode", "scan", {}, e => {
window.WindVane.call('Scancode', 'scan', {}, e => {
if (e && e.code) {
this.expressCode = e.code;
}
... ... @@ -246,23 +316,19 @@ export default {
this.deliverOrderToDepot({
orderCode: this.orderCode,
wayBillCode: this.expressCode,
depotNum: this.stateCenterAddress.id
depotNum: this.stateCenterAddress.id,
couponCode: this.selectCouponCode,
}).then(res => {
if (res.code === 200) {
this.$router.go(-1);
// Todo report()
} else {
this.toast(res.message || "网络异常,请稍后重试");
this.toast(res.message || '网络异常,请稍后重试');
}
});
} else {
this.toast("请输入正确的快递单号");
this.toast('请输入正确的快递单号');
}
}
},
components: {
CubeButton: Button,
CubeInput: Input
}
};
</script>
... ... @@ -412,6 +478,7 @@ export default {
display: flex;
align-items: flex-start;
padding-top: 16px;
padding-bottom: 40px;
.iconfont {
font-size: 32px;
... ... @@ -429,6 +496,70 @@ export default {
}
}
.coupon-wrapper {
display: flex;
padding: 40px 0;
justify-content: space-between;
align-items: center;
border-top: 1px solid #eee;
.title {
font-size: 32px;
display: flex;
align-items: center;
}
.desc {
font-size: 24px;
color: #9B9B9B;
margin-left: 12px;
}
.price {
color: #B0B0B0;
font-size: 32px;
margin-right: 10px;
}
.icon-right {
font-size: 24px;
color: #999;
}
}
.item-wrapper {
border-top: 1px solid #eee;
padding: 40px 0;
}
.price-info {
font-size: 28px;
& > p {
display: flex;
justify-content: space-between;
}
.platform-fee {
line-height: 1;
display: flex;
align-items: center;
}
.delivery-fee {
margin: 20px 0;
}
.pay-price {
color: #d0021b;
}
.label {
font-size: 28px;
margin-right: 12px;
}
}
.submit-warp {
width: 100%;
position: absolute;
... ...
... ... @@ -41,6 +41,10 @@
>
<span>{{ orderDetail.bankTransferFee }}</span>
</p>
<p class="coupon-fee" v-if="orderDetail.couponCutAmount">
<span class="label">优惠券:</span>
<span>{{ orderDetail.couponCutAmount }}</span>
</p>
<p>
<span class="label">实际收入:</span>
<span class="pay-price">{{ orderDetail.income }}</span>
... ... @@ -98,23 +102,23 @@
</template>
<script>
import { createNamespacedHelpers } from "vuex";
import { Button } from "cube-ui";
import Clipboard from "clipboard";
import { createNamespacedHelpers } from 'vuex';
import { Button } from 'cube-ui';
import Clipboard from 'clipboard';
import AddressInfo from "./components/sell-order-address-info";
import OrderItemInfo from "./components/order-detail-item";
import DetailHeader from "./components/header";
import DetailFooter from "./components//detail-footer";
import AddressInfo from './components/sell-order-address-info';
import OrderItemInfo from './components/order-detail-item';
import DetailHeader from './components/header';
import DetailFooter from './components//detail-footer';
import OrderActions from "../components/order-actions";
import OrderActions from '../components/order-actions';
import orderActionMixin from "../mixin/order-action";
import orderInSaleActionMixin from "../mixin/order-in-sale-action";
import orderActionMixin from '../mixin/order-action';
import orderInSaleActionMixin from '../mixin/order-in-sale-action';
import PlatformFeeInfo from "../components/platform-fee-info";
import PlatformFeeInfo from '../components/platform-fee-info';
const STORE_PATH = "order/orderDetail";
const STORE_PATH = 'order/orderDetail';
const { mapActions, mapState, mapGetters } = createNamespacedHelpers(
STORE_PATH
... ... @@ -140,36 +144,39 @@ export default {
return this.orderDetail.orderCode;
}
});
this.copyBtn.on("success", () => {
this.copyBtn.on('success', () => {
this.$createToast({
txt: "复制成功",
type: "txt"
txt: '复制成功',
type: 'txt'
}).show();
});
});
console.log('this.orderDetail======', this.orderDetail);
},
computed: {
...mapState(["orderDetail"]),
...mapState(['orderDetail']),
...mapGetters([
"lastExpressInfo",
"priceInfo",
"statusDetail",
"platformFee",
"actionList"
'lastExpressInfo',
'priceInfo',
'statusDetail',
'platformFee',
'actionList'
])
},
beforeRouteLeave(to, from, next) {
next();
},
methods: {
...mapActions(["fetchOrderDetail"]),
...mapActions(['fetchOrderDetail']),
onPlatformFee() {
const { platformFee = {} } = this.orderDetail;
this.$createDialog(
{
type: "alert",
title: "平台费用",
confirmBtn: { text: "我知道了" }
type: 'alert',
title: '平台费用',
confirmBtn: { text: '我知道了' }
},
createElement => {
return [
... ... @@ -177,24 +184,24 @@ export default {
props: {
platformFeeInfo: {
packageFee: platformFee.packageFee,
packageFeeDesc: "商品包装费",
packageFeeDesc: '商品包装费',
payChannelPercentage: platformFee.goodsPaymentRatePercent,
serviceFee: platformFee.serviceFee,
serviceFeeDesc: "平台服务费",
serviceFeeDesc: '平台服务费',
appraiseFee: platformFee.appraiseFee,
appraiseFeeDesc: "商品鉴定费"
appraiseFeeDesc: '商品鉴定费'
}
},
slot: "content"
slot: 'content'
})
];
}
).show();
},
onBack() {
if (this.from.name === "OrderPay") {
if (this.from.name === 'OrderPay') {
this.$router.replace({
name: "InSaleOrderList"
name: 'InSaleOrderList'
});
} else {
this.$router.back();
... ... @@ -314,6 +321,11 @@ export default {
color: #999;
}
.coupon-fee {
margin-bottom: 12px;
color: #999;
}
.pay-price {
color: #d0021b;
}
... ...
... ... @@ -12,7 +12,7 @@
<span class="wordText">{{price}}</span>
</div>
<OrderMargin class="order-item order-margin" :data="computeTip" :url="url" :superSell="isEntry" ></OrderMargin>
<OrderFee class="order-item" :data="computeTip"></OrderFee>
<OrderFee class="order-item" :data="computeTip"></OrderFee>
<AddressInfo :data="addressInfo" class="order-item"></AddressInfo>
</div>
... ...
... ... @@ -60,7 +60,7 @@ export default {
});
},
methods: {
...mapActions(['getCoupon']),
...mapActions(['getProductCoupon']),
onHidden() {
this.$emit('hidden');
},
... ... @@ -77,8 +77,7 @@ export default {
const user = await this.$yoho.auth();
if (user && user.uid) {
this.getCoupon({couponToken: couponToken}).then(result => {
console.log(result);
this.getProductCoupon({couponTokens: couponToken}).then(result => {
this.$createDialog({
type: 'alert',
title: result.code === 200 ? '领取优惠券成功' : result.message,
... ...
... ... @@ -4,6 +4,10 @@ export const Types = {
GET_COUPON_SUCCESS: 'GET_COUPON_SUCCESS',
GET_COUPON_FAILED: 'GET_COUPON_FAILED',
GET_SERVER_TIME_SUCCESS: 'GET_SERVER_TIME_SUCCESS',
GET_PRODUCT_COUPON_REQUEST: 'GET_PRODUCT_COUPON_REQUEST',
GET_PRODUCT_COUPON_SUCCESS: 'GET_PRODUCT_COUPON_SUCCESS',
GET_PRODUCT_COUPON_FAILED: 'GET_PRODUCT_COUPON_FAILED',
};
export default function() {
... ... @@ -11,7 +15,8 @@ export default function() {
namespaced: true,
state: {
fetchingCoupon: false,
serverTime: ''
serverTime: '',
fetchingProductCoupon: false
},
mutations: {
[Types.GET_COUPON_REQUEST](state) {
... ... @@ -26,7 +31,18 @@ export default function() {
[Types.GET_SERVER_TIME_SUCCESS](state, {time}) {
state.serverTime = time;
console.log('mutationServerTime', time);
}
},
// 这一块是商品详情页的领券,后来换的接口
[Types.GET_PRODUCT_COUPON_REQUEST](state) {
state.fetchingProductCoupon = true;
},
[Types.GET_PRODUCT_COUPON_SUCCESS](state) {
state.fetchingProductCoupon = false;
},
[Types.GET_PRODUCT_COUPON_FAILED](state) {
state.fetchingProductCoupon = false;
},
},
actions: {
async getCoupon({commit}, {couponToken}) {
... ... @@ -43,12 +59,27 @@ export default function() {
return result || {};
},
async getServerTime() {
const result = await this.$api.get('/app/ufo/getServerTime');
return result;
}
},
// 商品详情页领券接口
async getProductCoupon({commit}, { couponTokens }) {
commit(Types.GET_PRODUCT_COUPON_REQUEST);
const result = await this.$api.get('/api/ufo/coupons/getCoupon', { couponTokens: couponTokens });
if (result && result.code === 200) {
commit(Types.GET_PRODUCT_COUPON_SUCCESS);
} else {
commit(Types.GET_PRODUCT_COUPON_FAILED);
}
return result || {};
},
}
};
};
... ...
... ... @@ -56,6 +56,7 @@ export default function() {
page: couponData.page,
limit: couponData.limit,
type: couponData.type,
userType: param.userType
};
if (param.isReset) {
... ...
... ... @@ -3,6 +3,7 @@ import channel from './channel';
import favorite from './favorite';
import news from './news';
import coupon from './coupon';
import salerCoupon from './salerCoupon';
import bindAccount from './bindAccount';
export default function() {
return {
... ... @@ -24,6 +25,7 @@ export default function() {
favorite: favorite(),
news: news(),
coupon: coupon(),
salerCoupon: salerCoupon(),
bindAccount: bindAccount()
}
};
... ...
export default function() {
return {
namespaced: true,
state: {
unused: {
type: 'unused',
isFetching: false,
reachedEnd: false,
isEmpty: false,
list: [],
filter: 0,
page: 0,
limit: 10,
total: 0
},
used: {
type: 'used',
isFetching: false,
reachedEnd: false,
isEmpty: false,
list: [],
filter: 0,
page: 0,
limit: 10,
total: 0
},
overtime: {
type: 'overtime',
isFetching: false,
reachedEnd: false,
isEmpty: false,
list: [],
filter: 0,
page: 0,
limit: 10,
total: 0
},
},
mutations: {
addList(state, { data }) {
state[data.type] = data;
}
},
actions: {
async fetchSalerCouponList({ commit, state }, param) {
if (!param.type) {
return;
}
let couponData = {...state[param.type]};
if (!param.isReset && couponData.reachedEnd) {
return couponData.list;
}
let params = {
page: couponData.page,
limit: couponData.limit,
type: couponData.type,
userType: param.userType
};
if (param.isReset) {
params.page = 1;
} else {
params.page += 1;
}
params.filter = 0;
let result = await this.$api.get('/api/ufo/coupon/list', {...params});
if (result.code === 200) {
let data = result.data;
if (typeof data === 'object' && Object.keys(data).length) {
for (let key in data) {
if (key === 'coupons') {
couponData.list = data.page > 1 ? couponData.list.concat(data.coupons) : data.coupons;
} else {
couponData[key] = data[key];
}
}
if (data.page === data.totalPage) {
couponData.reachedEnd = true;
}
couponData.list.length ? couponData.isEmpty = false : couponData.isEmpty = true;
commit('addList', { data: couponData });
}
} else {
couponData.isEmpty = true;
commit('addList', { data: couponData });
}
return couponData.list || [];
}
},
};
}
... ...
export default function () {
import { get, find, filter } from 'lodash';
export default function() {
return {
namespaced: true,
state: {
appraiseAddress: {},
appraiseAddressCodes: []
appraiseAddressCodes: [],
orderFeeInfo: {},
selectCouponCode: ''
},
mutations: {
SET_APPRAISE_ADDRESS(state, { orderCode, data }) {
... ... @@ -14,7 +18,7 @@ export default function () {
state.appraiseAddressCodes.push(orderCode);
if (state.appraiseAddressCodes.length > 5) {
state.appraiseAddressCodes.shift()
state.appraiseAddressCodes.shift();
}
state.appraiseAddressCodes.forEach(code => {
... ... @@ -24,6 +28,30 @@ export default function () {
});
state.appraiseAddress = addr;
},
SET_ORDER_FEE(state, { data }) {
state.orderFeeInfo = data;
},
UPDATE_SELECT_COUPON_LIST(state, { couponCode }) {
const item = find(get(state.orderFeeInfo, 'couponList', []), { coupon_code: couponCode });
if (!item) {
return;
}
let lastSelectCouponCode = state.selectCouponCode;
if (item.selected === 'Y') {
item.selected = 'N';
state.selectCouponCode = '';
} else {
filter(get(state.orderFeeInfo, 'couponList', []), { coupon_code: lastSelectCouponCode }).forEach(i => {
i.selected = 'N';
});
item.selected = 'Y';
state.selectCouponCode = couponCode;
}
}
},
actions: {
... ... @@ -48,6 +76,7 @@ export default function () {
return res;
},
/**
* @param {
* orderCode 订单编码
... ... @@ -58,6 +87,7 @@ export default function () {
orderCode: orderCode + '',
});
},
/**
* @param {
* orderCode 订单编码
... ... @@ -65,13 +95,42 @@ export default function () {
* depotNum 鉴定中心id
* }
*/
async deliverOrderToDepot({ commit }, { orderCode, wayBillCode, depotNum } = {}) {
async deliverOrderToDepot({ commit }, { orderCode, wayBillCode, depotNum, couponCode } = {}) {
return await this.$api.post('/api/order/deliverToDepot', {
expressCompanyId: 23,
orderCode: orderCode + '',
wayBillCode,
depotNum
depotNum,
couponCode
});
},
/**
* @param {
* orderCode 订单编码
* couponCode 非必填(如刚进入发货页面时)
* autoRecommended 是否自动推荐券 Y :推荐,N :不推荐 ,默认N 不做推荐
* }
*/
async computeWithCoupon({ commit }, { orderCode, couponCode } = {}) {
const res = await this.$api.get('/api/seller/order/computeWithCoupon', {
orderCode: orderCode + '',
couponCode,
autoRecommended: 'N'
});
if (res.code === 200) {
commit('SET_ORDER_FEE', {
data: res.data
});
}
return res;
},
// 修改选中优惠券
async changeSelectCouponList({ commit }, { couponCode, couponType }) {
commit('UPDATE_SELECT_COUPON_LIST', {couponCode});
}
},
};
... ...
... ... @@ -68,6 +68,7 @@ export default {
productId: productId,
page: 1,
limit: 500,
api_version : 1
}
const result = await this.$api.get('/api/ufo/product/coupon', params);
... ... @@ -81,9 +82,10 @@ export default {
async fetchProductCouponTopList({ commit }, { productId }) {
let params = {
productId: productId,
api_version : 1
}
const result = await this.$api.post('/api/ufo/product/couponTopList', params);
const result = await this.$api.get('/api/ufo/product/couponTopList', params);
if (result.code === 200) {
const couponTopList = result.data || [];
... ...
... ... @@ -23,4 +23,17 @@ module.exports = {
coupon_tokens: {type: String}
},
},
// 商品详情页领券
'/api/ufo/coupons/getCoupon': {
auth: true,
accessLog: true,
checkSign: true,
ufo: true,
path: 'coupon',
api: 'ufo.coupons.getCoupon',
params: {
couponTokens: {type: String}
},
},
};
... ...
... ... @@ -377,6 +377,19 @@ module.exports = {
// wayBillCode: { type: String, require: true }, // 物流快递号
// orderCode: { type: String, require: true }, // 订单编号
// depotNum: { type: Number, require: true }, // 鉴定中心id
// couponCode: { type: String, require: false }, // 优惠券单号
},
},
// 卖家发货
'/api/seller/order/computeWithCoupon': {
ufo: true,
auth: true,
api: 'ufo.sellerOrder.computeWithCoupon',
params: {
orderCode: { type: String, require: true }, // 快递公司id
couponCode: { type: String, require: false }, // 物流快递号
autoRecommended: { type: String, require: false }
},
},
... ...
... ... @@ -59,16 +59,17 @@ module.exports = {
},
},
// 对应商品的券
// 商品详情页couponList
'/api/ufo/product/coupon': {
ufo: true,
auth: true,
path: '/couponCenter',
path: '/ufo-gateway/couponCenter', // 测试环境'/ufo-gateway/couponCenter',线上'/couponCenter'
api: 'ufo.couponsInPrdDetail.list',
params: {
productId: {type: Number}, // 商品id
productId: {type: Number},
limit: { type: Number },
page: { type: Number },
api_version: { type: Number} // 商品详情页券单独添加的字段
},
},
... ... @@ -76,10 +77,11 @@ module.exports = {
'/api/ufo/product/couponTopList': {
ufo: true,
auth: false,
path: '/couponCenter',
path: '/ufo-gateway/couponCenter', // 测试环境'/ufo-gateway/couponCenter',线上'/couponCenter'
api: 'ufo.couponTopListOfPrdDetail.list',
params: {
productId: {type: Number}, // 商品id
productId: {type: Number},
api_version: { type: Number} // 商品详情页券单独添加的字段
},
},
... ...