Authored by 邱骏

购买支付成功页增加资源位

... ... @@ -8,13 +8,27 @@
<div class="desc">如卖家原因导致交易失败,您可以获得相应赔偿金,具体金额参考《买家须知》。建议您设置支付宝账号作为赔偿收款账户,如未绑定支付宝账号视为放弃赔偿。</div>
<div class="btn-wrap">
<YohoButton :txt="authorizeFlag ? txt : txt1" class="btn-class" @click="onClick"></YohoButton>
</div>
<template v-if="!authorizeFlag">
<div class="btn-wrap">
<YohoButton :txt="authorizeFlag ? txt : txt1" class="btn-class" @click="onClick"></YohoButton>
</div>
<div class="info">
<div class="item" @click="goHome">随便逛逛</div>
</div>
</template>
<template v-else>
<!--资源位-->
<a class="resource-content" :href="resourceData.url" target="_blank">
<img :src="resourceData.src">
</a>
<div class="button-wrap">
<a href="javascript:void(0)" @click="onNoAuthorizeClick(1)">&lt;&lt;查看订单</a>
<a href="javascript:void(0)" @click="onNoAuthorizeClick(0)">&lt;&lt;返回首页</a>
</div>
</template>
<div class="info">
<div class="item" @click="goHome">随便逛逛</div>
</div>
<div class="recommend" v-if="productList.length">
<div class="recommend-title">为您推荐</div>
... ... @@ -32,6 +46,7 @@ import { get } from 'lodash';
const { mapActions: mapProductAction } = createNamespacedHelpers('product');
const { mapActions: mapOrderConfirmAction } = createNamespacedHelpers('order/orderConfirm');
const CONTENT_CODE = '5b2bf9b8a1affa6b6959002e9993cf73';// 支付成功资源位
export default {
name: 'BuyPayOk',
... ... @@ -44,7 +59,8 @@ export default {
txt: '返回首页',
txt1: '绑定支付宝',
authorizeFlag: false,
productList: []
productList: [],
resourceData: {},
};
},
activated() {
... ... @@ -56,12 +72,27 @@ export default {
this.fetchAlipayStatus().then(result => {
this.authorizeFlag = get(result, 'data.authorizeFlag', false);
console.log(result);
if (this.authorizeFlag) {
// 如果绑定了支付宝,则获取资源位
this.fetchOrderResource({contentCode: CONTENT_CODE}).then(content => {
console.log(content);
if (content && content.code === 200 && content.data.length > 0) {
let resourceData = content.data[0].data[0];
if (resourceData) {
resourceData.src = resourceData.src.replace(/{mode}/, 1).replace(/{width}/, 690).replace(/h\/{height}/, '');
this.resourceData = resourceData;
}
}
});
}
});
},
computed: {},
methods: {
...mapProductAction(['fetchRecommendProduct']),
...mapOrderConfirmAction(['fetchAlipayStatus']),
...mapOrderConfirmAction(['fetchAlipayStatus', 'fetchOrderResource']),
onClick() {
if (this.authorizeFlag) {
this.goHome();
... ... @@ -69,6 +100,13 @@ export default {
this.goBindAccount();
}
},
onNoAuthorizeClick(type) {
if (type === 0) {
this.goHome();
} else if (type === 1){
this.goOrderList();
}
},
goHome() {
this.$router.replace({
name: 'ChannelPage'
... ... @@ -81,6 +119,14 @@ export default {
back: 'ChannelPage'
}
});
},
goOrderList() {
this.$router.replace({
name: 'OrderList',
params: {
owner: 'buy'
},
})
}
}
};
... ... @@ -106,6 +152,29 @@ export default {
margin: 0 32px;
}
.button-wrap {
width: 100%;
text-align: center;
overflow: hidden;
a {
display: block;
font-size: 28px;
margin: 30px auto;
color: #169BD5;
}
}
.resource-content {
display: inline-block;
padding: 0 20px;
overflow: hidden;
img {
width: 100%;
}
}
.btn-class {
height: 88px;
font-size: 32px;
... ...
... ... @@ -304,6 +304,13 @@ export default function() {
return this.$api.post('/api/order/status', {
orderCode
});
},
// 获取支付成功后展示的资源位
async fetchOrderResource(ctx, {contentCode}) {
return this.$api.get('/api/order/resource', {
content_code: contentCode
});
}
},
getters: {},
... ...
... ... @@ -327,6 +327,14 @@ module.exports = {
params: {},
},
'/api/order/resource': {
ufo: true,
api: 'ufo.resource.get',
cache: true,
params: {
content_code: { type: String }},
},
// 订单物流信息
'/api/order/express': {
ufo: true,
... ...
... ... @@ -27,6 +27,7 @@ module.exports = async (req, res, next) => {
if (!apiInfo.service) {
baseParams.method = apiInfo.api;
}
if (apiInfo.auth) {
if (req.user && req.user.uid) {
baseParams.uid = {
... ... @@ -41,7 +42,6 @@ module.exports = async (req, res, next) => {
try {
const reqParams = Object.assign({}, req.query, req.body, baseParams);
const params = checkParams.getParams(reqParams, apiInfo, req);
const cache =
req.method.toLowerCase() !== 'get' || apiInfo.auth
... ...