Commit af6a02245051d29bb4d57ddf4db92f5acf41f4d8
1 parent
07d361f4
feature(uniapp商品): 商品详情
Showing
5 changed files
with
57 additions
and
11 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java
| 1 | 1 | package cn.iocoder.yudao.module.product.controller.app.spu; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.bean.BeanUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuPageReqVO; | |
| 6 | 6 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; |
| 7 | 7 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO; |
| 9 | +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuRespVO; | |
| 9 | 10 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; |
| 10 | 11 | import io.swagger.annotations.Api; |
| 11 | 12 | import io.swagger.annotations.ApiOperation; |
| 12 | 13 | import org.springframework.validation.annotation.Validated; |
| 13 | 14 | import org.springframework.web.bind.annotation.GetMapping; |
| 14 | -import org.springframework.web.bind.annotation.RequestBody; | |
| 15 | 15 | import org.springframework.web.bind.annotation.RequestMapping; |
| 16 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 16 | 17 | import org.springframework.web.bind.annotation.RestController; |
| 17 | 18 | |
| 18 | 19 | import javax.annotation.Resource; |
| ... | ... | @@ -34,4 +35,11 @@ public class AppProductSpuController { |
| 34 | 35 | public CommonResult<PageResult<AppSpuPageRespVO>> getSpuPage(@Valid AppSpuPageReqVO pageVO) { |
| 35 | 36 | return success(spuService.getSpuPage(pageVO)); |
| 36 | 37 | } |
| 38 | + | |
| 39 | + @GetMapping("/") | |
| 40 | + @ApiOperation("获取商品 - 通过商品id") | |
| 41 | + public CommonResult<AppSpuRespVO> getSpu(@RequestParam("spuId") Long spuId) { | |
| 42 | + AppSpuRespVO appSpuRespVO = BeanUtil.toBean(spuService.getSpu(spuId), AppSpuRespVO.class); | |
| 43 | + return success(appSpuRespVO); | |
| 44 | + } | |
| 37 | 45 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppSpuRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.product.controller.app.spu.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.product.controller.admin.spu.vo.SpuRespVO; | |
| 4 | +import io.swagger.annotations.ApiModel; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * <p> | |
| 11 | + * | |
| 12 | + * </p> | |
| 13 | + * | |
| 14 | + * @author LuoWenFeng | |
| 15 | + */ | |
| 16 | +@ApiModel("App - 商品spu Response VO") | |
| 17 | +@Data | |
| 18 | +@EqualsAndHashCode(callSuper = true) | |
| 19 | +public class AppSpuRespVO extends SpuRespVO { | |
| 20 | + | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-ui-app/api/product.js
| ... | ... | @@ -2,4 +2,7 @@ |
| 2 | 2 | const { http } = uni.$u |
| 3 | 3 | |
| 4 | 4 | // 查询商品spu列表 |
| 5 | -export const productSpuPage = params => http.get('/product/spu/page', { params }) | |
| 5 | +export const productSpuPage = params => http.get('product/spu/page', { params }) | |
| 6 | + | |
| 7 | +// 查询商品 | |
| 8 | +export const productSpu = params => http.get('product/spu/', { params }) | ... | ... |
yudao-ui-app/pages/index/index.vue
| ... | ... | @@ -169,8 +169,8 @@ export default { |
| 169 | 169 | } |
| 170 | 170 | }, |
| 171 | 171 | onLoad() { |
| 172 | - //this.loadBannerData(); | |
| 173 | - //this.loadNoticeData(); | |
| 172 | + this.loadBannerData(); | |
| 173 | + this.loadNoticeData(); | |
| 174 | 174 | }, |
| 175 | 175 | methods: { |
| 176 | 176 | loadBannerData() { |
| ... | ... | @@ -302,7 +302,7 @@ export default { |
| 302 | 302 | margin: 10rpx; |
| 303 | 303 | background: #ffffff; |
| 304 | 304 | border-radius: 10rpx; |
| 305 | - box-shadow: -1rpx 1rpx 2rpx #afd3f5, 1rpx 1rpx 0rpx #afd3f5; | |
| 305 | + box-shadow: 0rpx 6rpx 8rpx rgba(58,134,185,0.2); | |
| 306 | 306 | .prod-image { |
| 307 | 307 | width: 224rpx; |
| 308 | 308 | height: 224rpx; | ... | ... |
yudao-ui-app/pages/product/product.vue
| ... | ... | @@ -43,7 +43,7 @@ |
| 43 | 43 | <u-popup :show="skuPopup" :round="10" :closeable="true" :closeOnClickOverlay="false" @close="skuPopup = false"> |
| 44 | 44 | <view class="sku-popup-slot"> |
| 45 | 45 | <view class="current-sku-info"> |
| 46 | - <u--image class="current-sku-img" :showLoading="true" :src="product.sku[currentSkuIndex].image" width="120rpx" height="120rpx"></u--image> | |
| 46 | + <u--image class="current-sku-img" :showLoading="true" :src="product.sku[currentSkuIndex].picUrl" width="120rpx" height="120rpx"></u--image> | |
| 47 | 47 | <view class="current-sku-desc"> |
| 48 | 48 | <view class="name">{{ product.sku[currentSkuIndex].desc }}</view> |
| 49 | 49 | <custom-text-price color="red" size="12" intSize="18" :price="product.sku[currentSkuIndex].price"></custom-text-price> |
| ... | ... | @@ -178,6 +178,8 @@ |
| 178 | 178 | </template> |
| 179 | 179 | |
| 180 | 180 | <script> |
| 181 | + import { productSpu } from '../../api/product'; | |
| 182 | + | |
| 181 | 183 | export default { |
| 182 | 184 | data() { |
| 183 | 185 | return { |
| ... | ... | @@ -194,19 +196,19 @@ export default { |
| 194 | 196 | sku: [ |
| 195 | 197 | { |
| 196 | 198 | id: 0, |
| 197 | - image: 'https://cdn.uviewui.com/uview/album/1.jpg', | |
| 199 | + picUrl: 'https://cdn.uviewui.com/uview/album/1.jpg', | |
| 198 | 200 | price: 13.0, |
| 199 | 201 | desc: '山不在高,有仙则名。' |
| 200 | 202 | }, |
| 201 | 203 | { |
| 202 | 204 | id: 1, |
| 203 | - image: 'https://cdn.uviewui.com/uview/album/2.jpg', | |
| 205 | + picUrl: 'https://cdn.uviewui.com/uview/album/2.jpg', | |
| 204 | 206 | price: 11.0, |
| 205 | 207 | desc: '水不在深,有龙则灵。' |
| 206 | 208 | }, |
| 207 | 209 | { |
| 208 | 210 | id: 2, |
| 209 | - image: 'https://cdn.uviewui.com/uview/album/3.jpg', | |
| 211 | + picUrl: 'https://cdn.uviewui.com/uview/album/3.jpg', | |
| 210 | 212 | price: 10.0, |
| 211 | 213 | desc: '斯是陋室,惟吾德馨。' |
| 212 | 214 | } |
| ... | ... | @@ -302,7 +304,18 @@ export default { |
| 302 | 304 | } |
| 303 | 305 | }, |
| 304 | 306 | methods: { |
| 305 | - loadProductData() {}, | |
| 307 | + loadProductData() { | |
| 308 | + let param = {} | |
| 309 | + param.spuId = this.product.id | |
| 310 | + productSpu(param).then(res => { | |
| 311 | + this.product.images = res.data.picUrls; | |
| 312 | + this.product.sku = res.data.skus; | |
| 313 | + this.product.desc = res.data.description.replace(/<[^>]*>/g,''); | |
| 314 | + this.product.price = res.data.price; | |
| 315 | + this.product.title = res.data.name; | |
| 316 | + console.log(res) | |
| 317 | + }) | |
| 318 | + }, | |
| 306 | 319 | handleSkuItemClick(index) { |
| 307 | 320 | this.currentSkuIndex = index |
| 308 | 321 | }, | ... | ... |