buy.vue
11.1 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
<template>
<view class="buydetail">
<view class="buytop">
<text class="buytitle"> 数字货币</text>
<view class="buybox flexA">
<image :src="list1[0]" mode=""></image>
<view class="buymiss">
<view class="title">
{{topdetail.name}}
</view>
<view class="money">
<text>¥</text>{{topdetail.price}}
</view>
</view>
</view>
</view>
<view class="paymiss">
<view class="paybox">
<view class="boxtitle">
买家信息
</view>
<view class="paybar">
<view class="left">
<text>*</text>接收账户:
</view>
<view class="right">
<input type="text" placeholder="请输入手机号或钱包地址" v-model="lastInfo.buyer_package"
placeholder-style="color: rgba(0,0,0,0.26);font-size: 28rpx;">
</view>
</view>
<view class="paybar">
<view class="left">
<text>*</text>微信号:
</view>
<view class="right">
<input type="text" placeholder="请输入" v-model="lastInfo.buyer_wechat"
placeholder-style="color: rgba(0,0,0,0.26);font-size: 28rpx;">
</view>
</view>
<view class="paybar">
<view class="left">
联系人:
</view>
<view class="right">
<input type="text" placeholder="选填" v-model="lastInfo.buyer_name"
placeholder-style="color: rgba(0,0,0,0.26);font-size: 28rpx;">
</view>
</view>
<view class="paybar">
<view class="left">
联系电话:
</view>
<view class="right">
<input type="text" placeholder="选填" v-model="lastInfo.buyer_mobile"
placeholder-style="color: rgba(0,0,0,0.26);font-size: 28rpx;">
</view>
</view>
<view class="paybar">
<view class="left">
实名认证:<text v-if="lastInfo.is_cert==0">(未通过)</text><text class="ok" v-else>(已通过)</text>
</view>
<view class="right flexA" >
<text v-if="lastInfo.is_cert==0" @click="show=true">去认证</text>
<text class="ok" v-else>已认证</text>
<image src="../../static/ic-arrow.png" mode=""></image>
</view>
</view>
</view>
</view>
<view class="btn">
<view class="paybtn" v-if="lastInfo.is_cert==0">
确认支付
</view>
<view class="paybtn none" v-else @click="product_buy">
确认支付
</view>
</view>
<u-popup :show="show" @close="close" @open="open" mode="center" :round="12">
<view class="popname">
<view class="title">
实名认证
</view>
<view class="contant">
为了保证平台用户交易的安全性,您需要实名认证后,才能在平台中进行发布物品操作
</view>
<view class="btngroup">
<view class="concle" @click="show=false">
暂不认证
</view>
<view class="requt" @click="tocart">
立即认证
</view>
</view>
</view>
</u-popup>
</view>
</template>
<script>
import {toa} from '@/utils/toast.js'
var wx = require('jweixin-module')
import {
last_buy_data,
product_detail,
product_buy
} from '@/api/index.js'
export default {
data() {
return {
product_id: "",
String: "",
topdetail: "",
list1: [],
lastInfo: {
product_id: "",
buyer_package: "",
buyer_wechat: "",
buyer_name: "",
buyer_mobile: "",
is_cert: "",
},
show: false,
}
},
onLoad(options) {
this.product_id = options.id
this.product_detail()
this.last_buy_data()
},
onShow() {
},
methods: {
open() {
},
close() {
this.show = false
},
//实名认证
tocart() {
uni.navigateTo({
url: "/pages/index/realName"
})
},
//详情
async product_detail() {
try {
const res = await product_detail(this.product_id)
console.log('product_detail', res)
this.topdetail = res.detail
this.list1 = res.detail.images_preview
// 保存数据
} catch (err) {
uni.showToast({
title: err,
icon: 'none'
})
console.log('product_detail', err)
}
},
//下单
async product_buy() {
if(!this.lastInfo.buyer_package) return toa.toast('请输入接收账号')
if(!this.lastInfo.buyer_wechat) return toa.toast('请输入微信号')
// console.log(this.lastInfo, "000000")
let obj = {
openid:uni.getStorageSync('openId'),
product_id: this.product_id,
buyer_package: this.lastInfo.buyer_package,
buyer_wechat: this.lastInfo.buyer_wechat,
buyer_name: this.lastInfo.buyer_name,
buyer_mobile: this.lastInfo.buyer_mobile,
}
try {
const res = await product_buy(obj)
console.log('product_buy', res)
wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: res.pay_data.appId, // 必填,公众号的唯一标识
timestamp: res.pay_data.timeStamp, // 必填,生成签名的时间戳
nonceStr: res.pay_data.nonceStr, // 必填,生成签名的随机串
signature: res.pay_data.paySign, // 必填,签名
jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表
})
wx.ready(function () {
wx.chooseWXPay({
timestamp: res.pay_data.timeStamp, // 时间戳
nonceStr: res.pay_data.nonceStr, // 随机数
package: res.pay_data.package, //
signType: res.pay_data.signType,
paySign: res.pay_data.paySign, // 签名
success: function () {
toa.success('支付成功')
uni.redirectTo({
url:'/pages/mine/buyerOrder'
})
},
cancel: function () {
setTimeout(()=>{
toa.toast('取消支付')
},200)
uni.navigateBack({})
},
fail: function () {
setTimeout(()=>{
toa.toast('支付失败')
},200)
uni.navigateBack({})
}
})
})
// 保存数据
} catch (err) {
uni.showToast({
title: err,
icon: 'none'
})
console.log('product_buy', err)
}
},
//下单展示
async last_buy_data() {
try {
const res = await last_buy_data()
console.log('last_buy_data', res)
this.lastInfo = res.detail
// 保存数据
} catch (err) {
uni.showToast({
title: err,
icon: 'none'
})
console.log('last_buy_data', err)
}
},
}
}
</script>
<style lang="scss">
page {
background-color: #f0f0f0;
}
.buydetail {
.buytop {
width: 100%;
padding: 0 32rpx;
height: 294rpx;
background-image: url(@/static/ic_back3.png);
background-size: 100%;
background-repeat: no-repeat;
padding-top: 68rpx;
box-sizing: border-box;
.buytitle {
color: rgba(0, 0, 0, 1);
font-size: 36rpx;
font-weight: 600;
font-family: "PingFang SC";
}
.buybox {
margin-top: 24rpx;
background-color: #ffffff;
padding: 24rpx;
border-radius: 16rpx;
box-sizing: border-box;
image {
margin-right: 12rpx;
width: 120rpx;
height: 120rpx;
border-radius: 16rpx;
}
.buymiss {
.title {
color: rgba(0, 0, 0, 0.9);
font-size: 28rpx;
font-weight: 400;
font-family: "PingFang SC";
}
.money {
margin-top: 32rpx;
color: rgba(248, 83, 23, 1);
font-size: 32rpx;
font-weight: 700;
text {
font-size: 24rpx;
font-weight: 500;
}
}
}
}
}
.paymiss {
padding: 0 32rpx;
margin-top: 24rpx;
.paybox {
background-color: #ffffff;
padding: 24rpx;
.boxtitle {
color: rgba(0, 0, 0, 0.9);
font-size: 30rpx;
font-weight: 600;
font-family: "PingFang SC";
}
.paybar {
padding: 16rpx 0;
display: flex;
align-items: center;
justify-content: space-between;
.left {
flex: 1;
color: rgba(0, 0, 0, 0.9);
font-size: 28rpx;
font-weight: 400;
font-family: "PingFang SC";
text {
opacity: 1;
color: rgba(252, 67, 56, 1);
font-size: 28rpx;
font-weight: 400;
font-family: "PingFang SC";
}
.ok {
color: rgba(24, 209, 142, 1);
font-size: 28rpx;
font-weight: 400;
font-family: "PingFang SC";
}
}
.right {
text-align: right;
text {
color: rgba(33, 83, 212, 1);
font-size: 28rpx;
font-weight: 400;
font-family: "PingFang SC";
}
.ok {
color: rgba(24, 209, 142, 1);
font-size: 28rpx;
font-weight: 400;
font-family: "PingFang SC";
}
image {
width: 16rpx;
height: 32rpx;
}
}
}
}
}
.btn {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 128rpx;
padding: 16rpx 32rpx;
box-sizing: border-box;
opacity: 1;
background: rgba(255, 255, 255, 1);
.paybtn {
width: 100%;
height: 96rpx;
line-height: 96rpx;
text-align: center;
border-radius: 28rpx;
opacity: 1;
color: rgba(0, 0, 0, 0.9);
font-size: 32rpx;
font-weight: 600;
font-family: "PingFang SC";
background: rgba(240, 242, 245, 1);
}
.none {
background: linear-gradient(134.8deg, rgba(255, 232, 100, 1) 0%, rgba(255, 216, 0, 1) 100%);
}
}
.popname {
padding: 32rpx;
box-sizing: border-box;
width: 622rpx;
text-align: center;
.title {
color: rgba(0, 0, 0, 0.9);
font-size: 32rpx;
font-weight: 600;
font-family: "PingFang SC";
text-align: center;
}
.contant {
color: rgba(179, 179, 179, 1);
font-size: 28rpx;
font-weight: 400;
font-family: "PingFang SC";
text-align: center;
}
.btngroup {
margin-top: 80rpx;
display: flex;
align-items: center;
justify-content: space-between;
.concle {
width: 264rpx;
height: 76rpx;
border-radius: 16rpx;
opacity: 1;
line-height: 76rpx;
color: rgba(0, 0, 0, 0.9);
font-size: 28rpx;
font-weight: 500;
font-family: "PingFang SC";
text-align: center;
background: rgba(246, 246, 246, 1);
}
.requt {
width: 264rpx;
height: 76rpx;
color: rgba(0, 0, 0, 0.9);
font-size: 28rpx;
font-weight: 500;
font-family: "PingFang SC";
text-align: center;
line-height: 76rpx;
border-radius: 16rpx;
opacity: 1;
background: rgba(254, 208, 0, 1);
}
}
}
}
</style>