对接我的收藏接口

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"; import request from "../config/request";
export function GetFavorite(data){ export function GetFavoritePage(pageNo,pageSize){
return request({ return request({
url: '/User/GetFavorite', url: '/user-api/users/favorite/page',
method: 'post', method: 'get',
params: { data } params: { pageNo,pageSize }
}) })
} }
export function DelFavorite(id){ export function DelFavorite(spuId){
return request({ return request({
url: '/User/DelFavorite', url: '/user-api/users/favorite/remove',
method: 'get', method: 'DELETE',
params: { id:id } params: { spuId }
}) })
} }

View File

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

View File

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