ReedawFoodApp/pageTwo/cardList/card.vue

169 lines
3.4 KiB
Vue

<template>
<view class="content">
<!-- 已添加的卡片 -->
<view class="box">
<!-- <view class="tips">长按拖拽可调整卡片位置</view> -->
<view class="list">
<view class="item" v-for="(item,index) in cardList.chosen_fixed">
<view class="info">
<image :src="item.icon"></image>
<view>{{item.name}}</view>
</view>
</view>
<view class="item" v-for="(item,index) in cardList.chosen_yes" @click="deleteCard(item,index)">
<uni-icons type="minus-filled" size="18" color="#FF6D66" v-if="item.id!=2"></uni-icons>
<view class="info">
<image :src="item.icon"></image>
<view>{{item.name}}</view>
</view>
</view>
</view>
</view>
<!-- 可添加的卡片 -->
<view class="box">
<view class="tips2 tips">可添加的卡片</view>
<view class="list">
<view class="item" v-for="(item,index) in cardList.chosen_no" @click="addCard(item,index)">
<uni-icons type="plus-filled" size="18" color="#05BD79"></uni-icons>
<view class="info">
<image :src="item.icon"></image>
<view>{{item.name}}</view>
</view>
</view>
</view>
</view>
<view class="btn" @click="handleGradeList()">保存卡片</view>
</view>
</template>
<script>
import {
mapState
} from "vuex";
export default {
data() {
return {
// cardList: {
// chosen_no: [],
// chosen_yes: [],
// chosen_fixed: []
// },
}
},
computed: {
...mapState(['user', "CardList"]),
cardList() {
return this.CardList
}
},
methods: {
handleGradeList() {
let that = this
let list = []
that.cardList.chosen_yes.forEach(ite => {
list.push(ite.id)
})
that.$model.getCardAllOrder({
aud_id: that.user.aud_id,
card_list: list.join(",")
}).then(res => {
if (res.code != 0) {
that.$tools.msg(res.msg)
return
}
that.$store.dispatch("getCardAllList", {
aud_id: that.user.aud_id,
})
uni.navigateBack()
}).catch(err => {})
},
// 删除已选择卡片
deleteCard(item, index) {
let that = this
that.cardList.chosen_yes.splice(index, 1)
that.cardList.chosen_no.push(item)
},
// 添加已有的卡片
addCard(item, index) {
let that = this
that.cardList.chosen_no.splice(index, 1)
that.cardList.chosen_yes.push(item)
},
}
}
</script>
<style scoped lang="scss">
.content {
padding: 15px;
font-size: 32rpx;
background-color: #F5F6FA;
min-height: 100vh;
.box {
width: 100%;
}
.tips {
font-size: 32rpx;
color: #999;
width: 100%;
margin-bottom: 15px;
}
.tips2 {
color: #333;
font-size: 32rpx;
font-weight: bold;
}
.list {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
.item {
width: 47%;
background-color: #fff;
margin-bottom: 15px;
position: relative;
height: 60px;
line-height: 60px;
border-radius: 5px;
.uni-icons,
uni-icons {
font-size: 36rpx;
position: absolute;
top: -28px;
left: -5px;
}
.info {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
image {
width: 30px;
height: 30px;
background-color: #F2F2F2;
margin-right: 10px;
border-radius: 50%;
}
}
}
}
}
.btn {
width: calc(100% - 30px);
margin: 40px 15px 0;
background: $btncolor !important;
}
</style>