国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 熱點 > 微信 > 正文

微信小程序實現商品屬性聯動選擇

2024-07-22 01:19:04
字體:
來源:轉載
供稿:網友

本文實例為大家分享了微信小程序實現商品屬性聯動選擇的具體代碼,供大家參考,具體內容如下

效果演示:

代碼示例

1、commodity.xml

<!-- <view class="title">屬性值聯動選擇</view>  --><!--options--><view class="commodity_attr_list">   <!--每組屬性-->  <view class="attr_box" wx:for="{{attrValueList}}" wx:for-item="attrValueObj" wx:for-index="attrIndex">    <!--屬性名-->   <view class="attr_name">{{attrValueObj.attrKey}}</view>     <!--屬性值-->   <view class="attr_value_box">      <!--每個屬性值-->     <view class="attr_value {{attrIndex==firstIndex || attrValueObj.attrValueStatus[valueIndex]?(value==attrValueObj.selectedValue?'attr_value_active':''):'attr_value_disabled'}}" bindtap="selectAttrValue" data-status="{{attrValueObj.attrValueStatus[valueIndex]}}"     data-value="{{value}}" data-key="{{attrValueObj.attrKey}}" data-code="{{attrCode}}" data-index="{{attrIndex}}" data-selectedvalue="{{attrValueObj.selectedValue}}" wx:for="{{attrValueObj.attrValues}}" wx:for-item="value" wx:for-index="valueIndex">{{value}}</view>    </view>  </view> </view> <!--button--><view class="weui-btn-area">   <button class="weui-btn" bindtap="submit">選好了    </button> </view> 

上述代碼把頁面盒子分為兩部分commodity_attr_list和weui-btn-area。
commodity_attr_list:循環獲取商品的屬性名和相對應的屬性值,并布局頁面。
weui-btn-area:提交校驗并獲取選中商品屬性結果。

2、commodity.js

數據結構

//數據結構:以一組一組的數據來進行設定   commodityAttr: [   {    priceId: 1,    price: 35.0,    "stock": 8,    "attrValueList": [     {      "attrKey": "規格:",      "attrValue": "+免費配料",      "attrCode": "1001"     },     {      "attrKey": "甜度:",      "attrValue": "七分甜",      "attrCode": "2001"     },     {      "attrKey": "加料:",      "attrValue": "珍珠",      "attrCode": "3001"     },     {      "attrKey": "冰塊:",      "attrValue": "少冰",      "attrCode": "4001"     }    ]   },   {    priceId: 2,    price: 35.1,    "stock": 9,    "attrValueList": [     {      "attrKey": "規格:",      "attrValue": "+燕麥",      "attrCode": "1002"     },     {      "attrKey": "甜度:",      "attrValue": "五分甜",      "attrCode": "2002"     },     {      "attrKey": "加料:",      "attrValue": "椰果",      "attrCode": "3002"     },     {      "attrKey": "冰塊:",      "attrValue": "去冰",      "attrCode": "4002"     }    ]   },   {    priceId: 3,    price: 35.2,    "stock": 10,    "attrValueList": [     {      "attrKey": "規格:",      "attrValue": "+布丁",      "attrCode": "1003"     },     {      "attrKey": "甜度:",      "attrValue": "無糖",      "attrCode": "2003"     },     {      "attrKey": "加料:",      "attrValue": "仙草",      "attrCode": "3003"     },     {      "attrKey": "冰塊:",      "attrValue": "常溫",      "attrCode": "4003"     }    ]   },   {    priceId: 4,    price: 35.2,    "stock": 10,    "attrValueList": [     {      "attrKey": "規格:",      "attrValue": "再加一份奶霜",      "attrCode": "1004"     },     {      "attrKey": "甜度:",      "attrValue": "無糖",      "attrCode": "2003"     },     {      "attrKey": "加料:",      "attrValue": "仙草",      "attrCode": "3004"     },     {      "attrKey": "冰塊:",      "attrValue": "熱飲",      "attrCode": "4004"     }    ]   },   {    priceId: 5,    price: 35.2,    "stock": 10,    "attrValueList": [     {      "attrKey": "規格:",      "attrValue": "+免費配料",      "attrCode": "1004"     },     {      "attrKey": "甜度:",      "attrValue": "五分甜",      "attrCode": "2003"     },     {      "attrKey": "加料:",      "attrValue": "椰果",      "attrCode": "3004"     },     {      "attrKey": "冰塊:",      "attrValue": "常溫",      "attrCode": "4004"     }    ]   }  ],  attrValueList: [] }            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 手游| 藁城市| 大竹县| 隆子县| 许昌县| 永兴县| 扬州市| 乐业县| 旺苍县| 武山县| 津南区| 绍兴县| 福鼎市| 黎川县| 丰城市| 松阳县| 大同市| 南木林县| 楚雄市| 三江| 清丰县| 棋牌| 老河口市| 宜良县| 虎林市| 建水县| 灵丘县| 安平县| 衢州市| 临邑县| 邵阳市| 马尔康县| 紫阳县| 淮滨县| 商丘市| 抚宁县| 胶州市| 安阳县| 曲靖市| 昭通市| 重庆市|