examTeamApp/pages/cardList/card.vue

157 lines
3.1 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.user">
<uni-icons type="minus-filled" size="18" color="#FF6D66" @click="deleteCard(item,index)"
v-if="item.id!=2"></uni-icons>
<view class="info">
<image :src="item.pic"></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.all">
<uni-icons type="plus-filled" size="18" color="#05BD79" @click="addCard(item,index)"></uni-icons>
<view class="info">
<image :src="item.pic"></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 {}
},
onLoad() {},
computed: {
...mapState(["cardList", 'user']),
list() {
return this.cardList
}
},
methods: {
handleGradeList() {
let that = this
let list = []
that.cardList.user.forEach(ite => {
list.push(ite.id)
})
that.$model.getCardAllOrder({
aud_id: that.user.id,
card_order: list.join(",")
}).then(res => {
if (res.code != 0) {
that.$tools.msg(res.msg)
return
}
that.$store.dispatch('getUserInfo', {
aud_id: that.user.id
})
uni.switchTab({
url: "/pages/home/home"
})
}).catch(err => {})
},
// 删除已选择卡片
deleteCard(item, index) {
let that = this
that.cardList.user.splice(index, 1)
that.cardList.all.push(item)
// that.handleGradeList()
},
// 添加已有的卡片
addCard(item, index) {
let that = this
that.cardList.all.splice(index, 1)
that.cardList.user.push(item)
// that.handleGradeList()
},
}
}
</script>
<style scoped lang="scss">
.content {
padding: 15px;
font-size: 32rpx;
background-color: #F5F6FA;
min-height: 100vh;
.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: 45%;
background-color: #fff;
margin-bottom: 15px;
position: relative;
height: 60px;
line-height: 60px;
border-radius: 5px;
.uni-icons {
font-size: 36rpx;
position: absolute;
top: -28px;
left: -5px;
}
.info {
display: flex;
align-items: center;
justify-content: center;
image {
width: 30px;
height: 30px;
background-color: #F2F2F2;
margin-right: 10px;
border-radius: 50%;
}
}
}
}
}
.btn {
width: auto;
margin: 40px 15px 0;
background: $btncolor !important;
}
</style>