代理处理 首页处理

This commit is contained in:
wwz 2025-02-10 15:52:10 +08:00
parent ede860cec3
commit 6cea5aeb42
12 changed files with 519 additions and 138 deletions

View File

@ -13,7 +13,6 @@ const proxyApi = "/api"
const proxyApi = 'https://cashier.sxczgkj.cn/cashierService' // 线上
const proxyApiwws = 'wss://cashier.sxczgkj.cn/netty' // 线上
// #endif
// #ifdef H5
const baseUrl = debug ? proxyApi + '/cashierService' : "https://cashier.sxczgkj.cn/cashierService"
const baseUrlwws = 'ws://cashier.sxczgkj.cn/cashierService'

View File

@ -46,7 +46,7 @@ async function request(options) {
environment: 'app',
// #endif
// #ifdef H5
environment: 'h5',
environment: 'H5',
// #endif
// #ifdef MP-WEIXIN
environment: 'wx',
@ -57,8 +57,6 @@ async function request(options) {
token: uni.cache.get('token'),
openId: uni.cache.get('miniAppOpenId'),
id: uni.cache.get('userInfo').id,
loginName: "",
clientType: ''
}
} else {
@ -67,15 +65,6 @@ async function request(options) {
let res = await requestrequest(options);
if (res.code != 0) {
if (res.code == -4) {
// uni.showToast({
// title: res.message || res.msg,
// icon: "none",
// success: () => {
// // setTimeout(res => {
// // store.dispatch("loginEvent"); //获取shapid
// // }, 1000)
// }
// })
} else if (res.code == 482) {

66
framework/apis.js Normal file
View File

@ -0,0 +1,66 @@
export function request(options) {
return new Promise((resolve, reject) => {
uni.request({
url: uni.conf.baseUrl + options.url,
data: options.data || {},
method: options.method,
// 设置请求头,添加版本号
header: {
'Content-Type': 'application/json;charset=UTF-8',
version: uni.conf.version,
type: uni.getSystemInfoSync().platform,
// #ifdef APP-PLUS
environment: 'app',
// #endif
// #ifdef H5
environment: 'h5',
// #endif
// #ifdef MP-WEIXIN
environment: 'wx',
// #endif
// #ifdef MP-ALIPAY
environment: 'alipay',
// #endif
token: uni.cache.get('token'),
openId: uni.cache.get('miniAppOpenId'),
id: uni.cache.get('userInfo').id,
loginName: "",
},
success(res) {
const data = res.data || res;
// 根据项目返回的code判断
if (data.code != 0){
switch (data.code) {
case '200':
resolve(data.data);
break;
case '500':
uni.showToast({
title: data.message,
icon: "none"
});
reject(false);
break;
case '400':
uni.showToast({
title: data.message,
icon: "none"
});
// 跳转到登录页面等操作
reject(false);
break;
default:
reject(false);
break;
}
}else{
resolve(data.data);
}
},
fail(res) {
// 失败处理
reject(res);
}
});
});
}

View File

@ -67,28 +67,7 @@
"requiredPrivateInfos": ["getLocation", "onLocationChange", "chooseLocation", "chooseAddress"]
},
"h5": {
"devServer": {
"https": false,
"disableHostCheck": false,
"proxy": {
"/api": {
// "target": "https://wxcashiertest.sxczgkj.cn",
// "target" : "https://ky.sxczgkj.cn",
"target": "https://cashier.sxczgkj.cn",
"ws": false,
"changeOrigin": true, //
"secure": false, // https
"pathRewrite": {
"^/api": "" //rewrite,
}
}
}
},
"template": "template.h5.html",
"router": {
"mode": "history",
"base": "/h5/"
}
},
"mp-alipay": {
"usingComponents": true

View File

@ -1,13 +1,13 @@
<template>
<view class="onecontent flex-between">
<view class="onecontentleft">
<view class="onecontentleft" v-if="bannervo">
现有<text style="color: #FC851E;font-size: 24rpx;">
{{bannervo.coupons==null?116:bannervo.coupons}}
</text>
已免单
</view>
<view class="onecontentright flex-start">
<view class="onecontentrightimage">
<view class="onecontentrightimage" v-if="bannervo">
<view class="swiperPanel" @touchstart="startMove" @touchend="endMove">
<view class="swiperItem" v-for="(item, index) in bannervo.counponsInfo" :key="index"
:style="{transform: itemStyle[index].transform, zIndex: itemStyle[index].zIndex, opacity: itemStyle[index].opacity}">

View File

@ -1,5 +1,5 @@
<template>
<view class="fourcontent flex-between">
<view class="fourcontent flex-between" v-if="menu">
<view class="fourcontent_item flex-start" v-for="(item,index) in menu" :key="index"
@click="viewHistorycategoryss(item,index)"
:class="!item.isChild && viewHistoryindex == index ? 'fourcontent_itemactev':''">

View File

@ -1,5 +1,5 @@
<template>
<view class="towcontent flex-between">
<view class="towcontent flex-between" v-if="district">
<view class="towcontent_item flex-colum" v-for="(item,index) in district" :key="index"
@click="clickdistrict(item,index)">
<image :src="item.coverImg" mode="aspectFill"></image>

View File

@ -1,5 +1,5 @@
<template>
<view class="viewswiper">
<view class="viewswiper" v-if="carousel">
<up-swiper :list="carousel" keyName="coverImg" @change="e => current = e.current" indicatorStyle="right: 20px" height='242'>
<template #indicator>
<view class="indicator">

View File

@ -1,5 +1,5 @@
<template>
<view class="therecontent flex-between">
<view class="therecontent flex-between" v-if="salesList">
<view class="therecontent_box_item">
<view class="therecontent_box_imge flex-between" @click="jrtoday(0)">
<view class="therecontent_box_imge_text">
@ -83,9 +83,15 @@
} from 'vue';
const props = defineProps({
salesList: Object,
todayList: Object
todayList: {
type: Object,
default: () => ({
name:'',
date:'',
hotList:[]
}) //
},
});
const clickproduct = (item) => {
uni.pro.navigateTo('product/index', {
id: item.id

View File

@ -1,7 +1,7 @@
<template>
<view>
<Nav />
<view class="content">
<Nav v-if="showindex == 'index'" />
<view class="content" v-if="showindex == 'index'">
<!-- 轮播图 -->
<swipers :carousel='hometoplist.carousel'></swipers>
<!-- 广告 -->
@ -100,25 +100,39 @@
<view class="indexboxitemleftthere_countdown flex-between">
<text class="indexboxitemleftthere_countdowntext">共省{{item.save}}</text>
<view class="indexboxitemleftthere_countdowntexts">
<!-- <uni-countdown @timeup="updateCity" :show-day="false"
:day="item.end_times.d" :hour="item.end_times.h"
:minute="item.end_times.m" :second="item.end_times.s" :indexs='index'
color="#FFFFFF" border-color="#00B26A" splitorColor="#FFFFFF"
:font-size="10"></uni-countdown> -->
<up-count-down
:time="item.end_times.d * item.end_times.h * item.end_times.m *item.end_times.s"
format="HH:mm:ss" autoStart millisecond @change="onChange">
<view class="time">
<view class="time__custom">
<text
class="time__custom__item">{{ timeData.hours>10?timeData.hours:'0'+timeData.hours}}</text>
</view>
<text class="time__doc">:</text>
<view class="time__custom">
<text
class="time__custom__item">{{ timeData.minutes>10?timeData.minutes:'0'+timeData.minutes }}</text>
</view>
<text class="time__doc">:</text>
<view class="time__custom">
<text
class="time__custom__item">{{ timeData.seconds>10?timeData.seconds:'0'+timeData.seconds }}</text>
</view>
</view>
</up-count-down>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<up-loadmore height='40' :status="form.status" iconSize='16' fontSize='16' />
<up-loadmore height='40' :status="formhomelist.status" iconSize='16' fontSize='16' />
<!-- </scroll-view> -->
</view>
</view>
<!-- <indexs v-if="showindex == 'shopIndex'"></indexs> -->
</view>
</template>
@ -133,6 +147,7 @@
onLoad,
onReady,
onShow,
onReachBottom,
onPageScroll
} from '@dcloudio/uni-app'
import swipers from './components/swiper.vue' //
@ -159,71 +174,8 @@
isTransparent: false,
hasPlaceholder: false //
});
//
const hometoplist = reactive({})
//
const form = ref({
address: '', //
type: '', //
orderBy: '', //1. 2. 3.
other: '', //1KM 1 0
page: 1, //
size: 10, //
status: 'loadmore'
})
const homelist = ref([{
endRow: 1,
firstPage: 1,
hasNextPage: false,
hasPreviousPage: false,
isFirstPage: true,
isLastPage: true,
lastPage: 1,
list: [{
discount: 9,
distances: "1.1km",
districts: "未央区",
endTime: 1739059199999,
id: 661,
image: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240612/0c07e1f79a244ed498dfe4a70848c479.jpeg",
originPrice: 200,
proTag: [],
productName: "鸡尾酒套餐",
realSalesNumber: 0,
salePrice: 180,
save: 20,
shopImage: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240612/6f3618a31d2a4b489215647871ae732e.jpg",
shopName: "漫巷咖啡",
shopTag: [],
}],
discount: 9,
distances: "1.1km",
districts: "未央区",
endTime: 1739059199999,
id: 661,
image: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240612/0c07e1f79a244ed498dfe4a70848c479.jpeg",
originPrice: 200,
proTag: [],
productName: "鸡尾酒套餐",
realSalesNumber: 0,
salePrice: 180,
save: 20,
shopImage: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240612/6f3618a31d2a4b489215647871ae732e.jpg",
shopName: "漫巷咖啡",
shopTag: [],
navigateFirstPage: 1,
navigateLastPage: 1,
navigatePages: 8,
navigatepageNums: [1],
nextPage: 0,
pageNum: 1,
pageSize: 10,
pages: 1,
prePage: 0,
size: 1,
startRow: 1,
total: 1,
}])
//
const showindex = ref('index')
//广
const getStyle = (e) => {
if (e > hometoplist.bannerVO.counponsInfo.length / 2) {
@ -246,22 +198,102 @@
zIndex: 9999,
opacity: 1
}])
// 广
//
const hometoplist = reactive({})
//
const hometop = async () => {
// try {
try {
let res = await API.homehomePageUp()
console.log(res.data)
Object.assign(hometoplist, res.data)
// hometoplist = Object.assign(res.data)
if (hometoplist.bannerVO.counponsInfo) {
hometoplist.bannerVO.counponsInfo.forEach((item, index) => {
advertisementStyle.value.push(getStyle(index))
})
}
// swiper
// } catch (e) {}
} catch (e) {}
}
//
const formhomelist = reactive({ //
address: '', //
type: '', //
orderBy: '', //1. 2. 3.
other: '', //1KM 1 0
page: 1, //
size: 10, //
status: 'loadmore'
})
// 使 reactive
const timeData = ref({});
// onChange
const onChange = (e) => {
timeData.value = e;
};
const homelist = ref([]) //
const onLoadhome = async () => {
try {
let res = await API.home(formhomelist)
var dates = new Date().getTime();
res.data.list.forEach((item, index) => {
var leftTime = item.endTime - dates; //
if (leftTime >= 0) {
let d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
let h = Math.floor(leftTime / 1000 / 60 / 60 % 24);
let m = Math.floor(leftTime / 1000 / 60 % 60);
let s = Math.floor(leftTime / 1000 % 60);
item.end_times = {
d: d,
h: h,
m: m,
s: s
}
} else {
item.end_times = 0
}
})
if (res.data.pages < formhomelist.page) {
formhomelist.status = 'nomore'
if (form.page == 1 && res.data.list.length == 0) {
}
return false;
} else {
formhomelist.status = 'loading';
formhomelist.page = ++formhomelist.page;
setTimeout(() => {
homelist.value = [...homelist.value, ...res.data.list];
formhomelist.status = 'loading';
if (res.data.pageNum == res.data.pages) {
formhomelist.status = 'nomore';
} else {
formhomelist.status = 'loading';
}
}, 500)
}
} catch (e) {}
}
// /
const init_fn = async () => {
homelist.value = []
Object.assign(formhomelist, {
address: uni.cache.get('getLocationstorage').address, //
lng: uni.cache.get('getLocationstorage').lng,
lat: uni.cache.get('getLocationstorage').lat,
type: '', //
orderBy: 0, //1. 2. 3.
other: '', //1KM 1 0
page: 1, //
size: 10, //
status: 'loadmore'
})
onLoadhome()
}
const updateCity = async (data) => {
console.log(data)
// this.list[data].end_times = 0;
}
//
const elementTop = ref(0);
//
@ -282,14 +314,70 @@
uni.$u.debounce(store.scrollTop = res.scrollTop, 500)
});
onShow(() => {})
onMounted(() => {
hometop()
//
onMounted(async () => {
//
setTimeout(() => {
const query = uni.createSelectorQuery().select('#fourcontent');
query.boundingClientRect((rect) => {
console.log(rect.top, 111)
elementTop.value = rect.top - store.height
}).exec();
}, 500)
//
if (uni.cache.get('shopId') && uni.cache.get('token')) {
showindex.value = 'shopIndex'
uni.cache.set('types', 'index');
let res = await API.shopUserInfo({
"shopId": uni.cache.get('shopId'),
"userId": uni.cache.get('userInfo').id,
})
if (res.code == 0) {
shopUserInfo = res.data
// uni.cache.set('shopUserInfo', this.shopUserInfo)
}
if (uni.cache.get('forceUpdate') == 1) {
// this.forceUpdate = !this.forceUpdate;
}
// this.getShopExtend()
} else {
uni.getLocation({
type: 'wgs84',
success: async (res) => {
// console.log(res)
let successres = await API.geocodelocation({
lng: res.longitude,
lat: res.latitude,
})
if (successres.code == 0) {
let datastorage = {
country: successres.data.addressComponent.country, // ""
province: successres.data.addressComponent
.province, //province: "西"
address: successres.data.addressComponent.city, //district: "西"
district: successres.data.addressComponent
.district, //district: ""
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
}
},
fail: async (err) => {
showindex.value = 'index'
}
});
}
hometop()
init_fn()
});
onReachBottom(() => {
onLoadhome()
})
onLoad(() => {
})
</script>
<style lang="scss">
@ -549,6 +637,40 @@
font-weight: bold;
font-size: 16rpx;
color: #FFFFFF;
.time {
@include flex;
align-items: center;
&__custom {
margin-top: 4rpx;
width: 22rpx;
height: 22rpx;
border-radius: 4rpx;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
&__item {
color: #fff;
font-size: 14rpx;
text-align: center;
}
}
&__doc {
color: #fff;
padding: 0px 4rpx;
}
&__item {
color: #606266;
font-size: 15rpx;
margin-right: 4rpx;
}
}
}
}
}

