Authored by shuaiguo

Merge branch 'feature/pay-success-resource' into 'develop'

支付成功后增加资源位



See merge request !20
@@ -8,13 +8,27 @@ @@ -8,13 +8,27 @@
8 8
9 <div class="desc">如卖家原因导致交易失败,您可以获得相应赔偿金,具体金额参考《买家须知》。建议您设置支付宝账号作为赔偿收款账户,如未绑定支付宝账号视为放弃赔偿。</div> 9 <div class="desc">如卖家原因导致交易失败,您可以获得相应赔偿金,具体金额参考《买家须知》。建议您设置支付宝账号作为赔偿收款账户,如未绑定支付宝账号视为放弃赔偿。</div>
10 10
11 - <div class="btn-wrap">  
12 - <YohoButton :txt="authorizeFlag ? txt : txt1" class="btn-class" @click="onClick"></YohoButton>  
13 - </div> 11 + <template v-if="!authorizeFlag">
  12 + <div class="btn-wrap">
  13 + <YohoButton :txt="authorizeFlag ? txt : txt1" class="btn-class" @click="onClick"></YohoButton>
  14 + </div>
  15 +
  16 + <div class="info">
  17 + <div class="item" @click="goHome">随便逛逛</div>
  18 + </div>
  19 + </template>
  20 + <template v-else>
  21 + <!--资源位-->
  22 + <LayoutLink class="resource-content" :href="resourceData.url">
  23 + <img :src="resourceData.src">
  24 + </LayoutLink>
  25 + <div class="button-wrap">
  26 + <a href="javascript:void(0)" @click="onNoAuthorizeClick(1)">&lt;&lt;查看订单</a>
  27 + <a href="javascript:void(0)" @click="onNoAuthorizeClick(0)">&lt;&lt;返回首页</a>
  28 + </div>
  29 +
  30 + </template>
14 31
15 - <div class="info">  
16 - <div class="item" @click="goHome">随便逛逛</div>  
17 - </div>  
18 32
19 <div class="recommend" v-if="productList.length"> 33 <div class="recommend" v-if="productList.length">
20 <div class="recommend-title">为您推荐</div> 34 <div class="recommend-title">为您推荐</div>
@@ -29,14 +43,17 @@ @@ -29,14 +43,17 @@
29 import ProductList from '../list/components/productList'; 43 import ProductList from '../list/components/productList';
30 import { createNamespacedHelpers } from 'vuex'; 44 import { createNamespacedHelpers } from 'vuex';
31 import { get } from 'lodash'; 45 import { get } from 'lodash';
  46 +import LayoutLink from '../../components/layout/layout-link';
32 47
33 const { mapActions: mapProductAction } = createNamespacedHelpers('product'); 48 const { mapActions: mapProductAction } = createNamespacedHelpers('product');
34 const { mapActions: mapOrderConfirmAction } = createNamespacedHelpers('order/orderConfirm'); 49 const { mapActions: mapOrderConfirmAction } = createNamespacedHelpers('order/orderConfirm');
  50 +const CONTENT_CODE = '5b2bf9b8a1affa6b6959002e9993cf73';// 支付成功资源位
