微信ウィジェットは計算属性computedパッケージショッピングカートコンポーネントを使用する


1.計算属性のインストール
npm install --save miniprogram-computed
  npm

2.パッケージでOK
参照リソースソースgithubアドレス:
https://github.com/zhaoweidongsundi/custom-cart/tree/master

3.パラメータ
パラメータ
デフォルト
必要かどうか
説明
products
なし
はい
カートデータ
bindsubmit
なし
いいえ
決済コミットイベント
binddelete
なし
いいえ
カートイベントの削除
4.要求データフォーマット
Productsデータでは、オブジェクト内の要素フィールドが現在の効果である必要があります.変更するには、ソースコードを自分で変更する必要があります.
 products:[{
     
  //       ,           
  id:2,
  goodsname:"    ",
  goodspic:"/pages/cart/1.jpg",
  num:2,
  price:2000,
  checked:true
 }]
 

5.イベント返却データ
bindsubmitイベント
detailはカートにイベントを提出し、戻った総価格と総数量
type: "submit"
timeStamp: 6139
target: {
     id: "", dataset: {
     }}
currentTarget: {
     id: "", dataset: {
     }}
mark: {
     }
detail: {
     totalPrice: 5000, totalNum: 3}    //        
touches: undefined
changedTouches: undefined
mut: false
_requireActive: undefined

BindDeleteイベント
detailはカート削除イベントであり、現在削除されているデータのidとインデックス位置を返します.
type: "delete"
timeStamp: 16480
target: {
     id: "", dataset: {
     }}
currentTarget: {
     id: "", dataset: {
     }}
mark: {
     }
detail: {
     id: 1, index: 0}  //        
touches: undefined
changedTouches: undefined
mut: false
_requireActive: undefined