|
@@ -8,23 +8,7 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
isonline: 1,
|
|
|
- currentList: [{
|
|
|
- tit: '塑封包膜',
|
|
|
- num: "30",
|
|
|
- id: 1
|
|
|
- }, {
|
|
|
- tit: '绒面鞋补色',
|
|
|
- num: "20",
|
|
|
- id: 2
|
|
|
- }, {
|
|
|
- tit: '防水处理',
|
|
|
- num: "20",
|
|
|
- id: 3
|
|
|
- }, {
|
|
|
- tit: '防水处理',
|
|
|
- num: "10",
|
|
|
- id: 4
|
|
|
- }],
|
|
|
+ currentList: [],
|
|
|
mode: 1,
|
|
|
checked: true,
|
|
|
show1: false,
|
|
@@ -45,13 +29,8 @@ Page({
|
|
|
},
|
|
|
onLoad(opticon) {
|
|
|
let order_no = opticon.order_no;
|
|
|
- let currentList = this.data.currentList
|
|
|
- currentList.map(item => {
|
|
|
- item.active = false
|
|
|
- })
|
|
|
this.detail(order_no);
|
|
|
this.setData({
|
|
|
- currentList,
|
|
|
order_no
|
|
|
})
|
|
|
|
|
@@ -75,6 +54,12 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
goyhq(){
|
|
|
+ if(this.data.couponinfo){
|
|
|
+ this.setData({
|
|
|
+ total_price: parseFloat(parseFloat(this.data.total_price) + parseFloat(this.data.couponinfo.money)).toFixed(2)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log(this.data.total_price)
|
|
|
wx.navigateTo({
|
|
|
url: '../coupon/coupon?totalprice='+this.data.total_price+'&freight='+this.data.freight,
|
|
|
})
|
|
@@ -120,7 +105,12 @@ Page({
|
|
|
mode:unit.type,
|
|
|
order_type:unit.type,
|
|
|
freight:unit.price,
|
|
|
- total_price:(total_price+price).toFixed(2)
|
|
|
+ total_price:(total_price+price).toFixed(2),
|
|
|
+ currentList: res.message.data.services
|
|
|
+ })
|
|
|
+ let currentList = that.data.currentList
|
|
|
+ currentList.map(item => {
|
|
|
+ item.active = false
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -149,17 +139,26 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
chios(e) {
|
|
|
+ let that = this
|
|
|
let { item } = e.currentTarget.dataset
|
|
|
|
|
|
- let currentList = this.data.currentList
|
|
|
+ let currentList = that.data.currentList
|
|
|
currentList.map((it, index) => {
|
|
|
if (item.id == it.id) {
|
|
|
- it.active = !it.active
|
|
|
+ // it.active = !it.active
|
|
|
+ if(it.active){
|
|
|
+ it.active = false
|
|
|
+ that.setData({total_price: (parseFloat(that.data.total_price) + parseFloat((it.price.start_time && it.price.end_time)?it.price.sale_price*it.stock:it.price.price*it.stock)).toFixed(2)})
|
|
|
+ }else{
|
|
|
+ it.active = true
|
|
|
+ that.setData({total_price: (parseFloat(that.data.total_price) - parseFloat((it.price.start_time && it.price.end_time)?it.price.sale_price*it.stock:it.price.price*it.stock)).toFixed(2)})
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
- this.setData({
|
|
|
+ that.setData({
|
|
|
currentList
|
|
|
})
|
|
|
+ // total_price
|
|
|
},
|
|
|
changeMode(e) {
|
|
|
var id = e.currentTarget.dataset.id
|
|
@@ -167,13 +166,13 @@ Page({
|
|
|
var unit=this.data.orderinfo.network.unit[key];
|
|
|
|
|
|
|
|
|
- var total_price=parseFloat(this.data.orderinfo.total_price);
|
|
|
+ var total_price=parseFloat(this.data.total_price)
|
|
|
var price=parseFloat(unit.price)
|
|
|
-
|
|
|
+ console.log(total_price,price)
|
|
|
this.setData({
|
|
|
mode: id,
|
|
|
freight:unit.price,
|
|
|
- total_price:total_price+price
|
|
|
+ total_price:parseFloat(total_price+price).toFixed(2)
|
|
|
|
|
|
})
|
|
|
},
|
|
@@ -324,12 +323,24 @@ Page({
|
|
|
if(that.data.couponinfo!=''&&that.data.couponinfo!=undefined){
|
|
|
cid = that.data.couponinfo.pivot.id
|
|
|
}
|
|
|
+ let services = []
|
|
|
+ that.data.currentList.forEach((item,index)=>{
|
|
|
+ if(item.active){
|
|
|
+ services.push({
|
|
|
+ id: item.id,
|
|
|
+ price: parseFloat((item.price.start_time && item.price.end_time)?item.price.sale_price*item.stock:item.price.price*item.stock).toFixed(2),
|
|
|
+ price_id: item.price.id,
|
|
|
+ stock: item.stock
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
app.api.useApi(app.globalData.baseAppUrl + "api/orders", {
|
|
|
order_no: that.data.order_no,
|
|
|
order_type: that.data.mode,
|
|
|
user_remark: that.data.remark,
|
|
|
address_id:that.data.address_id,
|
|
|
- coupon_id: cid
|
|
|
+ coupon_id: cid,
|
|
|
+ services: services
|
|
|
}, "post").then(function (res) {
|
|
|
console.log(res)
|
|
|
if (res.code != 200) {
|