master
wbb 2 years ago
parent 628059f780
commit 21b40c1e5f

@ -1,45 +0,0 @@
Component({
data: {
selected: 0,
color: "#7A7E83",
selectedColor: "#3cc51f",
"list": [
{
"pagePath": "/pages/index/index",
"text": "首页",
"iconPath": "/images/home.png",
"selectedIconPath": "/images/home-active.png"
},
{
"pagePath": "/pages/fourm/fourm",
"text": "论坛",
"iconPath": "/images/message.png",
"selectedIconPath": "/images/message-active.png"
},
{"pagePath": "/pages/cart/cart",
"text": "购物车",
"iconPath": "/images/message.png",
"selectedIconPath": "/images/message-active.png"
},
{
"pagePath": "/pages/usercenter/usercenter",
"text": "我的",
"iconPath": "/images/message.png",
"selectedIconPath": "/images/message-active.png"
}
]
},
attached() {
},
methods: {
switchTab(e) {
const data = e.currentTarget.dataset
const url = data.path
wx.switchTab({url})
this.setData({
selected: data.index
})
}
}
})

@ -1,3 +0,0 @@
{
"component": true
}

@ -1,8 +0,0 @@
<!--miniprogram/custom-tab-bar/index.wxml-->
<cover-view class="tab-bar">
<cover-view class="tab-bar-border"></cover-view>
<cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
<cover-image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image>
<cover-view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</cover-view>
</cover-view>
</cover-view>

@ -1,38 +0,0 @@
.tab-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 48px;
background: white;
display: flex;
padding-bottom: env(safe-area-inset-bottom);
}
.tab-bar-border {
background-color: rgba(0, 0, 0, 0.33);
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 1px;
transform: scaleY(0.5);
}
.tab-bar-item {
flex: 1;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.tab-bar-item cover-image {
width: 27px;
height: 27px;
}
.tab-bar-item cover-view {
font-size: 10px;
}

@ -32,7 +32,22 @@ Page({
},
// 渲染数据
addCar: function (event) {
// 获取 event 事件对象
// 获取点击对应的下标
var index = event.currentTarget.dataset.foodid;
console.log(index);
//抓取id进行赋
//wx.navigateTo 会触发页面隐藏onHide
console.log('11111')
wx.showToast({
title: '加入购物车成功',
icon: 'success',
duration: 2000
});
},
/**

@ -1,7 +1,7 @@
<view class="container">
<view class="container" >
<image src="{{detailObj.url}}"></image>
<view class="detail">
<view class="detail" >
<text class="title">{{detailObj.food_name}}</text>
<text>{{detailObj.food_shop}}</text>
<text class="price">¥{{detailObj.price}}</text>
@ -14,6 +14,7 @@
<text>商品评价</text>
<text class="text-remark">东西还可以,好评~</text>
<view class="separate"></view>
<view class="detail-nav">
<button class="button-green" bindtap="addCar" formType="submit">加入购物车</button>
<button class="button-red" bindtap="immeBuy" formType="submit">立即购买</button></view>
<view class="detail-nav" data-foodid="{{detailObj._id}}" >
<button class="button-green" bindtap="addCar" formType="submit" >加入购物车</button>
<button class="button-red" bindtap="immeBuy" formType="submit">立即购买</button>
</view>

@ -37,7 +37,9 @@
"disableUseStrict": false,
"showES6CompileOption": false,
"useCompilerPlugins": false,
"minifyWXML": true
"minifyWXML": true,
"ignoreDevUnusedFiles": false,
"ignoreUploadUnusedFiles": false
},
"appid": "wxcc745ea897810e52",
"projectname": "quickstart-wx-cloud",

Loading…
Cancel
Save