123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955 |
- <template>
- <view class="shop-car1">
- <view v-if="list.length" class="list">
- <view class="shopcar-item" v-for="(item, index) in list" :key="index">
- <view class="name" @tap="chooseGood(!item.choosed, index)">
- <view class="left">
- <text v-if="item.choosed" class="cuIcon-roundcheckfill"></text>
- <text v-else class="cuIcon-round"></text>
- <view class="name ellipsis">{{ item.name }}</view>
- </view>
- <view class="right">
- <view class="right-box">
- <view style="margin-right: 40rpx;">
- <text class="one">数量:</text>
- <text class="two">{{item.goods_num}}</text>
- </view>
- <view class="">
- <text class="one">金额:</text>
- <text class="two">¥{{item.goods_money}}</text>
- </view>
- <!-- {{numChange}} -->
- </view>
- <text class="cuIcon-delete" @click.stop="deleteGood(index)"></text>
- </view>
-
- </view>
- <view class="sizeItem" v-for="(sizeItem, sizeIndex) in item.size" :key="sizeIndex" v-if="item.cart[sizeIndex]"
- @tap="chooseSize(!item.sizeChoosed[sizeIndex], index, sizeIndex,item.cart[sizeIndex])"
- >
- <text v-if="item.sizeChoosed[sizeIndex]" class="cuIcon-roundcheckfill"></text>
- <text v-else class="cuIcon-round"></text>
- <image :src="item.main_img"></image>
- <view class="info">
- <text>尺码:{{ sizeItem }}</text>
- <text class="basecolor">¥{{ item.money }}/{{ item.unit }}</text>
- </view>
- <NumInput :value="item.cart[sizeIndex]" :args="[index, sizeIndex]" @change="numChange" />
- </view>
- </view>
- <view class="gift_container" v-if="giftList.length > 0">
- <view class="fix_title">
- <text class="cuIcon-roundcheckfill"></text>
- <text class="title">赠品信息</text>
- </view>
- <div class="gift_list">
- <view class="gift_item" v-for="item in giftList" :key="item.id" v-show="Math.floor(giftNum / item.num) > 0">
- <template v-if="giftNum >= item.limit_num">
- <image :src="item.img" class="gift_img"></image>
- <view class="right">
- <view class="fixed">赠品名称:</view>
- <view class="bottom">
- <view class="name">{{item.name}}</view>
- <view class="num">数量:{{ Math.floor(giftNum / item.num) }}</view>
- </view>
- </view>
- </template>
- </view>
- </div>
- </view>
- </view>
- <view v-else class="none">
- <image src="../../static/icon/emptyshopcar.png"></image>
- <view class="big-btn" @tap="goToBuy">去下单</view>
- </view>
- <view class="buy">
- <view class="all" @tap="chooseAll(!choosedAll)">
- <text v-if="choosedAll" class="cuIcon-roundcheckfill"></text>
- <text v-else class="cuIcon-round"></text>
- <text>全选</text>
- </view>
- <view class="total">总计: <text>{{ '¥ ' + choosedPrice + '' }}</text></view>
- <view class="pay" @tap="confirm">结算({{ ' ' + choosedNum + ' ' }})</view>
- </view>
- </view>
- </template>
- <script>
- import { deepClone } from '@/common/util/index.js'
- import { _API_GoodList } from '@/apis/good.js'
- import { _API_GetallGift } from '@/apis/order.js'
- import NumInput from '@/components/public/num-input.vue'
- function sum(arr) {
- var len = arr.length;
- if(len == 0){
- return 0;
- } else if (len == 1){
- return arr[0];
- } else {
- return arr[0] + sum(arr.slice(1));
- }
- }
- export default {
- components: { NumInput },
- data() {
- return {
- giftList: []
- };
- },
- computed: {
- list() { return this.$store.state.cart.list },
- choosedAll() { return this.$store.getters['cart/choosedAll'] },
- choosedNum() { return this.$store.getters['cart/choosedNum'] },
- choosedPrice() { return this.$store.getters['cart/choosedPrice'] },
- giftNum() { return this.$store.getters['cart/giftNum'] },
- },
- // async onShow() {
- // uni.loading()
- // const { data: { list } } = await _API_GoodList()
- // for(let i = this.list.length - 1; i >= 0; i --) { // 遍历购物车
- // const inCartGood = list.find(listItem => listItem.attr_id == this.list[i].attr_id)
- // if (inCartGood) { // 如果购物车的商品存在于商品列表中
- // for(let j = this.list[i].size_id.length - 1; j >= 0; j --) {
- // const cartSize = this.list[i].size_id[j]
- // const inCartSize = inCartGood.size_id.find(e => e == cartSize)
- // console.log(inCartSize)
- // // // if (inCartSize) {
- // // // console.log(inCartSize)
- // // // } else {
- // // // console.log(inCartSize)
- // // // }
- // // console.log(inCartSize)
- // }
- // } else { // 不存直接删除
- // this.$store.commit('cart/DELETE', i)
- // }
- // }
- // },
- onShow() {
- console.log(this.$store.state.cart.list)
- const cartinfo = this.$store.state.cart.list
- for(var i=0;i<cartinfo.length;i++) {
- // cartinfo[i].goods_num= sum(cartinfo[i].cart)
- cartinfo[i].goods_money = sum(cartinfo[i].cart) * cartinfo[i].money
- let cart = cartinfo[i].cart
- let sizeChoosed = cartinfo[i].sizeChoosed
- let options = []
- for(var e=0;e<cart.length;e++){
- var a={};
- a.num=cart[e];
- a.sizeChoosed=sizeChoosed[e];
- options.push(a);
- }
- let newArr=options.filter((item,key)=>{return item.num!=0 && item.sizeChoosed!=false})
- cartinfo[i].options = newArr
- cartinfo[i].goods_num = newArr.reduce((p,e)=>p+e.num,0);
- cartinfo[i].goods_money = cartinfo[i].goods_num * cartinfo[i].money
-
-
- }
- console.log(cartinfo)
- // if (this.$store.getters['cart/shopcarNum']) {
- // // uni.setTabBarBadge({ index: 1, text: this.$store.getters['cart/shopcarNum'] + '' })
- // } else {
- // uni.removeTabBarBadge({ index: 1 })
- // }
- this.getAllGift()
-
- },
- methods: {
- getAllGift() {
- this.giftList = []
- _API_GetallGift().then(res => {
- if(res.code === 200) {
- this.giftList = res.data.list
- }
- })
- },
- numChange(value, index, sizeIndex) { // 购物车数量发生变化
- if (value) {
- const cartinfo = this.$store.state.cart.list
- cartinfo[index].cart[sizeIndex]=value
- cartinfo[index].goods_num = sum(cartinfo[index].cart)
- cartinfo[index].goods_money = sum(cartinfo[index].cart) * cartinfo[index].money
- this.$store.commit('cart/COUNTCHANGE', { value, index, sizeIndex, del: true })
- } else {
- uni.showModal({
- title: '提示',
- content: '确定删除这个尺寸?',
- success: res => {
- if (res.confirm) {
- const cartinfo = this.$store.state.cart.list
- cartinfo[index].cart[sizeIndex]=value
- cartinfo[index].goods_num = sum(cartinfo[index].cart)
- cartinfo[index].goods_money = sum(cartinfo[index].cart) * cartinfo[index].money
- this.$store.commit('cart/COUNTCHANGE', { value, index, sizeIndex, del: true })
- }
- }
- })
- }
- },
- chooseAll(to) { // 点击全选
- console.log(to)
- this.$store.commit('cart/CHOOSEDCHANGE', [to])
- if (to === true) {
- const cartinfo = this.$store.state.cart.list
- for(var i=0;i<cartinfo.length;i++) {
- cartinfo[i].goods_num= sum(cartinfo[i].cart)
- cartinfo[i].goods_money = sum(cartinfo[i].cart) * cartinfo[i].money
- }
- } else {
- const cartinfo = this.$store.state.cart.list
- for(var i=0;i<cartinfo.length;i++) {
- cartinfo[i].goods_num= 0
- cartinfo[i].goods_money = 0
- }
- }
- },
- chooseGood(to, index) { // 点击商品
- this.$store.commit('cart/CHOOSEDCHANGE', [to, index])
- console.log(to,index)
- if (to === true) {
- const cartinfo = this.$store.state.cart.list
- cartinfo[index].goods_num= sum(cartinfo[index].cart)
- cartinfo[index].goods_money = sum(cartinfo[index].cart) * cartinfo[index].money
- } else {
- const cartinfo = this.$store.state.cart.list
- cartinfo[index].goods_num= 0
- cartinfo[index].goods_money = 0
- }
- },
- chooseSize(to, index, sizeIndex,num) { // 点击尺寸
- console.log(to, index, sizeIndex,num)
- this.$store.commit('cart/CHOOSEDCHANGE', [to, index, sizeIndex])
- const cartinfo = this.$store.state.cart.list
- if (to === true) {
- cartinfo[index].goods_money = cartinfo[index].goods_money + cartinfo[index].money * num
- cartinfo[index].goods_num = cartinfo[index].goods_num + num
- // const cartinfo = this.$store.state.cart.list
- // cartinfo[index].goods_num= sum(cartinfo[index].cart)
- // cartinfo[index].goods_money = sum(cartinfo[index].cart) * cartinfo[index].money
- } else {
- cartinfo[index].goods_money = cartinfo[index].goods_money - cartinfo[index].money * num
- cartinfo[index].goods_num = cartinfo[index].goods_num - num
- // cartinfo[index].goods_money = -
- // const cartinfo = this.$store.state.cart.list
- // cartinfo[index].goods_num= 0
- // cartinfo[index].goods_money = 0
- }
- // for(var i=0;i<cartinfo.length;i++) {
- // // if (cartinfo[i].cart.index)
- // let num = sum(cartinfo[i].cart) - cartinfo[i].cart
- // // cartinfo[i].goods_num= sum(cartinfo[i].cart)
- // cartinfo[i].goods_money = sum(cartinfo[i].cart) * cartinfo[i].money
- // }
- },
- goToBuy() { // 点击去下单
- uni.navigateTo({ url: '../place-order/place-order' })
- },
- deleteGood(index) { // 点击删除商品
- uni.showModal({
- title: '提示',
- content: '确定删除这件商品?',
- success: res => {
- if (res.confirm) {
- this.$store.commit('cart/DELETE', index)
- }
- }
- })
- },
- confirm() { // 点击结算
- if (this.choosedNum) {
- uni.navigateTo({ url: '../confirm-order1/confirm-order1' })
- location.reload()
- }
- }
- }
- }
- </script>
- <style lang="scss">
- .shop-car1 {
- height: 100vh;
- overflow: auto;
- background: $app-base-bg;
- border-bottom: calc(var(--window-bottom) + 100rpx) solid transparent;
- .gift_container {
- width: 100%;
- .fix_title {
- height: 90rpx;
- line-height: 90rpx;
- padding: 0 32rpx;
- display: flex;
- justify-content: flex-start;
- align-items: center;
- border-bottom: 1px solid $app-base-bg;
- .cuIcon-roundcheckfill {
- color: #F76454;
- font-size: 32rpx;
- }
-
- .title {
- margin-left: 30rpx;
- color: #181818;
- font-size: 32rpx;
- }
- }
- .gift_list {
- background-color: #FFFFFF;
- .gift_item {
- padding: 28rpx 30rpx;
- margin-bottom: 1px;
- background-color: #FFFFFF;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .gift_img {
- display: block;
- width: 140rpx;
- height: 140rpx;
- }
- .right {
- width: calc(100% - 140rpx);
- height: 140rpx;
- padding: 0 50rpx 0 30rpx;
- display: flex;
- justify-content: space-between;
- flex-direction: column;
- .fixed {
- color: #181818;
- font-size: 32rpx;
- }
- .bottom {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .name {
- color: #F76454;
- font-size: 32rpx;
- }
- .num {
- color: #181818;
- font-size: 28rpx;
- }
- }
- }
- }
- }
- }
- .shopcar-item {
- margin-bottom: 10rpx;
- .name {
- background: #FFFFFF;
- padding: 20rpx 0;
- .left {
- @include flex();
- justify-content: flex-start;
- > .name {
- color: #181818;
- font-size: 32rpx;
- font-weight: bold;
- }
- .cuIcon-round, .cuIcon-roundcheckfill {
- @include flex();
- width: 102rpx;
- height: 100%;
- font-size: 32rpx;
- &.cuIcon-roundcheckfill {
- color: $app-base-color;
- }
- }
- }
- .right {
- margin-top: 15rpx;
- padding-left:92rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- &-box {
- // width: 384rpx;
- line-height: 52rpx;
- padding: 0 20rpx;
- background-color: #FFF4F3;
- border-radius: 8rpx;
- display: flex;
- font-size: 32rpx;
- .one {
- color: #333;
- }
- .two {
- color: #F76454;
- font-weight: bold;
- }
- }
- }
- .cuIcon-delete {
- font-size: 40rpx;
- margin-right: 30rpx;
- }
- }
- .sizeItem {
- @include flex();
- height: 200rpx;
- margin-top: 4rpx;
- background: #FFFFFF;
- box-sizing: border-box;
- padding-right: 39rpx;
- .cuIcon-round, .cuIcon-roundcheckfill {
- @include flex();
- width: 102rpx;
- height: 100%;
- font-size: 32rpx;
- &.cuIcon-roundcheckfill {
- color: $app-base-color;
- }
- }
- image {
- width: 140rpx;
- height: 140rpx;
- border-radius: 6rpx;
- }
- .info {
- flex: 1;
- height: 100%;
- @include flex(column);
- align-items: flex-start;
- padding: 43rpx 29rpx;
- box-sizing: border-box;
- justify-content: space-between;
- }
- }
- }
- .none {
- @include flex(column);
- height: 100%;
- image {
- width: 305rpx;
- height: 417rpx;
- }
- .big-btn {
- width: 280rpx;
- height: 80rpx;
- margin-top: 123rpx;
- border-radius: 40rpx;
- }
- }
- .buy {
- @include flex();
- position: fixed;
- left: 0;
- right: 0;
- bottom: var(--window-bottom);
- z-index: 1;
- height: 98rpx;
- font-size: 32rpx;
- background: #FFFFFF;
- justify-content: space-between;
- box-shadow: 0rpx -1rpx 0rpx 0rpx rgba(178,178,178,1);
- view {
- @include flex();
- height: 100%;
- &.all {
- font-size: 32rpx;
- text {
- margin-left: 30rpx;
- &.cuIcon-roundcheckfill {
- color: $app-base-color;
- }
- }
- }
- &.total {
- flex: 1;
- margin-right: 30rpx;
- justify-content: flex-end;
- text {
- color: $app-base-color;
- }
- }
- &.pay {
- width: 220rpx;
- color: #FFFFFF;
- background: $app-base-color;
- }
- }
- }
- }
- </style>
- <!-- var arr = [19,31,23]
- 下标为2以外的数字相加 --><template>
- <view class="shop-car1">
- <view v-if="list.length" class="list">
- <view class="shopcar-item" v-for="(item, index) in list" :key="index">
- <view class="name" @tap="chooseGood(!item.choosed, index)">
- <view class="left">
- <text v-if="item.choosed" class="cuIcon-roundcheckfill"></text>
- <text v-else class="cuIcon-round"></text>
- <view class="name ellipsis">{{ item.name }}</view>
- </view>
- <view class="right">
- <view class="right-box">
- <view style="margin-right: 40rpx;">
- <text class="one">数量:</text>
- <text class="two">{{item.goods_num}}</text>
- </view>
- <view class="">
- <text class="one">金额:</text>
- <text class="two">¥{{item.goods_money}}</text>
- </view>
- <!-- {{numChange}} -->
- </view>
- <text class="cuIcon-delete" @click.stop="deleteGood(index)"></text>
- </view>
-
- </view>
- <view class="sizeItem" v-for="(sizeItem, sizeIndex) in item.size" :key="sizeIndex" v-if="item.cart[sizeIndex]"
- @tap="chooseSize(!item.sizeChoosed[sizeIndex], index, sizeIndex,item.cart[sizeIndex])"
- >
- <text v-if="item.sizeChoosed[sizeIndex]" class="cuIcon-roundcheckfill"></text>
- <text v-else class="cuIcon-round"></text>
- <image :src="item.main_img"></image>
- <view class="info">
- <text>尺码:{{ sizeItem }}</text>
- <text class="basecolor">¥{{ item.money }}/{{ item.unit }}</text>
- </view>
- <NumInput :value="item.cart[sizeIndex]" :args="[index, sizeIndex]" @change="numChange" />
- </view>
- </view>
- <view class="gift_container" v-if="giftList.length > 0">
- <view class="fix_title">
- <text class="cuIcon-roundcheckfill"></text>
- <text class="title">赠品信息</text>
- </view>
- <div class="gift_list">
- <view class="gift_item" v-for="item in giftList" :key="item.id" v-show="Math.floor(giftNum / item.num) > 0">
- <template v-if="giftNum >= item.limit_num">
- <image :src="item.img" class="gift_img"></image>
- <view class="right">
- <view class="fixed">赠品名称:</view>
- <view class="bottom">
- <view class="name">{{item.name}}</view>
- <view class="num">数量:{{ Math.floor(giftNum / item.num) }}</view>
- </view>
- </view>
- </template>
- </view>
- </div>
- </view>
- </view>
- <view v-else class="none">
- <image src="../../static/icon/emptyshopcar.png"></image>
- <view class="big-btn" @tap="goToBuy">去下单</view>
- </view>
- <view class="buy">
- <view class="all" @tap="chooseAll(!choosedAll)">
- <text v-if="choosedAll" class="cuIcon-roundcheckfill"></text>
- <text v-else class="cuIcon-round"></text>
- <text>全选</text>
- </view>
- <view class="total">总计: <text>{{ '¥ ' + choosedPrice + '' }}</text></view>
- <view class="pay" @tap="confirm">结算({{ ' ' + choosedNum + ' ' }})</view>
- </view>
- </view>
- </template>
- <script>
- import { deepClone } from '@/common/util/index.js'
- import { _API_GoodList } from '@/apis/good.js'
- import { _API_GetallGift } from '@/apis/order.js'
- import NumInput from '@/components/public/num-input.vue'
- function sum(arr) {
- var len = arr.length;
- if(len == 0){
- return 0;
- } else if (len == 1){
- return arr[0];
- } else {
- return arr[0] + sum(arr.slice(1));
- }
- }
- export default {
- components: { NumInput },
- data() {
- return {
- giftList: []
- };
- },
- computed: {
- list() { return this.$store.state.cart.list },
- choosedAll() { return this.$store.getters['cart/choosedAll'] },
- choosedNum() { return this.$store.getters['cart/choosedNum'] },
- choosedPrice() { return this.$store.getters['cart/choosedPrice'] },
- giftNum() { return this.$store.getters['cart/giftNum'] },
- },
- // async onShow() {
- // uni.loading()
- // const { data: { list } } = await _API_GoodList()
- // for(let i = this.list.length - 1; i >= 0; i --) { // 遍历购物车
- // const inCartGood = list.find(listItem => listItem.attr_id == this.list[i].attr_id)
- // if (inCartGood) { // 如果购物车的商品存在于商品列表中
- // for(let j = this.list[i].size_id.length - 1; j >= 0; j --) {
- // const cartSize = this.list[i].size_id[j]
- // const inCartSize = inCartGood.size_id.find(e => e == cartSize)
- // console.log(inCartSize)
- // // // if (inCartSize) {
- // // // console.log(inCartSize)
- // // // } else {
- // // // console.log(inCartSize)
- // // // }
- // // console.log(inCartSize)
- // }
- // } else { // 不存直接删除
- // this.$store.commit('cart/DELETE', i)
- // }
- // }
- // },
- onShow() {
- console.log(this.$store.state.cart.list)
- const cartinfo = this.$store.state.cart.list
- for(var i=0;i<cartinfo.length;i++) {
- // cartinfo[i].goods_num= sum(cartinfo[i].cart)
- cartinfo[i].goods_money = sum(cartinfo[i].cart) * cartinfo[i].money
- let cart = cartinfo[i].cart
- let sizeChoosed = cartinfo[i].sizeChoosed
- let options = []
- for(var e=0;e<cart.length;e++){
- var a={};
- a.num=cart[e];
- a.sizeChoosed=sizeChoosed[e];
- options.push(a);
- }
- let newArr=options.filter((item,key)=>{return item.num!=0 && item.sizeChoosed!=false})
- cartinfo[i].options = newArr
- cartinfo[i].goods_num = newArr.reduce((p,e)=>p+e.num,0);
- cartinfo[i].goods_money = cartinfo[i].goods_num * cartinfo[i].money
-
-
- }
- console.log(cartinfo)
- // if (this.$store.getters['cart/shopcarNum']) {
- // // uni.setTabBarBadge({ index: 1, text: this.$store.getters['cart/shopcarNum'] + '' })
- // } else {
- // uni.removeTabBarBadge({ index: 1 })
- // }
- this.getAllGift()
-
- },
- methods: {
- getAllGift() {
- this.giftList = []
- _API_GetallGift().then(res => {
- if(res.code === 200) {
- this.giftList = res.data.list
- }
- })
- },
- numChange(value, index, sizeIndex) { // 购物车数量发生变化
- if (value) {
- const cartinfo = this.$store.state.cart.list
- cartinfo[index].cart[sizeIndex]=value
- cartinfo[index].goods_num = sum(cartinfo[index].cart)
- cartinfo[index].goods_money = sum(cartinfo[index].cart) * cartinfo[index].money
- this.$store.commit('cart/COUNTCHANGE', { value, index, sizeIndex, del: true })
- } else {
- uni.showModal({
- title: '提示',
- content: '确定删除这个尺寸?',
- success: res => {
- if (res.confirm) {
- const cartinfo = this.$store.state.cart.list
- cartinfo[index].cart[sizeIndex]=value
- cartinfo[index].goods_num = sum(cartinfo[index].cart)
- cartinfo[index].goods_money = sum(cartinfo[index].cart) * cartinfo[index].money
- this.$store.commit('cart/COUNTCHANGE', { value, index, sizeIndex, del: true })
- }
- }
- })
- }
- },
- chooseAll(to) { // 点击全选
- console.log(to)
- this.$store.commit('cart/CHOOSEDCHANGE', [to])
- if (to === true) {
- const cartinfo = this.$store.state.cart.list
- for(var i=0;i<cartinfo.length;i++) {
- cartinfo[i].goods_num= sum(cartinfo[i].cart)
- cartinfo[i].goods_money = sum(cartinfo[i].cart) * cartinfo[i].money
- }
- } else {
- const cartinfo = this.$store.state.cart.list
- for(var i=0;i<cartinfo.length;i++) {
- cartinfo[i].goods_num= 0
- cartinfo[i].goods_money = 0
- }
- }
- },
- chooseGood(to, index) { // 点击商品
- this.$store.commit('cart/CHOOSEDCHANGE', [to, index])
- console.log(to,index)
- if (to === true) {
- const cartinfo = this.$store.state.cart.list
- cartinfo[index].goods_num= sum(cartinfo[index].cart)
- cartinfo[index].goods_money = sum(cartinfo[index].cart) * cartinfo[index].money
- } else {
- const cartinfo = this.$store.state.cart.list
- cartinfo[index].goods_num= 0
- cartinfo[index].goods_money = 0
- }
- },
- chooseSize(to, index, sizeIndex,num) { // 点击尺寸
- console.log(to, index, sizeIndex,num)
- this.$store.commit('cart/CHOOSEDCHANGE', [to, index, sizeIndex])
- const cartinfo = this.$store.state.cart.list
- if (to === true) {
- cartinfo[index].goods_money = cartinfo[index].goods_money + cartinfo[index].money * num
- cartinfo[index].goods_num = cartinfo[index].goods_num + num
- // const cartinfo = this.$store.state.cart.list
- // cartinfo[index].goods_num= sum(cartinfo[index].cart)
- // cartinfo[index].goods_money = sum(cartinfo[index].cart) * cartinfo[index].money
- } else {
- cartinfo[index].goods_money = cartinfo[index].goods_money - cartinfo[index].money * num
- cartinfo[index].goods_num = cartinfo[index].goods_num - num
- // cartinfo[index].goods_money = -
- // const cartinfo = this.$store.state.cart.list
- // cartinfo[index].goods_num= 0
- // cartinfo[index].goods_money = 0
- }
- // for(var i=0;i<cartinfo.length;i++) {
- // // if (cartinfo[i].cart.index)
- // let num = sum(cartinfo[i].cart) - cartinfo[i].cart
- // // cartinfo[i].goods_num= sum(cartinfo[i].cart)
- // cartinfo[i].goods_money = sum(cartinfo[i].cart) * cartinfo[i].money
- // }
- },
- goToBuy() { // 点击去下单
- uni.navigateTo({ url: '../place-order/place-order' })
- },
- deleteGood(index) { // 点击删除商品
- uni.showModal({
- title: '提示',
- content: '确定删除这件商品?',
- success: res => {
- if (res.confirm) {
- this.$store.commit('cart/DELETE', index)
- }
- }
- })
- },
- confirm() { // 点击结算
- if (this.choosedNum) {
- uni.navigateTo({ url: '../confirm-order1/confirm-order1' })
- location.reload()
- }
- }
- }
- }
- </script>
- <style lang="scss">
- .shop-car1 {
- height: 100vh;
- overflow: auto;
- background: $app-base-bg;
- border-bottom: calc(var(--window-bottom) + 100rpx) solid transparent;
- .gift_container {
- width: 100%;
- .fix_title {
- height: 90rpx;
- line-height: 90rpx;
- padding: 0 32rpx;
- display: flex;
- justify-content: flex-start;
- align-items: center;
- border-bottom: 1px solid $app-base-bg;
- .cuIcon-roundcheckfill {
- color: #F76454;
- font-size: 32rpx;
- }
-
- .title {
- margin-left: 30rpx;
- color: #181818;
- font-size: 32rpx;
- }
- }
- .gift_list {
- background-color: #FFFFFF;
- .gift_item {
- padding: 28rpx 30rpx;
- margin-bottom: 1px;
- background-color: #FFFFFF;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .gift_img {
- display: block;
- width: 140rpx;
- height: 140rpx;
- }
- .right {
- width: calc(100% - 140rpx);
- height: 140rpx;
- padding: 0 50rpx 0 30rpx;
- display: flex;
- justify-content: space-between;
- flex-direction: column;
- .fixed {
- color: #181818;
- font-size: 32rpx;
- }
- .bottom {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .name {
- color: #F76454;
- font-size: 32rpx;
- }
- .num {
- color: #181818;
- font-size: 28rpx;
- }
- }
- }
- }
- }
- }
- .shopcar-item {
- margin-bottom: 10rpx;
- .name {
- background: #FFFFFF;
- padding: 20rpx 0;
- .left {
- @include flex();
- justify-content: flex-start;
- > .name {
- color: #181818;
- font-size: 32rpx;
- font-weight: bold;
- }
- .cuIcon-round, .cuIcon-roundcheckfill {
- @include flex();
- width: 102rpx;
- height: 100%;
- font-size: 32rpx;
- &.cuIcon-roundcheckfill {
- color: $app-base-color;
- }
- }
- }
- .right {
- margin-top: 15rpx;
- padding-left:92rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- &-box {
- // width: 384rpx;
- line-height: 52rpx;
- padding: 0 20rpx;
- background-color: #FFF4F3;
- border-radius: 8rpx;
- display: flex;
- font-size: 32rpx;
- .one {
- color: #333;
- }
- .two {
- color: #F76454;
- font-weight: bold;
- }
- }
- }
- .cuIcon-delete {
- font-size: 40rpx;
- margin-right: 30rpx;
- }
- }
- .sizeItem {
- @include flex();
- height: 200rpx;
- margin-top: 4rpx;
- background: #FFFFFF;
- box-sizing: border-box;
- padding-right: 39rpx;
- .cuIcon-round, .cuIcon-roundcheckfill {
- @include flex();
- width: 102rpx;
- height: 100%;
- font-size: 32rpx;
- &.cuIcon-roundcheckfill {
- color: $app-base-color;
- }
- }
- image {
- width: 140rpx;
- height: 140rpx;
- border-radius: 6rpx;
- }
- .info {
- flex: 1;
- height: 100%;
- @include flex(column);
- align-items: flex-start;
- padding: 43rpx 29rpx;
- box-sizing: border-box;
- justify-content: space-between;
- }
- }
- }
- .none {
- @include flex(column);
- height: 100%;
- image {
- width: 305rpx;
- height: 417rpx;
- }
- .big-btn {
- width: 280rpx;
- height: 80rpx;
- margin-top: 123rpx;
- border-radius: 40rpx;
- }
- }
- .buy {
- @include flex();
- position: fixed;
- left: 0;
- right: 0;
- bottom: var(--window-bottom);
- z-index: 1;
- height: 98rpx;
- font-size: 32rpx;
- background: #FFFFFF;
- justify-content: space-between;
- box-shadow: 0rpx -1rpx 0rpx 0rpx rgba(178,178,178,1);
- view {
- @include flex();
- height: 100%;
- &.all {
- font-size: 32rpx;
- text {
- margin-left: 30rpx;
- &.cuIcon-roundcheckfill {
- color: $app-base-color;
- }
- }
- }
- &.total {
- flex: 1;
- margin-right: 30rpx;
- justify-content: flex-end;
- text {
- color: $app-base-color;
- }
- }
- &.pay {
- width: 220rpx;
- color: #FFFFFF;
- background: $app-base-color;
- }
- }
- }
- }
- </style>
- <!-- var arr = [19,31,23]
- 下标为2以外的数字相加 -->
|