statements.js
6.22 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
import api from '../../common/api.js';
import {formatImageUrl} from '../../utils/util';
import {parseComputeData} from '../../utils/statementsUtil';
import { aliPay } from '../../utils/payUtil';
const FROM_PRODUCT_DETAIL = "productdetail";
const FROM_SHOPPING_CART = "shopcart"
Page({
data: {
// payment: {},
isDisplaydeliveryWay: false,
isShowAddNewAddress: false,
invoicesItem: {
id: "invoices",
title: "发票",
subtitle: "",
isChecked: false,
isShowHelp: false,
},
submitparam: {
address_id: 'nIwE1fqIniAyb+HmGedV4g==',//送货地址id
coupon_code: '',//优惠券code,多个用","分割
delivery_time: 0,//寄送时间类型
delivery_way: 1,//发货方式(1:普通, 2顺丰)
payment_id:15,//支付id 默认支付宝
payment_type:1,//支付方式,1 在线支付 2 货到付款
receiverMobile:'15950485925',
sale_channel:1,
use_red_envelopes: 0,//使用的红包,单位元
use_red_package: 0,//使用的红包,单位元
use_yoho_coin: 0,//使用的yoho币金额,单位元
// method: 'app.Buynow.submit',
// product_sku:'474098',
// sku_type: 'I',
// buy_number: 1,
uid: '600033236',
// invoice_content: 12,
// invoices_title: '个人',
// invoices_type: 2,
// buyerTaxNumber: '',
}
},
onLoad: function (option) {
if(option && option.fromPage){
let fromPage = option.fromPage;
this.data.fromPage = fromPage;
if(fromPage === FROM_PRODUCT_DETAIL){
this.data.submitparam.method = "app.Buynow.submit";
this.data.submitparam.sku_type = "I";
this.data.submitparam.buy_number = 1;
// this.data.submitparam.product_sku="474098";
}else if(fromPage === FROM_SHOPPING_CART ){
this.data.submitparam.method = "app.Shopping.submit";
this.data.submitparam.cart_type = "ordinary";
this.data.submitparam.is_continue_buy = "N";
this.data.submitparam.is_print_price = "N";
}
}
let pages = getCurrentPages();
let length =pages.length;
let payment = {};
if(length > 1){
let lastPageData = pages[length - 2].data;
this.setData({
lastPageData,
});
}
this.fechPaymentInfo();
},
onShow: function () {},
fechPaymentInfo: function () {
let that = this;
let param = {
buy_number:1,
is_support_apple_pay:'N',
method:'app.Buynow.enhancedPayment',
open_red_package:true,
product_sku:'1029813',
sku_type:'I',
uid:'600033236',
yoho_coin_mode:0
}
api.get({data: param})
.then(json=>{
if(json && json.code == 200){
let data = json.data;
if(data){
let resultData = parseComputeData(data,75,100);
let addressInfo = data.delivery_address;
if(addressInfo){
let addressId = resultData.delivery_address.address_id
that.data.submitparam.address_id = addressId;
that.data.isShowAddNewAddress = false;
}else {
that.data.isShowAddNewAddress = true;
}
if(that.data.fromPage === FROM_PRODUCT_DETAIL){
let productInfo = data.goods_list[0];
if(productInfo){
let productSku = productInfo.product_sku;
that.data.submitparam.product_sku = productSku;
}
}
that.setData({
data:resultData,
})
}
}
})
},
fechCompute: function (refreshParam) {
let that = this;
let goods_list = that.data.data.goods_list;
let goodsInfo = that.data.data.goods_list[0];
let params = {
buy_number:goodsInfo.buy_number,
cart_type:"ordinary",
// coupon_code:
// delivery_way:2,
method:"app.Buynow.compute",
open_red_package:false,
payment_type:1,
product_sku:goodsInfo.product_sku,
sku_type:"I",
uid:'600033236',
yoho_coin_mode:0
}
let assignData = Object.assign(refreshParam, params);
api.get({data: assignData})
.then(json=>{
if(json && json.code == 200){
let data = json.data;
let resultData = parseComputeData(data,75,100);
// data.delivery_way = this.parseDelivery(data.delivery_way);
let oldData = that.data.data;
let result = Object.assign(oldData, data);
that.setData({
data:result,
})
}
})
},
refreshCompute: function (e) {
let selectParam = e.detail.params;
this.fechCompute(selectParam);
},
onChangeSwitch: function (e) {
let isChecked = e.detail.isChecked;
this.data.invoicesItem.isChecked = isChecked;
},
addNewAddress: function () {
//新增收货地址,跳转到新增页面
},
navigateToInvoice: function () {
tt.navigateTo({
url: 'pages/invoice/invoceDetail',
success (res) {
console.log(`${res}`);
},
fail (res) {
console.log(`navigateTo调用失败`);
}
});
},
submit: function () {
debugger
let params = this.data.submitparam;
api.get({data: params})
.then(json=>{
if(json && json.code == 200){
let data = json.data;
aliPay(data);
}
})
}
})