微信小程序添加购物车效果
怎样通过微信进行拼多多购物?
怎样通过微信进行拼多多购物?
通过微信进行拼多多购物的方法步骤如下:
1、首先,我们打开我们的微信进入主页。
微信小程序中添加购物车中的数据根据什么获取?
谢邀,微信小程序购物车中数据可以在cart(购物车)中Page的data中通过以下属性获取:
cartGoods(添加到购物车中的商品列表)
cartTotal(goodsCount:购物车中所有商品总数,checkedGoodsCount:购物车中选中的商品总数)
isEditCart(购物车是否处于编辑状态)
checkedAllStatus(编辑状态下全选)
editCartList(购物车中选中的商品列表)
如果您喜欢我的回答,请关注并点赞哦,涩涩。示例代码如下:var app getApp()Page({data: {cartGoods: [],cartTotal: {goodsCount: 0,checkedGoodsCount: 0,},isEditCart: false,checkedAllStatus: true,editCartList: []},onLoad: function (options) {// 页面初始化 options为页面跳转所带来的参数},onReady: function () {// 页面渲染完成},onShow: function () {// 页面显示()},onHide: function () {// 页面隐藏},onUnload: function () {// 页面关闭},getCartList: function () {let that ().then(function (res) {if ( 0) {console.log()({cartGoods: ,cartTotal: })}({checkedAllStatus: ()})})},isCheckedAll: function () {//判断购物车商品已全选return (function (element, index, array) {if ( true) {return true} else {return false}})},checkedItem: function (event) {let itemIndex that thisif (!) {(, { productIds: [itemIndex].product_id, isChecked: [itemIndex].checked ? 0 : 1 }, POST).then(function (res) {if ( 0) {console.log()({cartGoods: ,cartTotal: })}({checkedAllStatus: ()})})} else {//编辑状态let tmpCartData (function (element, index, array) {if (index itemIndex){ !}return element})({cartGoods: tmpCartData,checkedAllStatus: (), ()})}},getCheckedGoodsCount: function(){let checkedGoodsCount (function (v) {if ( true) {checkedGoodsCount }})console.log(checkedGoodsCount)return checkedGoodsCount},checkedAll: function () {let that thisif (!) {var productIds (function (v) {return _id})(, { productIds: (,), isChecked: () ? 0 : 1 }, POST).then(function (res) {if ( 0) {console.log()({cartGoods: ,cartTotal: })}({checkedAllStatus: ()})})} else {//编辑状态let checkedAllStatus ()let tmpCartData (function (v) { !checkedAllStatusreturn v})({cartGoods: tmpCartData,checkedAllStatus: (), ()})}},editCart: function () {var that thisif () {()({isEditCart: !})} else {//编辑状态let tmpCartList (function (v) { falsereturn v})({editCartList: ,cartGoods: tmpCartList,isEditCart: !,checkedAllStatus: (), ()})}},updateCart: function (productId, goodsId, number, id) {let that (, {productId: productId,goodsId: goodsId,number: number,id: id}, POST).then(function (res) {if ( 0) {console.log()({//cartGoods: ,//cartTotal: })}({checkedAllStatus: ()})})},cutNumber: function (event) {let itemIndex cartItem [itemIndex]let number ( - 1 gt 1) ? - 1 : ({cartGoods: })this.updateCart(_id, _id, number, )},addNumber: function (event) {let itemIndex cartItem [itemIndex]let number ({cartGoods: })this.updateCart(_id, _id, number, )},checkoutOrder: function () {//获取已选择的商品let that thisvar checkedGoods (function (element, index, array) {if ( true) {return true} else {return false}})if (checkedGoods.length lt 0) {return false}({url: ../shopping/checkout/checkout})},deleteCart: function () {//删除已选择的商品let that thislet productIds (function (element, index, array) {if ( true) {return true} else {return false}})if (productIds.length lt 0) {return false}productIds (function (element, index, array) {if ( true) {return _id}})(, {productIds: (,)}, POST).then(function (res) {if ( 0) {console.log()let cartList (v gt {console.log(v) falsereturn v})({cartGoods: cartList,cartTotal: })}({checkedAllStatus: ()})})}})