马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
一、效果图
1、主页面
根据物品信息进行菜单分类,点击单项购物车图标添加至购物车,记载总购物车数目
2、购物车详情页
根据主页面选择的项,根据背景查询展示到页面,可进行多选,数目加减等
二、代码
1、主页面
页面展示顶部导航栏,侧边导航栏,以及导航栏执行下的内容,购物车的点击事件,内容单项的点击数目汇总到顶部总购物车总数目
wxml代码
- <view class="main">
- <view class="topinfo">
- <view class="topinfo_view flex center">
- <view class="topinfo_model1 flex center">
- <view class="topinfo_model1_search">
- <image src="{{search}}"></image>
- <input type="text" placeholder="请输入" placeholder-style="color:#CCCCCC" bindconfirm="search_info" />
- </view>
- </view>
- <view class="topinfo_model2 flex center" >
- <view class="topinfo_model2_circle flex center" bind:tap="shoppingClick">
- <image src="{{ShoppingCarGreen}}" />
- <view class="red_single1 flex center" wx:if="{{shoppingAllCount > 0}}">{{shoppingAllCount}}</view>
- </view>
- </view>
- </view>
- </view>
- <view class="menu">
- <view class="top-menu flex between">
- <block wx:for="{{Menus}}" wx:key="index">
- <view class="topmenu-item flex center {{currentTopMenu === item.topname ? 'topactive' :''}}" data-menu="{{item.topname}}" bind:tap="onTopMenuClick">{{item.topname}}</view>
- </block>
- </view>
- <view class="top-content flex center" wx:if="{{!linenone}}">
- <view class="left-menu">
- <block wx:for="{{LeftMenus}}" wx:key="index">
- <view class="left-menu-item flex center {{currentLeftMenu === item.name ? 'leftactive' : ''}}" bindtap="onLeftMenuClick" data-menu="{{item.name}}">
- <view class="left {{currentLeftMenu === item.name ? 'leftactivegreen' : ''}}"></view>
- <text>{{item.name}}</text>
- </view>
- </block>
- </view>
- <view class="right-content">
- <block wx:for="{{RightInfo}}" wx:key="index">
- <view class="right-content-view flex">
- <view class="content-img flex center">
- <image src="{{item.img}}" mode="aspectFill"/>
- </view>
- <view class="content-info">
- <view class="cinfo-line flex between">
- <text>标题1:{{item.info1}}</text>
- <text>标题2:{{item.info2}}</text>
- </view>
- <view class="cinfo-line flex between">
- <text>标题3:{{item.info3}}</text>
- <text>标题4:{{item.info4}}</text>
- </view>
- <view class="cinfo-line flex between">标题5:{{item.info5}}</view>
- <view class="cinfo-line flex flex-end">
- <view class="green-btn flex center" data-id="{{item.id}}" bind:tap="singleSel">
- <image src="{{ShoppingCarWhite}}" mode=""/>
- <view class="red_single flex center" wx:if="{{item.isshopping}}">{{item.shoppingCount}}</view>
- </view>
- </view>
- </view>
- </view>
- </block>
- </view>
- </view>
- <view wx:else class="none">暂无数据</view>
- </view>
- </view>
复制代码 wxss代码
主要采用flex布局进行布局
js代码
这里主要展示核心数据部门,具体可参考资源
- Menus: [{
- topname: '顶部菜单1',
- leftMenus: [{
- name: '侧边菜单1',
- items: [{
- id: 1,
- info1: '11',
- info2: '22',
- info3: '33',
- info4: '44',
- info5: '55',
- img: '../img/process_2.png'
- },
- {
- id: 2,
- info1: '22',
- info2: '22',
- info3: '22',
- info4: '22',
- info5: '22',
- img: '../img/process_1.png'
- },
- ],
- },
- {
- name: '侧边菜单2',
- items: [{
- id: 3,
- info1: '33',
- info2: '33',
- info3: '33',
- info4: '33',
- info5: '33',
- img: '../img/process_3.png'
- }],
- },
- ]
- },
- {
- topname: '顶部菜单2',
- leftMenus: []
- },
- {
- topname: '顶部菜单3',
- leftMenus: [{
- name: '侧边菜单3',
- items: [{
- id: 4,
- info1: '44',
- info2: '44',
- info3: '44',
- info4: '44',
- info5: '44',
- img: '../img/process_2.png'
- }],
- }],
- },
- {
- topname: '顶部菜单4',
- leftMenus: [{
- name: '侧边菜单4',
- items: [{
- id: 5,
- info1: '55',
- info2: '55',
- info3: '55',
- info4: '55',
- info5: '55',
- img: '../img/process_1.png'
- }],
- }],
- },
- ],
复制代码 2、购物车界面
主要完成页面的选中项的展示,根据主页页面传递的id参数可进行数据库的查询,这里没连接后端,所以直接展示的实例数据,循环出数据项后,可对数据项进行多选,数据加减等功能
wxml代码
实现页面
- <view class="main">
- <view class="itemallinfo">
- <view class="item_info flex center" wx:for="{{allinfo}}" wx:key="index" data-id="{{item.id}}">
- <view class="item flex center">
- <view class="sel_checkbox flex center">
- <checkbox value="{{item.id}}" checked="{{item.checked}}" bindtap="handleSelectItem" data-id="{{item.id}}" />
- </view>
- <view class="info_image flex center">
- <image src="{{item.img}}" mode="aspectFill" />
- </view>
- <view class="info_content">
- <view class="info_line1">配件名称:{{item.name}}</view>
- <view class="info_line1">库存数量:{{item.stockQty}}{{item.uom}}</view>
- <view class="info_line1 flex flex-end numbtn">
- <view class="btn_minus flex center" bindtap="handleMinus" data-id="{{item.id}}">-</view>
- <input class="input_count" type="number" value="{{item.count}}" bindinput="handleInputChange" data-id="{{item.id}}" />
- <view class="btn_plus flex center" bindtap="handlePlus" data-id="{{item.id}}">+</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="footer flex between">
- <view class="select_all flex center">
- <checkbox bindtap="handleSelectAll" checked="{{isAllSelected}}" /> 全选
- </view>
- <view class="bottom2 flex center">
- <view class="delete_btn surebtn flex center" bindtap="handleDelete">删除</view>
- </view>
- <view class="bottom3 flex center">
- <view class="submit_btn surebtn flex center" bindtap="handleSubmit">提交</view>
- </view>
- </view>
- </view>
复制代码 wxss代码
js代码
这里主要展示核心数据部门,具体可参考资源
- var allinfo = [{
- id: 1,
- info1: '11',
- info2: '22',
- info3: '33',
- info4: '44',
- info5: '55',
- img: '../img/process_2.png',
- count: 1,
- checked: false, // 默认未选中
- },
- {
- id: 3,
- info1: '33',
- info2: '33',
- info3: '33',
- info4: '33',
- info5: '33',
- img: '../img/process_3.png',
- count: 2,
- checked: false, // 默认未选中
- },
- {
- id: 5,
- info1: '55',
- info2: '55',
- info3: '55',
- info4: '55',
- info5: '55',
- img: '../img/process_1.png',
- count: 1,
- checked: false, // 默认未选中
- },
- ];
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |