绚火健康
This commit is contained in:
82
pages/mall/confirm/confirm.js
Normal file
82
pages/mall/confirm/confirm.js
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 手太欠
|
||||
* 愿这世界都如故事里一样 美好而动人~
|
||||
*/
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
disabled : true,//按钮
|
||||
skuId : '',
|
||||
goodsQty : '', // 产品数量
|
||||
address : '', // 地址
|
||||
addressId : '', // 地址id
|
||||
goodskData : '', // 数据
|
||||
amount : '', // 总金额
|
||||
freight : '', // 运费
|
||||
weight : '', // 重量
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
goodsQty: options.qty,
|
||||
skuId : options.skuId
|
||||
})
|
||||
// 获取商品下单信息
|
||||
this.placeInfo(options.skuId, options.qty);
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {},
|
||||
|
||||
/**
|
||||
* 商品下单信息
|
||||
*/
|
||||
placeInfo(skuid, qty) {
|
||||
wx.$api.mall.place({
|
||||
goods_sku_id:skuid,
|
||||
qty: qty,
|
||||
address_id: this.data.addressId
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
this.setData({
|
||||
address : res.data.address,
|
||||
addressId : res.data.address.address_id,
|
||||
goodskData: res.data.detail,
|
||||
amount : res.data.amount,
|
||||
freight : res.data.freight,
|
||||
weight : res.data.weight
|
||||
})
|
||||
}).catch(err =>{})
|
||||
},
|
||||
|
||||
/**
|
||||
* 商品确认下单
|
||||
*/
|
||||
buyTap() {
|
||||
wx.$api.mall.placeTrue({
|
||||
goods_sku_id:this.data.skuId,
|
||||
qty: this.data.goodsQty,
|
||||
address_id: this.data.addressId
|
||||
}).then(res => {
|
||||
this.setData({
|
||||
disabled: true
|
||||
})
|
||||
wx.redirectTo({
|
||||
url: '/pages/pay/index?params=' + encodeURIComponent(JSON.stringify(res.data))
|
||||
})
|
||||
}).catch(err =>{
|
||||
this.setData({
|
||||
disabled: false
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user