Merge remote-tracking branch 'origin/master'

This commit is contained in:
Cxpller 2023-10-23 20:46:32 +08:00
commit ec7668a991
15 changed files with 118 additions and 71 deletions

View File

@ -262,7 +262,6 @@ Component({
},
init() {
console.log(this.properties.goodsList);
this.genIndependentID(this.id || '');
this.setData({
type: this.properties.type

View File

@ -19,6 +19,10 @@ Component({
type: Boolean,
value: true,
}, // 是否有库存
isCollect: {
type: Boolean,
value: false,
}, // 是否收藏
isSlotButton: {
type: Boolean,
value: false,

View File

@ -8,6 +8,12 @@ import {
import {
fetchActivityList
} from '~/services/activity/fetchActivityList';
import {
addOrUpdateGoodsCollection
} from '~/services/usercenter/goods-collect/addOrUpdateGoodsCollection';
import {
CancelGoodsCollection
} from '~/services/usercenter/goods-collect/CancelGoodsCollection';
import {
getGoodsDetailsCommentList,
getGoodsDetailsCommentsCount,
@ -61,7 +67,6 @@ Page({
title: '收藏',
url: '',
iconName: 'star',
filled_iconName: 'star-filled',
},
{
title: '购物车',
@ -132,7 +137,14 @@ Page({
} = e.detail;
if (title == "收藏") {
console.log(this.data.details.spuId,'点击收藏的id');
if(this.data.details.isCollect){
CancelGoodsCollection({goodsGuid: this.data.details.spuId})
}
else{
addOrUpdateGoodsCollection({goodsGuid: this.data.details.spuId})
}
this.getDetail(this.data.spuId)
// console.log(this.data.details.spuId, '点击收藏的id');
// console.log("点击收藏");
} else {
wx.switchTab({
@ -449,7 +461,18 @@ Page({
// details.desc = details.desc.replace(/\<img/gi, '<img style="max-width:100%;height:auto" ');
// details.desc = details.desc.replace(/<img[^>]*style\s*=\s*(['"])[^'"]*\1[^>]*>/gi, '<img style="max-width:100%;height:auto;" ');
// details.desc = details.desc.replace(/<img[^>]*>/gi, '<img style="max-3999999996width:100%;height:auto;" >');
if (details.isCollect === true) {
this.data.jumpArray[0].iconName = 'star_filled';
this.setData({
jumpArray: this.data.jumpArray
})
}
else{
this.data.jumpArray[0].iconName = 'star';
this.setData({
jumpArray: this.data.jumpArray
})
}
skuList.forEach((item) => {
skuArray.push({

View File

@ -141,6 +141,7 @@
jumpArray="{{jumpArray}}"
soldout="{{soldout}}"
isStock="{{isStock}}"
isCollect="{{details.isCollect}}"
shopCartNum="{{cartNum}}"
buttonType="{{buttonType}}"
bind:toAddCart="toAddCart"

View File

@ -31,12 +31,12 @@
<view class="pay-item">
<text>运费</text>
<view class="pay-item__right font-bold">
<!-- <block wx:if="{{settleDetailData.totalDeliveryFee && settleDetailData.totalDeliveryFee != 0}}"> -->
<block wx:if="{{settleDetailData.totalDeliveryFee && settleDetailData.totalDeliveryFee != 0}}">
<!-- {{stores.deliveryFee}} -->
<block wx:if="{{stores.deliveryFee && stores.deliveryFee != 0}}">
<!-- <block wx:if="{{stores.deliveryFee && stores.deliveryFee != 0}}"> -->
+
<!-- <price priceUnit="yuan" fill decimalSmaller price="{{settleDetailData.totalDeliveryFee}}" /> -->
<price priceUnit="yuan" fill decimalSmaller price="{{stores.deliveryFee}}" />
<price priceUnit="yuan" fill decimalSmaller price="{{settleDetailData.totalDeliveryFee}}" />
<!-- <price priceUnit="yuan" fill decimalSmaller price="{{stores.deliveryFee}}" /> -->
</block>
<text wx:else>免运费</text>
</view>

View File

@ -12,7 +12,8 @@ Page({
* 页面的初始数据
*/
data: {
list: []
list: [],
goodsListLoadStatus: 0
},
/**
@ -26,9 +27,11 @@ Page({
init(reset = false) {
const params = {
pageSize: this.page.size,
pageIndex: this.page.num,
pageNum: this.page.num,
};
this.setData({
goodsListLoadStatus: 1,
});
return getGoodsCollectionList(params)
.then((res) => {
this.page.num++;
@ -36,25 +39,15 @@ Page({
if (res && res.data && res.data.result) {
this.setData({
list: res.data.result
})
list: this.data.list.concat(res.data.result),
goodsListLoadStatus: 0,
});
}
return new Promise((resolve) => {
if (reset) {
this.setData({
list: [],
},
() => resolve(),
);
} else resolve();
}).then(() => {
this.setData({
list: this.data.list.concat(list),
});
}).catch((err) => {
this.setData({
goodsListLoadStatus: 3,
});
})
.catch((err) => {
return Promise.reject(err);
});
},
@ -71,6 +64,12 @@ Page({
});
},
onReachBottom() {
if (this.data.goodsListLoadStatus === 0) {
this.init();
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
@ -106,13 +105,6 @@ Page({
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/

View File

@ -3,6 +3,7 @@
"usingComponents": {
"t-empty": "tdesign-miniprogram/empty/empty",
"t-toast": "tdesign-miniprogram/toast/toast",
"load-more": "/components/load-more/index",
"goods-list": "/components/goods-list/index"
}
}

View File

@ -12,7 +12,8 @@ Page({
* 页面的初始数据
*/
data: {
list: []
list: [],
goodsListLoadStatus: 0
},
/**
@ -22,39 +23,36 @@ Page({
this.init()
},
onReTry() {
this.init();
},
// 获取商品浏览记录列表
init(reset = false) {
async init(reset = false) {
const params = {
pageSize: this.page.size,
pageIndex: this.page.num,
pageNum: this.page.num,
};
this.setData({
goodsListLoadStatus: 1,
});
return getGoodsBrowsingHistoryList(params)
.then((res) => {
this.page.num++;
let list = [];
if (res && res.data && res.data.result) {
this.setData({
list: res.data.result
})
list: this.data.list.concat(res.data.result),
goodsListLoadStatus: 0,
});
}
return new Promise((resolve) => {
if (reset) {
this.setData({
list: [],
},
() => resolve(),
);
} else resolve();
}).then(() => {
this.setData({
list: this.data.list.concat(list),
});
});
})
.catch((err) => {
this.setData({
goodsListLoadStatus: 3,
});
return Promise.reject(err);
});
},
@ -71,6 +69,12 @@ Page({
});
},
onReachBottom() {
if (this.data.goodsListLoadStatus === 0) {
this.init();
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
@ -106,13 +110,6 @@ Page({
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/

View File

@ -3,6 +3,7 @@
"usingComponents": {
"t-empty": "tdesign-miniprogram/empty/empty",
"t-toast": "tdesign-miniprogram/toast/toast",
"load-more": "/components/load-more/index",
"goods-list": "/components/goods-list/index"
}
}

View File

@ -5,5 +5,6 @@
<t-empty t-class="empty-tips" size="240rpx" description="暂无浏览记录" />
</view>
<goods-list wx:else wr-class="wr-goods-list" type="history-card" goodsList="{{list}}" bind:click="gotoGoodsDetail" />
<load-more list-is-empty="{{!list.length}}" status="{{goodsListLoadStatus}}" bind:retry="onReTry" />
</view>
</view>

View File

@ -101,6 +101,10 @@ const getDefaultData = () => ({
nickName: '正在登录...',
phoneNumber: '',
},
collectData: {
collectCount: 0,
historyCount: 0,
},
menuData,
orderTagInfos,
customerServiceInfo: {},
@ -133,6 +137,7 @@ Page({
fetchUserCenter().then(
({
userInfo,
collectData,
// countsData,
// orderTagInfos: orderInfo,
// customerServiceInfo,
@ -151,9 +156,9 @@ Page({
// ...v,
// ...orderInfo[index],
// }));
console.log(userInfo,'来看看');
this.setData({
userInfo,
collectData,
// menuData,
// orderTagInfos: info,
// customerServiceInfo,

View File

@ -13,12 +13,12 @@
<!-- 收藏和足迹 -->
<view class="order-history-box">
<view class="order-history-content-box" bind:tap="jumpCollect">
<view class="order-history-content-num">0</view>
<view class="order-history-content-num">{{collectData.collectCount}}</view>
<view class="order-history-content-text">收藏</view>
</view>
<view class="order-history-content-line"></view>
<view class="order-history-content-box" bind:tap="jumpHistory">
<view class="order-history-content-num">0</view>
<view class="order-history-content-num">{{collectData.historyCount}}</view>
<view class="order-history-content-text">浏览记录</view>
</view>
</view>

View File

@ -13,12 +13,15 @@ export function fetchUserCenter() {
url: `CustomerApi/getCustomerDetails?CustomerGuid=` + userData?.customerGuid,
method: 'GET',
success: function (res) {
let userInfo = res.data;
let data = {
userInfo: {
avatarUrl: userInfo.customerAvatar,
nickName: userInfo.customerNickname,
phoneNumber: userInfo.customerMobilePhoneNumber,
avatarUrl: res.data.customerAvatar,
nickName: res.data.customerNickname,
phoneNumber: res.data.customerMobilePhoneNumber,
},
collectData: {
collectCount: res.data.collectCount,
historyCount: res.data.historyCount,
}
};
resolve(data);

View File

@ -0,0 +1,20 @@
import {
request
} from '~/services/_utils/request';
/** 删除商品收藏 */
export function CancelGoodsCollection(data) {
return new Promise((resolve, reject) => {
request({
url: `GoodsCollectionApi/CancelGoodsCollection`,
method: 'POST',
data: data,
success: function (res) {
resolve(res);
},
fail: function (error) {
reject(error);
}
});
});
}

View File

@ -2,11 +2,11 @@ import {
request
} from '~/services/_utils/request';
/** 添加商品浏览记录 */
export function addOrUpdateGoodsBrowsingHistory(data) {
/** 添加商品收藏 */
export function addOrUpdateGoodsCollection(data) {
return new Promise((resolve, reject) => {
request({
url: `GoodsCollectionApi/addOrUpdateGoodsBrowsingHistory`,
url: `GoodsCollectionApi/addOrUpdateGoodsCollection`,
method: 'Post',
data: data,
success: function (res) {