diff --git a/api-interface/itmk-base-parent/itmk-base-web/src/main/java/com/itmk/web/wxapi/controller/HomeController.java b/api-interface/itmk-base-parent/itmk-base-web/src/main/java/com/itmk/web/wxapi/controller/HomeController.java new file mode 100644 index 0000000..855b1e9 --- /dev/null +++ b/api-interface/itmk-base-parent/itmk-base-web/src/main/java/com/itmk/web/wxapi/controller/HomeController.java @@ -0,0 +1,57 @@ +package com.itmk.web.wxapi.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.itmk.utils.ResultUtils; +import com.itmk.utils.ResultVo; +import com.itmk.web.goods.entity.SysGoods; +import com.itmk.web.goods.service.SysGoodsService; +import com.itmk.web.goods_specs.entity.SysGoodsSpecs; +import com.itmk.web.goods_specs.service.SysGoodsSpecsService; +import com.itmk.web.banner.entity.SysBanner; +import com.itmk.web.banner.service.SysBannerService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequestMapping("/api/home") +public class HomeController { + @Autowired + private SysBannerService sysBannerService; + @Autowired + private SysGoodsService sysGoodsService; + @Autowired + private SysGoodsSpecsService sysGoodsSpecsService; + + //首页轮播图 + @GetMapping("/getSwipperList") + public ResultVo getSwipperList(){ + QueryWrapper query = new QueryWrapper<>(); + query.lambda().eq(SysBanner::getStatus,"1"); + List list = sysBannerService.list(query); + return ResultUtils.success("查询成功",list); + } + + //首页热推 + @GetMapping("/getHotList") + public ResultVo getHotList(){ + QueryWrapper query = new QueryWrapper<>(); + query.lambda().eq(SysGoods::getStatus,"1") + .orderByAsc(SysGoods::getOrderNum); + List list = sysGoodsService.list(query); + if(list.size() > 0){ + for (int i = 0; i < list.size(); i++) { + //查询价格 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(SysGoodsSpecs::getGoodsId,list.get(i).getGoodsId()) + .orderByAsc(SysGoodsSpecs::getOrderNum); + List specs = sysGoodsSpecsService.list(queryWrapper); + list.get(i).setSpecs(specs); + } + } + return ResultUtils.success("查询成功",list); + } +} \ No newline at end of file diff --git a/order-app/project.config.json b/order-app/project.config.json new file mode 100644 index 0000000..7beff81 --- /dev/null +++ b/order-app/project.config.json @@ -0,0 +1,25 @@ +{ + "setting": { + "es6": true, + "postcss": true, + "minified": true, + "uglifyFileName": false, + "enhance": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "useCompilerPlugins": false, + "minifyWXML": true + }, + "compileType": "miniprogram", + "simulatorPluginLibVersion": {}, + "packOptions": { + "ignore": [], + "include": [] + }, + "appid": "wx6a41b250d82adc97", + "editorSetting": {} +} \ No newline at end of file diff --git a/order-app/project.private.config.json b/order-app/project.private.config.json new file mode 100644 index 0000000..69bf04d --- /dev/null +++ b/order-app/project.private.config.json @@ -0,0 +1,14 @@ +{ + "libVersion": "3.9.1", + "projectname": "order-app", + "setting": { + "urlCheck": true, + "coverView": true, + "lazyloadPlaceholderEnable": false, + "skylineRenderEnable": false, + "preloadBackgroundData": false, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/order-app/src/api/home.js b/order-app/src/api/home.js new file mode 100644 index 0000000..023639c --- /dev/null +++ b/order-app/src/api/home.js @@ -0,0 +1,5 @@ +import http from '../common/http.js' +//轮播图 +export const getSwipperListApi = ()=>{ + return http.get("/api/home/getSwipperList") +} \ No newline at end of file diff --git a/order-app/src/common/http.js b/order-app/src/common/http.js new file mode 100644 index 0000000..52788f2 --- /dev/null +++ b/order-app/src/common/http.js @@ -0,0 +1,39 @@ +const baseUrl = 'http://localhost:8089' +const http = (options = {}) => { + return new Promise((resolve, reject) => { + uni.request({ + url: baseUrl + options.url || '', + method:options.type || 'GET' , + data: options.data || {}, + header: options.header || {}, + }).then((response) => { + console.log(response) + resolve(response.data); + }).catch(error => { + reject(error) + }) + }); +} +const get=(url,data,options={})=>{ + options.type='get'; + options.data = data; + options.url = url; + return http(options) +} +const post = (url, data, options = {}) => { + options.type = 'post'; + options.data = data; + options.url = url; + return http(options) +} +const put = (url, data, options = {}) => { + options.type = 'put'; + options.data = data; + options.url = url; + return http(options) +} +export default { + get, + post, + put +} \ No newline at end of file diff --git a/order-app/src/pages.json b/order-app/src/pages.json index 6209e48..6cf9333 100644 --- a/order-app/src/pages.json +++ b/order-app/src/pages.json @@ -1,11 +1,6 @@ { "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages { - "path": "pages/address/address", - "style": { - "navigationBarTitleText": "" - } - }, { "path": "pages/index/index", "style": { "navigationBarTitleText": "首页" @@ -37,6 +32,11 @@ "style": { "navigationBarTitleText": "" } + },{ + "path": "pages/address/address", + "style": { + "navigationBarTitleText": "" + } } ], "globalStyle": { diff --git a/order-app/src/pages/index/index.vue b/order-app/src/pages/index/index.vue index 8b0c715..8cf039b 100644 --- a/order-app/src/pages/index/index.vue +++ b/order-app/src/pages/index/index.vue @@ -1,5 +1,5 @@