Feat(购物车):购物车调整(完成)
This commit is contained in:
@@ -131,17 +131,25 @@ each(@colors, {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
.v12-justify-start{
|
||||||
|
display: flex;
|
||||||
|
justify-content: start;
|
||||||
|
}
|
||||||
.v12-d-grid-columns-2 {
|
.v12-d-grid-columns-2 {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==============v12 按钮样式======================*/
|
|
||||||
|
|
||||||
.v12-text-right{
|
.v12-text-right{
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
.v12-text-left{
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.v12-text-center{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
.v12-btn{
|
.v12-btn{
|
||||||
width: 136rpx;
|
width: 136rpx;
|
||||||
height: 50rpx;
|
height: 50rpx;
|
||||||
|
|||||||
+114
-8
@@ -6,10 +6,9 @@
|
|||||||
class="pages-cart tabbar-page"
|
class="pages-cart tabbar-page"
|
||||||
>
|
>
|
||||||
<u-navbar
|
<u-navbar
|
||||||
:left-icon="selectCount > 0 ? 'trash' : ''"
|
:left-icon="selectCount > 0 ? '' : ''"
|
||||||
title="购物车"
|
title="购物车"
|
||||||
fixed
|
fixed
|
||||||
@leftClick="remove"
|
|
||||||
/>
|
/>
|
||||||
<view v-if="isLoad">
|
<view v-if="isLoad">
|
||||||
<view
|
<view
|
||||||
@@ -23,6 +22,16 @@
|
|||||||
mode="scaleToFill"
|
mode="scaleToFill"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="v12-justify-between v12-px-2">
|
||||||
|
<view class="v12-font-28 v12-dark-text v12-align-center" @click="show = true">
|
||||||
|
<image :src="webUrl+'/orderIcon/map.png'" style="width: 30rpx;height: 30rpx" class="v12-mr-1"/>
|
||||||
|
<text>{{ addressInfo.city }}</text>
|
||||||
|
<view class="v12-ml-1" style="margin-top: 2px;">
|
||||||
|
<u-icon name="arrow-down"></u-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="v12-font-28 v12-font-bold v12-dark-text" @click="editCart">{{ isEdit ? '完成' : '管理' }}</view>
|
||||||
|
</view>
|
||||||
<view
|
<view
|
||||||
v-for="(item, index) in list"
|
v-for="(item, index) in list"
|
||||||
:key="index"
|
:key="index"
|
||||||
@@ -30,12 +39,12 @@
|
|||||||
>
|
>
|
||||||
<view class="flex jc-between">
|
<view class="flex jc-between">
|
||||||
<view class="flex ai-center mer-left">
|
<view class="flex ai-center mer-left">
|
||||||
<CheckboxIcon
|
<!-- <CheckboxIcon
|
||||||
:default-state="item['state']"
|
:default-state="item['state']"
|
||||||
:mark="[index]"
|
:mark="[index]"
|
||||||
style="margin-right: 24rpx;"
|
style="margin-right: 24rpx;"
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
/>
|
/> -->
|
||||||
<image
|
<image
|
||||||
:src="item['merAvatar']"
|
:src="item['merAvatar']"
|
||||||
class="store-cover"
|
class="store-cover"
|
||||||
@@ -151,13 +160,20 @@
|
|||||||
/>
|
/>
|
||||||
<text class="v12-dark-text v12-font-32 v12-font-bold">全选({{ selectCount }})</text>
|
<text class="v12-dark-text v12-font-32 v12-font-bold">全选({{ selectCount }})</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex ai-center">
|
<view class="flex ai-center" v-if="!isEdit">
|
||||||
<view >
|
<view >
|
||||||
<text class="v12-font-24 v12-dark-text v12-font-weight-550"> 合计:</text>
|
<text class="v12-font-24 v12-dark-text v12-font-weight-550"> 合计:</text>
|
||||||
<text class="v12-font-22 v12-primary-text v12-font-bold">¥</text>
|
<text class="v12-font-22 v12-primary-text v12-font-bold">¥</text>
|
||||||
<text class="v12-font-26 v12-primary-text v12-font-bold">{{ total }}</text>
|
<text class="v12-font-26 v12-primary-text v12-font-bold">{{ total }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="btn-submit v12-mx-3 bold flex jc-center ai-center v12-radius-80 v12-primary" @click="submit">结算</view>
|
<view class="btn-submit v12-mx-3 flex jc-center ai-center v12-radius-80 v12-primary" @click="submit">结算</view>
|
||||||
|
</view>
|
||||||
|
<view class="flex ai-center" v-else>
|
||||||
|
<view @click="clearCart" class="v12-justify-between v12-align-center">
|
||||||
|
<view style="margin-top: 1px"><u-icon name="trash"></u-icon> </view>
|
||||||
|
<view>清空</view>
|
||||||
|
</view>
|
||||||
|
<view @click="remove" class="btn-submit v12-mx-3 flex jc-center ai-center v12-radius-80 v12-primary">删除</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
@@ -225,11 +241,35 @@
|
|||||||
v-else
|
v-else
|
||||||
:show-avatar="false"
|
:show-avatar="false"
|
||||||
/>
|
/>
|
||||||
|
<u-popup :show="show " @close="closePopup" closeable>
|
||||||
|
<view class="v12-secondary-dark-text v12-font-32 v12-text-center v12-py-4">收货地址</view>
|
||||||
|
<view class="v12-px-3 v12-mb-3 v12-font-32 v12-justify-start v12-align-center">
|
||||||
|
<view style="opacity: 0; width: 28px">
|
||||||
|
<image :src="webUrl+'/orderIcon/map.png'" style="width: 30rpx;height: 30rpx" class="v12-mr-1"/>
|
||||||
|
</view>
|
||||||
|
<view>收货人:{{ addressInfo.realName }} {{ addressInfo.phone }}</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
<view class="v12-px-3 v12-mb-3 v12-font-28 v12-justify-between v12-align-start">
|
||||||
|
<view style="width: 30px;">
|
||||||
|
<image :src="webUrl+'/orderIcon/map.png'" style="width: 30rpx;height: 30rpx" class="v12-mr-1"/>
|
||||||
|
</view>
|
||||||
|
<view style="margin-bottom: 4px;width: 100%" class="more-t v12-text-left">{{ addressInfo.province }}{{ addressInfo.city }}{{ addressInfo.district }}{{ addressInfo.detail }}</view>
|
||||||
|
<view style="width: 50px;" @click="editAddress">
|
||||||
|
<image :src="webUrl+'/icon/icon-setting.png'" style="width: 30rpx;height: 30rpx" class="v12-mr-1"/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class=" v12-px-3">
|
||||||
|
<view class="v12-py-2 v12-primary-text v12-font-28 v12-radius-60 v12-text-center plus-btn" @click="addNewAddress">+ 添加新地址</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</u-popup>
|
||||||
<xdd-tabbar :curr-index="2" />
|
<xdd-tabbar :curr-index="2" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import XddTabbar from '@/components/xdd-tabbar'
|
import XddTabbar from '@/components/xdd-tabbar'
|
||||||
|
import {getAddressList} from "@/api/user";
|
||||||
import {
|
import {
|
||||||
changeCartNum,
|
changeCartNum,
|
||||||
getCartGroup,
|
getCartGroup,
|
||||||
@@ -247,6 +287,8 @@ export default {
|
|||||||
mixins: [pageListenMixins],
|
mixins: [pageListenMixins],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||||
|
show: false,
|
||||||
statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
|
statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
|
||||||
isLoad: false,
|
isLoad: false,
|
||||||
list: [],
|
list: [],
|
||||||
@@ -258,7 +300,10 @@ export default {
|
|||||||
productValueArr: []
|
productValueArr: []
|
||||||
},
|
},
|
||||||
showAttr: false,
|
showAttr: false,
|
||||||
pageKeyId: Object.freeze('landmarkGoodsIndex')
|
pageKeyId: Object.freeze('landmarkGoodsIndex'),
|
||||||
|
isEdit: false,
|
||||||
|
addressList:[],
|
||||||
|
addressInfo: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -283,6 +328,12 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getCart()
|
this.getCart()
|
||||||
|
this.getAddress()
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
uni.$on('chooseAddress', (res) => {
|
||||||
|
this.addressInfo = res;
|
||||||
|
})
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
if (!this.isLoad) {
|
if (!this.isLoad) {
|
||||||
@@ -295,6 +346,57 @@ export default {
|
|||||||
this.pageToHideHandle()
|
this.pageToHideHandle()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
closePopup() {
|
||||||
|
this.show = false
|
||||||
|
},
|
||||||
|
editAddress() {
|
||||||
|
this.$yrouter.push({
|
||||||
|
path: "/pages/user/address/AddressManagement/index",
|
||||||
|
query: {
|
||||||
|
choosMode: 1
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addNewAddress() {
|
||||||
|
this.$yrouter.push({
|
||||||
|
path: "/pages/user/address/AddAddress/index"
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getAddress() {
|
||||||
|
getAddressList({page: 1, limit: 9999}).then(res => {
|
||||||
|
this.addressList = res.data
|
||||||
|
this.addressInfo = res.data.find(e => e.isDefault == 1) || {}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
clearCart() {
|
||||||
|
const ids = this.list.map(l => {
|
||||||
|
return l.carts.map(g => g.id)
|
||||||
|
}).flat()
|
||||||
|
uni.showModal({
|
||||||
|
title: '确定清空购物车吗?',
|
||||||
|
content: '',
|
||||||
|
showCancel: true,
|
||||||
|
cancelText: '取消',
|
||||||
|
confirmText: '确认',
|
||||||
|
success: async (result) => {
|
||||||
|
if (result.confirm) {
|
||||||
|
uni.showLoading()
|
||||||
|
postCartDel(ids).then(res => {
|
||||||
|
const { success } = res
|
||||||
|
if (success) {
|
||||||
|
this.getCart()
|
||||||
|
}
|
||||||
|
}).finally(() => {
|
||||||
|
uni.hideLoading()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
editCart() {
|
||||||
|
this.isEdit = !this.isEdit
|
||||||
|
},
|
||||||
async getCart() {
|
async getCart() {
|
||||||
const res = await getCartGroup()
|
const res = await getCartGroup()
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
@@ -553,8 +655,9 @@ export default {
|
|||||||
submit() {
|
submit() {
|
||||||
const ids = this.handleIds()
|
const ids = this.handleIds()
|
||||||
if (ids.length === 0) return
|
if (ids.length === 0) return
|
||||||
|
uni.$emit('chooseAddress1', this.addressInfo)
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/order/OrderSubmission/index?id=' + ids.join(',')
|
url: '/pages/order/OrderSubmission/index?id=' + ids.join(',') + '&address=' + JSON.stringify(this.addressInfo)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -562,6 +665,9 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
.plus-btn{
|
||||||
|
background: rgba(197,39,51,0.2);
|
||||||
|
}
|
||||||
.v12-minus-btn{
|
.v12-minus-btn{
|
||||||
border-radius: 28rpx 0rpx 0rpx 28rpx;
|
border-radius: 28rpx 0rpx 0rpx 28rpx;
|
||||||
border: 1px solid #E6E6E6;
|
border: 1px solid #E6E6E6;
|
||||||
|
|||||||
@@ -442,7 +442,11 @@ export default {
|
|||||||
_this.usePointsCheck = true
|
_this.usePointsCheck = true
|
||||||
_this.usePointsNumber = data.maxPoints
|
_this.usePointsNumber = data.maxPoints
|
||||||
}
|
}
|
||||||
_this.addressInfo = data.addressInfo || {}
|
if(_this.$yroute.query.address !== undefined ) {
|
||||||
|
_this.addressInfo = JSON.parse(_this.$yroute.query.address) || {}
|
||||||
|
} else {
|
||||||
|
_this.addressInfo = data.addressInfo || {}
|
||||||
|
}
|
||||||
_this.systemStore = data.systemStore || {}
|
_this.systemStore = data.systemStore || {}
|
||||||
_this.storeSelfMention = data.storeSelfMention
|
_this.storeSelfMention = data.storeSelfMention
|
||||||
_this.computedPrice()
|
_this.computedPrice()
|
||||||
|
|||||||
Reference in New Issue
Block a user