Browse Source

购物车id

master
jiazhipeng 2 months ago
parent
commit
014394f931
  1. 4
      App.vue
  2. 8
      components/cartData.vue
  3. 4
      mixins/myMixins.js
  4. 12
      pages/cart/cart.vue

4
App.vue

@ -7,8 +7,8 @@
// 1 // 1
this.Post({id:2388},'/api/multimedia/detail').then(res => { this.Post({id:2388},'/api/multimedia/detail').then(res => {
try { try {
let SHFlag = res.data.company_name == 1 ? true : false // let SHFlag = res.data.company_name == 1 ? true : false
// let SHFlag = res.data.ext_link == 1 ? true : false let SHFlag = res.data.ext_link == 1 ? true : false
uni.setStorageSync('SHFlag', SHFlag) uni.setStorageSync('SHFlag', SHFlag)
} catch(e) { } catch(e) {
uni.setStorageSync('SHFlag', false) uni.setStorageSync('SHFlag', false)

8
components/cartData.vue

@ -173,9 +173,9 @@
}, },
clearAllGoods(){ clearAllGoods(){
let ids = this.cartData.map(v=>v.sku.id) let ids = this.cartData.map(v=>v.id)
if (ids.length>0) { if (ids.length>0) {
this.Post({sku_id:ids.join(',')},'/api/cart/del_sku').then(res=>{ this.Post({id:ids.join(',')},'/api/cart/del_sku').then(res=>{
this.cartData = [] this.cartData = []
this.setAllSelect() this.setAllSelect()
}) })
@ -195,13 +195,13 @@
addBuyNum(item, num,index){ addBuyNum(item, num,index){
if (num == -1 && item.num == 1) { if (num == -1 && item.num == 1) {
this.Post({sku_id: item.sku_id, num: 0},'/api/cart/del_sku').then(res =>{ this.Post({id: item.id, num: 0},'/api/cart/del_sku').then(res =>{
this.cartData.splice(index,1) this.cartData.splice(index,1)
this.setAllSelect() this.setAllSelect()
}) })
} else { } else {
let numData = item.num + num let numData = item.num + num
this.Post({sku_id: item.sku_id, num: numData},'/api/cart/update_sku').then(res =>{ this.Post({id: item.id, num: numData},'/api/cart/update_sku').then(res =>{
item.num += num item.num += num
this.setAllSelect() this.setAllSelect()
}) })

4
mixins/myMixins.js

@ -18,7 +18,7 @@ export const myMixins ={
title: '时味苏州', title: '时味苏州',
type: 0, type: 0,
summary: "edewdewdewf", summary: "edewdewdewf",
imageUrl: "https://static.ticket.sz-trip.com/uploads/20250813/b31ec3969350407f4fca5c0d283d9102.png" imageUrl: "https://static.ticket.sz-trip.com/uploads/20250818/5ea2c18a15db8a438f2ce642194b6051.jpg"
} }
}, },
onShareAppMessage() { onShareAppMessage() {
@ -35,7 +35,7 @@ export const myMixins ={
return { return {
title: '时味苏州', // 分享的名称 title: '时味苏州', // 分享的名称
path: `${view.route}?url=${url}`, // 将 url 作为参数传递 path: `${view.route}?url=${url}`, // 将 url 作为参数传递
imageUrl: "https://static.ticket.sz-trip.com/uploads/20250813/b31ec3969350407f4fca5c0d283d9102.png", imageUrl: "https://static.ticket.sz-trip.com/uploads/20250818/5ea2c18a15db8a438f2ce642194b6051.jpg",
mpId: 'wx699ed131345cf8dd' // 此处配置微信小程序的 AppId mpId: 'wx699ed131345cf8dd' // 此处配置微信小程序的 AppId
}; };
} }

12
pages/cart/cart.vue

@ -185,14 +185,14 @@
this.delItem(item) this.delItem(item)
} else { } else {
let numData = item.num + num let numData = item.num + num
this.Post({sku_id: item.sku_id, num: numData},'/api/cart/update_sku').then(res =>{ this.Post({id: item.id, num: numData},'/api/cart/update_sku').then(res =>{
item.num += num item.num += num
}) })
} }
}, },
// //
delItem(item){ delItem(item){
this.Post({sku_id: item.sku_id},'/api/cart/del_sku').then(res =>{ this.Post({id: item.id},'/api/cart/del_sku').then(res =>{
// this.cartData.splice(index,1) // this.cartData.splice(index,1)
this.getList() this.getList()
}) })
@ -200,8 +200,8 @@
}, },
// //
delCartByShop (item, index) { delCartByShop (item, index) {
let goods = item.goods.map(v=>v.sku_id) let goods = item.goods.map(v=>v.id)
this.Post({sku_id: goods.join(',')},'/api/cart/del_sku').then(res =>{ this.Post({id: goods.join(',')},'/api/cart/del_sku').then(res =>{
this.getList() this.getList()
}) })
}, },
@ -209,9 +209,9 @@
delAll () { delAll () {
let goods = [] let goods = []
this.cartList.forEach(v=>{ this.cartList.forEach(v=>{
v.goods.forEach(x=>{goods.push(x.sku_id)}) v.goods.forEach(x=>{goods.push(x.id)})
}) })
this.Post({sku_id: goods.join(',')},'/api/cart/del_sku').then(res =>{ this.Post({id: goods.join(',')},'/api/cart/del_sku').then(res =>{
this.getList() this.getList()
}) })
}, },

Loading…
Cancel
Save