diff --git a/pages/cart/cart.vue b/pages/cart/cart.vue
index 7fbcf26..0488387 100644
--- a/pages/cart/cart.vue
+++ b/pages/cart/cart.vue
@@ -1,5 +1,73 @@
+ 全部删除
+
+
+
+
+
+ {{item.shop_name}}
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+ {{goods.product.title}}
+ {{goods.sku.sku_name}}
+
+
+ {{goods.sku.price/100}}
+
+ -
+ {{goods.num}}
+ +
+
+
+
+
+
+
+
+ 请选择时间
+ >>
+
+
+
+ 商品已失效
+ 删除
+
+
+
+
+
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
+ 全选
+
+ 合计
+ {{total()}}
+
+ 去下单
+
+
@@ -12,28 +80,423 @@
},
data() {
return {
-
+ cartList: [],
+ allPrice: 0,
+ selectAll: false,
}
},
onLoad() {
},
onShow() {
-
+ this.getList()
},
methods: {
- getShoppingList () {
+ getList () {
+ this.Post({},"/api/cart/get_list").then(res=>{
+ let resData = (res.data ||[])
+ let shopSelectIds = []
+ let skuSelectIds = []
+ this.cartList.forEach(v=>{
+ if (v.is_seld) {shopSelectIds.push(v.id)}
+ v.goods.forEach(x=>{
+ if(x.is_seld) {skuSelectIds.push(x.sku_id)}
+ })
+ })
+
+ resData.forEach(v=>{
+ v.is_seld = shopSelectIds.includes(v.id)
+ // v.show = true
+ v.goods.forEach(x=>{
+ x.is_seld = skuSelectIds.includes(x.sku_id)
+ // v.show = true
+ })
+ })
+ this.cartList = resData
+ this.judgeSelectAll()
+ }).finally(()=>{
+ uni.hideLoading()
+ })
+ },
+ // 单个增加/减少
+ addBuyNum(item,num,index){
+ console.log(item)
+ if (num == -1 && item.num == 1) {
+ return // 单独走删除
+ this.delItem(item)
+ } else {
+ let numData = item.num + num
+ this.Post({sku_id: item.sku_id, num: numData},'/api/cart/update_sku').then(res =>{
+ item.num += num
+ })
+ }
+ },
+ // 单个删除
+ delItem(item){
+ this.Post({sku_id: item.sku_id},'/api/cart/del_sku').then(res =>{
+ // this.cartData.splice(index,1)
+ this.getList()
+ })
},
+ // 把店铺下的所有商品删除
+ delCartByShop (item, index) {
+ let goods = item.goods.map(v=>v.sku_id)
+ this.Post({sku_id: goods.join(',')},'/api/cart/del_sku').then(res =>{
+ this.getList()
+ })
+ },
+ // 删除全部
+ delAll () {
+ let goods = []
+ this.cartList.forEach(v=>{
+ v.goods.forEach(x=>{goods.push(x.sku_id)})
+ })
+ this.Post({sku_id: goods.join(',')},'/api/cart/del_sku').then(res =>{
+ this.getList()
+ })
+ },
+
+ // 全选
+ selectAllData (flag) {
+ this.selectAll = flag
+ if (flag) {
+ this.cartList.forEach(t=>{
+ t.goods.forEach(v=>{
+ if (v && v.product &&v.sku) {
+ if (v.sku.flag== "off") {
+ v.is_seld = false
+ } else {
+ if (v.product.type == 'hotel'&&(!v.strat_time||!v.end_time)) {
+ v.is_seld = false
+ } else {
+ v.is_seld = true
+ }
+ }
+ }
+ })
+ })
+ } else {
+ this.cartList.forEach(v=>{
+ v.is_seld = false
+ })
+ }
+ this.judgeSelectAll()
+ },
+ // 店铺选中
+ changeShopSelect(item, flag) {
+ if (flag) {
+ item.goods.forEach(v=>{
+ if (v.sku.flag== "off") {
+ v.is_seld = false
+ } else {
+ if (v.product.type == 'hotel'&&(!v.strat_time||!v.end_time)) {
+ v.is_seld = false
+ } else {
+ v.is_seld = true
+ }
+ }
+ })
+ item.is_seld = true
+ } else {
+ item.goods.forEach(v=>{
+ v.is_seld = false
+ })
+ item.is_seld = false
+ }
+ this.judgeSelectAll()
+ },
+ // 单个选中
+ changeGoodsSelect(item,flag) {
+ if (flag) {
+ if (item.sku.flag== "off") {
+ item.is_seld = false
+ } else {
+ if (item.product.type == 'hotel'&&(!item.strat_time||!item.end_time)) {
+ item.is_seld = false
+ uni.showToast({
+ title:'酒店产品需要选择时间',
+ icon:'none'
+ })
+ } else {
+ item.is_seld = true
+ }
+ }
+ } else {
+ item.is_seld = false
+ }
+ this.judgeSelectAll()
+ },
+ // 判断全选
+ judgeSelectAll () {
+ this.cartList.forEach(v=>{
+ if(v.goods.some(x=>x.sku&& x.sku.flag!= "off"&&!x.is_seld)) {
+ v.is_seld = false;
+ } else {
+ v.is_seld = true;
+ }
+ })
+
+ if (this.cartList.every(v=>v.is_seld)) {
+ this.selectAll = true
+ } else {
+ this.selectAll = false
+ }
+
+ },
+
+
+ // 去下单
+ goOrder () {
+ let buyGoods = this.cartList.filter(v=>v.is_seld)
+ if (buyGoods.length<=0) {
+ uni.showToast({
+ title: '请选择要购买的产品',
+ icon: 'none'
+ })
+ }
+
+ let ticketOrderList = [] // 门票类下单
+ let foodOrderList = [] // 农家烟火下单
+ let techanOrderList = [] // 邮寄自提下单
+ let hotelOrderList = [] // 酒店下单
+
+ buyGoods.forEach(v=>{
+ if (v.product.is_package == 1) {
+ foodOrderList.push({
+ pInfo: v.product,
+ sInfo: {...v.sku, buyNum: v.num}
+ })
+ } else if (v.product.type == "ticket") {
+ ticketOrderList.push({
+ pInfo: v.product,
+ sInfo: {...v.sku, buyNum: v.num}
+ })
+ } else if (v.product.type == "post") {
+ techanOrderList.push({
+ pInfo: v.product,
+ sInfo: {...v.sku, buyNum: v.num}
+ })
+ } else if (v.product.type == "hotel") {
+ hotelOrderList.push(v)
+ }
+ })
+
+ // 数据储存 todo
+ this.$store.commit("changeTechanOrderList", techanOrderList);
+ this.$store.commit("changeTicketOrderList", ticketOrderList);
+ this.$store.commit("changeFoodOrderList", foodOrderList);
+ this.$store.commit("changeHotelOrderList", hotelOrderList);
+ // 邮寄 > 门票 > 农家乐 > 酒店
+ this.goCartNextPage(0)
+
+ },
+
+ total () {
+ return 0
+ },
},
onReachBottom() {
-
}
}
-
diff --git a/static/js/CommonFunction.js b/static/js/CommonFunction.js
index f204a66..6fb7cbf 100644
--- a/static/js/CommonFunction.js
+++ b/static/js/CommonFunction.js
@@ -258,4 +258,31 @@ Vue.prototype.goCartPage = ()=>{
uni.switchTab({
url: "/pages/cart/cart"
})
+},
+
+// 购物车下单去下个页面
+Vue.prototype.goCartNextPage= function(currentPageIndex){
+ // currentPage "" 购物车 'techan' 'ticket' 'food' 'hotel'
+ // 0 1 2 3 4
+ let techanOrderList = this.$store.state.user.techanOrderList;
+ let ticketOrderList = this.$store.state.user.ticketOrderList;
+ let foodOrderList = this.$store.state.user.foodOrderList;
+ let hotelOrderList = this.$store.state.user.hotelOrderList;
+
+ let orderPage = [
+ {path: '/subPackages/techan/order', length: techanOrderList.length},
+ {path: '/subPackages/ticket/order', length: ticketOrderList.length},
+ {path: '/subPackages/food/order', length: foodOrderList.length},
+ {path: '',length: hotelOrderList.length}
+ ]
+ let nextPage = orderPage.find((v,index)=>v.length>0&&index>=currentPageIndex)
+ if (nextPage) {
+ console.log(nextPage)
+ uni.navigateTo({
+ url: nextPage.path+'?isShoppingCart=1'
+ })
+ } else {
+ console.log(orderPage, nextPage, '结束')
+ // todo 最后下单页面
+ }
}
\ No newline at end of file
diff --git a/static/js/request.js b/static/js/request.js
index d630e78..4f75e4b 100644
--- a/static/js/request.js
+++ b/static/js/request.js
@@ -2,8 +2,8 @@ import Vue from 'vue';
import store from '@/store';
// 定义 API URL
-const DEV_API_URL = 'https://api.cloud.sz-trip.com';
-// const DEV_API_URL = 'https://swsz.api.js-dyyj.com'
+// const DEV_API_URL = 'https://api.cloud.sz-trip.com';
+const DEV_API_URL = 'https://swsz.api.js-dyyj.com'
const PROD_API_URL = 'https://swsz.api.js-dyyj.com';
const NEWAPIURL = process.env.NODE_ENV === 'development' ? DEV_API_URL : PROD_API_URL;
@@ -40,8 +40,8 @@ Vue.prototype.NEWAPIURL = '/api';
// #endif
Vue.prototype.Post = (params = {}, apiurl) => {
- const token = getToken() || '0caa10fc-6d65-4d9c-8e57-b344be3fc526'; // 君到苏州
- // const token = getToken() || 'a090644d-2bdb-4807-833b-bb5bc2182ac5' // 时味苏州
+ // const token = getToken() || '0caa10fc-6d65-4d9c-8e57-b344be3fc526'; // 君到苏州
+ const token = getToken() || 'a090644d-2bdb-4807-833b-bb5bc2182ac5' // 时味苏州
if (token) {
params.token = token;
}
diff --git a/store/modules/user.js b/store/modules/user.js
index 9f6a62f..863cf3f 100644
--- a/store/modules/user.js
+++ b/store/modules/user.js
@@ -17,7 +17,7 @@ export default {
ticketOrderList: [], // 门票类下单
foodOrderList: [], // 农家烟火下单
techanOrderList: [], // 邮寄自提下单
-
+ hotelOrderList: [], // 酒店下单
meetRoomReserve: {
date: null, //使用日期信息
coupon: null, // 优惠券信息
@@ -88,5 +88,9 @@ export default {
changeFoodOrderList(state, data){
state.foodOrderList = data
},
+ // 酒店下单
+ changeHotelOrderList(state, data){
+ state.hotelOrderList = data
+ },
}
}
diff --git a/subPackages/food/detail.vue b/subPackages/food/detail.vue
index 56a2e4a..7a4f31f 100644
--- a/subPackages/food/detail.vue
+++ b/subPackages/food/detail.vue
@@ -271,7 +271,7 @@
sInfo: goods,
}]
- uni.setStorageSync('foodOrder', JSON.stringify(orderInfo)); //规格
+ this.$store.commit("changeFoodOrderList", orderInfo);
uni.navigateTo({
url: '/subPackages/food/order'
});
diff --git a/subPackages/food/order.vue b/subPackages/food/order.vue
index de56d4d..4111660 100644
--- a/subPackages/food/order.vue
+++ b/subPackages/food/order.vue
@@ -148,15 +148,7 @@
initPageData () {
- let data = uni.getStorageSync('foodOrder');
- try{
- data = JSON.parse(data)
- this.orderList = data
- console.log(this.orderList)
-
- } catch(e){
- console.log(e)
- }
+ this.orderList = this.$store.state.user.foodOrderList;
this.getMaxCouponData()
},
@@ -238,6 +230,13 @@
goods.push(param)
})
+ // 如果是购物车下单
+ if (this.isShoppingCart) {
+ this.$store.commit("changeFoodOrderList", this.orderList);
+ this.goCartNextPage(3)
+ return
+ }
+
let data = {
product_list: goods,
diff --git a/subPackages/techan/detail.vue b/subPackages/techan/detail.vue
index 6cdfb76..762cb41 100644
--- a/subPackages/techan/detail.vue
+++ b/subPackages/techan/detail.vue
@@ -245,13 +245,13 @@
// post: 0,
}]
- uni.setStorageSync('teChanOrder', JSON.stringify(orderInfo)); //规格
+ this.$store.commit("changeTechanOrderList", orderInfo);
uni.navigateTo({
url: '/subPackages/techan/order'
});
},
addToCart () {
- let goods = this.trueSku[this.productIndex]
+ let goods = this.sku[this.productIndex]
goods.buyNum = this.buyNum
this.Post({sku_id: goods.id,num: this.buyNum },'/api/cart/add_sku').then(res => {
if (res.code == 1) {
diff --git a/subPackages/techan/index.vue b/subPackages/techan/index.vue
index a11f44b..e7cddbe 100644
--- a/subPackages/techan/index.vue
+++ b/subPackages/techan/index.vue
@@ -123,7 +123,7 @@
-
+