对接我的收藏接口

This commit is contained in:
xiaofeng 2019-07-10 22:44:27 +08:00
parent ae47bf7e60
commit 11f601a0d4
3 changed files with 22 additions and 19 deletions

View File

@ -1,18 +1,18 @@
import request from "../config/request";
export function GetFavorite(data){
export function GetFavoritePage(pageNo,pageSize){
return request({
url: '/User/GetFavorite',
method: 'post',
params: { data }
url: '/user-api/users/favorite/page',
method: 'get',
params: { pageNo,pageSize }
})
}
export function DelFavorite(id){
export function DelFavorite(spuId){
return request({
url: '/User/DelFavorite',
method: 'get',
params: { id:id }
url: '/user-api/users/favorite/remove',
method: 'DELETE',
params: { spuId }
})
}

View File

@ -9,6 +9,7 @@
<div v-for="(item,index) in list" :key="index">
<van-swipe-cell :right-width="65" :on-close="onClose(item)">
<product-card :product='item' />
<span>{{item.spuName}}</span>
<span slot="right" >删除</span>
</van-swipe-cell>
</div>
@ -17,7 +18,7 @@
</template>
<script>
import { GetFavorite ,DelFavorite} from "../../../api/user.js";
import { GetFavoritePage ,DelFavorite} from "../../../api/user.js";
export default {
data(){
@ -26,6 +27,7 @@ export default {
finished:false,
list:[],
page:0,
pageSize:10
}
},
methods:{
@ -41,9 +43,9 @@ export default {
this.$dialog.confirm({
message: '确定删除吗?'
}).then(() => {
DelFavorite(item.id).then(response=>{
DelFavorite(item.spuId).then(response=>{
this.$toast('删除成功');
this.$router.go(0);
this.$router.go(0);
})
instance.close();
}).catch(() => {
@ -54,16 +56,18 @@ export default {
}
},
onLoad() {
this.page++;
GetFavorite().then(response=>{
response.list.forEach(item => {
this.list.push(item);
});
let pageNo = this.page + 1;
GetFavoritePage(pageNo,this.pageSize).then(response=>{
this.page = pageNo;
this.list.push(...response.list);
// response.list.forEach(item => {
// this.list.push(item);
// });
this.loading = false;
if(response.TotalPage<=this.page){
if(this.list.length >= response.total){
this.finished = true;
}
})
}
},

View File

@ -24,7 +24,6 @@
<where>
user_id = #{userId} AND deleted = 0
</where>
ORDER BY sort ASC
<if test="offset != null and limit != null">
LIMIT #{offset}, #{limit}
</if>