创建微服务:microservice-provider-shop-8003;小程序商品列表筛选、商品详情完成
This commit is contained in:
parent
ee7e2e9acb
commit
7eab148104
2
backend/.idea/encodings.xml
generated
2
backend/.idea/encodings.xml
generated
@ -9,6 +9,8 @@
|
|||||||
<file url="file://$PROJECT_DIR$/microservice-provider-access-8002/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/microservice-provider-access-8002/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/microservice-provider-miniprogram-8080/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/microservice-provider-miniprogram-8080/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/microservice-provider-miniprogram-8080/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/microservice-provider-miniprogram-8080/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/microservice-provider-shop-8003/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/microservice-provider-shop-8003/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/microservice-provider-test-8011/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/microservice-provider-test-8011/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/microservice-provider-test-8011/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/microservice-provider-test-8011/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/microservice-provider-user-8001/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/microservice-provider-user-8001/src/main/java" charset="UTF-8" />
|
||||||
|
10
backend/.idea/runConfigurations/MiniProgram.xml
generated
10
backend/.idea/runConfigurations/MiniProgram.xml
generated
@ -1,10 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="MiniProgram" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
|
|
||||||
<option name="ACTIVE_PROFILES" />
|
|
||||||
<option name="SPRING_BOOT_MAIN_CLASS" value="com.cxyxiaomo.epp.miniprogram.Application" />
|
|
||||||
<option name="VM_PARAMETERS" value="-Xms64m -Xmx256m" />
|
|
||||||
<method v="2">
|
|
||||||
<option name="Make" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
17
backend/.idea/runConfigurations/ShopProvider.xml
generated
Normal file
17
backend/.idea/runConfigurations/ShopProvider.xml
generated
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="ShopProvider" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
|
||||||
|
<option name="ACTIVE_PROFILES" />
|
||||||
|
<module name="microservice-provider-shop-8003" />
|
||||||
|
<option name="SPRING_BOOT_MAIN_CLASS" value="com.cxyxiaomo.epp.shop.ShopProvider" />
|
||||||
|
<option name="VM_PARAMETERS" value="-Xms64m -Xmx256m" />
|
||||||
|
<extension name="coverage">
|
||||||
|
<pattern>
|
||||||
|
<option name="PATTERN" value="com.cxyxiaomo.epp.shop.*" />
|
||||||
|
<option name="ENABLED" value="true" />
|
||||||
|
</pattern>
|
||||||
|
</extension>
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
20
backend/.idea/runConfigurations/ShopProvider_Remote.xml
generated
Normal file
20
backend/.idea/runConfigurations/ShopProvider_Remote.xml
generated
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="ShopProvider-Remote" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
|
||||||
|
<option name="ACTIVE_PROFILES" />
|
||||||
|
<envs>
|
||||||
|
<env name="--spring.profiles.active" value="remote" />
|
||||||
|
</envs>
|
||||||
|
<module name="microservice-provider-shop-8003" />
|
||||||
|
<option name="SPRING_BOOT_MAIN_CLASS" value="com.cxyxiaomo.epp.shop.ShopProvider" />
|
||||||
|
<option name="VM_PARAMETERS" value="-Xms64m -Xmx256m" />
|
||||||
|
<extension name="coverage">
|
||||||
|
<pattern>
|
||||||
|
<option name="PATTERN" value="com.cxyxiaomo.epp.shop.*" />
|
||||||
|
<option name="ENABLED" value="true" />
|
||||||
|
</pattern>
|
||||||
|
</extension>
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.cxyxiaomo.epp.common.pojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true) // 链式写法
|
||||||
|
public class Good {
|
||||||
|
Long id;
|
||||||
|
String goodsName;
|
||||||
|
Integer categoryId;
|
||||||
|
Integer brand;
|
||||||
|
String gallery;
|
||||||
|
String brief;
|
||||||
|
Boolean isOnSale;
|
||||||
|
String picUrl;
|
||||||
|
Integer type;
|
||||||
|
String unit;
|
||||||
|
Double counterPrice;
|
||||||
|
Double retailPrice;
|
||||||
|
String detail;
|
||||||
|
Boolean deleted;
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.cxyxiaomo.epp.common.pojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true) // 链式写法
|
||||||
|
public class GoodCategory {
|
||||||
|
Long id;
|
||||||
|
String categoryName;
|
||||||
|
Integer order;
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package com.cxyxiaomo.epp.common.vo;
|
||||||
|
|
||||||
|
import com.cxyxiaomo.epp.common.pojo.GoodCategory;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
// 数据库关系映射
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true) // 链式写法
|
||||||
|
// 微服务必须要实现Serializable
|
||||||
|
public class GoodCategoryVO implements Serializable {
|
||||||
|
|
||||||
|
Long id;
|
||||||
|
String categoryName;
|
||||||
|
Integer order;
|
||||||
|
|
||||||
|
public static GoodCategoryVO convertFrom(GoodCategory goodCategory) {
|
||||||
|
if (goodCategory == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
GoodCategoryVO goodCategoryVO = new GoodCategoryVO();
|
||||||
|
BeanUtils.copyProperties(goodCategory, goodCategoryVO);
|
||||||
|
return goodCategoryVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<GoodCategoryVO> convertFrom(List<GoodCategory> goodCategoryList) {
|
||||||
|
if (goodCategoryList == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<GoodCategoryVO> goodCategoryVOList = goodCategoryList.stream().map(GoodCategoryVO::convertFrom).collect(Collectors.toList());
|
||||||
|
return goodCategoryVOList;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.cxyxiaomo.epp.common.vo;
|
||||||
|
|
||||||
|
import com.cxyxiaomo.epp.common.pojo.Good;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
// 数据库关系映射
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true) // 链式写法
|
||||||
|
// 微服务必须要实现Serializable
|
||||||
|
public class GoodVO implements Serializable {
|
||||||
|
Long id;
|
||||||
|
String goodsName;
|
||||||
|
Integer categoryId;
|
||||||
|
Integer brand;
|
||||||
|
String gallery;
|
||||||
|
String brief;
|
||||||
|
Boolean isOnSale;
|
||||||
|
String picUrl;
|
||||||
|
Integer type;
|
||||||
|
String unit;
|
||||||
|
Double counterPrice;
|
||||||
|
Double retailPrice;
|
||||||
|
String detail;
|
||||||
|
|
||||||
|
public static GoodVO convertFrom(Good good) {
|
||||||
|
if (good == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
GoodVO goodVO = new GoodVO();
|
||||||
|
BeanUtils.copyProperties(good, goodVO);
|
||||||
|
return goodVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<GoodVO> convertFrom(List<Good> goodList) {
|
||||||
|
if (goodList == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<GoodVO> goodVOList = goodList.stream().map(GoodVO::convertFrom).collect(Collectors.toList());
|
||||||
|
return goodVOList;
|
||||||
|
}
|
||||||
|
}
|
@ -25,6 +25,11 @@ spring:
|
|||||||
predicates:
|
predicates:
|
||||||
- Path=/access/**
|
- Path=/access/**
|
||||||
- Method=GET,POST
|
- Method=GET,POST
|
||||||
|
- id: shop
|
||||||
|
uri: lb://microservice-provider-shop
|
||||||
|
predicates:
|
||||||
|
- Path=/shop/**
|
||||||
|
- Method=GET,POST
|
||||||
|
|
||||||
- id: test1
|
- id: test1
|
||||||
uri: lb://microservice-provider-test
|
uri: lb://microservice-provider-test
|
||||||
|
@ -6,5 +6,8 @@
|
|||||||
<settings>
|
<settings>
|
||||||
<!--开启二级缓存-->
|
<!--开启二级缓存-->
|
||||||
<setting name="cacheEnabled" value="true"/>
|
<setting name="cacheEnabled" value="true"/>
|
||||||
|
|
||||||
|
<!--下划线转小驼峰-->
|
||||||
|
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||||
</settings>
|
</settings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
159
backend/microservice-provider-shop-8003/pom.xml
Normal file
159
backend/microservice-provider-shop-8003/pom.xml
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>epp</artifactId>
|
||||||
|
<groupId>com.cxyxiaomo</groupId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>microservice-provider-shop</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.7</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- 实体类 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cxyxiaomo</groupId>
|
||||||
|
<artifactId>microservice-common</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- mybatis -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- mysql -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- junit -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- lombok -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<!-- druid -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- logback -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-simple</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Spring Boot -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-test</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- OpenFeign -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Fastjson -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
<artifactId>fastjson2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- OkHttp -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- WebSocket -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
||||||
|
<plugins>
|
||||||
|
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</plugin>
|
||||||
|
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.22.1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
|
<version>2.5.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<version>2.8.2</version>
|
||||||
|
</plugin>
|
||||||
|
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
|
<version>3.7.1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.cxyxiaomo.epp.shop;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
|
// 启动类
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableDiscoveryClient
|
||||||
|
@EnableFeignClients
|
||||||
|
public class ShopProvider {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ShopProvider.class, args);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package com.cxyxiaomo.epp.shop.controller;
|
||||||
|
|
||||||
|
import com.cxyxiaomo.epp.common.response.Res;
|
||||||
|
import com.cxyxiaomo.epp.common.vo.GoodCategoryVO;
|
||||||
|
import com.cxyxiaomo.epp.common.vo.GoodVO;
|
||||||
|
import com.cxyxiaomo.epp.shop.service.GoodsServiceImpl;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/shop/good")
|
||||||
|
public class GoodsController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
GoodsServiceImpl goodsService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序端商品列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/miniprogram/list")
|
||||||
|
public Res list(@RequestParam(value = "cateId", required = false) Integer cateId,
|
||||||
|
@RequestParam(value = "searchText", required = false) String searchText) {
|
||||||
|
if (cateId != null && cateId <= 0) {
|
||||||
|
cateId = null;
|
||||||
|
}
|
||||||
|
if (searchText != null) {
|
||||||
|
searchText = searchText.trim();
|
||||||
|
if (searchText.contains("%") || searchText.contains("_")) {
|
||||||
|
searchText = searchText
|
||||||
|
.replaceAll("[_%]", "");
|
||||||
|
}
|
||||||
|
if ("".equals(searchText)) {
|
||||||
|
searchText = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<GoodVO> list = goodsService.list(cateId, searchText);
|
||||||
|
return Res.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序端商品详情
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/miniprogram/detail")
|
||||||
|
public Res detail(@RequestParam("id") Long id) {
|
||||||
|
GoodVO goodVO = goodsService.getById(id);
|
||||||
|
return Res.success(goodVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序端商品分类列表
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/miniprogram/cateList")
|
||||||
|
public Res cateList() {
|
||||||
|
List<GoodCategoryVO> list = goodsService.cateList();
|
||||||
|
return Res.success(list);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.cxyxiaomo.epp.shop.dao;
|
||||||
|
|
||||||
|
import com.cxyxiaomo.epp.common.pojo.GoodCategory;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface GoodsCategoryDao {
|
||||||
|
|
||||||
|
List<GoodCategory> list();
|
||||||
|
|
||||||
|
GoodCategory getById(Integer id);
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.cxyxiaomo.epp.shop.dao;
|
||||||
|
|
||||||
|
import com.cxyxiaomo.epp.common.pojo.Good;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface GoodsDao {
|
||||||
|
|
||||||
|
List<Good> list(@Param("cateId") Integer cateId, @Param("searchText") String searchText);
|
||||||
|
|
||||||
|
Good getById(Long id);
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.cxyxiaomo.epp.shop.service;
|
||||||
|
|
||||||
|
import com.cxyxiaomo.epp.common.vo.GoodCategoryVO;
|
||||||
|
import com.cxyxiaomo.epp.common.vo.GoodVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface GoodsService {
|
||||||
|
|
||||||
|
List<GoodVO> list(Integer cateId, String searchText);
|
||||||
|
|
||||||
|
GoodVO getById(Long id);
|
||||||
|
|
||||||
|
List<GoodCategoryVO> cateList();
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.cxyxiaomo.epp.shop.service;
|
||||||
|
|
||||||
|
import com.cxyxiaomo.epp.common.pojo.Good;
|
||||||
|
import com.cxyxiaomo.epp.common.pojo.GoodCategory;
|
||||||
|
import com.cxyxiaomo.epp.common.vo.GoodCategoryVO;
|
||||||
|
import com.cxyxiaomo.epp.common.vo.GoodVO;
|
||||||
|
import com.cxyxiaomo.epp.shop.dao.GoodsCategoryDao;
|
||||||
|
import com.cxyxiaomo.epp.shop.dao.GoodsDao;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GoodsServiceImpl implements GoodsService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
GoodsDao goodsDao;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
GoodsCategoryDao goodsCategoryDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GoodVO> list(Integer cateId, String searchText) {
|
||||||
|
List<Good> list = goodsDao.list(cateId, searchText);
|
||||||
|
List<GoodVO> goodVOS = GoodVO.convertFrom(list);
|
||||||
|
return goodVOS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoodVO getById(Long id) {
|
||||||
|
Good good = goodsDao.getById(id);
|
||||||
|
GoodVO goodVO = GoodVO.convertFrom(good);
|
||||||
|
return goodVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GoodCategoryVO> cateList() {
|
||||||
|
List<GoodCategory> list = goodsCategoryDao.list();
|
||||||
|
List<GoodCategoryVO> goodCategoryVOList = GoodCategoryVO.convertFrom(list);
|
||||||
|
return goodCategoryVOList;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
url: jdbc:mysql://127.0.0.1:3306/epp?useUnicode=true&characterEncoding=utf8&useSSL=false
|
||||||
|
username: root
|
||||||
|
password: 123456
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
server-addr: 106.75.217.14:8488
|
@ -0,0 +1,23 @@
|
|||||||
|
server:
|
||||||
|
port: 8003
|
||||||
|
|
||||||
|
# Mybatis 配置
|
||||||
|
mybatis:
|
||||||
|
type-aliases-package: com.cxyxiaomo.epp.pojo
|
||||||
|
config-location: classpath:mybatis/mybatis-config.xml
|
||||||
|
mapper-locations: classpath:mybatis/mapper/*.xml
|
||||||
|
|
||||||
|
# Spring 配置
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: microservice-provider-shop
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
server-addr: 127.0.0.1:8848
|
||||||
|
datasource:
|
||||||
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
url: jdbc:mysql://127.0.0.1:3306/epp?useUnicode=true&characterEncoding=utf8&useSSL=false
|
||||||
|
username: root
|
||||||
|
password: root
|
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.cxyxiaomo.epp.shop.dao.GoodsCategoryDao">
|
||||||
|
<select id="list" resultType="com.cxyxiaomo.epp.common.pojo.GoodCategory">
|
||||||
|
SELECT * FROM goods_category
|
||||||
|
WHERE 1 = 1
|
||||||
|
order by `order` asc
|
||||||
|
</select>
|
||||||
|
<select id="getById" parameterType="java.lang.Integer" resultType="com.cxyxiaomo.epp.common.pojo.GoodCategory">
|
||||||
|
SELECT * FROM goods_category
|
||||||
|
WHERE id = #{id}
|
||||||
|
order by `order` asc
|
||||||
|
</select>
|
||||||
|
</mapper>
|
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.cxyxiaomo.epp.shop.dao.GoodsDao">
|
||||||
|
<!--<insert id="insert" parameterType="com.cxyxiaomo.epp.common.pojo.Good">-->
|
||||||
|
<!-- INSERT INTO report (`user_id`, `name`, `address`, `time`, `temperature`)-->
|
||||||
|
<!-- VALUES (#{userId}, #{name}, #{address}, #{time}, #{temperature})-->
|
||||||
|
<!--</insert>-->
|
||||||
|
<select id="list" resultType="com.cxyxiaomo.epp.common.pojo.Good">
|
||||||
|
SELECT *
|
||||||
|
FROM goods
|
||||||
|
WHERE 1 = 1
|
||||||
|
<if test="cateId != null">
|
||||||
|
AND category_id = #{cateId}
|
||||||
|
</if>
|
||||||
|
<if test="searchText != null">
|
||||||
|
AND goods_name LIKE concat('%',#{searchText,jdbcType=VARCHAR},'%')
|
||||||
|
</if>
|
||||||
|
order by `sort_order` asc
|
||||||
|
</select>
|
||||||
|
<select id="getById" parameterType="java.lang.Long" resultType="com.cxyxiaomo.epp.common.pojo.Good">
|
||||||
|
SELECT *
|
||||||
|
FROM goods
|
||||||
|
WHERE id = #{id}
|
||||||
|
order by `sort_order` asc
|
||||||
|
</select>
|
||||||
|
</mapper>
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE configuration
|
||||||
|
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||||
|
<configuration>
|
||||||
|
<settings>
|
||||||
|
<!--开启二级缓存-->
|
||||||
|
<setting name="cacheEnabled" value="true"/>
|
||||||
|
|
||||||
|
<!--下划线转小驼峰-->
|
||||||
|
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||||
|
</settings>
|
||||||
|
</configuration>
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.cxyxiaomo;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit test for simple App.
|
||||||
|
*/
|
||||||
|
public class AppTest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Rigorous Test :-)
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void shouldAnswerWithTrue()
|
||||||
|
{
|
||||||
|
assertTrue( true );
|
||||||
|
}
|
||||||
|
}
|
@ -6,5 +6,8 @@
|
|||||||
<settings>
|
<settings>
|
||||||
<!--开启二级缓存-->
|
<!--开启二级缓存-->
|
||||||
<setting name="cacheEnabled" value="true"/>
|
<setting name="cacheEnabled" value="true"/>
|
||||||
|
|
||||||
|
<!--下划线转小驼峰-->
|
||||||
|
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||||
</settings>
|
</settings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
<module>microservice-common</module>
|
<module>microservice-common</module>
|
||||||
<module>microservice-provider-user-8001</module>
|
<module>microservice-provider-user-8001</module>
|
||||||
<module>microservice-provider-access-8002</module>
|
<module>microservice-provider-access-8002</module>
|
||||||
|
<module>microservice-provider-shop-8003</module>
|
||||||
<module>microservice-provider-test-8011</module>
|
<module>microservice-provider-test-8011</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Navicat Premium Data Transfer
|
Navicat Premium Data Transfer
|
||||||
|
|
||||||
Source Server : 192.168.2.29 测试库(装Nacos的Ubuntu)
|
Source Server : localhost MySQL 8.0 123456
|
||||||
Source Server Type : MySQL
|
Source Server Type : MySQL
|
||||||
Source Server Version : 80032
|
Source Server Version : 80012
|
||||||
Source Host : 192.168.2.29:3306
|
Source Host : localhost:3306
|
||||||
Source Schema : epp
|
Source Schema : epp
|
||||||
|
|
||||||
Target Server Type : MySQL
|
Target Server Type : MySQL
|
||||||
Target Server Version : 80032
|
Target Server Version : 80012
|
||||||
File Encoding : 65001
|
File Encoding : 65001
|
||||||
|
|
||||||
Date: 17/03/2023 02:12:17
|
Date: 18/03/2023 21:36:40
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
@ -93,45 +93,51 @@ INSERT INTO `feedback1` VALUES (5, '123', '123456', '2022-03-28 19:34:04', 2, NU
|
|||||||
DROP TABLE IF EXISTS `goods`;
|
DROP TABLE IF EXISTS `goods`;
|
||||||
CREATE TABLE `goods` (
|
CREATE TABLE `goods` (
|
||||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
|
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
`goods_name` varchar(127) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品名称',
|
`goods_name` varchar(127) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商品名称',
|
||||||
`category_id` int NULL DEFAULT 0 COMMENT '商品所属类目ID',
|
`category_id` int NULL DEFAULT 0 COMMENT '商品所属类目ID',
|
||||||
`brand` int NULL DEFAULT 0 COMMENT '商品品牌',
|
`brand` int NULL DEFAULT 0 COMMENT '商品品牌',
|
||||||
`gallery` varchar(1023) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品宣传图片列表,采用JSON数组格式',
|
`gallery` varchar(1023) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品宣传图片列表,采用JSON数组格式',
|
||||||
`brief` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品简介',
|
`brief` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品简介',
|
||||||
`is_on_sale` tinyint(1) NULL DEFAULT 1 COMMENT '是否上架',
|
`is_on_sale` tinyint(1) NULL DEFAULT 1 COMMENT '是否上架 0为下架 1为上架',
|
||||||
`sort_order` smallint NULL DEFAULT 100 COMMENT '排序',
|
`sort_order` smallint NULL DEFAULT 100 COMMENT '排序',
|
||||||
`pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品页面商品图片',
|
`pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品页面商品图片',
|
||||||
`type` tinyint(1) NULL DEFAULT 0 COMMENT '商品类型',
|
`type` tinyint(1) NULL DEFAULT 0 COMMENT '商品类型',
|
||||||
`unit` varchar(31) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '’件‘' COMMENT '商品单位,例如件、盒',
|
`unit` varchar(31) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '件' COMMENT '商品单位,例如件、盒',
|
||||||
`counter_price` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '专柜价格',
|
`counter_price` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '专柜价格(原价 / 划线价)',
|
||||||
`retail_price` decimal(10, 2) NULL DEFAULT 100000.00 COMMENT '零售价格',
|
`retail_price` decimal(10, 2) NULL DEFAULT 100000.00 COMMENT '零售价格(售价 / 未划线价)',
|
||||||
`detail` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '商品详细介绍,是富文本格式',
|
`detail` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '商品详细介绍,是富文本格式',
|
||||||
`deleted` tinyint(1) NULL DEFAULT 0 COMMENT '逻辑删除 0为正常 1为删除',
|
`deleted` tinyint(1) NULL DEFAULT 0 COMMENT '逻辑删除 0为正常 1为删除',
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
INDEX `category_id`(`category_id`) USING BTREE,
|
INDEX `category_id`(`category_id`) USING BTREE,
|
||||||
INDEX `brand_id`(`brand`) USING BTREE,
|
INDEX `brand_id`(`brand`) USING BTREE,
|
||||||
INDEX `sort_order`(`sort_order`) USING BTREE
|
INDEX `sort_order`(`sort_order`) USING BTREE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '商品基本信息表' ROW_FORMAT = DYNAMIC;
|
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '商品基本信息表' ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of goods
|
-- Records of goods
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `goods` VALUES (1, '口罩', 0, 0, NULL, NULL, 1, 100, NULL, 0, '’件‘', 0.00, 100000.00, NULL, 0);
|
INSERT INTO `goods` VALUES (1, '口罩', 3, 0, NULL, '', 1, 100, 'https://cdn-we-retail.ym.tencent.com/tsr/goods/gh-2b.png?imageMogr2/thumbnail/320x320/quality/70/strip/format/webp', 0, '件', 20.00, 48.00, NULL, 0);
|
||||||
|
INSERT INTO `goods` VALUES (2, '水银温度计', 3, 0, NULL, '医用玻璃水银体温计腋下温度计家用成人儿童婴儿口腔发烧探热针', 1, 200, 'https://cdn-we-retail.ym.tencent.com/tsr/goods/muy-3a.png?imageMogr2/thumbnail/320x320/quality/70/strip/format/webp', 0, '件', 59.90, 66.90, NULL, 0);
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for goods_category
|
-- Table structure for goods_category
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
DROP TABLE IF EXISTS `goods_category`;
|
DROP TABLE IF EXISTS `goods_category`;
|
||||||
CREATE TABLE `goods_category` (
|
CREATE TABLE `goods_category` (
|
||||||
`id` int NOT NULL,
|
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||||
`category_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品分类名',
|
`category_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品分类名',
|
||||||
`order` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '排序',
|
`order` int NULL DEFAULT NULL COMMENT '排序',
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of goods_category
|
-- Records of goods_category
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
INSERT INTO `goods_category` VALUES (1, '水果蔬菜', 1);
|
||||||
|
INSERT INTO `goods_category` VALUES (2, '日用品', 2);
|
||||||
|
INSERT INTO `goods_category` VALUES (3, '药品', 4);
|
||||||
|
INSERT INTO `goods_category` VALUES (4, '防疫物资', 3);
|
||||||
|
INSERT INTO `goods_category` VALUES (5, '零食', 5);
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for notice1
|
-- Table structure for notice1
|
||||||
@ -213,7 +219,7 @@ CREATE TABLE `user` (
|
|||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of user
|
-- Records of user
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `user` VALUES (1, 'root', '99adc231b045331e514a516b4b7680f588e3823213abe901738bc3ad67b2f6fcb3c64efb93d18002588d3ccc1a49efbae1ce20cb43df36b38651f11fa75678e8', '管理员 密码root', '420111111111111111', NULL, 1, NULL, NULL, 0, NULL);
|
INSERT INTO `user` VALUES (1, 'root', '99adc231b045331e514a516b4b7680f588e3823213abe901738bc3ad67b2f6fcb3c64efb93d18002588d3ccc1a49efbae1ce20cb43df36b38651f11fa75678e8', '管理员 密码root', '420111111111111111', NULL, 2, NULL, NULL, 0, NULL);
|
||||||
INSERT INTO `user` VALUES (2, 'lhz', 'lhz', '廖鸿志', NULL, NULL, 2, NULL, NULL, 0, NULL);
|
INSERT INTO `user` VALUES (2, 'lhz', 'lhz', '廖鸿志', NULL, NULL, 2, NULL, NULL, 0, NULL);
|
||||||
INSERT INTO `user` VALUES (3, '21180000', '21180000', '李', NULL, NULL, 2, NULL, NULL, 0, NULL);
|
INSERT INTO `user` VALUES (3, '21180000', '21180000', '李', NULL, NULL, 2, NULL, NULL, 0, NULL);
|
||||||
INSERT INTO `user` VALUES (4, '211', '211', '11', NULL, NULL, 2, NULL, NULL, 0, NULL);
|
INSERT INTO `user` VALUES (4, '211', '211', '11', NULL, NULL, 2, NULL, NULL, 0, NULL);
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"info": {
|
"info": {
|
||||||
"_postman_id": "0d464ada-cc15-4b2f-a0b7-5ee5fc690c39",
|
"_postman_id": "2cec316d-df1e-4815-b5b7-b49cf2e9c197",
|
||||||
"name": "epp",
|
"name": "epp",
|
||||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
|
||||||
|
"_exporter_id": "24657033"
|
||||||
},
|
},
|
||||||
"item": [
|
"item": [
|
||||||
{
|
{
|
||||||
@ -218,6 +219,101 @@
|
|||||||
"response": []
|
"response": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ShopProvider",
|
||||||
|
"item": [
|
||||||
|
{
|
||||||
|
"name": "[线上] 获取商品列表",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "https://epp.only4.work/shop/good/miniprogram/list?cateId=4&searchText=罩",
|
||||||
|
"protocol": "https",
|
||||||
|
"host": [
|
||||||
|
"epp",
|
||||||
|
"only4",
|
||||||
|
"work"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"shop",
|
||||||
|
"good",
|
||||||
|
"miniprogram",
|
||||||
|
"list"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "cateId",
|
||||||
|
"value": "4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "searchText",
|
||||||
|
"value": "%25%25",
|
||||||
|
"disabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "searchText",
|
||||||
|
"value": "罩"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "[线上] 获取商品详情",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "https://epp.only4.work/shop/good/miniprogram/detail?id=1",
|
||||||
|
"protocol": "https",
|
||||||
|
"host": [
|
||||||
|
"epp",
|
||||||
|
"only4",
|
||||||
|
"work"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"shop",
|
||||||
|
"good",
|
||||||
|
"miniprogram",
|
||||||
|
"detail"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "id",
|
||||||
|
"value": "1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "[线上] 获取商品分类列表",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "https://epp.only4.work/shop/good/miniprogram/cateList",
|
||||||
|
"protocol": "https",
|
||||||
|
"host": [
|
||||||
|
"epp",
|
||||||
|
"only4",
|
||||||
|
"work"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"shop",
|
||||||
|
"good",
|
||||||
|
"miniprogram",
|
||||||
|
"cateList"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -6,6 +6,7 @@
|
|||||||
"pages/residents/report",
|
"pages/residents/report",
|
||||||
"pages/residents/reportHistory",
|
"pages/residents/reportHistory",
|
||||||
"pages/shop/shop",
|
"pages/shop/shop",
|
||||||
|
"pages/shop/goodDetail",
|
||||||
"pages/scan/entrance",
|
"pages/scan/entrance",
|
||||||
"pages/person/person"
|
"pages/person/person"
|
||||||
],
|
],
|
||||||
@ -64,4 +65,4 @@
|
|||||||
"lazyCodeLoading": "requiredComponents",
|
"lazyCodeLoading": "requiredComponents",
|
||||||
"style": "v2",
|
"style": "v2",
|
||||||
"sitemapLocation": "sitemap.json"
|
"sitemapLocation": "sitemap.json"
|
||||||
}
|
}
|
||||||
|
@ -15,23 +15,29 @@ Component({
|
|||||||
* 组件的初始数据
|
* 组件的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
displayGoodsInfo: "",
|
// displayGoodsInfo: "",
|
||||||
displayInfo: "",
|
|
||||||
},
|
},
|
||||||
|
|
||||||
observers: {
|
// observers: {
|
||||||
'goodinfo': function (goodinfo) {
|
// 'goodinfo': function (goodinfo) {
|
||||||
console.log("observers -> goodinfo", goodinfo)
|
// console.log("observers -> goodinfo", goodinfo)
|
||||||
this.setData({
|
// this.setData({
|
||||||
displayGoodsInfo: JSON.stringify(this.properties.goodinfo)
|
// displayGoodsInfo: JSON.stringify(this.properties.goodinfo)
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件的方法列表
|
* 组件的方法列表
|
||||||
*/
|
*/
|
||||||
methods: {
|
methods: {
|
||||||
|
cardOntap(event) {
|
||||||
|
let dataset = event.currentTarget.dataset
|
||||||
|
console.log("cardOntap dataset", dataset)
|
||||||
|
let goodInfo = dataset.goodinfo
|
||||||
|
wx.navigateTo({
|
||||||
|
url: '/pages/shop/goodDetail?id=' + goodInfo.id,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--pages/shop/components/good-list-card.wxml-->
|
<!--pages/shop/components/good-list-card.wxml-->
|
||||||
<view class="good-card-container">
|
<view class="good-card-container" bindtap="cardOntap" data-goodinfo="{{goodinfo}}">
|
||||||
<!-- <view class="good-card-image" style="background-image: url('../../../image/home.jpg');">
|
<!-- <view class="good-card-image" style="background-image: url('../../../image/home.jpg');">
|
||||||
</view> -->
|
</view> -->
|
||||||
<view class="good-card-image" style="background-image: {{ 'url(' + goodinfo.picUrl + ');'}};">
|
<view class="good-card-image" style="background-image: {{ 'url(' + goodinfo.picUrl + ');'}};">
|
||||||
|
85
weixin-miniprogram/pages/shop/goodDetail.js
Normal file
85
weixin-miniprogram/pages/shop/goodDetail.js
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// pages/shop/goodDetail.js
|
||||||
|
|
||||||
|
const goodService = require("../../services/good")
|
||||||
|
|
||||||
|
Page({
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面的初始数据
|
||||||
|
*/
|
||||||
|
data: {
|
||||||
|
goodId: -1,
|
||||||
|
goodinfo: {}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面加载
|
||||||
|
*/
|
||||||
|
onLoad(options) {
|
||||||
|
console.log("goodDetail ->options", options)
|
||||||
|
let goodId = options.id
|
||||||
|
this.setData({
|
||||||
|
goodId: goodId
|
||||||
|
})
|
||||||
|
this.loadPageData()
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面初次渲染完成
|
||||||
|
*/
|
||||||
|
onReady() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面显示
|
||||||
|
*/
|
||||||
|
onShow() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面隐藏
|
||||||
|
*/
|
||||||
|
onHide() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面卸载
|
||||||
|
*/
|
||||||
|
onUnload() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||||||
|
*/
|
||||||
|
onPullDownRefresh() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面上拉触底事件的处理函数
|
||||||
|
*/
|
||||||
|
onReachBottom() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户点击右上角分享
|
||||||
|
*/
|
||||||
|
onShareAppMessage() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
loadPageData() {
|
||||||
|
(async () => {
|
||||||
|
let goodDetail = await goodService.getGoodDetail(this.data.goodId)
|
||||||
|
console.log("goodDetail", goodDetail)
|
||||||
|
this.setData({
|
||||||
|
goodinfo: goodDetail
|
||||||
|
})
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
})
|
4
weixin-miniprogram/pages/shop/goodDetail.json
Normal file
4
weixin-miniprogram/pages/shop/goodDetail.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {},
|
||||||
|
"navigationBarTitleText": "商品详情"
|
||||||
|
}
|
20
weixin-miniprogram/pages/shop/goodDetail.wxml
Normal file
20
weixin-miniprogram/pages/shop/goodDetail.wxml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<!--pages/shop/goodDetail.wxml-->
|
||||||
|
<view>
|
||||||
|
<image class="good-image" src="{{goodinfo.picUrl}}" />
|
||||||
|
<view class="good-detail">
|
||||||
|
<view class="good-price good-price-counter">
|
||||||
|
<!-- 原价 -->
|
||||||
|
<view class="good-price-symbol">¥</view>
|
||||||
|
<view class="good-price-number">{{ goodinfo.counterPrice }}</view>
|
||||||
|
</view>
|
||||||
|
<view class="good-price good-price-retail">
|
||||||
|
<!-- 售价 -->
|
||||||
|
<view style="height:0.12em;" class="good-price-line"></view>
|
||||||
|
<view class="good-price-symbol">¥</view>
|
||||||
|
<view class="good-price-number">{{ goodinfo.retailPrice }}</view>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<text class="good-title line-wrap">{{ goodinfo.goodsName }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
68
weixin-miniprogram/pages/shop/goodDetail.wxss
Normal file
68
weixin-miniprogram/pages/shop/goodDetail.wxss
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/* pages/shop/goodDetail.wxss */
|
||||||
|
.good-image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.good-detail {
|
||||||
|
padding: 5px 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 商品价格 */
|
||||||
|
.good-price {
|
||||||
|
white-space: nowrap;
|
||||||
|
font-weight: 700;
|
||||||
|
margin: 0;
|
||||||
|
display: inline;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.good-price-counter {
|
||||||
|
color: #fa4126;
|
||||||
|
font-size: 72rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.good-price-retail {
|
||||||
|
color: #bbbbbb;
|
||||||
|
font-size: 32rpx;
|
||||||
|
margin: 0 0 0 18rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.good-price-counter .good-price-symbol {
|
||||||
|
font-size: 36rpx;
|
||||||
|
display: inline;
|
||||||
|
margin-right: 6rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.good-price-retail .good-price-symbol {
|
||||||
|
font-size: 24rpx;
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.good-price .good-price-number {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.good-price .good-price-line {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
margin: 0;
|
||||||
|
background-color: currentColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 商品标题 */
|
||||||
|
.good-title {
|
||||||
|
width: 600rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
overflow: hidden;
|
||||||
|
font-size: 32rpx;
|
||||||
|
word-break: break-all;
|
||||||
|
color: #333333;
|
||||||
|
}
|
@ -1,4 +1,7 @@
|
|||||||
// pages/shop/shop.js
|
// pages/shop/shop.js
|
||||||
|
|
||||||
|
const goodService = require("../../services/good")
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -6,48 +9,49 @@ Page({
|
|||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
sidebarActiveId: -1,
|
sidebarActiveId: -1,
|
||||||
|
searchText: '',
|
||||||
sidebarList: [
|
sidebarList: [
|
||||||
{
|
{
|
||||||
id: -1,
|
id: -1,
|
||||||
title: "全部分类",
|
categoryName: "全部分类",
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
title: "1",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
title: "防疫物资",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
title: "111",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 4,
|
|
||||||
title: "111",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 5,
|
|
||||||
title: "111",
|
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// id: 1,
|
||||||
|
// title: "1",
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id: 2,
|
||||||
|
// title: "防疫物资",
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id: 3,
|
||||||
|
// title: "111",
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id: 4,
|
||||||
|
// title: "111",
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// id: 5,
|
||||||
|
// title: "111",
|
||||||
|
// },
|
||||||
],
|
],
|
||||||
|
|
||||||
tabbarList: [
|
tabbarList: [
|
||||||
{
|
// {
|
||||||
id: 1,
|
// id: 1,
|
||||||
goodsName: "温度计",
|
// goodsName: "温度计",
|
||||||
counterPrice: "10.00",
|
// counterPrice: "10.00",
|
||||||
retailPrice: "12.00",
|
// retailPrice: "12.00",
|
||||||
picUrl: "https://cdn-we-retail.ym.tencent.com/tsr/goods/gh-2b.png?imageMogr2/thumbnail/320x320/quality/70/strip/format/webp",
|
// picUrl: "https://cdn-we-retail.ym.tencent.com/tsr/goods/gh-2b.png?imageMogr2/thumbnail/320x320/quality/70/strip/format/webp",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
id: 2,
|
// id: 2,
|
||||||
goodsName: "医用口罩",
|
// goodsName: "医用口罩",
|
||||||
counterPrice: "100.00",
|
// counterPrice: "100.00",
|
||||||
retailPrice: "12.50",
|
// retailPrice: "12.50",
|
||||||
picUrl: "https://cdn-we-retail.ym.tencent.com/tsr/goods/muy-3a.png?imageMogr2/thumbnail/320x320/quality/70/strip/format/webp",
|
// picUrl: "https://cdn-we-retail.ym.tencent.com/tsr/goods/muy-3a.png?imageMogr2/thumbnail/320x320/quality/70/strip/format/webp",
|
||||||
}
|
// }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -55,7 +59,7 @@ Page({
|
|||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
this.loadPageData();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,7 +94,8 @@ Page({
|
|||||||
* 页面相关事件处理函数--监听用户下拉动作
|
* 页面相关事件处理函数--监听用户下拉动作
|
||||||
*/
|
*/
|
||||||
onPullDownRefresh() {
|
onPullDownRefresh() {
|
||||||
|
console.log('sidebarActiveId', this.data.sidebarActiveId)
|
||||||
|
this.updatePageData()
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,6 +113,20 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
bindSearchInput(e) {
|
||||||
|
this.setData({
|
||||||
|
searchText: e.detail.value,
|
||||||
|
})
|
||||||
|
this.updatePageData()
|
||||||
|
},
|
||||||
|
clearSearchInput() {
|
||||||
|
this.setData({
|
||||||
|
searchText: '',
|
||||||
|
sidebarActiveId: -1,
|
||||||
|
})
|
||||||
|
this.updatePageData()
|
||||||
|
},
|
||||||
|
|
||||||
sidebarItemTap(event) {
|
sidebarItemTap(event) {
|
||||||
// 清除原来的选中项,并设置新的选中项
|
// 清除原来的选中项,并设置新的选中项
|
||||||
// console.log("event.target", event.target)
|
// console.log("event.target", event.target)
|
||||||
@ -117,6 +136,51 @@ Page({
|
|||||||
this.setData({
|
this.setData({
|
||||||
sidebarActiveId: dataset.item.id,
|
sidebarActiveId: dataset.item.id,
|
||||||
})
|
})
|
||||||
|
this.loadPageData()
|
||||||
return
|
return
|
||||||
|
},
|
||||||
|
|
||||||
|
loadPageData() {
|
||||||
|
(async () => {
|
||||||
|
let goodCategoryListPromise = goodService.getGoodCategoryList()
|
||||||
|
let goodListPromise = goodService.getGoodList(this.data.sidebarActiveId, this.data.searchText)
|
||||||
|
Promise.all([
|
||||||
|
goodCategoryListPromise,
|
||||||
|
goodListPromise,
|
||||||
|
]).then(data => {
|
||||||
|
let goodCategoryList = data[0]
|
||||||
|
let goodList = data[1]
|
||||||
|
console.log("goodCategoryList", goodCategoryList)
|
||||||
|
console.log("goodList", goodList)
|
||||||
|
goodCategoryList.unshift({
|
||||||
|
id: -1,
|
||||||
|
categoryName: "全部分类",
|
||||||
|
order: 0
|
||||||
|
})
|
||||||
|
console.log("goodCategoryList", goodCategoryList)
|
||||||
|
this.setData({
|
||||||
|
sidebarList: goodCategoryList,
|
||||||
|
tabbarList: goodList,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})();
|
||||||
|
},
|
||||||
|
|
||||||
|
updatePageData() {
|
||||||
|
(async () => {
|
||||||
|
this.setData({
|
||||||
|
tabbarList: [],
|
||||||
|
})
|
||||||
|
let goodListPromise = goodService.getGoodList(this.data.sidebarActiveId, this.data.searchText)
|
||||||
|
Promise.all([
|
||||||
|
goodListPromise,
|
||||||
|
]).then(data => {
|
||||||
|
let goodList = data[0]
|
||||||
|
console.log("goodList", goodList)
|
||||||
|
this.setData({
|
||||||
|
tabbarList: goodList,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})();
|
||||||
}
|
}
|
||||||
})
|
})
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"listcard":"./components/good-list-card"
|
"listcard": "./components/good-list-card"
|
||||||
},
|
},
|
||||||
"navigationBarTitleText": "生活物资"
|
"navigationBarTitleText": "生活物资",
|
||||||
|
"enablePullDownRefresh": true
|
||||||
}
|
}
|
@ -1,14 +1,20 @@
|
|||||||
<!--pages/shop/shop.wxml-->
|
<!--pages/shop/shop.wxml-->
|
||||||
|
<view class="search">
|
||||||
|
<input id="search-input" class="search-input" maxlength="15" confirm-type="搜索" placeholder="搜索商品" value="{{searchText}}" bindblur="bindSearchInput" bindconfirm="bindSearchInput" />
|
||||||
|
</view>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<!-- sidebar -->
|
<!-- sidebar -->
|
||||||
<view class="sidebar">
|
<view class="sidebar">
|
||||||
<view class="sidebar-item {{ cate.id == sidebarActiveId ? 'active' : 'deactive' }}" wx:for="{{sidebarList}}" wx:for-item="cate" wx:key="id" bindtap="sidebarItemTap" data-item="{{cate}}" data-item2="aaa">
|
<view class="sidebar-item {{ cate.id == sidebarActiveId ? 'active' : 'deactive' }}" wx:for="{{sidebarList}}" wx:for-item="cate" wx:key="id" bindtap="sidebarItemTap" data-item="{{cate}}">
|
||||||
<text class="sidebar-item-text">{{ cate.title }}</text>
|
<text class="sidebar-item-text">{{ cate.categoryName }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- tabbar -->
|
<!-- tabbar -->
|
||||||
<view class="tabbar">
|
<view class="tabbar">
|
||||||
|
<view wx:if="{{ searchText || sidebarActiveId > 0 }}" style="text-align: center;">
|
||||||
|
<button type="default" size="mini" bindtap="clearSearchInput">清空筛选条件</button>
|
||||||
|
</view>
|
||||||
<view class="tabbar-group">
|
<view class="tabbar-group">
|
||||||
<listcard class="tabbar-item" wx:for="{{tabbarList}}" wx:for-item="item" wx:key="id" goodinfo="{{item}}" />
|
<listcard class="tabbar-item" wx:for="{{tabbarList}}" wx:for-item="item" wx:key="id" goodinfo="{{item}}" />
|
||||||
</view>
|
</view>
|
||||||
|
@ -1,7 +1,23 @@
|
|||||||
/* pages/shop/shop.wxss */
|
/* pages/shop/shop.wxss */
|
||||||
|
.search {
|
||||||
|
height: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input {
|
||||||
|
margin: 4px 10px;
|
||||||
|
padding: 2px 18px;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 28px;
|
||||||
|
background-color: rgb(226, 226, 226);
|
||||||
|
border-radius: 50px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
/* background-color: aqua; */
|
/* background-color: aqua; */
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
|
height: calc(100vh - 50px);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
||||||
@ -66,6 +82,6 @@
|
|||||||
|
|
||||||
.no-more {
|
.no-more {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color:grey;
|
color: grey;
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
"projectname": "weixin-miniprogram",
|
"projectname": "weixin-miniprogram",
|
||||||
"setting": {
|
"setting": {
|
||||||
"compileHotReLoad": true,
|
"compileHotReLoad": true,
|
||||||
"urlCheck": false
|
"urlCheck": false,
|
||||||
|
"bigPackageSizeSupport": true
|
||||||
},
|
},
|
||||||
"libVersion": "2.21.4"
|
"libVersion": "2.21.4"
|
||||||
}
|
}
|
34
weixin-miniprogram/services/good.js
Normal file
34
weixin-miniprogram/services/good.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* eslint-disable no-param-reassign */
|
||||||
|
|
||||||
|
const send_request = require('../utils/sendRequest')
|
||||||
|
|
||||||
|
/** 获取商品分类列表 */
|
||||||
|
export function getGoodCategoryList() {
|
||||||
|
return send_request({
|
||||||
|
url: '/shop/good/miniprogram/cateList',
|
||||||
|
method: "GET"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取商品列表 */
|
||||||
|
export function getGoodList(goodCategoryId, searchText) {
|
||||||
|
return send_request({
|
||||||
|
url: '/shop/good/miniprogram/list',
|
||||||
|
method: "GET",
|
||||||
|
data: {
|
||||||
|
cateId: goodCategoryId,
|
||||||
|
searchText: searchText.trim(),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取商品详情 */
|
||||||
|
export function getGoodDetail(id) {
|
||||||
|
return send_request({
|
||||||
|
url: '/shop/good/miniprogram/detail',
|
||||||
|
method: "GET",
|
||||||
|
data: {
|
||||||
|
id: id,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
54
weixin-miniprogram/utils/sendRequest.js
Normal file
54
weixin-miniprogram/utils/sendRequest.js
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
const app = getApp()
|
||||||
|
|
||||||
|
module.exports = function send_request({ url, method, data }) {
|
||||||
|
wx.showLoading({
|
||||||
|
title: '加载中'
|
||||||
|
});
|
||||||
|
wx.showNavigationBarLoading()
|
||||||
|
// wx.startPullDownRefresh() // 会触发页面的刷新事件 造成死循环
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let requestOption = {
|
||||||
|
url: `${app.globalData.baseUrl}${url}`,
|
||||||
|
method: method,
|
||||||
|
data: data,
|
||||||
|
success: function (d) {
|
||||||
|
wx.hideLoading()
|
||||||
|
let result = d.data;
|
||||||
|
if (result.success) {
|
||||||
|
// console.log('result', result)
|
||||||
|
resolve(result.data)
|
||||||
|
} else {
|
||||||
|
wx.showToast({
|
||||||
|
title: result.msg,
|
||||||
|
icon: 'error',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
resolve(null)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: function (err) {
|
||||||
|
wx.hideLoading()
|
||||||
|
wx.showToast({
|
||||||
|
title: "请求失败",
|
||||||
|
icon: 'error',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
reject(err)
|
||||||
|
},
|
||||||
|
complete: function () {
|
||||||
|
wx.hideNavigationBarLoading()
|
||||||
|
wx.stopPullDownRefresh()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (method.toUpperCase) {
|
||||||
|
case "GET":
|
||||||
|
break;
|
||||||
|
case "POST":
|
||||||
|
requestOption.header = {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded" //用于post
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
wx.request(requestOption)
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user