161 lines
3.6 KiB
JavaScript
161 lines
3.6 KiB
JavaScript
const requireCustom = wx.requireCustom;
|
|
const customRequest = requireCustom(9887);
|
|
const Ay = requireCustom(4752).Ay;
|
|
|
|
Page({
|
|
data: {
|
|
getDetailParam: {
|
|
api: 'mtop.alibaba.detail.subpage.getdetail',
|
|
v: '2.0',
|
|
data: {}
|
|
},
|
|
detailResult: {},
|
|
ticketPriceParam: {
|
|
api: 'mtop.damai.item.calcTicketPrice',
|
|
v: '2.0',
|
|
method: 'GET',
|
|
data: {}
|
|
},
|
|
ticketPriceResult: {},
|
|
orderBuildParam: {
|
|
api: 'mtop.damai.trade.order.build.h5',
|
|
v: '1.0',
|
|
data: {},
|
|
timeout: 15e3,
|
|
method: 'POST'
|
|
},
|
|
orderBuildResult: {}
|
|
},
|
|
async onLoad(options) {
|
|
let detailResult = await this.getDetail('1001240724661')
|
|
|
|
if (detailResult[0]) {
|
|
this.showToast(detailResult[0].message)
|
|
return
|
|
}
|
|
|
|
this.setData({
|
|
detailResult: detailResult[1]
|
|
})
|
|
|
|
let ticketPrice = await this.calcTicketPrice();
|
|
|
|
if (ticketPrice[0]) {
|
|
this.showToast(ticketPrice[0].message)
|
|
return
|
|
}
|
|
|
|
this.setData({
|
|
ticketPriceResult: ticketPrice[1]
|
|
})
|
|
|
|
let orderBuildResult = await this.buildOrder();
|
|
|
|
if (orderBuildResult[0]) {
|
|
this.showToast(orderBuildResult[0].message)
|
|
return
|
|
}
|
|
|
|
this.setData({
|
|
orderBuildResult: orderBuildResult[1]
|
|
})
|
|
|
|
console.log(this.data.orderBuildResult)
|
|
},
|
|
|
|
onReady() {
|
|
|
|
},
|
|
|
|
onShow() {
|
|
|
|
},
|
|
|
|
onHide() {
|
|
|
|
},
|
|
showToast(msg) {
|
|
wx.showToast({
|
|
title: msg,
|
|
icon: 'none',
|
|
})
|
|
},
|
|
getDetail(itemId) {
|
|
const param = {
|
|
bizCode: 'ali.china.damai',
|
|
scenario: 'itemsku',
|
|
itemId,
|
|
exParams: JSON.stringify({
|
|
dataType: 4,
|
|
dataId: '',
|
|
activityId: ''
|
|
})
|
|
}
|
|
|
|
return new customRequest.p({
|
|
...this.data.getDetailParam,
|
|
...param
|
|
}).create();
|
|
},
|
|
calcTicketPrice() {
|
|
const calculatePriceControl = this.data.detailResult.actionControl.calculatePriceControl;
|
|
const itemBasicInfo = this.data.detailResult.itemBasicInfo;
|
|
const perform = this.data.detailResult.perform;
|
|
const sku = perform.skuList[perform.skuList.length - 1];
|
|
|
|
|
|
const param = {
|
|
itemId: itemBasicInfo.itemId,
|
|
performId: perform.performId,
|
|
calculateTag: calculatePriceControl.calculateTag,
|
|
skuParamListJson: JSON.stringify([{
|
|
priceId: sku.priceId,
|
|
price: Number(sku.price),
|
|
count: 1,
|
|
}]),
|
|
exParams: {}
|
|
}
|
|
|
|
return new customRequest.p({
|
|
...this.data.ticketPriceParam,
|
|
...param
|
|
}).create();
|
|
},
|
|
async buildOrder() {
|
|
const globalCode = 'ali.china.damai';
|
|
const ttid = '#t#ip##_h5_2014';
|
|
|
|
const itemBasicInfo = this.data.detailResult.itemBasicInfo;
|
|
const perform = this.data.detailResult.perform;
|
|
|
|
const param = {
|
|
buyNow: true,
|
|
exParams: JSON.stringify({
|
|
channel: 'damai_app',
|
|
damai: '1',
|
|
umpChannel: '100031002',
|
|
subChannel: 'damai@weixin_weapp',
|
|
atomSplit: 1,
|
|
signKey: itemBasicInfo.t,
|
|
rtc: this.data.detailResult.actionControl.tradeControl.rtc ? 1 : 0,
|
|
serviceVersion: '2.0.0',
|
|
customerType: 'default',
|
|
}),
|
|
buyParam: itemBasicInfo.itemId + '_' + 1 + '_' + perform.skuList[0].skuId
|
|
}
|
|
|
|
return new customRequest.p({
|
|
...this.data.orderBuildParam,
|
|
...param,
|
|
ext_querys: {
|
|
ttid
|
|
},
|
|
headers: {
|
|
globalCode,
|
|
},
|
|
ext_headers: {
|
|
globalCode
|
|
}
|
|
}).create();
|
|
}
|
|
}) |