购物车渲染成功显示,个人主页更新

master
wbb 2 years ago
parent 3602f7d731
commit b7fb4b4510

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

@ -8,35 +8,33 @@ Page({
data: { data: {
cartlistsee:[] cartlistsee:[]
}, },
async f() {
const res = await db.collection('user').doc('eda7dd506371adb300c89bc66afc4601').get();
console.log(res);
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad:function(options) { onLoad:function(options) {
var _this = this;
const db = wx.cloud.database({ const db = wx.cloud.database({
//这个是环境ID不是环境名称 //这个是环境ID不是环境名称
env: 'cloud1-8g5wmepxce8a3b8a' env: 'cloud1-8g5wmepxce8a3b8a'
}) })
//2、开始查询数据了 news对应的是集合的名称 //2、开始查询数据了 news对应的是集合的名称
db.collection('user').doc('eda7dd506371adb300c89bc66afc4601').get({ db.collection("user")
//如果查询成功的话 .doc("eda7dd506371adb300c89bc66afc4601")
success: res => { .get()
console.log(res.data) .then(res => {
//这一步很重要给ne赋值没有这一步的话前台就不会显示值 console.log("列表页", res.data);
console.log(res.data.cartlist)
//再次显示数据
this.setData({ this.setData({
cartlist: res.data cartlistsee:res.data.cartlist
}) })
}
}) })
}, .catch(err => {
console.log("加载失败", err);
})
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */

@ -1,2 +1,44 @@
<!--pages/cart/cart.wxml--> <!--pages/cart/cart.wxml-->
<view catchtap="f">测试</view> <view>
<scroll-view class="scrol_view_style" scroll-x="{{false}}" scroll-y="{{true}}">
<view style="height: 10rpx;"></view>
<view wx:for-items="{{cartlistsee}}" class="list_item_style" wx:key="{{ index }}">
<checkbox-group bindchange="checkboxChange" style="height:100%" data-index="{{index}}" data-checks="{{item.checks}}">
<view class="carts_box">
<checkbox value="{{item.cart_id}}" checked="{{item.checks}}" class="checkbox_one" data-index="{{index}}" bindtap="allCheckbox" />
<image src="{{item.url}}" class="good_main_image" style="border-radius: 20px;"></image>
<view class="cart_content_right">
<text class="item_good_title">{{item.food_name}}</text>
<view class="price_back_view">
<text class="right_list_item_price">¥{{item.price}}</text>
</view>
<view class="cart_content_bottom">
<view class='btn_wrap'>
<!-- <image src="/images/reduce.png" class = "reduce_image_style" id = "{{index}}" bindtap = "reduceButtonClick"></image> -->
<input type='text' value='-' disabled='true' id="{{index}}" bindtap="reduceButtonClick"></input>
<input type='text' value="{{item.num}}" />
<!-- <image src="/images/add.png" class = "add_image_style" id = "{{index}}" bindtap = "addButtonClick"></image> -->
<input type='text' value='+' disabled='true' id="{{index}}" bindtap="addButtonClick"></input>
</view>
<view class="delete" bindtap="deleteGoods">删除</view>
</view>
</view>
</view>
</checkbox-group>
</view>
<view class='buy_shop'>
<view class="select_allbox">
<checkbox value="{{item.food_name}}" checked="{{checked}}" style='margin-left:20rpx;' bindtap='setChecked' />
<text>全选</text>
</view>
<text class='heji'>合计:<text class='all_shop_price'>¥{{total_all_price}}</text></text>
<view class='jiesuan' bindtap="toBuy">
<text>结算</text>
</view>
</view>
<view style="height:10px;background-color:#F5F5F5;width:100%"></view>
<view class='no_shop' wx:if="{{is_shop}}">
<text>购物车中没有商品</text>
</view>
</scroll-view>
</view>

@ -1 +1,239 @@
/* pages/cart/cart.wxss */ /* pages/cart/cart.wxss */
/*list样式*/
.scrol_view_style {
background: #f5f5f5;
}
.carts_box {
display: flex;
align-items: center;
height: 100%;
}
/*item*/
.list_item_style {
height: 180rpx;
background: white;
padding-bottom: 20rpx;
padding-left: 20rpx;
padding-right: 20rpx;
}
/*商品主图*/
.good_main_image {
width: 180rpx;
height: 180rpx;
margin-left: 10rpx;
border: 1rpx solid #bbb;
}
/*商品名称*/
.item_good_title {
text-align: left;
font-size: 32rpx;
height: auto;
white-space: nowrap;
word-break: keep-all;
overflow: hidden;
text-overflow: ellipsis;
width: 90%;
}
.cart_content_right {
display: flex;
flex-direction: column;
height: 100%;
margin-left: 20rpx;
}
.btn_wrap {
display: flex;
flex-direction: row;
align-items: center;
width: 200rpx;
}
.btn_wrap input {
background: #f8f8f8;
color: #666;
font-size: 26rpx;
right: 10rpx;
width: 50rpx;
text-align: center;
}
.btn_wrap input:nth-child(2) {
margin: 0 10rpx;
}
/*+号按钮*/
.add_image_style {
width: 20rpx;
height: 20rpx;
position: relative;
top: 60rpx;
right: 10rpx;
float: right;
}
/*——号按钮*/
.reduce_image_style {
width: 20rpx;
height: 20rpx;
position: relative;
top: 60rpx;
right: 10rpx;
float: right;
}
/*购买数量*/
.good_buy_number {
height: 25rpx;
position: relative;
top: 57rpx;
background: #f8f8f8;
color: #666;
font-size: 22rpx;
right: 10rpx;
width: 50rpx;
text-align: center;
float: right;
margin-right: 5rpx;
margin-left: 5rpx;
border-radius: 5rpx;
}
/*价钱的背景试图*/
.price_back_view {
display: flex;
align-items: center;
justify-content: space-between;
width: 460rpx;
padding-top: 20rpx;
}
.cart_content_bottom {
display: flex;
align-items: center;
justify-content: space-between;
width: 460rpx;
padding-top: 25rpx;
}
.cart_content_bottom .delete {
font-size: 28rpx;
}
/*售价*/
.right_list_item_price {
color: #ff5d08;
font-size: 32rpx;
}
/* 没有商品时的购物车样式 */
.no_shop {
text-align: center;
font-size: 50rpx;
color: #bbb;
margin-top: 100px;
}
/*规格的样式*/
.guige {
font-size: 28rpx;
}
/* 未选中的 背景样式 */
checkbox .wx-checkbox-input {
border-radius: 50%; /* 圆角 */
width: 35rpx; /* 背景的宽 */
height: 35rpx; /* 背景的高 */
}
/* 选中后的 背景样式 (红色背景 无边框 可根据UI需求自己修改 */
checkbox .wx-checkbox-input.wx-checkbox-input-checked {
border-color: red;
background: red;
}
/* 选中后的 对勾样式 (白色对勾 可根据UI需求自己修改 */
checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
border-radius: 50%; /* 圆角 */
width: 35rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
height: 35rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
line-height: 35rpx;
text-align: center;
font-size: 25rpx; /* 对勾大小 30rpx */
color: #fff; /* 对勾颜色 白色 */
background: transparent;
transform: translate(-50%, -50%) scale(1);
-webkit-transform: translate(-50%, -50%) scale(1);
}
/*合计样式*/
.heji {
/* margin-left: 140px; */
float: right;
margin-right: 75px;
}
/*合计价格的样式*/
.all_shop_price {
color: #ff6261;
}
/*结算的样式*/
.jiesuan {
position: absolute;
height: 100%;
border-radius: 5rpx;
line-height: 80rpx;
padding: 0 30rpx;
color: white;
font-size: 28rpx;
background: #ff5d08;
bottom: 0rpx;
right: 0rpx;
}
/*全选的样式*/
.buy_shop {
width: 100%;
height: 80rpx;
background-color: white;
line-height: 80rpx;
position: fixed;
bottom: 0;
font-size: 28rpx;
z-index: 999;
box-shadow: 0 0 10rpx rgba(155, 143, 143, 0.6);
display: flex;
align-items: center;
}
.select_allbox{
display: flex;
align-items: center;
width: 57%;
}
.select_allbox text{
padding-left: 10rpx;
}

@ -11,6 +11,7 @@ Page({
detailObj: {}, detailObj: {},
list:[], list:[],
clockresult:[], clockresult:[],
userid:null
}, },
@ -20,26 +21,33 @@ Page({
onLoad: function (options) { onLoad: function (options) {
let foodid =options.id let foodid =options.id
var userid=options.aid
console.log('1111wb');
cont.doc(foodid).get({ cont.doc(foodid).get({
success: res => { success: res => {
console.log(res.data) console.log(res.data)
//这一步很重要给ne赋值没有这一步的话前台就不会显示值 //这一步很重要给ne赋值没有这一步的话前台就不会显示值
this.setData({ this.setData({
detailObj: res.data detailObj: res.data,
}) })
} }
}) })
}, },
// 渲染数据 // 渲染数据
async addCar(event) { async addCar(event) {
var detailObj= event.currentTarget.dataset.item; var detailObj= event.currentTarget.dataset.item;
var userid=event.currentTarget.dataset.userid;
db.collection('user').doc('eda7dd506371adb300c89bc66afc4601').update({ db.collection('user').doc('eda7dd506371adb300c89bc66afc4601').update({
data:{ data:{
cartlist:db.command.push(detailObj) cartlist:db.command.push(detailObj)
} }
}) })
wx.showToast({ wx.showToast({
title: '加入购物车成功', title: '加入购物车成功',
icon: 'success', icon: 'success',

@ -15,6 +15,6 @@
<text class="text-remark">东西还可以,好评~</text> <text class="text-remark">东西还可以,好评~</text>
<view class="separate"></view> <view class="separate"></view>
<view class="detail-nav" > <view class="detail-nav" >
<button class="button-green" catchtap="addCar" formType="submit" data-item="{{detailObj}}">加入购物车</button> <button class="button-green" catchtap="addCar" formType="submit" data-item="{{detailObj}}" data-userid="{userid}">加入购物车</button>
<button class="button-red" bindtap="immeBuy" data-item="{{detailObj._id}}" formType="submit">立即购买</button> <button class="button-red" bindtap="immeBuy" data-item="{{detailObj._id}}" formType="submit">立即购买</button>
</view> </view>

@ -2,26 +2,26 @@
<!-- 第一部分 --> <!-- 第一部分 -->
<view class="view_1"> <view class="view_1">
<view class="view_image_text"> <view class="view_image_text">
<image class="image_radius" src="../images/timg.png" /> <image class="image_radius" src="../images/icon9.jpeg" />
<text>张三</text> <text>张三</text>
</view> </view>
</view> </view>
<!-- 第二部分 --> <!-- 第二部分 -->
<view class="view_2"> <view class="view_2">
<view class="view_tupianwenzi"> <view class="view_tupianwenzi">
<image class="image_tupian" src="../images/test1.png"></image> <image class="image_tupian" src="/images/test1.jpg"></image>
<text class="text_saoyisao">待付款</text> <text class="text_saoyisao">待付款</text>
</view> </view>
<view class="view_tupianwenzi"> <view class="view_tupianwenzi">
<image class="image_tupian" src="../images/test2.png"></image> <image class="image_tupian" src="/images/test2.jpg"></image>
<text class="text_saoyisao">待发货</text> <text class="text_saoyisao">待发货</text>
</view> </view>
<view class="view_tupianwenzi"> <view class="view_tupianwenzi">
<image class="image_tupian" src="../images/test3.png"></image> <image class="image_tupian" src="/images/test3.jpg"></image>
<text class="text_saoyisao">待收货</text> <text class="text_saoyisao">待收货</text>
</view> </view>
<view class="view_tupianwenzi"> <view class="view_tupianwenzi">
<image class="image_tupian" src="../images/test4.png"></image> <image class="image_tupian" src="/images/test4.jpg"></image>
<text class="text_saoyisao">待评价</text> <text class="text_saoyisao">待评价</text>
</view> </view>
@ -29,29 +29,29 @@
<!-- 第三部分 --> <!-- 第三部分 -->
<view class="view_3"> <view class="view_3">
<view class="list-item"> <view class="list-item">
<image class="item-image" src="../images/test5.png"></image> <image class="item-image" src="/images/test6.jpg"></image>
<text class="item-text">我的收藏</text> <text class="item-text">我的收藏</text>
<image class="image-jiantou" src="../images/jiantou.png"></image>
</view> </view>
<view class="line"></view> <view class="line"></view>
<view class="list-item"> <view class="list-item">
<image class="item-image" src="../images/test6.png"></image> <image class="item-image" src="/images/test6.jpg"></image>
<text class="item-text">我的评价</text> <text class="item-text">我的评价</text>
<image class="image-jiantou" src="../images/jiantou.png"></image>
</view> </view>
<view class="line"></view> <view class="line"></view>
<view class="line"></view> <view class="line"></view>
<view class="list-item"> <view class="list-item">
<image class="item-image" src="../images/test9.png"></image> <image class="item-image" src="/images/test6.jpg"></image>
<text class="item-text">售后记录</text> <text class="item-text">售后记录</text>
<image class="image-jiantou" src="../images/jiantou.png"></image>
</view> </view>
<view class="line"></view> <view class="line"></view>
<view class="list-item"> <view class="list-item">
<image class="item-image" src="../images/test12.png"></image> <image class="item-image" src="/images/test6.jpg"></image>
<text class="item-text">分享邀请</text> <text class="item-text">分享邀请</text>
<image class="image-jiantou" src="../images/jiantou.png"></image>
</view> </view>
<view class="line"></view> <view class="line"></view>
</view> </view>

@ -51,6 +51,20 @@
"pathName": "pages/updateRecordSuccess/index", "pathName": "pages/updateRecordSuccess/index",
"query": "", "query": "",
"scene": null "scene": null
},
{
"name": "",
"pathName": "pages/usercenter/usercenter",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/cart/cart",
"query": "",
"launchMode": "default",
"scene": null
} }
] ]
} }

Loading…
Cancel
Save