201
pages/index/indexs.vue Normal file
View File

@ -0,0 +1,201 @@
<template>
<view class="content">
<view class="contentbox" :style="'background:url('+(shopExtend?shopExtend.value:'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png')+') no-repeat center center / cover' ">
<view class="contentboxitem flex-between">
<view class="contentboxitemleft flex-colum" @click="scanCodehandle(0)">
<image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/Xdiancan.png" mode="aspectFill">
</image>
<text class="contentboxitemlefttextone">点餐</text>
<text class="contentboxitemlefttexttow">在线点不排队</text>
</view>
<view class="contentboxitemright">
<view class="contentboxitemright_item flex-between" @click="memberindex('member/memberdetails')">
<image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/Xvip.png" mode="aspectFill">
</image>
<view class="contentboxitemright_itembox flex-colum">
<text>会员</text>
<text>入会享权益</text>
</view>
</view>
<view class="contentboxitemright_item flex-between" @click="memberindex('member/index')">
<image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/Xchong.png"
mode="aspectFill"></image>
<view class="contentboxitemright_itembox flex-colum">
<text>充值</text>
<text>充值享更多优惠</text>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
userInfo: null,
};
},
props: {
shopUserInfo: {
type: Object,
default () {
return {
amount: '',
shopName: ""
}
}
},
shopExtend: {
type: Object,
default () {
return {}
}
},
},
mounted() {
this.userInfo = uni.cache.get('userInfo');
},
methods: {
scanCodehandle(i) {
setTimeout(()=>{
uni.cache.set('forceUpdate',2)
},200)
uni.scanCode({
success: async (res) => {
let tableCode = this.getQueryString(decodeURIComponent(res.result), 'code')
uni.cache.set('tableCode', tableCode)
if (tableCode) {
let data = await this.api.productqueryShop({
code: uni.cache.get('tableCode'),
})
console.log()
if ( data.data.shopTableInfo && !data.data.shopTableInfo.choseCount ) {
uni.pro.navigateTo('/pagesOrder/orderAMeal/index', {
tableCode: tableCode,
shopId: data.data.storeInfo.id,
})
} else {
uni.pro.navigateTo('order_food/order_food', {
tableCode: tableCode,
})
}
}
},
fail: () => {
}
})
},
memberindex(url) {
uni.pro.navigateTo(url, {
shopId: uni.cache.get('shopId'),
type: 'index',
})
},
getQueryString(url, name) { //
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
var r = url.substr(1).match(reg)
if (r != null) {
return r[2]
}
return null;
},
}
};
</script>
<style scoped lang="scss">
page {
background: #F6F8FA;
}
.content {
.contentbox {
position: relative;
width: 100%;
height: 1046rpx;
padding: 0 24rpx;
.contentboxitem {
position: absolute;
bottom: 0;
width: 90%;
left: 50%;
transform: translate(-50%, 50%);
padding: 38rpx 0 26rpx 0;
background: rgba(255, 255, 255, 0.98);
box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(0, 0, 0, 0.16);
border-radius: 20rpx 20rpx 20rpx 20rpx;
.contentboxitemleft {
width: 50%;
border-right: 2rpx solid #623618;
image {
width: 134rpx;
height: 134rpx;
}
.contentboxitemlefttextone {
margin-top: 10rpx;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 32rpx;
color: #333333;
}
.contentboxitemlefttexttow {
margin-top: 2rpx;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 24rpx;
color: #999999;
}
}
.contentboxitemright {
width: 50%;
padding: 0 34rpx;
.contentboxitemright_item:nth-child(2) {
margin-top: 30rpx;
}
.contentboxitemright_item {
image {
width: 96rpx;
height: 96rpx;
}
.contentboxitemright_itembox {
width: 170rpx;
text:nth-child(1) {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 32rpx;
color: #333333;
}
text:nth-child(2) {
margin-top: 2rpx;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 24rpx;
color: #999999;
}
}
}
}
}
}
}
</style>

19
vite.config.js Normal file
View File

@ -0,0 +1,19 @@
import {
defineConfig
} from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
export default defineConfig({
plugins: [uni()],
server: {
hmr: true,
proxy: {
'/api': {
target: 'https://cashier.sxczgkj.cn',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, ''),
secure: false
}
}
}
})