diff --git a/api/order.js b/api/order.js
index c14c136..4fcc542 100644
--- a/api/order.js
+++ b/api/order.js
@@ -92,6 +92,14 @@ export const apiGetCartList = (data) => {
);
}
+// 删除购物车
+export const apiDeleteCart = (data) => {
+ return httpRequest.post(
+ `${baseUrl}/shipping/cart/delete`,
+ data
+ );
+ }
+
// 获取订单详情
export const apiGetOrderDetail = (data) => {
return httpRequest.post(
diff --git a/components/page/diyComponents/goods/index.vue b/components/page/diyComponents/goods/index.vue
index 279556d..5538646 100644
--- a/components/page/diyComponents/goods/index.vue
+++ b/components/page/diyComponents/goods/index.vue
@@ -80,7 +80,7 @@
-
+
@@ -371,6 +371,7 @@
text-align: center;
.cart-icon {
+ color: $main-bg;
font-size: 36rpx;
}
}
diff --git a/pages/cart/index.vue b/pages/cart/index.vue
index 80e2e19..e800af1 100644
--- a/pages/cart/index.vue
+++ b/pages/cart/index.vue
@@ -270,7 +270,7 @@
// 确认删除商品
onClearCart() {
const app = this
- CartApi.clear(app.checkedIds)
+ OrderApi.apiDeleteCart({ shoppingCartIds: app.checkedIds })
.then(result => {
app.getCartList()
app.handleToggleMode()
diff --git a/pages/category/components/commodity.vue b/pages/category/components/commodity.vue
index 589bae2..b5c20ce 100644
--- a/pages/category/components/commodity.vue
+++ b/pages/category/components/commodity.vue
@@ -168,9 +168,6 @@
const app = this
const categoryId = app.getCategoryId()
return new Promise((resolve, reject) => {
- GoodsApi.list({ categoryId, page: pageNo }, { load: false }).then(res => {
- console.warn('----- my data is categoryId: ', res)
- })
// testorigin GoodsApi.list({ categoryId, page: pageNo }, { load: false })
GoodsApi.apiGetCommodityList({ categoryId })
.then(result => {
diff --git a/pages/comment/index.vue b/pages/comment/index.vue
index abbcd9b..e7062bd 100644
--- a/pages/comment/index.vue
+++ b/pages/comment/index.vue
@@ -51,7 +51,7 @@
import { apiGetCommentList } from '@/api/goods'
const pageSize = 15
- const tabs = [{ name: `全部`, scoreType: -1 }, { name: `好评`, scoreType: 10 }, { name: `中评`, scoreType: 20 }, { name: `差评`, scoreType: 30 }]
+ const tabs = [{ name: `全部`, level: '' }, { name: `好评`, level: 'good' }, { name: `中评`, level: 'common' }, { name: `差评`, level: 'notgood' }]
export default {
components: {
@@ -88,11 +88,10 @@
methods: {
/**
* 上拉加载的回调 (页面初始化时也会执行一次)
- * @param {Object} page
*/
upCallback(page) {
const app = this
- apiGetCommentList({ productId: app.goodsId, scoreType: app.tabs[app.curTab].scoreType, page: page.num }).then(res => {
+ apiGetCommentList({ productId: app.goodsId, level: app.tabs[app.curTab].level, page: page.num }).then(res => {
const data = res.data.map(item => ({
...item,
skuInfo: JSON.parse(item.skuInfo)
@@ -100,7 +99,7 @@
app.list.data = getMoreListData({ data }, app.list, page.num)
app.mescroll.endBySize(data.length, data.length)
}).catch(() => app.mescroll.endErr())
- CommentApi.list({})
+ // CommentApi.list({})
},
// 获取指定评分总数
getTotal() {
diff --git a/pages/goods/list.vue b/pages/goods/list.vue
index 5082d49..608ceb3 100644
--- a/pages/goods/list.vue
+++ b/pages/goods/list.vue
@@ -24,10 +24,10 @@
价格
-
+
-
+
@@ -35,56 +35,68 @@
-
+
-
+
- {{ item.goods_name }}
+ {{ item.title }}
- {{ item.selling_point }}
+ {{ item.feature1 }} {{ item.feature2 }}
- 已售{{ item.goods_sales }}件
+ 已售{{ item.showSaleCount }}件
+
+
+
+
+
-
+
- {{ item.goods_name }}
+ {{ item.title }}
- ¥{{ item.goods_price_min }}
- ¥{{ item.line_price_min }}
+ ¥{{ item.showPromotionPrice }}
+ ¥{{ item.showSalePrice }}
+
+
+
+
+
+
+
@@ -93,23 +105,24 @@
import * as GoodsApi from '@/api/goods'
import { getEmptyPaginateObj, getMoreListData } from '@/core/app'
import Search from '@/components/search'
+ import AddCartPopup from '@/components/add-cart-popup'
const pageSize = 15
const showViewKey = 'GoodsList-ShowView';
export default {
components: {
- Search
+ Search,
+ AddCartPopup
},
mixins: [MescrollMixin],
data() {
return {
showView: false, // 列表显示方式 (true列表、false平铺)
- sortType: 'all', // 排序类型
- sortPrice: false, // 价格排序 (true高到低 false低到高)
+ sortType: 'all', // 排序类型: all, sales, price
+ sortPrice: undefined, // 价格排序 (true高到低 false低到高) ASC升序、DESC降序
options: {}, // 当前页面参数
list: getEmptyPaginateObj(), // 商品列表数据
-
// 上拉加载配置
upOption: {
// 首次自动执行
@@ -121,51 +134,36 @@
}
}
},
-
- /**
- * 生命周期函数--监听页面加载
- */
onLoad(options) {
- // 记录options
this.options = options
- // 设置默认列表显示方式
- this.setShowView()
+ this.showView = uni.getStorageSync(showViewKey) || false // 设置默认列表显示方式
},
-
methods: {
-
- /**
- * 上拉加载的回调 (页面初始化时也会执行一次)
- * 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
- * @param {Object} page
- */
+ // 上拉加载的回调 (页面初始化时也会执行一次)
upCallback(page) {
const app = this
- // 设置列表数据
- app.getGoodsList(page.num)
- .then(list => {
- const curPageLen = list.data.length
- const totalSize = list.total
- app.mescroll.endBySize(curPageLen, totalSize)
- })
- .catch(() => app.mescroll.endErr())
+ GoodsApi.apiGetCommodityList({
+ page: page.num,
+ pageSize: page.size,
+ productName: app.options.search || undefined,
+ saleCountSort: app.sortType === 'sales' ? 'DESC' : undefined,
+ salePriceSort: app.sortType === 'price' ? app.sortPrice : undefined,
+ }).then(res => {
+ app.list.data = getMoreListData({ data: res.data.rows }, app.list, page.num)
+ app.mescroll.endBySize(res.data.rows.length, res.data.total)
+ console.log(res)
+ }).catch(() => app.mescroll.endErr())
+ // app.getGoodsList(page.num)
},
-
- // 设置默认列表显示方式
- setShowView() {
- this.showView = uni.getStorageSync(showViewKey) || false
- },
-
/**
* 获取商品列表
* @param {number} pageNo 页码
*/
getGoodsList(pageNo = 1) {
const app = this
- console.log(app.options)
const param = {
sortType: app.sortType,
- sortPrice: Number(app.sortPrice),
+ sortPrice: app.sortPrice,
categoryId: app.options.categoryId || 0,
goodsName: app.options.search || '',
page: pageNo
@@ -181,33 +179,38 @@
.catch(reject)
})
},
-
// 切换排序方式
handleSortType(newSortType) {
const app = this
- const newSortPrice = newSortType === 'price' ? !app.sortPrice : true
+ if (newSortType === 'price') {
+ app.sortPrice = app.sortPrice === 'ASC' ? 'DESC' : 'ASC'
+ } else {
+ app.sortPrice = undefined
+ }
app.sortType = newSortType
- app.sortPrice = newSortPrice
// 刷新列表数据
app.list = getEmptyPaginateObj()
app.mescroll.resetUpScroll()
},
-
// 切换列表显示方式
handleShowView() {
const app = this
app.showView = !app.showView
uni.setStorageSync(showViewKey, app.showView)
},
-
// 跳转商品详情页
onTargetDetail(goodsId) {
this.$navTo('pages/goods/detail', { goodsId })
},
-
- /**
- * 商品搜索
- */
+ // 点击加入购物车
+ handleAddCart(item) {
+ this.$refs.AddCartPopup.handle(item)
+ },
+ // 更新购物车角标
+ onAddCart(total) {
+ setCartTabBadge()
+ },
+ // 商品搜索
handleSearch() {
const searchPageUrl = 'pages/search/index'
// 判断来源页面
@@ -220,12 +223,8 @@
// 跳转到商品搜索页
this.$navTo(searchPageUrl)
},
-
},
-
- /**
- * 设置分享内容
- */
+ // 设置分享内容
onShareAppMessage() {
// 构建分享参数
const app = this
@@ -234,7 +233,6 @@
path: "/pages/goods/list?" + this.$getShareUrlParams(app.options)
}
},
-
/**
* 分享到朋友圈
* 本接口为 Beta 版本,暂只在 Android 平台支持,详见分享到朋友圈 (Beta)
@@ -351,8 +349,8 @@
.image {
display: block;
- width: 240rpx;
- height: 240rpx;
+ width: 200rpx;
+ height: 200rpx;
}
}
@@ -398,7 +396,14 @@
text-decoration: line-through;
}
}
- }
+}
+.action{
+ position: absolute;
+ right: 30rpx;
+ bottom: -30rpx;
+ font-size: 36rpx;
+ color: $main-bg;
+}
// 平铺显示
.goods-list.column-2 {
@@ -438,6 +443,7 @@
}
.detail {
+ position: relative;
padding: 8rpx;
background: #fff;
@@ -459,6 +465,10 @@
text-decoration: line-through;
}
}
+ .action{
+ bottom: 0;
+ right: 15rpx;
+ }
}
}
\ No newline at end of file