35 51
36 export default { 52 export default {
37 name: 'BuyPayOk', 53 name: 'BuyPayOk',
38 props: ['productId', 'orderCode'], 54 props: ['productId', 'orderCode'],
39 components: { 55 components: {
  56 + LayoutLink,
40 ProductList 57 ProductList
41 }, 58 },
42 data() { 59 data() {
@@ -44,7 +61,8 @@ export default { @@ -44,7 +61,8 @@ export default {
44 txt: '返回首页', 61 txt: '返回首页',
45 txt1: '绑定支付宝', 62 txt1: '绑定支付宝',
46 authorizeFlag: false, 63 authorizeFlag: false,
47 - productList: [] 64 + productList: [],
  65 + resourceData: {},
48 }; 66 };
49 }, 67 },
50 activated() { 68 activated() {
@@ -56,12 +74,27 @@ export default { @@ -56,12 +74,27 @@ export default {
56 74
57 this.fetchAlipayStatus().then(result => { 75 this.fetchAlipayStatus().then(result => {
58 this.authorizeFlag = get(result, 'data.authorizeFlag', false); 76 this.authorizeFlag = get(result, 'data.authorizeFlag', false);
  77 + console.log(result);
  78 + if (this.authorizeFlag) {
  79 + // 如果绑定了支付宝,则获取资源位
  80 + this.fetchOrderResource({contentCode: CONTENT_CODE}).then(content => {
  81 + console.log(content);
  82 + if (content && content.code === 200 && content.data.length > 0) {
  83 + let resourceData = content.data[0].data[0];
  84 +
  85 + if (resourceData) {
  86 + resourceData.src = resourceData.src.replace(/{mode}/, 1).replace(/{width}/, 690).replace(/h\/{height}/, '');
  87 + this.resourceData = resourceData;
  88 + }
  89 + }
  90 + });
  91 + }
59 }); 92 });
60 }, 93 },
61 computed: {}, 94 computed: {},
62 methods: { 95 methods: {
63 ...mapProductAction(['fetchRecommendProduct']), 96 ...mapProductAction(['fetchRecommendProduct']),
64 - ...mapOrderConfirmAction(['fetchAlipayStatus']), 97 + ...mapOrderConfirmAction(['fetchAlipayStatus', 'fetchOrderResource']),
65 onClick() { 98 onClick() {
66 if (this.authorizeFlag) { 99 if (this.authorizeFlag) {
67 this.goHome(); 100 this.goHome();
@@ -69,6 +102,13 @@ export default { @@ -69,6 +102,13 @@ export default {
69 this.goBindAccount(); 102 this.goBindAccount();
70 } 103 }
71 }, 104 },
  105 + onNoAuthorizeClick(type) {
  106 + if (type === 0) {
  107 + this.goHome();
  108 + } else if (type === 1){
  109 + this.goOrderList();
  110 + }
  111 + },
72 goHome() { 112 goHome() {
73 this.$router.replace({ 113 this.$router.replace({
74 name: 'ChannelPage' 114 name: 'ChannelPage'
@@ -81,6 +121,14 @@ export default { @@ -81,6 +121,14 @@ export default {
81 back: 'ChannelPage' 121 back: 'ChannelPage'
82 } 122 }
83 }); 123 });
  124 + },
  125 + goOrderList() {
  126 + this.$router.replace({
  127 + name: 'OrderList',
  128 + params: {
  129 + owner: 'buy'
  130 + },
  131 + })
84 } 132 }
85 } 133 }
86 }; 134 };
@@ -106,6 +154,29 @@ export default { @@ -106,6 +154,29 @@ export default {
106 margin: 0 32px; 154 margin: 0 32px;
107 } 155 }
108 156
  157 +.button-wrap {
  158 + width: 100%;
  159 + text-align: center;
  160 + overflow: hidden;
  161 +
  162 + a {
  163 + display: block;
  164 + font-size: 28px;
  165 + margin: 30px auto;
  166 + color: #169BD5;
  167 + }
  168 +}
  169 +
  170 +.resource-content {
  171 + display: inline-block;
  172 + padding: 0 20px;
  173 + overflow: hidden;
  174 +
  175 + img {
  176 + width: 100%;
  177 + }
  178 +}
  179 +
109 .btn-class { 180 .btn-class {
110 height: 88px; 181 height: 88px;
111 font-size: 32px; 182 font-size: 32px;
@@ -304,6 +304,13 @@ export default function() { @@ -304,6 +304,13 @@ export default function() {
304 return this.$api.post('/api/order/status', { 304 return this.$api.post('/api/order/status', {
305 orderCode 305 orderCode
306 }); 306 });
  307 + },
  308 +
  309 + // 获取支付成功后展示的资源位
  310 + async fetchOrderResource(ctx, {contentCode}) {
  311 + return this.$api.get('/api/order/resource', {
  312 + content_code: contentCode
  313 + });
307 } 314 }
308 }, 315 },
309 getters: {}, 316 getters: {},
@@ -327,6 +327,14 @@ module.exports = { @@ -327,6 +327,14 @@ module.exports = {
327 params: {}, 327 params: {},
328 }, 328 },
329 329
  330 + '/api/order/resource': {
  331 + ufo: true,
  332 + api: 'ufo.resource.get',
  333 + cache: true,
  334 + params: {
  335 + content_code: { type: String }},
  336 + },
  337 +
330 // 订单物流信息 338 // 订单物流信息
331 '/api/order/express': { 339 '/api/order/express': {
332 ufo: true, 340 ufo: true,
@@ -27,6 +27,7 @@ module.exports = async (req, res, next) => { @@ -27,6 +27,7 @@ module.exports = async (req, res, next) => {
27 if (!apiInfo.service) { 27 if (!apiInfo.service) {
28 baseParams.method = apiInfo.api; 28 baseParams.method = apiInfo.api;
29 } 29 }
  30 +
30 if (apiInfo.auth) { 31 if (apiInfo.auth) {
31 if (req.user && req.user.uid) { 32 if (req.user && req.user.uid) {
32 baseParams.uid = { 33 baseParams.uid = {
@@ -41,7 +42,6 @@ module.exports = async (req, res, next) => { @@ -41,7 +42,6 @@ module.exports = async (req, res, next) => {
41 42
42 try { 43 try {
43 const reqParams = Object.assign({}, req.query, req.body, baseParams); 44 const reqParams = Object.assign({}, req.query, req.body, baseParams);
44 -  
45 const params = checkParams.getParams(reqParams, apiInfo, req); 45 const params = checkParams.getParams(reqParams, apiInfo, req);
46 const cache = 46 const cache =
47 req.method.toLowerCase() !== 'get' || apiInfo.auth 47 req.method.toLowerCase() !== 'get' || apiInfo.auth