|
|
import ensureModel from '../../../models/cart/ensure';
|
|
|
import addressModel from '../../../models/home/address';
|
|
|
import wechatAddressUtil from '../../../utils/wechatAddress';
|
|
|
import { wechatPay } from '../../../common/pay/wechat';
|
|
|
|
|
|
const SKU_TYPE = 'O';
|
|
|
|
...
|
...
|
@@ -35,23 +38,42 @@ function formatPaymentData(data) { |
|
|
return value;
|
|
|
});
|
|
|
|
|
|
info.deliveryWayList.map(value => {
|
|
|
if (value.default === 'Y') {
|
|
|
value.checked = true;
|
|
|
info.deliveryWayText = `${value.delivery_way_name}:运费¥${value.delivery_way_cost}`;
|
|
|
let selectWay,
|
|
|
selectTime;
|
|
|
|
|
|
if (info.deliveryWayList.length) {
|
|
|
info.deliveryWayList.map((value, index) => {
|
|
|
if (value.default === 'Y') {
|
|
|
value.checked = true;
|
|
|
selectWay = value;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (!selectWay) {
|
|
|
selectWay = info.deliveryWayList[0];
|
|
|
info.deliveryWayList[0].checked = true;
|
|
|
}
|
|
|
|
|
|
return value;
|
|
|
});
|
|
|
info.deliveryWayId = selectWay.delivery_way_id;
|
|
|
info.deliveryWayText = `${selectWay.delivery_way_name}:运费¥${selectWay.delivery_way_cost}`;
|
|
|
}
|
|
|
|
|
|
if (info.deliveryTimeList.length) {
|
|
|
info.deliveryTimeList.map((value, index) => {
|
|
|
if (value.default === 'Y') {
|
|
|
value.checked = true;
|
|
|
selectTime = value;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
info.deliveryTimeList.map(value => {
|
|
|
if (value.default === 'Y') {
|
|
|
value.checked = true;
|
|
|
info.deliveryTimeText = value.delivery_time_string || '';
|
|
|
if (!selectTime) {
|
|
|
selectTime = info.deliveryTimeList[0];
|
|
|
info.deliveryTimeList[0].checked = true;
|
|
|
}
|
|
|
|
|
|
return value;
|
|
|
});
|
|
|
info.deliveryTimeId = selectTime.delivery_time_id;
|
|
|
info.deliveryTimeText = selectTime.delivery_time_string || '';
|
|
|
}
|
|
|
|
|
|
return info;
|
|
|
}
|
...
|
...
|
@@ -77,28 +99,36 @@ Page({ |
|
|
this.orderData = {};
|
|
|
this.loadEnsurePayment({productSku: 2030762});
|
|
|
},
|
|
|
loadEnsurePayment(options) {
|
|
|
loadEnsurePayment(options, reload) {
|
|
|
if (options.productSku) {
|
|
|
this.orderType = ORDER_TYPE.BUYNOW;
|
|
|
|
|
|
Object.assign(this.orderData, {
|
|
|
productSku: options.productSku,
|
|
|
buyNumber: options.buyNumber || 1
|
|
|
});
|
|
|
|
|
|
ensureModel.buynowPayment({
|
|
|
sku_type: SKU_TYPE,
|
|
|
product_sku: this.orderData.productSku,
|
|
|
buy_number: this.orderData.buyNumber,
|
|
|
product_sku: options.productSku,
|
|
|
buy_number: options.buyNumber || 1,
|
|
|
yoho_coin_mode: 0,
|
|
|
is_support_apple_pay: 'N',
|
|
|
}).then(res => {
|
|
|
console.log(res)
|
|
|
if (res.code !== 200) {
|
|
|
wx.showModal({
|
|
|
content: res.message,
|
|
|
showCancel: false,
|
|
|
confirmText: '好的',
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
this.setData(formatPaymentData(res.data));
|
|
|
let data = formatPaymentData(res.data);
|
|
|
|
|
|
Object.assign(this.orderData, {
|
|
|
productSku: options.productSku,
|
|
|
buyNumber: options.buyNumber || 1,
|
|
|
deliveryWayId: data.deliveryWayId,
|
|
|
deliveryTimeId: data.deliveryTimeId
|
|
|
});
|
|
|
|
|
|
this.setData(data);
|
|
|
});
|
|
|
}
|
|
|
},
|
...
|
...
|
@@ -124,9 +154,7 @@ Page({ |
|
|
|
|
|
});
|
|
|
}
|
|
|
console.log(res);
|
|
|
});
|
|
|
|
|
|
},
|
|
|
navigateTo(url) {
|
|
|
wx.navigateTo({url: url});
|
...
|
...
|
@@ -148,18 +176,18 @@ Page({ |
|
|
this.navigateTo(`/pages/home/address/list?type=add`);
|
|
|
},
|
|
|
chooseWechatAddress() {
|
|
|
wx.chooseAddress({
|
|
|
success(res) {
|
|
|
console.log(res);
|
|
|
// TODO
|
|
|
},
|
|
|
fail() {
|
|
|
wx.showModal({
|
|
|
content: '获取微信地址失败或未授权',
|
|
|
showCancel: false,
|
|
|
confirmText: '好的'
|
|
|
});
|
|
|
}
|
|
|
wechatAddressUtil.choose(res => {
|
|
|
addressModel.saveWechatAddressData(res).then(result => {
|
|
|
if (result.code === 200) {
|
|
|
this.chooseAddressCallback(result.data);
|
|
|
} else {
|
|
|
wx.showToast({
|
|
|
title: result.message,
|
|
|
icon: 'none',
|
|
|
duration: 1500
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
toggleDeliveryWayList() {
|
...
|
...
|
@@ -177,7 +205,6 @@ Page({ |
|
|
}
|
|
|
|
|
|
this.buynowCompute({deliveryWayId: id});
|
|
|
|
|
|
this.setData({
|
|
|
deliveryWayText: name,
|
|
|
deliveryWayEditStatus: false,
|
...
|
...
|
@@ -250,23 +277,26 @@ Page({ |
|
|
} else {
|
|
|
// 普通购物车下单
|
|
|
}
|
|
|
|
|
|
console.log('submitOrder');
|
|
|
},
|
|
|
buynowOrderSubmit() {
|
|
|
if (this.orderSubmiting) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
return wechatPay({
|
|
|
order_amount
:
399
,
|
|
|
order_code
:
21551043925
|
|
|
});
|
|
|
|
|
|
let param = {
|
|
|
sku_type: SKU_TYPE,
|
|
|
product_sku: this.orderData.productSku,
|
|
|
buy_number: this.orderData.buyNumber,
|
|
|
payment_id: PAYMENT.ID,
|
|
|
payment_type: PAYMENT.TYPE,
|
|
|
// qhy_union: {client_id: app.getAppId()}
|
|
|
qhy_union: JSON.stringify({client_id: app.getUnionType()})
|
|
|
}
|
|
|
console.log({client_id: app.getAppId()});
|
|
|
|
|
|
if (this.orderData.deliveryWayId) {
|
|
|
param.delivery_way = this.orderData.deliveryWayId;
|
|
|
}
|
...
|
...
|
@@ -278,7 +308,7 @@ console.log({client_id: app.getAppId()}); |
|
|
if (this.data.choosedAddress && this.data.choosedAddress.address_id) {
|
|
|
param.address_id = this.data.choosedAddress.address_id;
|
|
|
} else {
|
|
|
this.showToast('请选择收件地址');
|
|
|
return this.showToast('请选择收件地址');
|
|
|
}
|
|
|
|
|
|
if (this.data.invoiceNeedStatus) {
|
...
|
...
|
@@ -295,7 +325,7 @@ console.log({client_id: app.getAppId()}); |
|
|
}
|
|
|
|
|
|
if (+param.invoices_type === 2 && !param.receiverMobile) {
|
|
|
this.showToast('请填写电子发票接收手机号');
|
|
|
return this.showToast('请填写电子发票接收手机号');
|
|
|
}
|
|
|
|
|
|
this.orderSubmiting = true;
|
...
|
...
|
@@ -304,7 +334,7 @@ console.log({client_id: app.getAppId()}); |
|
|
this.orderSubmiting = false;
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
wechatPay(res.data);
|
|
|
} else {
|
|
|
wx.showModal({
|
|
|
content: res.message,
|
...
|
...
|
|