|
@@ -1,5 +1,5 @@
|
|
|
// pages/order/placeOrder/placeOrder.js
|
|
|
-const app=getApp();
|
|
|
+const app = getApp();
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -17,18 +17,20 @@ Page({
|
|
|
carNum: 0,
|
|
|
carPrice: '',
|
|
|
shoppingList: [],
|
|
|
- worke:"",
|
|
|
- status:""
|
|
|
+ shop: [],
|
|
|
+ worke: "",
|
|
|
+ status: ""
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
-
|
|
|
- var worke=JSON.parse(options.parmise)
|
|
|
+
|
|
|
+ var worke = JSON.parse(options.parmise)
|
|
|
+ console.log(worke)
|
|
|
this.setData({
|
|
|
- worke:worke,
|
|
|
+ worke: worke,
|
|
|
status: app.globalData.status
|
|
|
})
|
|
|
this.getHeight()
|
|
@@ -44,6 +46,10 @@ Page({
|
|
|
console.log(item);
|
|
|
|
|
|
this.changeCarList(item)
|
|
|
+ var good_id = items.id;
|
|
|
+ var money = items.price.sale_price;
|
|
|
+ var stock = item.num;
|
|
|
+ this.cartChang(good_id, money, stock);
|
|
|
|
|
|
}
|
|
|
})
|
|
@@ -59,8 +65,18 @@ Page({
|
|
|
if (items.id == item.id) {
|
|
|
item.num++
|
|
|
this.changeCarList(item)
|
|
|
+
|
|
|
+ var good_id = items.id;
|
|
|
+ var money = items.price.sale_price;
|
|
|
+ var stock = item.num;
|
|
|
+ this.cartChang(good_id, money, stock);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
this.setData({
|
|
|
shoppingList: list
|
|
|
})
|
|
@@ -103,6 +119,42 @@ Page({
|
|
|
|
|
|
},
|
|
|
|
|
|
+ //修改购物车
|
|
|
+ cartChang(good_id, money, stock) {
|
|
|
+ var nid = this.data.worke.id;
|
|
|
+ app.api.useApi(app.globalData.baseAppUrl + "api/change_cart", {
|
|
|
+ network_id: nid,
|
|
|
+ good_id: good_id,
|
|
|
+ money: money,
|
|
|
+ stock: stock
|
|
|
+ }, "post").then(function (res) {
|
|
|
+ console.log(res);
|
|
|
+ if (res.code != 200) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: res.message.status,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ var data = res.message.data;
|
|
|
+ var shop = [];
|
|
|
+ for (var index in data) {
|
|
|
+ shop[data[index].id] = data[index].goods
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ that.setData({
|
|
|
+ navList: res.message.data,
|
|
|
+ shoppingList: res.message.data[0].goods,
|
|
|
+ shop: shop
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ wx.hideLoading();
|
|
|
+
|
|
|
+ }).catch(function (err) {
|
|
|
+ console.log(222);
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
changeShoppingList(item) {
|
|
|
console.log(item);
|
|
|
let shoppingList = this.data.shoppingList;
|
|
@@ -118,16 +170,39 @@ Page({
|
|
|
},
|
|
|
|
|
|
getCarAll() {
|
|
|
- this.setData({
|
|
|
- carNum: 0,
|
|
|
- carPrice: 0
|
|
|
+ var nid = this.data.worke.id;
|
|
|
+ var that=this;
|
|
|
+ app.api.useApi(app.globalData.baseAppUrl + "api/cart_info", {
|
|
|
+ network_id: nid,
|
|
|
+ }, "get").then(function (res) {
|
|
|
+ console.log(res);
|
|
|
+ if (res.code != 200) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: res.message.msg,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log(res.message.data.carPrice)
|
|
|
+ that.setData({
|
|
|
+ carList:res.message.data.cart.data,
|
|
|
+ carNum: res.message.data.carNum,
|
|
|
+ carPrice: res.message.data.carPrice
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ wx.hideLoading();
|
|
|
+
|
|
|
+ }).catch(function (err) {
|
|
|
+ console.log(222);
|
|
|
})
|
|
|
+
|
|
|
+
|
|
|
let carList = this.data.carList
|
|
|
carList.map(item => {
|
|
|
wx.nextTick(() => {
|
|
|
this.setData({
|
|
|
carNum: this.data.carNum + item.num,
|
|
|
- carPrice: this.data.carPrice + item.price * item.num
|
|
|
+ carPrice: this.data.carPrice + item.price.sale_price * item.num
|
|
|
})
|
|
|
|
|
|
})
|
|
@@ -197,8 +272,11 @@ Page({
|
|
|
},
|
|
|
changeActive(e) {
|
|
|
let { activekey } = e.currentTarget.dataset
|
|
|
+ var id = e.target.dataset.id;
|
|
|
+
|
|
|
this.setData({
|
|
|
- activeKey: activekey
|
|
|
+ activeKey: activekey,
|
|
|
+ shoppingList: this.data.shop[id]
|
|
|
})
|
|
|
},
|
|
|
addressDetail() {
|
|
@@ -248,19 +326,27 @@ Page({
|
|
|
leftList: function () {
|
|
|
var that = this;
|
|
|
var nid = this.data.worke.id;
|
|
|
-
|
|
|
+
|
|
|
app.api.useApi(app.globalData.baseAppUrl + "api/good", {
|
|
|
network_id: nid,
|
|
|
}, "get").then(function (res) {
|
|
|
console.log(res);
|
|
|
if (res.code != 200) {
|
|
|
wx.showLoading({
|
|
|
- title: res.message.status,
|
|
|
+ title: res.message.status,
|
|
|
})
|
|
|
} else {
|
|
|
+ var data = res.message.data;
|
|
|
+ var shop = [];
|
|
|
+ for (var index in data) {
|
|
|
+ shop[data[index].id] = data[index].goods
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
that.setData({
|
|
|
navList: res.message.data,
|
|
|
- shoppingList:res.message.data[0].good
|
|
|
+ shoppingList: res.message.data[0].goods,
|
|
|
+ shop: shop
|
|
|
})
|
|
|
}
|
|
|
|