|
@@ -5,17 +5,19 @@
|
|
|
<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
|
|
|
<view class="list-scroll-view">
|
|
|
<view class="list" v-for="(item, index) in list" :key="index" @click="toView(item)">
|
|
|
- <image class="image" :src="item.file" mode=""></image>
|
|
|
+ <image class="image"
|
|
|
+ :src="item.goods.file&&item.goods.file.length>0?item.goods.file[0].url:''" mode="">
|
|
|
+ </image>
|
|
|
<view class="name">
|
|
|
- {{item.name||'暂无'}}
|
|
|
+ {{item.goods.name||'暂无'}}
|
|
|
</view>
|
|
|
<view class="money">
|
|
|
<text>¥</text>
|
|
|
- <text>{{item.money}}</text>
|
|
|
+ <text>{{item.goods.money}}</text>
|
|
|
</view>
|
|
|
<view class="other">
|
|
|
<view class="other_1">
|
|
|
- {{item.num||0}}人评价
|
|
|
+ {{item.goods.num||0}}人评价
|
|
|
</view>
|
|
|
<view class="other_2">
|
|
|
<text @click="toDel(item)" class="iconfont icon-del"></text>
|
|
@@ -34,29 +36,17 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- list: [{
|
|
|
- file: require('@/static/test.png'),
|
|
|
- name: '摩奇桃汁250ml*24盒',
|
|
|
- money: 59.90,
|
|
|
- num: 0
|
|
|
- },
|
|
|
- {
|
|
|
- file: require('@/static/test.png'),
|
|
|
- name: '摩奇桃汁250ml*24盒',
|
|
|
- money: 59.90,
|
|
|
- num: 0
|
|
|
- },
|
|
|
- {
|
|
|
- file: require('@/static/test.png'),
|
|
|
- name: '摩奇桃汁250ml*24盒',
|
|
|
- money: 59.90,
|
|
|
- num: 0
|
|
|
- }
|
|
|
- ]
|
|
|
+ user: {},
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+ skip: 0,
|
|
|
+ limit: 5,
|
|
|
+ page: 0
|
|
|
};
|
|
|
},
|
|
|
onShow: function() {
|
|
|
-
|
|
|
+ const that = this;
|
|
|
+ that.watchLogin()
|
|
|
},
|
|
|
methods: {
|
|
|
// 详细信息
|
|
@@ -67,12 +57,100 @@
|
|
|
// 删除
|
|
|
toDel(e) {
|
|
|
const that = this;
|
|
|
- console.log(e);
|
|
|
+ let user = that.user;
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '确定取消收藏吗?',
|
|
|
+ success: async function(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ let res = await that.$api(`/storeGoods`, `POST`, {
|
|
|
+ customer: user._id,
|
|
|
+ goods: that.id
|
|
|
+ });
|
|
|
+ const arr = await that.$api(`/storeGoods`, 'POST', {
|
|
|
+ customer: user._id,
|
|
|
+ goods: e.goods._id
|
|
|
+ });
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ uni.showToast({
|
|
|
+ title: '取消收藏成功',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ that.clearPage();
|
|
|
+ that.search();
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: arr.errmsg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 监听用户是否登录
|
|
|
+ watchLogin() {
|
|
|
+ const that = this;
|
|
|
+ uni.getStorage({
|
|
|
+ key: 'token',
|
|
|
+ success: function(res) {
|
|
|
+ let user = that.$jwt(res.data);
|
|
|
+ that.$set(that, `user`, user);
|
|
|
+ that.search()
|
|
|
+ },
|
|
|
+ fail: function(err) {
|
|
|
+ uni.reLaunch({
|
|
|
+ url: `/pages/login/index`
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 查询列表
|
|
|
+ async search() {
|
|
|
+ const that = this;
|
|
|
+ let user = that.user;
|
|
|
+ let info = {
|
|
|
+ skip: that.skip,
|
|
|
+ limit: that.limit,
|
|
|
+ customer: user._id
|
|
|
+ }
|
|
|
+ const res = await that.$api(`/storeGoods`, 'GET', {
|
|
|
+ ...info
|
|
|
+ })
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ let list = [...that.list, ...res.data];
|
|
|
+ that.$set(that, `list`, list);
|
|
|
+ that.$set(that, `total`, res.total)
|
|
|
+ }
|
|
|
},
|
|
|
// 分页
|
|
|
toPage(e) {
|
|
|
-
|
|
|
+ const that = this;
|
|
|
+ let list = that.list;
|
|
|
+ let limit = that.limit;
|
|
|
+ if (that.total > list.length) {
|
|
|
+ uni.showLoading({
|
|
|
+ title: '加载中',
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ let page = that.page + 1;
|
|
|
+ that.$set(that, `page`, page)
|
|
|
+ let skip = page * limit;
|
|
|
+ that.$set(that, `skip`, skip)
|
|
|
+ that.search();
|
|
|
+ uni.hideLoading();
|
|
|
+ } else uni.showToast({
|
|
|
+ title: '没有更多数据了'
|
|
|
+ });
|
|
|
},
|
|
|
+ // 清空列表
|
|
|
+ clearPage() {
|
|
|
+ const that = this;
|
|
|
+ that.$set(that, `list`, [])
|
|
|
+ that.$set(that, `skip`, 0)
|
|
|
+ that.$set(that, `limit`, 5)
|
|
|
+ that.$set(that, `page`, 0)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|