This commit is contained in:
2020-06-30 18:06:50 +08:00
parent c7136c2c11
commit dc69746320
21 changed files with 471 additions and 1315 deletions

View File

@@ -12,45 +12,47 @@
<image src="../static/image/1.png" class="right"></image>
</view>
<view class="main">
<view class="goods-info">
<view class="store">
<image class="avatar"></image>
<view>胖胖的店</view>
<image src="../static/image/1.png" class="right"></image>
</view>
<view class="goods">
<view v-for="(goods, g_index) in 1" :key="g_index" class="goods-item">
<image></image>
<view class="info">
<view class="name u-line-2">木糖少女小紫薯西装领连衣裙夏季新款女装夏收腰格子格纹裙子</view>
<view class="cart-info">
<view class="price">99</view>
<u-number-box :input-width="38" :input-height="39" :size="22" bg-color="#FFFFFF" color="#FF780F" :index="g_index"></u-number-box>
<view v-for="(item, index) in orderInfo.store_cart_list" :key="index">
<view class="goods-info">
<view class="store">
<image class="avatar" :src="item[0].store_avatar"></image>
<view>{{ item[0].store_name }}</view>
<image src="../static/image/1.png" class="right"></image>
</view>
<view class="goods">
<view v-for="(goods, g_index) in item" :key="g_index" class="goods-item">
<image :src="goods.goods_image_url"></image>
<view class="info">
<view class="name u-line-2">{{ goods.goods_name }}</view>
<view class="cart-info">
<view class="price">{{ goods.goods_price }}</view>
<u-number-box :input-width="38" :input-height="39" :size="22" bg-color="#FFFFFF" color="#FF780F" :index="g_index" v-model="goods.goods_num"></u-number-box>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="order-info">
<view>
<view class="title">优惠券折扣</view>
<view class="value">
<view>-10.00</view>
<image src="../static/image/1.png"></image>
<view class="order-info">
<view>
<view class="title">优惠券折扣</view>
<view class="value">
<view>-10.00</view>
<image src="../static/image/1.png"></image>
</view>
</view>
</view>
<view>
<view class="title">配送方式</view>
<view class="value">
<view>快递</view>
<image src="../static/image/1.png"></image>
<view>
<view class="title">配送方式</view>
<view class="value">
<view>快递</view>
<image src="../static/image/1.png"></image>
</view>
</view>
</view>
<view>
<view class="title">支付方式</view>
<view class="value">
<view>微信</view>
<image src="../static/image/1.png"></image>
<view>
<view class="title">支付方式</view>
<view class="value">
<view>微信</view>
<image src="../static/image/1.png"></image>
</view>
</view>
</view>
</view>
@@ -58,7 +60,7 @@
<view class="bottom">
<view class="left">
<view class="title">合计</view>
<view class="price">9.80</view>
<view class="price">{{ orderInfo.store_goods_total | showTotalPrice }}</view>
</view>
<view class="right">
<view class="num">共1件商品</view>
@@ -70,9 +72,57 @@
<script>
export default {
data() {
return {}
return {
orderInfo: {},
totalPrice: '0.00',
}
},
filters: {
showTotalPrice(object) {
let price = 0;
for (const key in object) {
if (object.hasOwnProperty(key)) {
const element = object[key];
price += Number(element);
}
}
return price.toFixed(2);
}
},
onLoad(option) {
console.log(JSON.parse(option.info));
this.orderInfo = JSON.parse(option.info);
// this.orderListInit();
this.showTotalPrice();
},
methods: {
// orderListInit() {
// this.orderList = this.orderInfo.store_list;
// for (const key in this.orderList) {
// if (this.orderList.hasOwnProperty(key)) {
// const element = this.orderList[key];
// let tempArray = Object.entries(this.orderInfo.store_cart_list);
// tempArray.forEach(item => {
// if (item[0])
// })
// let temp = this.orderInfo.store_cart_list.filters(store => {
// return store.store_id == item.store_id
// })
// element
// }
// }
// this.orderList.forEach(item => {
// let temp = this.orderInfo.store_cart_list.filters(store => {
// return store.store_id == item.store_id
// })
// Object.assign(item, { goods_list: temp });
// })
// console.log(this.orderList);
// },
showTotalPrice() {
},
settlement() {
uni.navigateTo({
url: '/pageE/order/Details'
@@ -127,75 +177,77 @@ export default {
}
}
.main {
.goods-info {
background-color: #ffffff;
padding: 30rpx;
margin-bottom: 2rpx;
.store {
display: flex;
align-items: center;
margin-bottom: 20rpx;
.avatar {
width: 60rpx;
height: 60rpx;
border-radius: 50%;
border: 1rpx solid #000;
margin-right: 15rpx;
}
> view {
font-size: 28rpx;
color: rgba(51,51,51,1);
margin-right: 15rpx;
}
.right {
flex-shrink: 0;
width: 11rpx;
height: 22rpx;
}
}
.goods {
.goods-item {
> view {
.goods-info {
background-color: #ffffff;
padding: 30rpx;
margin-bottom: 2rpx;
.store {
display: flex;
align-items: center;
&:not(:last-child) {
margin-bottom: 20rpx;
margin-bottom: 20rpx;
.avatar {
width: 60rpx;
height: 60rpx;
border-radius: 50%;
border: 1rpx solid #000;
margin-right: 15rpx;
}
> image {
margin-right: 30rpx;
width: 180rpx;
height: 160rpx;
border-radius: 10rpx;
background-color: aqua;
> view {
font-size: 28rpx;
color: rgba(51,51,51,1);
margin-right: 15rpx;
}
.right {
flex-shrink: 0;
width: 11rpx;
height: 22rpx;
}
.info {
// width: 418rpx;
height: 160rpx;
}
.goods {
.goods-item {
display: flex;
flex-direction: column;
justify-content: space-between;
.name {
font-size: 30rpx;
color: rgba(51,51,51,1);
align-items: center;
&:not(:last-child) {
margin-bottom: 20rpx;
}
.cart-info {
> image {
margin-right: 30rpx;
width: 180rpx;
height: 160rpx;
border-radius: 10rpx;
background-color: aqua;
flex-shrink: 0;
}
.info {
// width: 418rpx;
height: 160rpx;
display: flex;
align-items: center;
flex-direction: column;
justify-content: space-between;
.price {
.name {
font-size: 30rpx;
font-weight: 500;
color: rgba(255,49,49,1);
color: rgba(51,51,51,1);
}
.u-numberbox {
border: 1rpx solid rgba(217,215,215,1);
border-radius:4px;
/deep/ .u-number-input {
margin: 0;
color: #333 !important;
border: 1rpx #D9D7D7 solid {
top: 0px;
bottom: 0px;
.cart-info {
display: flex;
align-items: center;
justify-content: space-between;
.price {
font-size: 30rpx;
font-weight: 500;
color: rgba(255,49,49,1);
}
.u-numberbox {
border: 1rpx solid rgba(217,215,215,1);
border-radius:4px;
/deep/ .u-number-input {
margin: 0;
color: #333 !important;
border: 1rpx #D9D7D7 solid {
top: 0px;
bottom: 0px;
}
}
}
}
@@ -203,30 +255,30 @@ export default {
}
}
}
}
.order-info {
> view {
height: 98rpx;
background: rgba(255,255,255,1);
padding: 35rpx 30rpx;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 2rpx;
.title {
font-size: 28rpx;
color: rgba(102,102,102,1);
}
.value {
.order-info {
> view {
height: 98rpx;
background: rgba(255,255,255,1);
padding: 35rpx 30rpx;
display: flex;
align-items: center;
font-size: 30rpx;
color:rgba(51,51,51,1);
> image {
width: 12rpx;
height: 22rpx;
flex-shrink: 0;
margin-left: 20rpx;
justify-content: space-between;
margin-bottom: 2rpx;
.title {
font-size: 28rpx;
color: rgba(102,102,102,1);
}
.value {
display: flex;
align-items: center;
font-size: 30rpx;
color:rgba(51,51,51,1);
> image {
width: 12rpx;
height: 22rpx;
flex-shrink: 0;
margin-left: 20rpx;
}
}
}
}

View File

@@ -18,7 +18,7 @@
<view class="name u-line-2">{{ goods.goods_name }}</view>
<view class="cart-info">
<view class="price">{{ goods.goods_price }}</view>
<u-number-box :input-width="38" :input-height="39" :size="22" bg-color="#FFFFFF" color="#FF780F" :index="g_index" @minus="reduce($event, s_index)" @plus="plus($event, s_index)" v-model="goods.goods_num"></u-number-box>
<u-number-box :input-width="38" :input-height="39" :size="22" bg-color="#FFFFFF" :disabled-input=true color="#FF780F" :index="goods.cart_id" @minus="reduce" @plus="plus" v-model="goods.goods_num"></u-number-box>
</view>
</view>
</view>
@@ -36,7 +36,7 @@
<view class="title">合计</view>
<view class="value">{{ totalPrice }}</view>
</view>
<view class="cart-btn" v-if="status == '编辑'" @click="settlement">结算</view>
<view class="cart-btn" v-if="status == '编辑'" @click="settlementOrder">结算</view>
<view class="delete-btn" v-if="status == '完成'" @click="deleteGoods">删除</view>
<u-toast ref="uToast" />
</view>
@@ -63,8 +63,9 @@ export default {
})
checkedGoods = checkedGoods.concat(temp);
})
console.log(checkedGoods);
// console.log(checkedGoods);
this.checkedGoods = checkedGoods;
this.calculatePrice();
},
deep: true
}
@@ -73,14 +74,45 @@ export default {
this.getCartList();
},
methods: {
// 计算价格
calculatePrice() {
// console.log(this.checkedGoods);
let temp = 0;
this.checkedGoods.forEach(item => {
temp += item.goods_num * (item.goods_price * 100) / 100;
})
this.totalPrice = temp.toFixed(2);
},
// 结算
settlementOrder() {
let id = [], temp = '';
this.checkedGoods.forEach(item => {
temp = item.cart_id + '|' + item.goods_num;
id.push(temp);
temp = '';
})
// console.log(id);
this.$u.api.settlementOrder({ cart_id: id }).then(res => {
if(res.errCode == 0) {
this.$u.route({
url: '/pageC/cart/ConfirmOrder',
params: {
info: JSON.stringify(res.data),
}
})
}
})
},
getCartList() {
this.$u.api.getCartTreeList().then((res)=>{
this.$u.api.getCartTreeList().then(res => {
if (res.errCode == 0) {
let list = res.data.store_cart_list;
list.forEach(item => {
Object.assign(item, { checked: false });
item.goods.forEach(goods => {
Object.assign(goods, { checked: false });
list.forEach((item, l_index) => {
// 判断有无 checked 属性,如果有取值再赋值, 没有给默认值 false
Object.assign(item, { checked: this.list.length ? this.list[l_index].checked : false });
item.goods.forEach((goods, g_index) => {
Object.assign(goods, { checked: this.list.length ? this.list[l_index].goods[g_index].checked : false });
})
})
// console.log(list);
@@ -95,7 +127,6 @@ export default {
id.push(item.cart_id);
})
// console.log(id);
this.$u.api.deleteCart({ id }).then(res => {
if (res.errCode == 0) {
if(!res.data.msg) {
@@ -109,16 +140,23 @@ export default {
}
})
},
reduce(value, store) {
console.log(value, store)
reduce(e) {
this.cartUpdateNumber(e.index, e.value);
},
plus(value, store) {
console.log(value, store)
plus(e) {
this.cartUpdateNumber(e.index, e.value);
},
settlement() {
uni.navigateTo({
url: './ConfirmOrder'
});
async cartUpdateNumber(id, number) {
try {
await this.$u.api.cartUpdateNumber({
cart_id: id,
quantity: number,
}).then(res => {
this.getCartList();
})
} catch (error) {
this.getCartList();
}
},
totalChange(e) {
// 切换所有商品的状态
@@ -171,7 +209,6 @@ export default {
// #ifdef APP-PLUS
let currentWebview = page.$getAppWebview();
let titleObj = currentWebview.getStyle().titleNView;
console.log(1);
console.log(JSON.stringify(titleObj.buttons[0]));
if (!titleObj.buttons) {
return;

View File

@@ -5,19 +5,19 @@
:scroll-into-view="itemId">
<view v-for="(item,index) in tabbar" :key="index" class="u-tab-item" :class="[current == index ? 'u-tab-item-active' : '']"
@tap.stop="swichMenu(index)">
<text class="u-line-1">{{item.name}}</text>
<text class="u-line-1">{{item.gc_name}}</text>
</view>
</scroll-view>
<scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box" @scroll="rightScroll">
<view class="page-view">
<view class="class-item" :id="'item' + index" v-for="(item , index) in tabbar" :key="index">
<view class="class-item" :id="'item' + index" v-for="(item, index) in tabbar" :key="index">
<view class="item-title">
<text>{{item.name}}</text>
<text>{{item.gc_name}}</text>
</view>
<view class="item-container">
<view class="thumb-box" v-for="(item1, index1) in item.foods" :key="index1">
<image class="item-menu-image" :src="item1.icon" mode=""></image>
<view class="item-menu-name">{{item1.name}}</view>
<view class="thumb-box" v-for="(item1, index1) in item._child" :key="index1">
<image class="item-menu-image" :src="item1.img" mode=""></image>
<view class="item-menu-name">{{item1.gc_name}}</view>
</view>
</view>
</view>
@@ -27,7 +27,6 @@
</view>
</template>
<script>
import classifyData from '@/static/js/classify.data.js';
export default {
data() {
return {
@@ -37,21 +36,28 @@
menuHeight: 0, // 左边菜单的高度
menuItemHeight: 0, // 左边菜单item的高度
itemId: '', // 栏目右边scroll-view用于滚动的id
tabbar: classifyData,
tabbar: [],
menuItemPos: [],
arr: [],
scrollRightTop: 0, // 右边栏目scroll-view的滚动条高度
timer: null, // 定时器
}
},
onLoad() {
onShow() {
this.getClassifyList();
},
onReady() {
this.getMenuItemTop()
},
methods: {
// 获取分类列表
getClassifyList() {
this.$u.api.getGoodsClassifyList().then(res => {
if(res.errCode == 0) {
this.tabbar = res.data;
}
})
},
// 点击左边的栏目切换
async swichMenu(index) {
if(this.arr.length == 0) {
@@ -137,7 +143,7 @@
if(this.arr.length == 0) {
await this.getMenuItemTop();
}
if(this.timer) return ;
if(this.timer) return;
if(!this.menuHeight) {
await this.getElRect('menu-scroll-view', 'menuHeight');
}
@@ -205,6 +211,7 @@
justify-content: center;
font-size: 28rpx;
color: #666666;
padding: 0 30rpx;
}
.u-tab-item-active {
position: relative;
@@ -223,7 +230,7 @@
height: 100%;
}
.right-box {
background-color: rgb(250, 250, 250);
background-color: #fff;
}
.page-view {
padding: 16rpx;
@@ -261,5 +268,6 @@
.item-menu-image {
width: 150rpx;
height: 150rpx;
margin-bottom: 15rpx;
}
</style>