buy-pay-ok.vue
4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<template>
<LayoutApp :show-back="true" title="支付成功">
<div class="body">
<div class="header">
<i class="iconfont iconOk icon-class"></i>
</div>
<div class="title">支付成功</div>
<div class="desc">如卖家原因导致交易失败,您可以获得相应赔偿金,具体金额参考《买家须知》。建议您设置支付宝账号作为赔偿收款账户,如未绑定支付宝账号视为放弃赔偿。</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)"><<查看订单</a>
<a href="javascript:void(0)" @click="onNoAuthorizeClick(0)"><<返回首页</a>
</div>
</template>
<div class="recommend" v-if="productList.length">
<div class="recommend-title">为您推荐</div>
<ProductList :list="productList"></ProductList>
</div>
</div>
</LayoutApp>
</template>
<script>
import ProductList from '../list/components/productList';
import { createNamespacedHelpers } from 'vuex';
import { get } from 'lodash';
const { mapActions: mapProductAction } = createNamespacedHelpers('product');
const { mapActions: mapOrderConfirmAction } = createNamespacedHelpers('order/orderConfirm');
const CONTENT_CODE = '5b2bf9b8a1affa6b6959002e9993cf73';// 支付成功资源位
export default {
name: 'BuyPayOk',
props: ['productId', 'orderCode'],
components: {
ProductList
},
data() {
return {
txt: '返回首页',
txt1: '绑定支付宝',
authorizeFlag: false,
productList: [],
resourceData: {},
};
},
activated() {
if (this.productId) {
this.fetchRecommendProduct({ productId: this.productId }).then(result => {
this.productList = result;
});
}
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', 'fetchOrderResource']),
onClick() {
if (this.authorizeFlag) {
this.goHome();
} else {
this.goBindAccount();
}
},
onNoAuthorizeClick(type) {
if (type === 0) {
this.goHome();
} else if (type === 1){
this.goOrderList();
}
},
goHome() {
this.$router.replace({
name: 'ChannelPage'
});
},
goBindAccount() {
this.$router.replace({
name: 'bindAccount',
query: {
back: 'ChannelPage'
}
});
},
goOrderList() {
this.$router.replace({
name: 'OrderList',
params: {
owner: 'buy'
},
})
}
}
};
</script>
<style lang="scss" scoped>
.body {
height: 100%;
padding-bottom: 140px;
overflow-y: auto;
}
.header {
margin-top: 80px;
text-align: center;
}
.icon-class {
font-size: 120px;
}
.btn-wrap {
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;
line-height: 88px;
}
.desc {
width: 560px;
margin: 60px auto;
font-size: 24px;
color: #999;
text-align: center;
line-height: 40px;
}
.title {
font-size: 40px;
font-weight: bold;
text-align: center;
margin-bottom: 60px;
}
.info {
font-size: 28px;
display: flex;
margin-top: 30px;
margin-bottom: 66px;
.item {
width: 100%;
text-align: center;
}
}
.recommend {
background: #f5f5f5;
.recommend-title {
font-weight: bold;
font-size: 36px;
line-height: 50px;
padding: 20px 0 0;
margin: 0 40px;
}
}
</style>