diff --git a/App.vue b/App.vue index e322074..2f48e54 100644 --- a/App.vue +++ b/App.vue @@ -4,7 +4,7 @@ }, onLaunch: function() { - // this.login(); // 校验登录态 TODO 等待与后端对接 + this.login(); // 校验登录态 TODO 等待与后端对接 }, onShow: function() { // #ifdef MP-WEIXIN @@ -17,6 +17,7 @@ methods: { // 接口code换取用户信息 userCode(code){ + return console.log("code", code); this.$http('', { code }).then(res => { console.log("获得用户信息", res); }) diff --git a/common/api.js b/common/api.js index 91c7cdc..fe04211 100644 --- a/common/api.js +++ b/common/api.js @@ -17,3 +17,6 @@ export const API_ORDER_DETAILS = '/api/order/detail'; //确认订单详情 export const API_COFIRMORDER_DETAILS = '/api/order/confirm'; +/* 商品详情相关 */ +export const API_GOODS_DETAIL = '/api/goods/detail'; // 商品详情 +export const API_COLLECT_DEAL = '/api/collect/deal'; // 商品收藏 \ No newline at end of file diff --git a/pages/goodsDetail/index.vue b/pages/goodsDetail/index.vue index 84c2060..3f699d3 100644 --- a/pages/goodsDetail/index.vue +++ b/pages/goodsDetail/index.vue @@ -2,31 +2,27 @@ - - - - - + + + - 网红辣椒棒 魔鬼辣椒挑战全网第一辣 网红优惠季 网红优惠季 网红优惠季 + {{ goods_detail.name }} - ¥ 19.90 - ¥ 39.00 - 2.9折 + ¥{{ goods_detail.specs[0].selling_price }} + ¥{{ goods_detail.specs[0].original_price }} + {{ goods_detail.specs[0].cost }} - 已售4.5万份 - 库存仅剩98份 + {{ goods_detail.specs[0].sold_stock_text }} + {{ goods_detail.specs[0].stock_text }} - - 过期退 - 满减优惠 - 信用付 + + {{ item }} @@ -34,43 +30,43 @@ 适用门店 - - 李大叔家的店的店的店的店的店 + + {{ goods_detail.store.name }} - 南宁市青秀区 金湖广场 金浦路 地铁1号线A出口 右转200米 + {{ goods_detail.store.address }} 商品详情 - - + - + 首页 - + 客服 - - - 收藏 + + + + {{ is_collect ? '已收藏' : '收藏' }} - + @@ -82,14 +78,35 @@ data(){ return { current: 0, // 轮播下标 - goods_id: 0 + goods_id: 0, + goods_detail: {}, + is_collect: 0 // 1为当前收藏商品了,0为否 } }, onLoad(options){ this.goods_id = options.id; + this.getGoodsDetail(); }, methods: { - + getGoodsDetail(){ + this.$http(this.API.API_GOODS_DETAIL, {goods_id: this.goods_id}).then(res => { + console.log("res", res); + this.goods_detail = res.data; + this.is_collect = Boolean(res.data.user.is_collect); + }) + }, + // 切换商品收藏 + switchCollect(){ + this.$http(this.API.API_COLLECT_DEAL, {goods_id: this.goods_id}).then(res => { + console.log("res", res); + this.is_collect = Boolean(res.data.user.is_collect); + }) + } + }, + onShareAppMessage(){ + return { + title: '测试' + } } } @@ -169,6 +186,7 @@ width: 60rpx; height: 60rpx; border-radius: 10rpx; + background-color: #EEEEEE; } } @@ -204,8 +222,16 @@ padding-bottom: constant(safe-area-inset-bottom); padding-bottom: env(safe-area-inset-bottom); .icon-item{ - padding: 0 10rpx; + padding: 0 14rpx; margin-right: 16rpx; + background-color: transparent; + margin: 0; + line-height: initial; + font-size: 28rpx; + font-weight: inherit; + &:first-child{ + padding-left: 0; + } } .btn{ margin: 0;