Merge pull request '完成小程序端首页轮播图对接' (#40) from Brunch_LPQ into main

pull/45/head
ppnwsfegt 2 months ago
commit 830c9dbe90

@ -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<SysBanner> query = new QueryWrapper<>();
query.lambda().eq(SysBanner::getStatus,"1");
List<SysBanner> list = sysBannerService.list(query);
return ResultUtils.success("查询成功",list);
}
//首页热推
@GetMapping("/getHotList")
public ResultVo getHotList(){
QueryWrapper<SysGoods> query = new QueryWrapper<>();
query.lambda().eq(SysGoods::getStatus,"1")
.orderByAsc(SysGoods::getOrderNum);
List<SysGoods> list = sysGoodsService.list(query);
if(list.size() > 0){
for (int i = 0; i < list.size(); i++) {
//查询价格
QueryWrapper<SysGoodsSpecs> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysGoodsSpecs::getGoodsId,list.get(i).getGoodsId())
.orderByAsc(SysGoodsSpecs::getOrderNum);
List<SysGoodsSpecs> specs = sysGoodsSpecsService.list(queryWrapper);
list.get(i).setSpecs(specs);
}
}
return ResultUtils.success("查询成功",list);
}
}

@ -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": {}
}

@ -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
}
}

@ -0,0 +1,5 @@
import http from '../common/http.js'
//轮播图
export const getSwipperListApi = ()=>{
return http.get("/api/home/getSwipperList")
}

@ -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
}

@ -1,11 +1,6 @@
{
"pages": [ //pageshttps://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": {

@ -1,5 +1,5 @@
<template>
<u-swiper border-radius='1' :duration='duration' :interval='interval' :height="height" :list="swiperList">
<u-swiper name='images' border-radius='1' :duration='duration' :interval='interval' :height="height" :list="swiperList">
</u-swiper>
<u-divider margin-top='20' margin-bottom='20' color="#F3AF28">店长推荐</u-divider>
<view class="wrap">
@ -47,6 +47,8 @@
import {
ref
} from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import {getSwipperListApi} from '../../api/home.js'
const carimg = ref('/static/goodscar.png')
//
const height = ref('400')
@ -58,14 +60,8 @@
const interval = ref(2000)
//
const duration = ref(500)
//
const swiperList = ref([{
image: '/static/swipper1.png'
}, {
image: '/static/swipper2.png'
}, {
image: '/static/swipper3.png'
}])
//,
const swiperList = ref([])
//
const flowList = ref([{
price: 20,
@ -115,6 +111,17 @@
url: '../detail/detail?goods=' + JSON.stringify(item)
});
}
//
const getSwipperList = async () => {
let res = await getSwipperListApi()
if (res && res.code == 200) {
console.log(res.data)
swiperList.value = res.data;
}
}
onLoad(() => {
getSwipperList()
})
</script>
<style lang="scss">

@ -1,6 +1,6 @@
<template>
<el-upload ref="uploadRef" action="#" :on-change="uploadFile" list-type="picture-card" :auto-upload="false"
:file-list="fileList" :show-file-list="true" :limit="3" :on-remove="handleRemove" :on-exceed="moreLimit">
:file-list="fileList" :show-file-list="true" :limit="1" :on-remove="handleRemove" :on-exceed="moreLimit">
<el-icon>
<Plus />
</el-icon>

Loading…
Cancel
Save