|
@@ -1,5 +1,6 @@
|
|
|
// pages/confirmOrder/confirmOrder.js
|
|
|
const getReq = require('./../../config.js').getReq
|
|
|
+import Bundle from '../../utils/Bundle'
|
|
|
let appInstance = getApp()
|
|
|
Page({
|
|
|
|
|
@@ -14,7 +15,8 @@ Page({
|
|
|
goods_list: [],
|
|
|
firstLoad: true,
|
|
|
defaultAddress: null,
|
|
|
- cart_id: ''
|
|
|
+ cart_id: '',
|
|
|
+ n_goods_list: [],
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -31,9 +33,15 @@ Page({
|
|
|
num,
|
|
|
cart_id
|
|
|
})
|
|
|
- // console.log(goods_id, iscart, num, cart_id);
|
|
|
this.getDatas(goods_id, iscart, num, cart_id)
|
|
|
- // this.getDatas(4807, 0, 1, '')
|
|
|
+
|
|
|
+ // 测试套装数据
|
|
|
+ // this.getDatas(goods_id, 1, num, '16403,16406')
|
|
|
+ // act:member_buy
|
|
|
+ // cart_id:16403,16406
|
|
|
+ // op:step_first
|
|
|
+ // from:YWN0PWNhcnQmb3A9ZXhnb29kcyZjdXJwYWdlPTE%3D
|
|
|
+ // ifcart:1
|
|
|
},
|
|
|
getDatas(goods_id, ifcart, num, cart_id) {
|
|
|
wx.showLoading({
|
|
@@ -47,19 +55,37 @@ Page({
|
|
|
else {
|
|
|
goods_datas = cart_id;
|
|
|
}
|
|
|
- getReq({
|
|
|
+ // let bundleParams = {
|
|
|
+ // act: 'member_buy',
|
|
|
+ // op: 'step_first',
|
|
|
+ // cart_id: '16407,16408',
|
|
|
+ // ifcart: 1
|
|
|
+ // }
|
|
|
+
|
|
|
+ // let defaultParams = {
|
|
|
+ // act: 'member_buy',
|
|
|
+ // cart_id: '4807|1',
|
|
|
+ // op: 'step_first',
|
|
|
+ // ifcart: 0
|
|
|
+ // }
|
|
|
+
|
|
|
+ let params = {
|
|
|
act: 'member_buy',
|
|
|
op: 'step_first',
|
|
|
curpage: 1,
|
|
|
cart_id: goods_datas,
|
|
|
ifcart,
|
|
|
- }, function (res) {
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ getReq(params, function (res) {
|
|
|
wx.hideLoading()
|
|
|
if (res.code == 200) {
|
|
|
- console.log(res);
|
|
|
let datas = res.datas
|
|
|
- let goods_list = self.getGoodsList(datas.summary, datas.goods_list)
|
|
|
- console.log('goods_list', goods_list);
|
|
|
+ console.log('datas:', datas);
|
|
|
+ let { goods_list, summary, bundling } = res.datas
|
|
|
+ let n_goods_list = self.getNewGoodsList(goods_list, summary, bundling)
|
|
|
+
|
|
|
if (datas.address) {
|
|
|
let { true_name, mob_phone, area_info, address, address_id } = datas.address;
|
|
|
appInstance.checkDefaultAddress({
|
|
@@ -72,7 +98,7 @@ Page({
|
|
|
}
|
|
|
self.setData({
|
|
|
datas,
|
|
|
- goods_list,
|
|
|
+ n_goods_list,
|
|
|
firstLoad: false,
|
|
|
defaultAddress: datas.address
|
|
|
})
|
|
@@ -84,26 +110,26 @@ Page({
|
|
|
duration: 2000
|
|
|
})
|
|
|
appInstance.globalData.fcodeErr = res.message
|
|
|
- wx.navigateBack()
|
|
|
+ wx.navigateBack()
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- getGoodsList(summary, goods_list) {
|
|
|
- console.log('summary', summary);
|
|
|
- console.log('goods_list', goods_list);
|
|
|
- let newGoodsList = []
|
|
|
- goods_list.map((item, index) => {
|
|
|
- summary.find((list, key) => {
|
|
|
- if (item.goods_id == list.goods_id) {
|
|
|
- let goods_item = list
|
|
|
- goods_item.goods_num = item.goods_num
|
|
|
- newGoodsList.push(goods_item)
|
|
|
- return true
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- return newGoodsList
|
|
|
- },
|
|
|
+ // getGoodsList(summary, goods_list) {
|
|
|
+ // console.log('summary', summary);
|
|
|
+ // console.log('goods_list', goods_list);
|
|
|
+ // let newGoodsList = []
|
|
|
+ // goods_list.map((item, index) => {
|
|
|
+ // summary.find((list, key) => {
|
|
|
+ // if (item.goods_id == list.goods_id) {
|
|
|
+ // let goods_item = list
|
|
|
+ // goods_item.goods_num = item.goods_num
|
|
|
+ // newGoodsList.push(goods_item)
|
|
|
+ // return true
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // return newGoodsList
|
|
|
+ // },
|
|
|
toPay() {
|
|
|
if (!this.data.defaultAddress) {
|
|
|
wx.showToast({
|
|
@@ -117,7 +143,7 @@ Page({
|
|
|
let goods_num = this.data.num
|
|
|
let iscart = this.data.ifcart
|
|
|
let cart_id = this.data.cart_id
|
|
|
-
|
|
|
+
|
|
|
let vat_hash = this.data.datas['payinfo'].vat_hash
|
|
|
let offpay_hash = this.data.datas['payinfo'].offpay_hash
|
|
|
let offpay_hash_batch = this.data.datas['payinfo'].offpay_hash_batch
|
|
@@ -128,7 +154,8 @@ Page({
|
|
|
getReq({
|
|
|
act: 'member_buy',
|
|
|
op: 'step_second',
|
|
|
- payment: 'jspay',
|
|
|
+ // payment: 'jspay',
|
|
|
+ payment: 'minipay',
|
|
|
usebonus: 1,
|
|
|
ifcart,
|
|
|
cart_id: cartids,
|
|
@@ -147,16 +174,19 @@ Page({
|
|
|
package: param.package,
|
|
|
signType: param.signType, //微信签名方式:
|
|
|
paySign: param.paySign, //微信签名
|
|
|
- success:function(res){
|
|
|
- wx.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: res,
|
|
|
- duration: 2000
|
|
|
+ success: function (res) {
|
|
|
+ // wx.showToast({
|
|
|
+ // icon: 'none',
|
|
|
+ // title: res,
|
|
|
+ // duration: 2000
|
|
|
+ // })
|
|
|
+ wx.reLaunch({
|
|
|
+ url: "/pages/index/index"
|
|
|
})
|
|
|
- console.log("成功:"+res);
|
|
|
+ console.log("成功:" + res);
|
|
|
console.log('支付成功')
|
|
|
},
|
|
|
- fail:function(res){
|
|
|
+ fail: function (res) {
|
|
|
wx.showToast({
|
|
|
icon: 'none',
|
|
|
title: res,
|
|
@@ -177,6 +207,59 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+ getNewGoodsList(goods_list, summary, bundling) {
|
|
|
+ let summaryMap = new Map()
|
|
|
+ let bundlingMap = new Map()
|
|
|
+ summary.map(item => {
|
|
|
+ summaryMap.set(item['goods_id'], item)
|
|
|
+ })
|
|
|
+ if (bundling.length) {
|
|
|
+ bundling.map(item => {
|
|
|
+ bundlingMap.set(item['bl_id'], item)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ let n_goods_list = new Bundle(goods_list, summaryMap, bundlingMap).createOrders()
|
|
|
+ return n_goods_list
|
|
|
+ },
|
|
|
+
|
|
|
+ // testBundle() {
|
|
|
+ // let bundleParams = {
|
|
|
+ // act: 'member_buy',
|
|
|
+ // op: 'step_first',
|
|
|
+ // cart_id: '16407,16408',
|
|
|
+ // ifcart: 1
|
|
|
+ // }
|
|
|
+
|
|
|
+ // let defaultParams = {
|
|
|
+ // act: 'member_buy',
|
|
|
+ // cart_id: '4807|1',
|
|
|
+ // op: 'step_first',
|
|
|
+ // ifcart: 0
|
|
|
+ // }
|
|
|
+ // let self = this
|
|
|
+ // getReq(bundleParams, function (res) {
|
|
|
+ // console.log('Bundle', res);
|
|
|
+ // if (res.code == 200) {
|
|
|
+ // let { goods_list, summary, bundling } = res.datas
|
|
|
+ // let summaryMap = new Map()
|
|
|
+ // let bundlingMap = new Map()
|
|
|
+ // summary.map(item => {
|
|
|
+ // summaryMap.set(item['goods_id'], item)
|
|
|
+ // })
|
|
|
+ // if (bundling.length) {
|
|
|
+ // bundling.map(item => {
|
|
|
+ // bundlingMap.set(item['bl_id'], item)
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // let n_goods_list = new Bundle(goods_list, summaryMap, bundlingMap).createOrders()
|
|
|
+ // console.log('n_goods_list: ', n_goods_list);
|
|
|
+ // self.setData({
|
|
|
+ // n_goods_list
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|