小程序购物车怎么实现(拼多多小程序怎么加购物车?)
拼多多小程序怎么加购物车?
开通拼多多账户并授权登录。点击需要添加到购物车的商品。打开购物车后,单击添加到购物车。谢谢你邀请我。小程序购物车中的数据可以通过以下属性在购物车中页面的数据中获取:
CartGoods(添加到购物车的商品列表)
CartTotal(goodsCount:购物车中所有商品的总数,checkedGoodsCount:购物车中所选商品的总数)
IsEditCart(购物车是否处于编辑状态)
CheckedAllStatus(在编辑状态下全选)
EditCartList(购物车中所选商品的列表)
如果你喜欢我的回答,请关注并喜欢。示例代码如下:varapp = g:、{cartGoods:、[],cartTotal:、{";goodsCount";: 0、 ";checkedGoodsCount";: 0,},isEditCart: false,check: true,editCartList:[]}、OnLoad:函数(options){//页面初始化选项是参数}、onR:函数()带来的页面跳转{//页面渲染完成}、OnShow:函数(){//Pag:函数(){//Pag:函数()然后(function(RES){ if(= = = 0){console.log()({cartGoods:,cartTotal:·})}({check:()})} },isCheck: function () {//判断购物车中所有商品已被选中return (function (element,index,array){ if(= = true){ return true } else { return false } } },check:函数(event){ let item index = that = this if(!){(,{ productIds:[item index].产品标识,isCheck:[项目索引]。检查过了?0 : 1 }、 邮政和邮政。;).然后(function(RES){ if(= = = 0){console.log()({cartGoods:,CartTotal:·})}({check:()})} } else {//编辑状态let tmpcartdata =(function(element,index,array) {if (index = = itemindex) {=!} return element})({cartGoods: tmpCartData,check: (),;;:()})} },getCheckedGoodsCount: function(){ let checkedGoodsCount =(function(v){ if(= = = true){ checkedGoodsCount = } })console . log(checkedGoodsCount)return checkedGoodsCount},check: function(){ let that = this if(!){ var product ids =(function(v){ return _ id })(,{ productIds:( ;, ),isCheck:()?0 : 1 }、 邮政和邮政。;).然后(function(RES){ if(= = = 0){console.log()({cartGoods:,CartTotal: })}({check:()})} } else {//编辑状态let checked all status =()let tmpcartdata =(function(v){ =!checkedAllStatusreturn v})({cartGoods: tmpCartData,check: (),;;:()})} },editCart:函数(){ var that = thisif(){()({isEditCart:!})} else {//编辑状态let tmpc art list =(function(v){ = false返回v})({editCartList: ,cartGoods: tmpCartList,isEditCart:!,check: (),;;: ()})}},updateCart:函数(productId,goodsId,number,id) {let that =(,{productId: productId,goodsId: goodsId,numb: numb: id }, 邮政和邮政。;).然后(function(RES){ if(= = = 0){console.log()({//cartGoods:·,//cartTotal: })}({ check: ()})})},cutNumb:函数(事件){ let item index = cartIt: = ({cartGoods: })this . update cart(_id,_id,numb:函数(event){ let item Index = cartItem =[item index]let Number = = ({cartGoods: })this . update cart(_ id,_ id,Number,)},checkoutOrd:函数(){//Get selected goods let = this var checked goods =(function(element,index,array){ if(= = true){ return true } else { return false } })if(check: ;../shopping/check out/Checkout;})},deleteCart:函数(){//删除选中的商品let that = this let products =(function(element,index,array){ if(= = true){ return true } else { return false } })if(product ids . length lt = 0){ return false } product ids =(function(element,index,array) {if ( == true) {return _id}})(,{productIds:( ;, )}, 邮政和邮政。;).then(function (res) {if ( === 0) {con sole . log()let cart list =(v = gt { console . log(v)= false return v})({cartGoods:·cartList,cartTotal:·})}({check:()})})} })
版权声明:本文内容由互联网用户自发贡献,本站不承担相关法律责任.如有侵权/违法内容,本站将立刻删除。