index.vue
5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<template>
<view class="container">
<view style="display:flex;align-items:center;justify-content:space-between;font-size:40rpx;border-bottom:1px solid #e0e0e0;padding-bottom:10px;background-color:white;padding:20rpx;">
<view :class="num==1?'btn':''" @click="change(1)">商品</view>
<view @click="ChangeInfo" style="font-size:25rpx;">{{IsStyle==false?'管理':'完成'}}</view>
</view>
<view v-if="num==1">
<view style="margin-top:20rpx;">
<view style="width:100%;display:flex;align-items:center;justify-content:center;flex-direction:column;" v-if="list.length==0">
<image mode="aspectFit" :src="BASE_URL+'/api/File/Image/annexpic/nullImg.png'" style="width:400rpx;height:400rpx;"></image>
<text style="color:gray;font-size:30rpx;">暂无数据</text>
</view>
<block v-else>
<view style="display:flex;align-items:center;background-color:white;padding:10rpx;margin:20rpx 0rpx 20rpx 0rpx;" v-for="(item,index) in list" :key="index">
<view v-if="IsStyle">
<checkbox-group @change="changeitem(item)" style="margin:0 auto;">
<checkbox :checked="item.checked" style="transform:scale(0.8);" ></checkbox>
</checkbox-group>
</view>
<view @click="RedirectDetail(item)" style="display:flex;align-items:center;">
<view>
<image :src="item.goods!=null?BASE_URL+item.goods.Banner[0].url:''" style="width:200rpx;height:200rpx;"></image>
</view>
<view style="margin-left:20rpx;display:flex;flex-direction:column;height:200rpx;justify-content:space-evenly;">
<view>{{item.goods&&item.goods.Title}}</view>
<view>
<text style="color:red;font-size:20rpx;">¥</text>
<text style="color:red;font-weight:bold;">{{item.goods&&item.goods.StartMoneys}}</text>
</view>
</view>
</view>
</view>
</block>
</view>
</view>
<view style="background-color:white;padding:20rpx;display:flex;align-items:center;position:fixed;bottom:0px;width:100%;border-top:1px solid #e0e0e0;" v-if="IsStyle">
<view style="width:50%;">
<label>
<checkbox-group @change="selectAll" style="margin:0 auto;">
<checkbox :checked="allChecked" style="transform:scale(0.8);" ></checkbox>
<text style="margin-top:5rpx;font-size:25rpx;">全选</text>
</checkbox-group>
</label>
</view>
<view style="width:50%;">
<view @click="DelCollectGoods" style="padding:20rpx;border-radius:20rpx;border:1px solid #e0e0e0;width:30%;text-align:center;margin:0 auto;">
<text>删除</text>
</view>
</view>
</view>
</view>
</template>
<script>
import BASE_URL from '../../common/config.js'
import service from '../../service/service.js'
export default{
data(){
return{
BASE_URL,
num:1,
list:[],
IsStyle:false,
allChecked:false,
bl:true,
model:{
userId:'',
currentPage:1,
pageSize:20,
sidx:'',
sort:'desc'
},
total:0
}
},
onLoad() {
this.ShowList()
},
onReachBottom() {
var _this = this;
if (_this.bl) {
_this.bl = false;
if (_this.model.currentPage <= _this.total / _this.model.pageSize) {
_this.model.currentPage++;
_this.ShowList()
}
}
},
methods:{
RedirectDetail(item){
console.log('www',item)
uni.navigateTo({
url:'/pages/meansdetail/index?id='+item.goods.Id
})
},
// DelMultipleCollect
DelCollectGoods(){
let arr=[]
let data=this.list.filter(o=>o.checked!=false)
data.forEach((item,index)=>{
arr.push(item.id)
})
this.API.DelMultipleCollect(arr.toString()).then(res=>{
console.log('数据',res)
if(res.code==200){
uni.showToast({
title:'删除成功',
icon:'none'
})
this.ShowList()
}else{
uni.showToast({
title:res.msg,
icon:'none'
})
}
})
},
selectAll(){
// 全选
this.allChecked=!this.allChecked
if (this.allChecked) {
this.list.map(item => {
item.checked = true
})
} else {
this.list.map(item => {
item.checked = false
})
}
},
// 单选
changeitem(item){
item.checked=!item.checked
},
ChangeInfo(){
this.IsStyle=!this.IsStyle
},
ShowList(){
this.model.userId=service.getUser().id
this.API.GetCollectList(this.model).then(res=>{
res.data.list.forEach((item,index)=>{
item.checked=false
if(item.goods){
item.goods.Banner=JSON.parse(item.goods.Banner)
}
})
if (this.bl) {
this.list = res.data.list
} else {
this.list = this.list.concat(res.data.list)
}
this.total = res.data.pagination.total
})
}
}
}
</script>
<style>
</style>