计算购物车钱之前

This commit is contained in:
wwz 2025-02-26 17:39:46 +08:00
parent f2513ef13a
commit 0ab9235f6c
33 changed files with 4225 additions and 903 deletions

60
App.vue
View File

@ -10,7 +10,10 @@
} from '@dcloudio/uni-app';
import {
getCurrentInstance
} from 'vue'
} from 'vue';
import {
Storelogin
} from '@/stores/user.js';
const {
proxy
} = getCurrentInstance()
@ -18,7 +21,15 @@
onLaunch(async () => {
//
const store = useNavbarStore();
store.initNavbarHeight();
await store.initNavbarHeight();
// #ifndef H5
try {
const storelogin = Storelogin();
await storelogin.actionslogin()
} catch (error) {
console.log(error)
}
// #endif
try {
uni.getLocation({
type: 'wgs84',
@ -27,40 +38,43 @@
lng: res.longitude,
lat: res.latitude,
})
if (successres.code == 0) {
if (successres) {
let datastorage = {
country: successres.data.addressComponent.country, // ""
province: successres.data.addressComponent
country: successres.addressComponent.country, // ""
province: successres.addressComponent
.province, //province: "西"
address: successres.data.addressComponent.city, //district: "西"
district: successres.data.addressComponent
.district, //district: ""
address: successres.addressComponent.city, //district: "西"
district: successres.addressComponent.district, //district: ""
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
//
proxy.$isResolve()
}
},
});
} catch (error) {
let successres = await APIgeocodelocation({
lng: '',
lat: '',
})
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,
try {
let successres = await APIgeocodelocation({
lng: '',
lat: '',
})
if (successres) {
let datastorage = {
country: successres.addressComponent.country, // ""
province: successres.addressComponent
.province, //province: "西"
address: successres.addressComponent.city, //district: "西"
district: successres.addressComponent.district, //district: ""
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
proxy.$isResolve()
}
uni.cache.set('getLocationstorage', datastorage);
} catch (error) {
proxy.$isResolve()
}
}

View File

@ -1,20 +1,33 @@
// 引入 request 文件
import request from '@/common/api/request.js'
const url = '/account'
//根据经纬度获取信息
export const APIgeocodelocation = (data) => {
return request({
url: '/location/geocode',
url: url + '/user/geo/geocode',
method: 'get',
data: data,
toast: false
})
}
//根据经纬度获取信息
export const APIcustomlogin = (data) => {
//登录
export const APIuserlogin = (data) => {
return request({
url: '/login/auth/custom/login',
url: url + '/user/login',
method: 'post',
data: data
data: data,
toast: false
})
}
}
//用户信息获取
export const APIuser = (data) => {
return request({
url: url + '/user',
method: 'get',
data: data,
toast: false
})
}

View File

@ -1,9 +1,10 @@
// 引入 request 文件
import request from '@/common/api/request.js'
//获取优惠券参数列表
const url = '/account'
export const APIordergetYhqPara = (data) => {
return request({
url: '/order/getYhqPara',
url: url + '/order/getYhqPara',
method: 'get',
data: data
})
@ -11,7 +12,7 @@ export const APIordergetYhqPara = (data) => {
//系统优惠券
export const APIorderfindCoupons = (data) => {
return request({
url: '/order/findCoupons',
url: url + '/order/findCoupons',
method: 'get',
data: data
})
@ -19,7 +20,7 @@ export const APIorderfindCoupons = (data) => {
// 我的优惠券
export const APIordermineCoupons = (data) => {
return request({
url: '/order/mineCoupons',
url: url + '/order/mineCoupons',
method: 'post',
data: data,
toast: false

View File

@ -1,44 +1,28 @@
// 引入 request 文件
const url = '/account'
import request from '@/common/api/request.js'
//首页上半部分
export const APIhomehomePageUp = (data) => {
return request({
url: '/home/homePageUp',
method: 'post',
url: url + '/user/home/homePageUp',
method: 'GET',
data: data
})
}
//首页半部分
//首页xia半部分
export const APIhome = (data) => {
return request({
url: '/home',
method: 'post',
data: data,
toast: false
})
}
//首页上半部分
export const APIshopUserInfo = (data) => {
return request({
url: '/user/shopUserInfo',
method: 'get',
data: data,
toast: false
})
}
//首页上半部分
export const APIgeocodelocation = (data) => {
return request({
url: '/location/geocode',
method: 'get',
url: url + '/user/home/home',
method: 'GET',
data: data,
toast: false
})
}
///商户登录后 shopId和autokey
export const APIshopExtend = (data) => {
return request({
url: '/common/shopExtend',
url: url + '/common/shopExtend',
method: 'post',
data: data,
toast: false

View File

@ -1,9 +1,10 @@
// 引入 request 文件
import request from '@/common/api/request.js'
const url = '/account'
//获取top部分(店铺列表)
export const APIdistiricttopCommon = (data) => {
return request({
url: '/distirict/topCommon',
url: url + '/distirict/topCommon',
method: 'get',
data: data
})
@ -11,7 +12,7 @@ export const APIdistiricttopCommon = (data) => {
//预约到店(店铺列表)
export const APIdistirictsubShopList = (data) => {
return request({
url: '/distirict/subShopList',
url: url + '/distirict/subShopList',
method: 'get',
data: data
})

11
common/api/order/index.js Normal file
View File

@ -0,0 +1,11 @@
// 引入 request 文件
import request from '@/common/api/request.js'
const url = '/order'
//订单列表
export const APIuserorder = (data) => {
return request({
url: url + '/user/order',
method: 'post',
data: data
})
}

View File

@ -1,10 +1,66 @@
// 引入 request 文件
import request from '@/common/api/request.js'
//通过桌码获取店铺信息
const urlAccount = '/account'
const urlProduct = '/product'
const urlOrder = '/order'
//桌码换取详细店铺信息
export const APIproductqueryShop = (data) => {
return request({
url: '/product/queryShop',
url: urlAccount + '/user/shopInfo',
method: 'get',
data: data
})
}
// 获取登录用户店铺会员信息
export const APIshopUserInfo = (data) => {
return request({
url: urlAccount + '/user/shopUser',
method: 'get',
data: data,
toast: false
})
}
//获取商品列表数据
export const APIproductqueryProduct = (data) => {
return request({
url: urlProduct + '/user/product/miniApp/home/queryProduct',
method: 'get',
data: data
})
}
//小程序点餐-热销商品查询
export const productminiApphotsquery = (data) => {
return request({
url: urlProduct + '/user/product/miniApp/hots/query',
method: 'get',
data: data
})
}
//小程序点餐-分组商品列表
export const APIgroupquery = (data) => {
return request({
url: urlProduct + '/user/product/miniApp/group/query',
method: 'get',
data: data
})
}
//小程序点餐-分组商品列表
export const APIminiAppinfo = (data) => {
return request({
url: urlProduct + '/user/product/miniApp/info/' + data,
method: 'get'
})
}
//小程序点餐-分组商品列表
export const APIminiAppskuinfo = (data) => {
return request({
url: urlProduct + '/user/product/miniApp/sku/info',
method: 'get',
data: data
})

View File

@ -19,11 +19,10 @@ export default (params) => {
// #ifdef MP-ALIPAY
environment: 'alipay',
// #endif
token: uni.cache.get('token'),
openId: uni.cache.get('miniAppOpenId'),
id: uni.cache.get('userInfo').id,
shopId: uni.cache.get('shopId'),
userId: uni.cache.get('userInfo').id,
token: uni.cache.get('token') || '',
id: uni.cache.get('userInfo').id || '',
shopId: uni.cache.get('shopId') || '',
userId: uni.cache.get('userInfo').id || '',
}
if (toast) {
uni.showLoading({
@ -41,10 +40,10 @@ export default (params) => {
const res = response.data
// 根据返回的状态码做出对应的操作
//获取成功
if (res.code == 0) {
if (res.code == 200) {
uni.hideLoading();
uni.hideToast();
resolve(res);
resolve(res.data);
} else {
switch (res.code) {
case '-4':

View File

@ -1,231 +1,301 @@
class webSocketUtils {
constructor(url, time, params) {
this.socketTask = null;
this.is_open_socket = false; //避免重复连接
this.url = url;
this.params = params ? params : null; ////是否初始化请求
this.connectNum = 1; // 重连次数
//这个参数是防止重连失败之后onClose方法会重复执行reconnect方法导致重连定时器出问题
//连接并打开之后可重连,且只执行重连方法一次
this.canReconnect = false; // 是否可以重连
//心跳检测
this.timeout = time ? time : 5000; //多少秒执行检测
this.heartbeatInterval = null; //检测服务器端是否还活着
this.reconnectTimeOut = null; //重连之后多久再次重连
try {
return this.connectSocketInit({
data: this.params,
type: 'connectSocketInit',
});
} catch (e) {
// console.log('catch');
this.reconnect();
}
}
// 进入这个页面的时候创建websocket连接【整个页面随时使用】
connectSocketInit(data) {
let _this = this;
this.data = data;
// #ifdef MP-WEIXIN
this.socketTask = uni.connectSocket({
// #endif
// #ifdef MP-ALIPAY
my.connectSocket({
// #endif
url: this.url,
success: (res) => {
console.log('创建websocketc成功...');
// uni.hideLoading();
// 返回实例
return this.socketTask;
},
fail: (res) => {
}
});
// #ifdef MP-WEIXIN
this.socketTask.onOpen((res) => {
// #endif
// #ifdef MP-ALIPAY
my.onSocketOpen((res) => {
// #endif
uni.hideLoading()
this.connectNum = 1;
console.log('WebSocket连接正常==',res);
if (this.params) { //是否初始化请求
this.send(this.params);
}
clearInterval(this.reconnectTimeOut);
clearInterval(this.heartbeatInterval);
this.is_open_socket = true;
this.canReconnect = true;
this.start();
// 注:只有连接正常打开中 ,才能正常收到消息
// #ifdef MP-WEIXIN
this.socketTask.onMessage((e) => {
// #endif
// #ifdef MP-ALIPAY
my.onSocketMessage((e)=>{
// #endif
// 字符串转json
let res = JSON.parse(e.data);
uni.$emit('message', res)
// 普通socket信息处理 TODO
});
});
// 监听连接失败这里代码我注释掉的原因是因为如果服务器关闭后和下面的onclose方法一起发起重连操作这样会导致重复连接
// #ifdef MP-WEIXIN
uni.onSocketError((res) => {
// #endif
// #ifdef MP-ALIPAY
my.onSocketError((res) => {
// #endif
console.log('网络断开,请检查!');
this.socketTask = null;
this.is_open_socket = false;
// this.Close()
this.canReconnect = true;
clearInterval(this.heartbeatInterval);
clearInterval(this.reconnectTimeOut);
try {
if (this.connectNum <= 10) {
// uni.showLoading({
// title: `网络连接失败,正尝试第${this.connectNum}次连接`,
// mask: true
// })
uni.$emit('message', 1) //进行重连
uni.showToast({
title: `网络连接失败,正尝试第${this.connectNum}次连接`,
icon: 'none',
});
this.reconnect();
this.connectNum += 1;
} else {
// uni.$emit('connectError');
uni.showToast({
title: `网络连接失败,请检查网络!`,
icon: 'none',
});
this.connectNum = 1;
this.canReconnect = false;
this.Close()
setTimeout(res => {
uni.switchTab({
url: '/pages/index/index'
})
uni.hideLoading()
}, 1000)
import {
ref,
onMounted,
onBeforeUnmount
} from 'vue';
const useWebSocket = (options = {}) => {
const {
heartbeatInterval = 10000, //心跳是10秒一次
reconnectInterval = 3000, //重新连接间隔时间的一个参数
maxReconnectAttempts = 3, //最大重连接次数
initialReconnectInterval = 3000, // 初始重连间隔
initMessage,
initMessageRetryCount = 3, // 新增:初始化消息发送重试次数
initMessageRetryInterval = 2000, // 新增:初始化消息重试间隔
maxReconnectDuration = Infinity
} = options;
const autoReconnect = ref(true); //是否自动重新连接
const socketTask = ref(null);
const isConnected = ref(false); //表示是否已连接上。
const heartbeatTimer = ref(null); //心跳定时器
const reconnectTimer = ref(null); //重连定时器
const reconnectAttempts = ref(0); //重连的尝试次数
const isNetworkConnected = ref(true); //监听当前网络连接状态
const isManuallyClosed = ref(false); //是否是被手动关闭的
const receivedMessages = ref([]); //储从 WebSocket 服务器接收到的消息
const initMessageSendAttempts = ref(0); //初始化连接多少次
const reconnectStartTime = ref(0); //新增:记录重连开始时间
// 关闭现有连接并清理资源
const closeExistingConnection = () => {
if (socketTask.value) {
// 关闭 WebSocket 连接
socketTask.value.close({
success: () => {
console.log('WebSocket 连接已关闭');
},
fail: (err) => {
console.error('关闭 WebSocket 连接失败:', err);
}
} catch (e) {
//TODO handle the exception
}
});
// 这里仅是事件监听【如果socket关闭了会执行】
// #ifdef MP-WEIXIN
this.socketTask.onClose(() => {
// #endif
// #ifdef MP-ALIPAY
my.onSocketClose((res) => {
// #endif
console.log("socket关闭了")
this.socketTask = null;
clearInterval(this.heartbeatInterval);
clearInterval(this.reconnectTimeOut);
// #ifdef MP-ALIPAY
// 支付宝小程序的ws连接问题关闭连接时需关闭对于接受防止关闭失败
my.offSocketMessage();
my.offSocketError();
my.offSocketOpen();
my.offSocketClose();
// #endif
this.is_open_socket = false;
if (this.canReconnect) {
this.reconnect();
this.canReconnect = false;
}
});
}
// 主动关闭socket连接
Close() {
this.is_open_socket = true;
this.canReconnect = false;
// #ifdef MP-WEIXIN
if (this.socketTask) {
this.socketTask.close({
success(res) {
console.log('手动关闭成功');
},
});
// 清除心跳定时器
clearInterval(heartbeatTimer.value);
heartbeatTimer.value = null;
// 清除重连定时器
clearTimeout(reconnectTimer.value);
reconnectTimer.value = null;
// 标记连接已断开
isConnected.value = false;
}
// #endif
// #ifdef MP-ALIPAY
my.closeSocket({
success(res) {
console.log('手动关闭成功');
// #ifdef MP-ALIPAY
// 支付宝小程序的ws连接问题关闭连接时需关闭对于接受防止关闭失败
my.offSocketMessage();
my.offSocketError();
my.offSocketOpen();
my.offSocketClose();
// #endif
};
// 连接 WebSocket
const connect = () => {
if (!isNetworkConnected.value) {
console.log('网络未连接,暂不尝试连接 WebSocket');
return;
}
// 关闭现有连接并清理资源
closeExistingConnection();
socketTask.value = uni.connectSocket({
url: uni.conf.baseUrlwws,
success: (res) => {
isConnected.value = true;
reconnectAttempts.value = 0;
// 监听初始化成功在开启心跳
// startHeartbeat();
},
fail: (res) => {
console.log('手动关闭失败==',res);
fail: () => {
console.error('WebSocket 连接失败,尝试重连');
if (autoReconnect.value) {
handleReconnect();
}
}
});
// #endif
}
//发送消息
send(data) {
// console.log("发送消息---------->", data);
// 注:只有连接正常打开中 ,才能正常成功发送消息
// #ifdef MP-WEIXIN
if (this.socketTask) {
this.socketTask.send({
if (socketTask.value) {
socketTask.value.onOpen(() => {
// 初始化 初始购物车
sendMessage(initMessage)
});
socketTask.value.onMessage((res) => {
// console.log(res, 'receivedMessages.value')
let list = JSON.parse(res.data)
receivedMessages.value.push(list);
if (list.type == 'p') {
console.log('心跳响应正常');
// 心跳正常,重置重连尝试次数
reconnectAttempts.value = 0;
clearTimeout(reconnectTimer.value);
}
});
socketTask.value.onClose((res) => {
console.log(res, 'WebSocket 连接已关闭,尝试重连');
isConnected.value = false;
clearInterval(heartbeatTimer.value); // 停止心跳定时器
clearTimeout(reconnectTimer.value); // 清除重连定时器
if (res.code == '1006') {
console.log('服务器正常关闭,停止重连');
autoReconnect.value = false;
return false;
}
if (autoReconnect.value && !isManuallyClosed.value) {
handleReconnect();
}
});
socketTask.value.onError((err) => {
console.error('WebSocket 连接发生错误:', err);
isConnected.value = false;
clearInterval(heartbeatTimer.value);
if (autoReconnect.value && !isManuallyClosed.value) {
handleReconnect();
}
});
} else {
console.error('socketTask 未正确初始化');
}
};
// 启动心跳机制
const startHeartbeat = () => {
if (!isNetworkConnected.value) {
console.log('网络未连接,暂停心跳');
return;
}
heartbeatTimer.value = setInterval(() => {
if (isConnected.value) {
socketTask.value.send({
data: JSON.stringify({
type: 'pong'
}),
success: () => {
console.log('心跳消息发送成功');
const pongTimer = setTimeout(() => {
console.error('心跳超时,未收到响应,尝试重连');
clearInterval(heartbeatTimer.value);
if (autoReconnect) {
handleReconnect();
}
}, heartbeatInterval * 1.2);
socketTask.value.onMessage((res) => {
if (res.data === 'ping') {
clearTimeout(pongTimer);
}
});
},
fail: () => {
console.error('心跳消息发送失败,尝试重连');
clearInterval(heartbeatTimer.value);
if (autoReconnect) {
handleReconnect();
}
}
});
}
}, heartbeatInterval);
};
// 手动关闭连接
const closeSocket = () => {
isManuallyClosed.value = true;
closeExistingConnection();
};
// 发送消息
const sendMessage = async (data) => {
if (isConnected.value) {
await socketTask.value.send({
data: JSON.stringify(data),
async success() {
// console.log("消息发送成功");
success: () => {
// console.log('消息发送成功');
},
fail: () => {
// console.error('消息发送失败');
}
});
} else {
console.error('WebSocket 未连接,无法发送消息');
}
};
// 处理重连逻辑
const handleReconnect = () => {
if (!isNetworkConnected.value) {
console.log('网络未连接,暂停重连');
return;
}
if (isManuallyClosed.value) {
console.log('手动关闭连接,不进行重连');
return;
}
if (reconnectAttempts.value < maxReconnectAttempts) {
reconnectAttempts.value++;
const reconnectInterval = initialReconnectInterval * Math.pow(2, reconnectAttempts.value - 1);
const randomizedInterval = reconnectInterval + Math.floor(Math.random() * 1000);
console.log(`尝试第 ${reconnectAttempts.value} 次重连,重连间隔: ${randomizedInterval}ms...`);
reconnectTimer.value = setTimeout(() => {
connect();
}, randomizedInterval);
} else {
console.error('重连次数达到上限,停止重连');
uni.showToast({
title: '重连次数达到上限,停止重连',
icon: 'none'
});
}
// #endif
// #ifdef MP-ALIPAY
my.sendSocketMessage({
data: JSON.stringify(data),
success(res) {
// console.log("消息发送成功");
};
// 发送初始化消息
const sendInitMessage = async () => {
if (initMessageSendAttempts.value < initMessageRetryCount) {
initMessageSendAttempts.value++;
await socketTask.value.send({
data: JSON.stringify(initMessage),
success: () => {
console.log('初始化消息发送成功');
initMessageSendAttempts.value = 0; // 重置尝试次数
},
fail: () => {
console.log(
`初始化消息发送失败,第 ${initMessageSendAttempts.value} 次尝试,将在 ${initMessageRetryInterval} 后重试`
);
setTimeout(() => {
sendInitMessage();
}, initMessageRetryInterval);
}
});
} else {
console.error('初始化消息发送失败,已达到最大重试次数');
// initMessageSendAttempts.value = 0; // 重置尝试次数
}
};
// 网络状态监听
const initNetworkListener = () => {
uni.getSystemInfo({
success: (res) => {
if (res.platform !== 'devtools') {
uni.onNetworkStatusChange((statusRes) => {
isNetworkConnected.value = statusRes.isConnected;
if (statusRes.isConnected && !isManuallyClosed.value) {
console.log('网络已连接,尝试重新连接 WebSocket');
if (!isConnected.value && autoReconnect.value) {
connect();
}
} else if (!statusRes.isConnected) {
console.log('网络已断开,暂停 WebSocket 操作');
clearInterval(heartbeatTimer.value);
clearTimeout(reconnectTimer.value);
if (socketTask.value) {
socketTask.value.close();
isConnected.value = false;
}
}
});
}
},
fail: (err) => {
console.error('获取系统信息失败:', err);
}
});
// #endif
}
//开启心跳检测
start(data) {
// console.log('开启心跳检测', data)
this.heartbeatInterval = setInterval(() => {
this.send({
data: '心跳检测',
type: 'heartbeat',
});
}, this.timeout);
}
//重新连接
reconnect() {
//停止发送心跳
clearInterval(this.heartbeatInterval);
//如果不是人为关闭的话,进行重连
if (!this.is_open_socket) {
console.log('进行重连');
this.canReconnect = true;
this.reconnectTimeOut = setInterval(() => {
this.connectSocketInit(this.data);
}, this.timeout);
}
}
}
module.exports = webSocketUtils;
uni.getNetworkType({
success: (res) => {
isNetworkConnected.value = res.networkType !== 'none';
if (!isNetworkConnected.value) {
console.log('初始网络未连接,暂不尝试连接 WebSocket');
}
}
});
};
onMounted(() => {
initNetworkListener();
connect();
});
onBeforeUnmount(() => {
closeSocket();
});
return {
isConnected,
sendMessage,
closeSocket,
receivedMessages
};
};
export default useWebSocket;

View File

@ -33,19 +33,22 @@
reactive,
watch,
onMounted,
computed
computed,
toRefs
} from 'vue';
const store = useNavbarStore();
const {
showBack,
rightText,
showSearch,
title,
isTransparent,
height,
hasPlaceholder
} = store;
const showSearch = computed(() => store.showSearch);
const title = computed(() => store.title);
hasPlaceholder,
scrollTop
} = toRefs(store);
const keyword = ref()
const goBack = () => {
@ -60,7 +63,7 @@
const navbarStyle = computed(() => {
return {
height: `${height}px`,
// height: `${height}px`,
backgroundColor: store.scrollTop >= 44 ? '#fff' : 'transparent'
};
});
@ -70,21 +73,21 @@
towStyle: {}
});
onMounted(() => {
// #ifdef MP-WEIXIN
// #ifdef MP-WEIXIN || MP-ALIPAY
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
const systemInfo = uni.getSystemInfoSync();
const statusBarHeight = systemInfo.statusBarHeight;
console.log(menuButtonInfo)
//
const verticalOffset = menuButtonInfo.top;
// const verticalOffset = menuButtonInfo.top - statusBarHeight;
const verticalOffset = menuButtonInfo.top > menuButtonInfo.height ? menuButtonInfo.height : Math.abs(
menuButtonInfo.top - menuButtonInfo.height)
// const verticalOffset = menuButtonInfo.top > menuButtonInfo.height ? menuButtonInfo.height : Math.abs(
// menuButtonInfo.top - menuButtonInfo.height)
const titleHeight = menuButtonInfo.height;
centerContentStyle.oneStyle = {
paddingTop: `${verticalOffset}px`,
paddingRight: `${menuButtonInfo.width +20}px`,
// paddingTeft: `${menuButtonInfo.width +20}px`,
height: `${height}px`,
// height: `${height}px`,
boxSizing: 'border-box',
};
centerContentStyle.towStyle = {

View File

@ -29,16 +29,16 @@
</template>
<script setup>
import {
useNavbarStore
} from '@/stores/navbarStore';
import {
ref,
watch,
onMounted,
computed
computed,
toRefs
} from 'vue';
import {
useNavbarStore
} from '@/stores/navbarStore';
const store = useNavbarStore();
const {
showBack,
@ -49,7 +49,7 @@
height,
hasPlaceholder,
scrollTop
} = store;
} = toRefs(store);
const keyword = ref()
@ -62,30 +62,30 @@
const onRightTextClick = () => {
console.log('右边文字被点击');
};
const navbarStyle = computed(() => {
return {
height: `${height}px`,
backgroundColor: store.scrollTop >= 44 ? '#F9F9F9' : 'transparent'
// height: `${height.value}px`,
backgroundColor: scrollTop.value >= 44 ? '#F9F9F9' : 'transparent'
};
});
//
const centerContentStyle = ref({});
onMounted(() => {
// #ifdef MP-WEIXIN
// #ifdef MP-WEIXIN || MP-ALIPAY
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
const systemInfo = uni.getSystemInfoSync();
const statusBarHeight = systemInfo.statusBarHeight;
//
const verticalOffset = menuButtonInfo.top;
// const verticalOffset = menuButtonInfo.top - statusBarHeight;
const verticalOffset = menuButtonInfo.top > menuButtonInfo.height ? menuButtonInfo.height : Math.abs(
menuButtonInfo.top - menuButtonInfo.height)
// const verticalOffset = menuButtonInfo.top > menuButtonInfo.height ? menuButtonInfo.height : Math.abs(
// menuButtonInfo.top - menuButtonInfo.height)
const titleHeight = menuButtonInfo.height;
centerContentStyle.value = {
paddingTop: `${verticalOffset}px`,
paddingRight: `${menuButtonInfo.width +20}px`,
height: `${height}px`,
lineHeight: `${height}px`,
// height: `${height.value}px`,
// lineHeight: `${height.value}px`,
boxSizing: 'border-box',
};
// #endif

View File

@ -2,28 +2,29 @@ const debug = process.env.NODE_ENV == 'development' ? true : false;
// #ifdef H5
const proxyApi = "/api"
// #endif
// #ifdef MP-WEIXIN || APP || MP-ALIPAY
// const proxyApi = 'http://192.168.1.15:9888/cashierService' // 王伟
// const proxyApi = 'http://192.168.1.27:9888/cashierService' // 帆哥
// const proxyApiwws = 'ws://192.168.1.15:9888/netty' // 测试
// const proxyApi = 'https://wxcashiertest.sxczgkj.cn/cashierService' // 测试
// const proxyApiwws = 'wss://wxcashiertest.sxczgkj.cn/netty' // 测试
// const proxyApi = 'https://pre-cashier.sxczgkj.cn/cashierService' // 预发布
// const proxyApiwws = 'wss://pre-cashier.sxczgkj.cn/netty' // 预发布
const proxyApi = 'https://cashier.sxczgkj.cn/cashierService' // 线上
const proxyApiwws = 'wss://cashier.sxczgkj.cn/netty' // 线上
const proxyApi = 'https://tapi.cashier.sxczgkj.cn' // 调试地址
const proxyApiwws = 'wss://sockets.sxczgkj.com/wss' // 调试地址
// #endif
// #ifdef H5
const baseUrl = debug ? proxyApi + '/cashierService' : "https://cashier.sxczgkj.cn/cashierService"
const baseUrlwws = 'ws://cashier.sxczgkj.cn/cashierService'
const baseUrl = debug ? proxyApi : "https://tapi.cashier.sxczgkj.cn"
const baseUrlwws = 'wss://sockets.sxczgkj.com/wss'
// #endif
// #ifdef APP || MP-WEIXIN || MP-ALIPAY
const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.cn/cashierService' // 线上
const baseUrlwws = debug ? proxyApiwws : 'wss://cashier.sxczgkj.cn/netty' // 线上
// const baseUrl = 'https://wxcashiertest.sxczgkj.cn/cashierService' // 测试
// const baseUrlwws = 'wss://wxcashiertest.sxczgkj.cn/netty' // 测试
const baseUrl = debug ? proxyApi : 'https://tapi.cashier.sxczgkj.cn' // 线上
const baseUrlwws = debug ? proxyApiwws : 'wss://sockets.sxczgkj.com/wss' // 线上
// #endif
// import VConsole from "./vConsole.js"

View File

@ -5,39 +5,24 @@
* @return {String} 缓存值
*/
function get(key) {
try {
let res = uni.getStorageSync(key)
try {
let res = uni.getStorageSync(key)
if (!res) {
return ''
}
// res = JSON.parse(res)
if (!res) {
return ''
}
if (res.__expiretime && res.__expiretime < uni.utils.timestamp()) {
// res = JSON.parse(res)
if (res.__expiretime && res.__expiretime < uni.utils.timestamp()) {
remove(key)
return ''
} else {
try {
const parsed = JSON.parse(res);
C
} catch (e) {
return res
}
// // #ifdef H5
// try {
// const parsed = JSON.parse(res);
// return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) ? parsed : ''
// } catch (e) {
// return res
// }
// // #endif
// // #ifndef H5
// return res
// // #endif
}
} catch (e) {
return ''
}
return ''
} else {
return res
}
} catch (e) {
return ''
}
}
@ -48,19 +33,19 @@ function get(key) {
* @return {String} 缓存值
*/
function getStorageData(key) {
try {
let res = uni.getStorageSync(key);
try {
let res = uni.getStorageSync(key);
if (!res) {
return ''
}
if (!res) {
return ''
}
res = JSON.parse(res)
res = JSON.parse(res)
return res.data
} catch (e) {
return ''
}
return res.data
} catch (e) {
return ''
}
}
/**
@ -72,20 +57,14 @@ function getStorageData(key) {
* @return void
*/
function set(key, value, expire = uni.conf.default_expire) {
let cacheItem = {}
cacheItem = value
let cacheItem = {}
cacheItem = value
// console.log(cacheItem)
// if (expire > 0) {
// cacheItem.__expiretime = uni.utils.timestamp() + expire
// }
// // #ifdef H5
// uni.setStorageSync(key, JSON.stringify(cacheItem))
// // #endif
// // #ifndef H5
// uni.setStorageSync(key, cacheItem)
// // #endif
uni.setStorageSync(key, JSON.stringify(cacheItem))
// uni.setStorageSync(key, cacheItem)
if (expire > 0) {
cacheItem.__expiretime = uni.utils.timestamp() + expire
}
// uni.setStorageSync(key,JSON.stringify(cacheItem))
uni.setStorageSync(key,cacheItem)
}
/**
@ -97,14 +76,14 @@ function set(key, value, expire = uni.conf.default_expire) {
* @return {Promise} Promise对象
*/
async function remember(key, callback, expire = uni.conf.default_expire) {
let ret = this.get(key)
if (ret) {
return ret
} else {
ret = await callback()
set(key, ret, expire)
return ret
}
let ret = this.get(key)
if (ret) {
return ret
} else {
ret = await callback()
set(key, ret, expire)
return ret
}
}
/**
@ -114,7 +93,7 @@ async function remember(key, callback, expire = uni.conf.default_expire) {
* @return {void}
*/
function remove(key) {
uni.removeStorageSync(key)
uni.removeStorageSync(key)
}
/**
@ -124,22 +103,22 @@ function remove(key) {
* @return void
*/
function removeList(prefix) {
let keys = uni.getStorageInfoSync().keys
if (keys && keys.length > 0) {
keys.forEach(key => {
if (key.indexOf(prefix) === 0) {
uni.removeStorageSync(key)
}
})
}
let keys = uni.getStorageInfoSync().keys
if (keys && keys.length > 0) {
keys.forEach(key => {
if (key.indexOf(prefix) === 0) {
uni.removeStorageSync(key)
}
})
}
}
function _randomRemove() {
const info = uni.getStorageInfoSync()
if (info.currentSize > 0.7 * info.limitSize ||
info.keys.length > uni.conf.autoRemoveCache.count ||
info.currentSize > uni.conf.autoRemoveCache.size) {
for (let i = 0; i < 100; i++) {
if (info.currentSize > 0.7 * info.limitSize
|| info.keys.length > uni.conf.autoRemoveCache.count
|| info.currentSize > uni.conf.autoRemoveCache.size) {
for (let i = 0; i < 100; i++) {
if (info.keys.length < 1) {
return
}
@ -152,9 +131,9 @@ function _randomRemove() {
function _removeExpired(key) {
let res = uni.getStorageSync(key);
if (!res) {
return
return
}
res = JSON.parse(res)
if (res.__expiretime && res.__expiretime < uni.utils.timestamp()) {
remove(key)
@ -163,13 +142,13 @@ function _removeExpired(key) {
function _autoRemoveExpired() {
const info = uni.getStorageInfoSync()
if (info.currentSize > 0.7 * info.limitSize ||
info.keys.length > uni.conf.autoRemoveCache.count ||
info.currentSize > uni.conf.autoRemoveCache.size) {
if (info.currentSize > 0.7 * info.limitSize
|| info.keys.length > uni.conf.autoRemoveCache.count
|| info.currentSize > uni.conf.autoRemoveCache.size) {
if (info.keys && info.keys.length > 0) {
info.keys.forEach(key => {
_removeExpired(key)
})
info.keys.forEach(key => {
_removeExpired(key)
})
}
}
}
@ -179,7 +158,7 @@ function autoRemove(is_once = true) {
if (info.currentSize > 0.9 * info.limitSize) {
clearMemory()
}
if (is_once) {
_autoRemoveExpired()
} else {
@ -190,13 +169,13 @@ function autoRemove(is_once = true) {
function clearFetch(url) {
const prefixCacheKey = 'memory:fetch:' + url
removeList(prefixCacheKey)
const prefixCacheKey = 'memory:fetch:' + url
removeList(prefixCacheKey)
}
function clearMemory() {
const prefixCacheKey = 'memory:'
removeList(prefixCacheKey)
const prefixCacheKey = 'memory:'
removeList(prefixCacheKey)
}
/**
@ -205,22 +184,22 @@ function clearMemory() {
* @return void
*/
function clear() {
uni.clearStorageSync()
uni.clearStorageSync()
}
function getInfo() {
return uni.getStorageInfoSync()
return uni.getStorageInfoSync()
}
uni.cache = {
get,
getStorageData,
set,
remove,
remember,
clearFetch,
clearMemory,
clear,
getInfo,
get,
getStorageData,
set,
remove,
remember,
clearFetch,
clearMemory,
clear,
getInfo,
autoRemove,
}

View File

@ -1,85 +1,90 @@
{
"name": "wepp",
"appid": "__UNI__9EC799C",
"description": "",
"versionName": "1.0.0",
"versionCode": "100",
"transformPx": false,
/* 5+App */
"app-plus": {
"usingComponents": true,
"nvueStyleCompiler": "uni-app",
"compilerVersion": 3,
"splashscreen": {
"alwaysShowBeforeRender": true,
"waiting": true,
"autoclose": true,
"delay": 0
},
/* */
"modules": {},
/* */
"distribute": {
/* android */
"android": {
"permissions": [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios */
"ios": {},
/* SDK */
"sdkConfigs": {}
}
},
/* */
"quickapp": {},
/* */
"mp-weixin": {
"appid": "wxd88fffa983758a30",
"setting": {
"urlCheck": false,
"minified": true,
"es6": true,
"postcss": true
},
"usingComponents": true,
"libVersion": "latest",
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"requiredPrivateInfos": ["getLocation", "onLocationChange", "chooseLocation", "chooseAddress"]
},
"h5": {
},
"mp-alipay": {
"usingComponents": true
},
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao": {
"usingComponents": true
},
"uniStatistics": {
"enable": false
},
"vueVersion": "3"
}
"name" : "wepp",
"appid" : "__UNI__9EC799C",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
/* 5+App */
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
/* */
"modules" : {},
/* */
"distribute" : {
/* android */
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios */
"ios" : {},
/* SDK */
"sdkConfigs" : {}
}
},
/* */
"quickapp" : {},
/* */
"mp-weixin" : {
"appid" : "wxd88fffa983758a30",
"setting" : {
"urlCheck" : false,
"minified" : true,
"es6" : true,
"postcss" : true
},
"usingComponents" : true,
"libVersion" : "latest",
"permission" : {
"scope.userLocation" : {
"desc" : "你的位置信息将用于小程序位置接口的效果展示"
}
},
"requiredPrivateInfos" : [ "getLocation", "onLocationChange", "chooseLocation", "chooseAddress" ]
},
"h5" : {},
"mp-alipay" : {
"usingComponents" : true,
"appid" : "2021004145625815",
"devServer" : {
"autoOpen" : true // true
},
"unipush" : {
"enable" : false
}
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "3"
}

View File

@ -1,5 +1,6 @@
{
"dependencies": {
"@dcloudio/uni-app": "^2.0.2-4040520250103001",
"dayjs": "^1.11.13",
"pinia": "^2.3.1",
"pinia-plugin-persistedstate": "^4.2.0"

View File

@ -12,14 +12,13 @@
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom"
}
},
{
"path": "pages/index/indexs",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom"
"navigationStyle": "custom",
"mp-alipay": {
"transparentTitle": "always",
"titlePenetrate": "YES",
"autoBackButton": false,
"allowsBounceVertical": "NO"
}
}
},
{
@ -42,6 +41,12 @@
"navigationStyle": "custom"
}
},
{
"path": "pages/order/index",
"style": {
"navigationBarTitleText": "订单列表"
}
},
{
"path": "pages/user/user",
"style": {
@ -73,6 +78,11 @@
"selectedIconPath": "static/tabbar/1-1.png",
"pagePath": "pages/index/index",
"text": "首页"
}, {
"iconPath": "static/tabbar/2.png",
"selectedIconPath": "static/tabbar/2-1.png",
"pagePath": "pages/order/index",
"text": "订单列表"
},
{
"iconPath": "static/tabbar/4.png",

View File

@ -14,15 +14,12 @@
defineProps
} from 'vue';
import {
APIproductqueryShop
} from "@/common/api/product/product.js";
import {
Storelogin
} from '@/stores/share.js';
productStore
} from '@/stores/user.js';
const props = defineProps({
district: Array
});
const clickdistrict = (item) => {
const clickdistrict = async (item) => {
switch (item.jumpType) {
case 'absolute':
uni.pro.navigateTo('webview/webview', {
@ -36,47 +33,13 @@
uni.pro.navigateTo(item.absUrl);
break;
case 'scan':
// #ifndef H5
if (!uni.utils.pluschooseImage()) {
return false
}
// #ifdef APP || MP-WEIXIN || MP-ALIPAY
uni.scanCode({
success: async (res) => {
let tableCode = getQueryString(decodeURIComponent(res.result), 'code')
uni.cache.set('tableCode', tableCode)
if (tableCode) {
let data = await APIproductqueryShop({
code: uni.cache.get('tableCode'),
})
// -4
const store = Storelogin();
if (data.code == '-4') {
if (await store.actionslogin()) {
//
} else {
//
await store.actionslogin()
}
}
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: (res) => {
console.log(res)
}
});
// #endif
const store = productStore();
await store.scanCodeactions()
break;
}
}

View File

@ -186,8 +186,8 @@
const ordergetYhqParass = async () => {
let res = await APIordergetYhqPara()
try {
orderview.list = res.data
for (let i = 0; i <= res.data.length; i++) {
orderview.list = res
for (let i = 0; i <= res.length; i++) {
orderfindCouponses(i, orderview.list[i].name);
}
} catch (e) {
@ -202,7 +202,7 @@
size: 10,
type: name
})
orderview.list[i].orderview.listdata = res.data.list
orderview.list[i].orderview.listdata = res.list
console.log(orderview.list)
}
const ordermineCouponsthis = async () => {
@ -214,8 +214,8 @@
orderId: ''
})
try {
viewlist.totalnumber = res.data.total
viewlist.list = res.data.list.slice(0, 2)
viewlist.totalnumber = res.total
viewlist.list = res.list.slice(0, 2)
} catch (e) {
//TODO handle the exception
}
@ -272,8 +272,8 @@
// async ordergetYhqParass() { //
// let res = await this.api.ordergetYhqPara()
// try {
// this.orderview.list = res.data
// for (let i = 0; i <= res.data.length; i++) {
// this.orderview.list = res
// for (let i = 0; i <= res.length; i++) {
// this.orderfindCouponses(i, this.orderview.list[i].name);
// }
// } catch (e) {
@ -286,7 +286,7 @@
// size: 10,
// type: name
// })
// this.orderview.list[i].orderview.listdata = res.data.list
// this.orderview.list[i].orderview.listdata = res.list
// console.log(this.orderview.list)
// this.$forceUpdate();
// },
@ -299,8 +299,8 @@
// orderId: ''
// })
// try {
// this.viewlist.totalnumber = res.data.total
// this.viewlist.list = res.data.list.slice(0, 2)
// this.viewlist.totalnumber = res.total
// this.viewlist.list = res.list.slice(0, 2)
// } catch (e) {
// //TODO handle the exception
// }

View File

@ -12,129 +12,119 @@
<!-- 今日上线 -->
<todaylist :todayList='hometoplist.todayList' :salesList='hometoplist.salesList'></todaylist>
<!-- 类目 -->
<!-- #ifdef MP-WEIXIN -->
<!-- 只有小程序需要加height -->
<up-sticky :offset-top="store.height">
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<up-sticky>
<!-- #endif -->
<view class="fourcontent" id="fourcontent">
<view class="flex-between" style="flex-wrap: inherit;">
<view class="fourcontent_item flex-start" v-for="(item,index) in hometoplist.menu"
:key="index" @click="viewHistory(item,index)"
:class="!item.isChild && viewHistoryindex == index ? 'fourcontent_itemactev':''">
<text style="margin-right: 10rpx;">{{item.name}}</text>
<up-icon v-if="item.isChild" style="margin-left: 10rpx;"
:name="showproductlist && viewHistoryindex == index ?'arrow-up-fill':'arrow-down-fill'"
color="#333333" size="12"></up-icon>
</view>
</view>
<view class="componentsclass" v-if="showproductlist">
<AreaSelect v-if="viewHistoryindex == 0" @updateValue="openproductlist" />
<grouping v-if="viewHistoryindex == 1 || viewHistoryindex == 2 || viewHistoryindex == 3"
@grouping="openproductlist" />
</view>
<view :style="{'top':store.height+'px'}" class="fourcontent" id="fourcontent">
<view class="flex-between" style="flex-wrap: inherit;">
<view class="fourcontent_item flex-start" v-for="(item,index) in hometoplist.menu" :key="index"
@click="viewHistory(item,index)"
:class="!item.isChild && viewHistoryindex == index ? 'fourcontent_itemactev':''">
<text style="margin-right: 10rpx;">{{item.name}}</text>
<up-icon v-if="item.isChild" style="margin-left: 10rpx;"
:name="showproductlist && viewHistoryindex == index ?'arrow-up-fill':'arrow-down-fill'"
color="#333333" size="12"></up-icon>
</view>
</up-sticky>
<!-- 首页抢购区域 -->
<view class="fivecontent">
<view class="fivecontent_item" v-for="(item,index) in homelist" :key="index"
@click="fivecontentclick(item)">
<view class="fivecontent_item_nav flex-start">
<image :src="item.shopImage" mode="aspectFill"></image>
<view class="fivecontent_item_nav_left">
<view class="fivecontent_item_nav_lefttop flex-between">
<view>
{{item.shopName}}
</view>
<view>
{{item.districts}}&nbsp;{{item.distances}}
</view>
</view>
<view class="fivecontent_item_nav_lefttopstart flex-start">
<view class="fivecontent_item_nav_leftlang flex-start"
v-for="(s,index1) in item.shopTag" :key="index1"
:style="{'background':s.backColor,'color':s.backColor}">
<image class="fivecontent_item_nav_leftlangimage" v-if="s.shareImg"
:src="s.shareImg" mode="aspectFill"></image>
<text class="fivecontent_item_nav_leftlangtext">{{s.name}}</text>
</view>
</view>
</view>
</view>
<view class="fivecontent_item_box">
<view class="fivecontent_item_boxitem flex-between">
<image :src="`${item.image}?x-oss-process=image/resize,m_lfit,w_192,h_192`"
mode="aspectFill"></image>
<view class="fivecontent_item_boxitemleft flex-colum-start">
<view class="fivecontent_item_boxitemleftone flex-between"
style="display: flex;justify-content: space-between;align-items: center;">
<view>
{{item.productName.length>7?item.productName.substring(0,7)+'...':item.productName}}
</view>
<text>已抢{{item.realSalesNumber}}</text>
</view>
<view class="flex-start flexstartboxfttow">
<view class="fivecontent_item_boxitemlefttow flex-start"
v-for="(c,index2) in item.proTag" :key="index2"
:style="{'background':c.backColor,'color':c.backColor}">
<image class="fivecontent_item_boxitemlefttowimage" v-if="c.shareImg"
:src="c.shareImg" mode="aspectFill"></image>
<text class="fivecontent_item_boxitemlefttowtext">{{c.name}}</text>
</view>
</view>
<view class="indexboxitemleftthere flex-colum-start">
<view class="indexboxitemleftthereabsolute">
马上抢
</view>
<view class="indexboxitemlefttheretext flex-start">
<view class="fivecontent_item_boxitemlefthere_one flex-start">
<text class="flex_startone">到手</text>
<text class="flex_starttow">¥{{item.salePrice}}</text>
</view>
<view class="fivecontent_item_boxitemlefthere_tow">
{{item.discount || ''}}
</view>
<view class="fivecontent_item_boxitemlefthere_there">
¥{{item.originPrice}}
</view>
</view>
<view class="indexboxitemleftthere_countdown flex-between">
<text class="indexboxitemleftthere_countdowntext">共省{{item.save}}</text>
<view class="indexboxitemleftthere_countdowntexts">
<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>
<up-loadmore height='40' :status="formhomelist.status" iconSize='16' fontSize='16' />
</view>
<view class="componentsclass" v-if="showproductlist">
<AreaSelect v-if="viewHistoryindex == 0" @updateValue="openproductlist" />
<grouping v-if="viewHistoryindex == 1 || viewHistoryindex == 2 || viewHistoryindex == 3"
@grouping="openproductlist" />
</view>
</view>
<!-- 首页抢购区域 -->
<view class="fivecontent">
<view class="fivecontent_item" v-for="(item,index) in homelist" :key="index"
@click="fivecontentclick(item)">
<view class="fivecontent_item_nav flex-start">
<image :src="item.shopImage" mode="aspectFill"></image>
<view class="fivecontent_item_nav_left">
<view class="fivecontent_item_nav_lefttop flex-between">
<view>
{{item.shopName}}
</view>
<view>
{{item.districts}}&nbsp;{{item.distances}}
</view>
</view>
<view class="fivecontent_item_nav_lefttopstart flex-start">
<view class="fivecontent_item_nav_leftlang flex-start"
v-for="(s,index1) in item.shopTag" :key="index1"
:style="{'background':s.backColor,'color':s.backColor}">
<image class="fivecontent_item_nav_leftlangimage" v-if="s.shareImg"
:src="s.shareImg" mode="aspectFill"></image>
<text class="fivecontent_item_nav_leftlangtext">{{s.name}}</text>
</view>
</view>
</view>
</view>
<view class="fivecontent_item_box">
<view class="fivecontent_item_boxitem flex-between">
<image :src="`${item.image}?x-oss-process=image/resize,m_lfit,w_192,h_192`"
mode="aspectFill"></image>
<view class="fivecontent_item_boxitemleft flex-colum-start">
<view class="fivecontent_item_boxitemleftone flex-between"
style="display: flex;justify-content: space-between;align-items: center;">
<view>
{{item.productName.length>7?item.productName.substring(0,7)+'...':item.productName}}
</view>
<text>已抢{{item.realSalesNumber}}</text>
</view>
<view class="flex-start flexstartboxfttow">
<view class="fivecontent_item_boxitemlefttow flex-start"
v-for="(c,index2) in item.proTag" :key="index2"
:style="{'background':c.backColor,'color':c.backColor}">
<image class="fivecontent_item_boxitemlefttowimage" v-if="c.shareImg"
:src="c.shareImg" mode="aspectFill"></image>
<text class="fivecontent_item_boxitemlefttowtext">{{c.name}}</text>
</view>
</view>
<view class="indexboxitemleftthere flex-colum-start">
<view class="indexboxitemleftthereabsolute">
马上抢
</view>
<view class="indexboxitemlefttheretext flex-start">
<view class="fivecontent_item_boxitemlefthere_one flex-start">
<text class="flex_startone">到手</text>
<text class="flex_starttow">¥{{item.salePrice}}</text>
</view>
<view class="fivecontent_item_boxitemlefthere_tow">
{{item.discount || ''}}
</view>
<view class="fivecontent_item_boxitemlefthere_there">
¥{{item.originPrice}}
</view>
</view>
<view class="indexboxitemleftthere_countdown flex-between">
<text class="indexboxitemleftthere_countdowntext">共省{{item.save}}</text>
<view class="indexboxitemleftthere_countdowntexts">
<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>
<up-loadmore height='40' :status="formhomelist.status" iconSize='16' fontSize='16' />
</view>
</view>
<indexs v-if="showindex == 'shopIndex'"></indexs>
</view>
@ -171,14 +161,18 @@
import Nav from '@/components/indexnav.vue'; //
import {
APIhomehomePageUp,
APIhome,
APIshopUserInfo
APIhome
} from "@/common/api/index/index.js"
import {
APIshopUserInfo
} from "@/common/api/product/product.js"
import {
useNavbarStore
} from '@/stores/navbarStore';
import {
productStore
} from '@/stores/user.js';
const store = useNavbarStore();
//
store.updateNavbarConfig({
showBack: true, //
rightText: '', //
@ -219,12 +213,19 @@
const hometop = async () => {
try {
let res = await APIhomehomePageUp()
Object.assign(hometoplist, res.data)
Object.assign(hometoplist, res)
if (hometoplist.bannervo.counponsInfo) {
hometoplist.bannervo.counponsInfo.forEach((item, index) => {
advertisementStyle.value.push(getStyle(index))
})
}
// dom
setTimeout(() => {
const query = uni.createSelectorQuery().select('#fourcontent');
query.boundingClientRect((rect) => {
elementTop.value = rect.top - store.height
}).exec();
}, 500)
} catch (e) {}
}
//
@ -249,7 +250,7 @@
try {
let res = await APIhome(formhomelist)
var dates = new Date().getTime();
res.data.list.forEach((item, index) => {
res.list.forEach((item, index) => {
var leftTime = item.endTime - dates; //
if (leftTime >= 0) {
let d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
@ -266,9 +267,9 @@
item.end_times = 0
}
})
if (res.data.pages < formhomelist.page) {
if (res.pages < formhomelist.page) {
formhomelist.status = 'nomore'
if (form.page == 1 && res.data.list.length == 0) {
if (form.page == 1 && res.list.length == 0) {
}
return false;
@ -276,9 +277,9 @@
formhomelist.status = 'loading';
formhomelist.page = ++formhomelist.page;
setTimeout(() => {
homelist.value = [...homelist.value, ...res.data.list];
homelist.value = [...homelist.value, ...res.list];
formhomelist.status = 'loading';
if (res.data.pageNum == res.data.pages) {
if (res.pageNum == res.pages) {
formhomelist.status = 'nomore';
} else {
formhomelist.status = 'loading';
@ -341,28 +342,21 @@
onShow(() => {})
onMounted(async () => {
await proxy.$onLaunched;
console.log(uni.cache.get('shopId'))
if (uni.cache.get('shopId') && uni.cache.get('token')) {
showindex.value = 'shopIndex'
let res = await APIshopUserInfo({
"shopId": uni.cache.get('shopId'),
"userId": uni.getStorageSync('userInfo').id,
})
if (res.code == 0) {
if (res) {
//
uni.cache.set('shopUserInfo', res.data)
uni.cache.set('ShopUser', res)
}
} else {
hometop()
init_fn()
showindex.value = 'index'
//
setTimeout(() => {
const query = uni.createSelectorQuery().select('#fourcontent');
query.boundingClientRect((rect) => {
elementTop.value = rect.top - store.height
}).exec();
}, 500)
}
});
@ -383,16 +377,22 @@
background: #F9F9F9;
.fourcontent {
position: sticky;
padding: 32rpx 0;
overflow-x: auto;
flex-wrap: nowrap;
background: #f9f9f9;
margin: 0 32rpx;
z-index: 99;
left: 0;
.flex-between {
margin: 0 32rpx;
}
.componentsclass {
margin-top: 32rpx;
left: 0;
position: absolute;
position: relative;
width: 100%;
height: 100vh;
transition-duration: 350ms;

View File

@ -36,17 +36,14 @@
import {
ref,
onMounted,
reactive
reactive,
} from "vue";
import {
onShow,
} from '@dcloudio/uni-app'
import {
APIproductqueryShop
} from "@/common/api/product/product.js";
import {
APIshopExtend
} from "@/common/api/index/index.js";
import {
productStore
} from '@/stores/user.js';
const shopExtend = reactive({
autokey: "index_bg",
@ -59,34 +56,11 @@
value: ""
})
const userInfo = uni.cache.get('userInfo')
const shopUserInfo = uni.cache.get('shopUserInfo')
const shopUserInfo = uni.cache.get('ShopUser')
const scanCodehandle = (i) => {
uni.pro.navigateTo('product/index', {
tableCode: uni.cache.get('tableCode')
})
// uni.scanCode({
// success: async (res) => {
// let tableCode = getQueryString(decodeURIComponent(res.result), 'code')
// uni.cache.set('tableCode', tableCode)
// if (tableCode) {
// let data = await APIproductqueryShop({
// code: uni.cache.get('tableCode'),
// })
// 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('product/product', {
// tableCode: tableCode,
// })
// }
// }
// },
// fail: () => {}
// })
const scanCodehandle = async (i) => {
const store = productStore();
await store.scanCodeactions()
}
const memberindex = (url) => {
uni.pro.navigateTo(url, {
@ -102,12 +76,12 @@
}
return null;
}
onShow(async () => {
onMounted(async () => {
let res = await APIshopExtend({
shopId: uni.cache.get('shopId'),
autokey: "index_bg" //index_bg my_bg member_bg shopInfo_bg
})
Object.assign(shopExtend, res.data)
Object.assign(shopExtend, res)
})
</script>

View File

@ -1,6 +1,6 @@
<template>
<view>
<Nav />
<Nav v-if="store.scrollTop>=44" />
<view class="content">
</view>
</view>
@ -15,7 +15,8 @@
import {
onLoad,
onReady,
onShow
onShow,
onPageScroll
} from '@dcloudio/uni-app'
import Nav from '@/components/CustomNavbar.vue'; //
// pinia
@ -24,15 +25,23 @@
} from '@/stores/navbarStore';
const store = useNavbarStore();
// 44
const navScroll = ref(false)
//
store.updateNavbarConfig({
showBack: true, //
rightText: '', //
showSearch: true, //true
title: '我的页面',
title: '',
isTransparent: false,
hasPlaceholder: false //
});
//
onPageScroll((res) => {
uni.$u.debounce(store.scrollTop = res.scrollTop, 500)
});
</script>
<style lang="scss" scoped>

View File

@ -94,9 +94,9 @@
type: 'subShop', //Id/subShop-
orderBy: ''
})
console.log(res.data.carousel[0])
if (res.code == 0) {
toplist.value = res.data.carousel[0]
console.log(res.carousel[0])
if (res) {
toplist.value = res.carousel[0]
//
store.updateNavbarConfig({
showBack: true, //
@ -132,21 +132,21 @@
page: form.page, //
size: form.size, //
})
if (res.data.pages < form.page) {
if (res.pages < form.page) {
form.status = 'nomore'
if (form.page == 1 && res.data.list.length == 0) {
if (form.page == 1 && res.list.length == 0) {
list.value = []
}
return false;
} else {
form.status = 'loading';
if (form.page == 1) {
list.value = res.data.list
list.value = res.list
} else {
list.value = [...list.value, ...res.data.list];
list.value = [...list.value, ...res.list];
}
form.page = ++form.page;
if (form.page > res.data.pages) {
if (form.page > res.pages) {
form.status = 'nomore';
} else {
form.status = 'loading';

545
pages/order/index.vue Normal file
View File

@ -0,0 +1,545 @@
<template>
<view>
<view>
<!-- <view class="navtab flex-center">
<view class="navtabpost flex-center">
<view :class="navtabindex == 0 ? 'navtabone':'navtabtow'" @click="navtabclick(0)">
到店订单
</view>
<view :class="navtabindex == 1 ? 'navtabone':'navtabtow'" @click="navtabclick(1)">
团购订单
</view>
</view>
</view> -->
<up-sticky>
<view class="tab-wrap">
<view class="item" :class="{'active':active == index}" v-for="(item, index) in tabs" :key="index"
@click="orderswitch(item,index)">
<text>{{ item.name }}</text>
</view>
</view>
</up-sticky>
<view class="list-wrap" v-if="!is_end">
<view class="item" v-for="(item,index) in orderForm.list" :key="index" @click="orderinfo(item)">
<view class="header-wrap">
<view class="header-wrap-left">
<text class="sendType" v-if="item.sendType == 'post'">快递</text>
<text class="sendType" v-if="item.sendType == 'takeaway'">外卖</text>
<text class="sendType" v-if="item.sendType == 'takeself'">自提</text>
<text class="sendType" v-if="item.sendType == 'table'">堂食</text>
<text class="shopName"> {{ item.shopName || ''}} </text>
</view>
<text class="status" v-if="item.status == 'unpaid' || item.status == 'paying'">
<text style="color: #333;">待付款</text>
</text>
<text class="status" v-if="item.status == 'unsend'">
<text>待发货</text>
</text>
<text class="status" v-if="item.status == 'closed'">
<text>已完成</text>
</text>
<text class="status" v-if="item.status == 'send'">
<text> 已发</text>
</text>
<text class="status" v-if="item.status == 'refunding'">
<text>申请退单</text>
</text>
<text class="status" v-if="item.status == 'refund'">
<text>退单</text>
</text>
<text class="status" v-if="item.status == 'cancelled'">
<text>已取消</text>
</text>
<text class="status" v-if="item.status == 'merge'">
<text>合台</text>
</text>
</view>
<view class="content">
<view></view>
<view class="intro-wrap">
下单日期{{$u.timeFormat(item.createdAt, 'yyyy-mm-dd hh:MM')}}
</view>
<view class="shop-info">
<view class="shop-item">
<view class="cover" v-for="(item1,index1) in item.detailList" :key="index1">
<u-image width="112" height="112" radius="20" :src='item1.productImg'
v-if="item1.productId!=-999"></u-image>
<u-image width="112" height="112" radius="20"
:src="'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/table.png'"
mode="heightFix" v-else></u-image>
<text class="productName"> {{ item1.productName }} </text>
</view>
</view>
<view class="shop-amount">
<text class="orderAmount">{{item.orderAmount}}</text>
<text class="totalNumber">{{item.totalNumber}}</text>
</view>
</view>
</view>
<view class="footer-wrap">
<view class="btn" @click.stop="$u.debounce(isRemoveOrder(item,index),1000)"
v-if="item.status != 'unpaid' && item.status != 'paying'"> 删除订单 </view>
<view class="btn s" @click.stop="$u.debounce(showpopupclick(item),1000)"
v-if="item.status == 'unpaid' || item.status == 'paying'"> 去付款 </view>
</view>
</view>
</view>
<!-- 新订单 -->
<!-- <view class="orderList" v-if="navtabindex == 1">
<view class="listBox" v-for="(item,i) in groupList" :key="i" @click="orderinfoTo(item)">
<view class="df">
<view style="display: flex;">
<text>{{item.proName.length>10?item.proName.substring(0,10)+'...':item.proName}}</text><u-icon
name="arrow-right" color="#000" size="28"></u-icon>
</view>
<text
:class="[item.status=='unpaid'||item.status=='unused'?'state':'state2']">{{item.status|statusFirter}}</text>
</view>
<view class="df" style="justify-content: flex-start;margin-top: 32rpx;">
<image style="width:120rpx; height: 120rpx;border-radius: 12rpx 12rpx 12rpx 12rpx;"
:src="item.proImg" mode="aspectFill">
</image>
<view class="ml-20 fontStyle">
<view>数量{{item.number}}</view>
<view>实付<text style="color: #FF4C11;">{{item.payAmount}}</text></view>
</view>
</view>
<button v-if="item.status=='unused'" type="primary" class="buttonStyle">查看券码</button>
<button v-if="item.status=='unpaid'" type="primary" class="buttonStyle">去付款</button>
</view>
</view>
<image style="width: 402rpx;height: 442rpx;margin:240rpx auto 32rpx;"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/nomore.png" v-if="list.length <= 0 "
mode="aspectFill"></image>
<u-modal width="450rpx" :show="removeOrderShow" @confirm="$u.debounce(removeOrder(),1000)"
@cancel="removeOrderShow = false" @close="removeOrderShow = false" :showCancelButton="true"
:closeOnClickOverlay="true" :title="'是否删除当前订单'"></u-modal>-->
<u-loadmore :status="form.status" fontSize="14" color="#999" iconSize="14" />
</view>
</view>
</template>
<script setup>
import {
ref,
reactive,
onMounted
} from "vue";
import {
onLoad,
onReady,
onShow,
onPageScroll
} from '@dcloudio/uni-app'
import Nav from '@/components/CustomNavbar.vue'; //
import {
APIuserorder
} from '@/common/api/order/index.js'
// pinia
import {
useNavbarStore
} from '@/stores/navbarStore';
const store = useNavbarStore();
//
const tabs = [{
name: '全部',
type: 1,
status: ''
},
{
name: '待支付',
type: 2,
status: 'unpaid'
},
{
name: '待发货',
type: 3,
status: 'unsend'
},
{
name: '已完成',
type: 4,
status: 'closed'
},
{
name: '退款/售后',
type: 5,
status: 'refund'
},
]
//
const navtabindex = ref('2')
//
const orderForm = reactive({
list: [],
groupList: [],
is_end: [],
status: '',
form: {
page: 1,
size: 10,
status: 'loadmore',
}
})
const form = reactive({
page: 1,
size: 10,
status: 'loadmore',
})
//
// const getorderList = async () => {
// await API()
// }
//
const userorderList = async () => {
let res = await APIuserorder({
page: orderForm.form.page,
size: orderForm.form.size,
// status: orderForm.status
})
console.log(res)
if (res.totalPage == 1 && res.totalRow <= 10) {
orderForm.form.status = 'nomore'
orderForm.list = res.records
if (orderForm.form.page == 1 && res.records.length == 0) {
orderForm.records = []
orderForm.is_end = true
}
return false;
} else {
orderForm.form.status = 'loading';
orderForm.list = [...orderForm.list, ...res.records];
orderForm.form.page = ++orderForm.form.page;
if (orderForm.form.page > res.totalPage) {
orderForm.form.status = 'nomore';
} else {
orderForm.form.status = 'loading';
}
}
// if (res.totalPage < orderForm.form.page) {
// orderForm.form.status = 'nomore'
// if (orderForm.form.page == 1 && res.records.length == 0) {
// orderForm.records = []
// orderForm.is_end = true
// }
// return false;
// } else {
// orderForm.form.status = 'loading';
// if (orderForm.form.page == 1) {
// orderForm.list = res.list
// } else {
// orderForm.list = [...orderForm.records, ...res.records];
// }
// orderForm.form.page = ++orderForm.form.page;
// if (orderForm.form.page > res.pages) {
// orderForm.form.status = 'nomore';
// } else {
// orderForm.form.status = 'loading';
// }
// }
}
//
const init_fn = () => {
orderForm.groupList = []
orderForm.is_end = false
orderForm.form.page = 1
orderForm.form.size = 10
orderForm.form.status = 'loadmore'
navtabindex.value == '1' ? getorderList() : userorderList()
}
onShow(() => {
init_fn()
})
// onMounted(() => {})
</script>
<style scoped lang="scss">
page {
// background: #f6f6f6;
}
.navtab {
width: 100%;
height: 56rpx;
background: #ffd158;
.navtabpost {
position: relative;
background: #FFFFFF;
border-radius: 12rpx;
padding: 0 10rpx;
.navtabone {
// margin-left: -10rpx;
width: 166rpx;
height: 36rpx;
background: #FFEAB1;
border-radius: 12rpx;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 500;
font-size: 28rpx;
color: #333333;
line-height: 36rpx;
text-align: center;
z-index: 10;
}
.navtabtow {
// margin-left: -10rpx;
z-index: 9;
width: 146rpx;
height: 56rpx;
line-height: 56rpx;
text-align: center;
// border-radius: 0 12rpx 12rpx 0;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 24rpx;
color: #666666;
}
}
}
.tab-wrap {
display: flex;
position: relative;
background: #fff;
padding: 40rpx 46rpx;
border-radius: 0rpx 0rpx 34rpx 34rpx;
.item {
flex: auto;
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
position: relative;
z-index: 2;
text {
font-weight: 400;
font-size: 28rpx;
color: #999999;
}
}
.item.active {
text {
font-weight: bold;
font-size: 32rpx;
color: #000000;
}
}
}
.list-wrap {
padding: 0 28rpx 48rpx 28rpx;
position: relative;
margin-top: 48rpx;
border-radius: 24rpx 24rpx 0rpx 0rpx;
.item {
border-radius: 20upx;
background-color: #fff;
&:not(:first-child) {
margin-top: 48rpx;
}
.header-wrap {
padding: 16rpx 18rpx;
display: flex;
justify-content: space-between;
align-items: center;
.header-wrap-left {
display: flex;
align-items: center;
}
.sendType {
height: 48rpx;
line-height: 48rpx;
font-weight: 400;
font-size: 24rpx;
color: #E3AD7F;
border-radius: 10rpx 10rpx 10rpx 10rpx;
border: 2rpx solid #E3AD7F;
margin-right: 24rpx;
padding: 0 20rpx;
}
.shopName {
font-weight: bold;
font-size: 32rpx;
color: #333333;
}
.status {
text {
font-weight: 400;
font-size: 24rpx;
color: #666666;
}
}
}
.content {
padding: 0 18rpx 18rpx 18rpx;
.shop-info {
display: flex;
.shop-item {
width: 100%;
display: flex;
overflow: hidden;
overflow-x: scroll;
.cover:nth-child(1) {
margin-left: 0rpx;
}
.cover {
margin-left: 20rpx;
display: flex;
flex-direction: column;
align-items: center;
flex-shrink: 0;
.productName {
flex-shrink: 0;
margin-top: 16rpx;
}
}
}
.shop-amount {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-end;
flex-shrink: 0;
padding-left: 20rpx;
.orderAmount {
font-weight: bold;
font-size: 28rpx;
color: #333333;
margin-bottom: 22rpx;
}
.totalNumber {
font-weight: 400;
font-size: 24rpx;
color: #999999;
}
}
}
.intro-wrap {
font-weight: 400;
color: #666;
font-size: 24upx;
margin-bottom: 16rpx;
}
}
.footer-wrap {
display: flex;
justify-content: flex-end;
padding: 0 18rpx 32rpx 18rpx;
.btn {
width: 128rpx;
height: 48rpx;
line-height: 43rpx;
text-align: center;
background: #FFFFFF;
border-radius: 10rpx 10rpx 10rpx 10rpx;
border: 2rpx solid #EDEDED;
font-weight: 400;
font-size: 24rpx;
color: #333333;
margin-left: 32rpx;
}
.s {
background: #343030;
border: 2rpx solid #EDEDED;
color: #fff;
}
}
}
}
.orderList {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
.listBox {
padding: 16rpx 18rpx;
margin-top: 48rpx;
font-size: 32rpx;
width: 694rpx;
height: 248rpx;
background: #FFFFFF;
border-radius: 24rpx 24rpx 24rpx 24rpx;
position: relative;
.buttonStyle {
position: absolute;
right: 20rpx;
bottom: 50rpx;
font-size: 28rpx;
width: 170rpx;
height: 64rpx;
background: #FFD100;
border-radius: 32rpx 32rpx 32rpx 32rpx;
border: none;
color: #000;
}
.state {
color: #FF4C11;
}
.state2 {
color: #999;
}
.fontStyle {
font-size: 28rpx;
font-weight: 400;
color: #666666;
}
}
}
.df {
display: flex;
align-items: center;
justify-content: space-between;
}
.ml-20 {
margin-left: 20rpx;
}
</style>

View File

@ -0,0 +1,93 @@
<template>
<view>
<!-- 店铺详情 -->
<up-popup :show="showShopInfo" :round="20" mode="bottom" @close="showShopInfo = false" height="500">
<view class="shop-info-wrap">
<view class="info-wrap flex-between">
<view></view>
<text class="shopName">{{ shopInfo.shopName }}</text>
<view class="close" @click="showShopInfo = false">
<up-icon name="close" color="#999999" size="16"></up-icon>
</view>
</view>
<view class="info-wrap-title">商家信息</view>
<view class="row" style="margin-bottom: 20rpx;">
<view class="col">
<text class="l">营业时间</text>
<text
class="t">{{ (shopInfo.businessStartDay || '--') +'至'+ (shopInfo.businessEndDay || '--') +' '+ (shopInfo.businessTime || '')}}</text>
</view>
<view class="col">
<text class="l">商家地址</text>
<text class="t">{{ shopInfo.address }}</text>
</view>
<view class="col" @click="makePhoneCall(shopInfo.phone)">
<text class="l">商家电话</text>
<text class="t">{{ shopInfo.phone }}</text>
</view>
</view>
<view class="info-wrap-title">商家公告</view>
<view class="row">
<view class="col">
<text class="l">公告</text>
<text class="t">{{ shopInfo.detail }}</text>
</view>
</view>
</view>
</up-popup>
</view>
</template>
<script setup>
import {
ref,
defineExpose
} from "vue";
//
const showShopInfo = ref(false)
const shopInfo = uni.cache.get('shopInfo')
const childMethod = () => {
showShopInfo.value = !showShopInfo.value
};
defineExpose({
childMethod
});
</script>
<style lang="scss" scoped>
.shop-info-wrap {
padding: 0 30rpx 50rpx;
box-sizing: border-box;
.info-wrap {
padding: 30rpx 0;
box-sizing: border-box;
.shopName {
align-self: center;
font-size: 32rpx;
color: #333;
font-weight: bold;
}
}
.info-wrap-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
}
.row {
.col {
margin-bottom: 10rpx;
}
.l,
.t {
font-size: 24rpx;
color: #999;
}
}
}
</style>

View File

@ -0,0 +1,146 @@
<template>
<view class="cart-wrap" v-if="cartListsdatashow">
<view class="cart-content">
<view class="left">
<view class="iconBox">
<image class="icon" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/shopDetails/shopIcon.png"
mode="aspectFill" @click="isOpen">
</image>
<text class="u-badge"> {{cartLists_count<99?cartLists_count:'99+'}} </text>
</view>
<text class="i"></text>
<text class="num"
v-if="shopInfo.isVip == 1 && cartLists.memberAmount > 0">{{cartLists.memberAmount||'0.00'}}</text>
<text class="num" v-else>{{cartLists.amount||'0.00'}}</text>
</view>
<view class="btn" @tap="$u.debounce(orderdetail, 500)">
<text class="t">去结算</text>
</view>
</view>
</view>
</template>
<script setup>
import {
ref,
defineProps,
} from 'vue'
const shopInfo = uni.cache.get('shopInfo')
const cartListsdatashow = ref(false)
const showCart = ref(false)
const orderdetail = () => {
if (this.cartLists.data.length == 0) {
uni.showToast({
title: '请先添加商品',
icon: 'none'
})
return false
}
uni.navigateTo({
url: `/pagesOrder/confirm_order/index?storeInfo=${encodeURIComponent(JSON.stringify(this.storeInfo))}&cartLists=${JSON.stringify(this.cartLists)}&tableCode=${this.tableCode||''}`
});
}
const isOpen = () => {
showCart.value = !showCart.value
}
</script>
<style lang="scss">
.cart-wrap {
width: 100%;
padding: 0 20rpx;
box-sizing: border-box;
position: fixed;
bottom: 40rpx;
left: 0;
z-index: 99;
.cart-content {
display: flex;
align-items: center;
height: 128rpx;
background: #FFFFFF;
box-shadow: 0rpx 0rpx 20rpx 2rpx rgba(0, 0, 0, 0.15);
border-radius: 58rpx;
padding: 0 36rpx;
box-sizing: border-box;
.left {
flex: 1;
display: flex;
align-items: center;
position: relative;
.iconBox {
position: relative;
}
.icon {
width: 76rpx;
height: 88rpx;
margin-left: 22rpx;
}
.u-badge {
position: absolute;
top: -30rpx;
right: -30rpx;
background-color: #FF4B33;
color: #fff;
border-radius: 58rpx;
padding: 5rpx 14rpx;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
font-size: 20rpx;
}
.i,
.num {
color: #333;
}
.i {
font-size: 20upx;
position: relative;
top: 4upx;
margin-left: 64rpx;
}
.num {
font-size: 42upx;
font-weight: bold;
}
}
.btn {
height: 100%;
width: 40%;
display: flex;
align-items: center;
justify-content: flex-end;
.t {
width: 160rpx;
height: 64rpx;
line-height: 64rpx;
text-align: center;
background: #E7AE7B;
border-radius: 36rpx 36rpx 36rpx 36rpx;
border: 2rpx solid #E8AD7B;
font-weight: bold;
font-size: 28rpx;
color: #FFFFFF;
}
}
}
}
</style>

View File

@ -0,0 +1,397 @@
<template>
<view>
<up-popup :show="showCart" :round="20" :safeAreaInsetBottom="false" :zIndex="98" :overlayStyle="{ zIndex: 98 }"
@close="close">
<view class="cart-list-wrap">
<view class="cart-header flex-between">
<view class="num">已点 {{ cartLists_count }} </view>
<view class="clear" @click="cartclear">
<up-icon name="trash" color="#999"></up-icon>
<text class="t">清空</text>
</view>
</view>
<scroll-view scroll-y class="scroll-view">
<view class="list-wrap">
<view class="shop-item" v-for="(item,index) in props.cartList" :key="item.id">
<view class="shop-item-content">
<view class="cover" v-if="item.productId!=-999">
<up-image :src="item.coverImg" width="120" radius="10" height="120"></up-image>
</view>
<view class="info">
<view class="name"> {{ item.name }} </view>
<view class="select-sku-wrap" v-if="item.skuList">
<text v-for="i in item.skuList" :key="i.id">
{{item.id == i.productId && item.skuId == i.id ? i.specInfo :""}}
</text>
</view>
<view class="price-wrap" style="padding-top: 0;">
<view class="price">
<text class="i"></text>
<!-- 会员价与价格 -->
<text
class="price">{{shopInfo.isVip ==1?item.memberPrice:item.salePrice}}</text>
<!-- <text class="originalprice"
v-if="item.originPrice">¥{{item.originPrice}}</text>
<text class="unit" v-if="item.unitName">/{{item.unitName}}</text> -->
</view>
<view class="operation-wrap">
<view class="btn">
<up-icon name="minus-circle-fill" size="25"></up-icon>
<view class="btnClick" @click="cartListadd(item,'-')"></view>
</view>
<text class="num">{{ ifcartNumber(item) }}</text>
<view class="btn">
<!-- <up-icon name="plus-circle-fill"
:color="shopInfo.isVip == 1 ? '#CECECE' : '#E9AB7A'"
size="25"></up-icon> -->
<up-icon name="plus-circle-fill" color="#E9AB7A" size="25"></up-icon>
<view class="btnClick" @click="cartListadd(item,'+')"></view>
</view>
</view>
</view>
</view>
</view>
<!-- <view class="shop-item-remark" v-if="item.productId!=-999">
<view class="label">备注</view>
<up--input placeholder="商品备注(选填)" border="none" v-model="item.note"
@blur="productBlur(item)"></up--input>
</view> -->
</view>
</view>
</scroll-view>
</view>
</up-popup>
</view>
</template>
<script setup>
import {
ref,
defineProps,
computed,
defineEmits
} from 'vue';
import {
productStore
} from '@/stores/user.js';
//
const emits = defineEmits(['customevent', 'close']);
const props = defineProps({
cartList: {
type: Array
},
cartLists_count: {
type: Number,
default: 0
},
showCart: {
type: Boolean
},
});
const shopInfo = uni.cache.get('shopInfo')
// ifcartNumber
const ifcartNumber = computed(() => {
return (item) => {
// item cartNumber 0
if (!item || typeof item.cartNumber !== 'string') {
return 0;
}
let numValue = parseFloat(item.cartNumber);
if (isNaN(numValue)) {
// NaN cartNumber 0
return 0;
}
// type string single- sku- package- weight- coupon-
if (item.type === 'weight') {
//
return parseFloat(numValue.toFixed(2));
} else {
//
return Math.round(numValue);
}
//
return item.cartNumber;
};
})
const close = () => {
emits("close", false)
}
//
const cartListadd = async (item, i) => {
emits('customevent', {
id: item.cartListId ? item.cartListId : '',
type: 'shopping',
table_code: uni.cache.get('tableCode'),
shop_id: uni.cache.get('shopId'),
operate_type: calculateValue(item.cartNumber, i) == 'del' ? 'del' : item.cartListId &&
item.cartNumber > 0 ? 'edit' : 'add',
product_id: item.id,
sku_id: item.skuId,
number: await calculateValue(item.cartNumber, i),
})
}
//
const calculateValue = (cartNumber, i, step = 1) => {
if (i == '+') {
const result = parseFloat(cartNumber) + step;
return result.toFixed(2);
} else {
const result = parseFloat(cartNumber) - step;
return result == 0 ? 'del' : result.toFixed(2);
}
};
//
const productBlur = (item) => {
let params = {
"skuId": item.skuId,
"num": item.number, //
"type": item.type,
"isVip": item.isVip,
"productId": item.productId, //id
"note": item.note,
"shopId": this.shopId,
"userId": uni.cache.get('userInfo').id,
"tableId": this.tableCode,
}
this.$emit("addCart", params)
}
//
const cartclear = () => {
emits('customevent', {
type: 'shopping',
table_code: uni.cache.get('tableCode'),
shop_id: uni.cache.get('shopId'),
operate_type: 'cleanup',
})
}
</script>
<style lang="scss">
.cart-list-wrap {
.cart-header {
display: flex;
height: 72rpx;
background-color: #F2F2F2;
align-items: center;
justify-content: space-between;
padding: 20upx 28rpx;
border-radius: 20upx 20upx 0 0;
.num {
font-weight: 400;
font-size: 28rpx;
color: #333333;
}
.clear {
display: flex;
align-items: center;
.t {
font-size: 24upx;
color: #999;
margin-left: 4upx;
}
}
}
.scroll-view {
max-height: 50vh;
margin-bottom: 190rpx;
}
.list-wrap {
padding: 28rpx 0 0 28rpx;
}
.shop-item {
display: flex;
flex-direction: column;
padding-bottom: 28rpx;
.shop-item-content {
display: flex;
}
.shop-item-remark {
display: flex;
align-items: center;
padding-right: 180rpx;
margin-top: 10rpx;
.label {
font-size: 28rpx;
color: #666;
margin-right: 20rpx;
}
}
.langcover {
position: relative;
}
.langcover::after {
content: '加载中..';
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: #e8e8e8;
color: #6b6b6b;
border-radius: 10rpx;
text-align: center;
line-height: 180rpx;
z-index: 1;
}
.info {
flex: 1;
padding-left: 20upx;
padding-right: 28rpx;
.name {
font-size: 28upx;
font-weight: bold;
color: #333;
margin-bottom: 5rpx;
}
.select-sku-wrap {
font-weight: 400;
font-size: 24rpx;
color: #999999;
}
.price-wrap {
margin-top: 16rpx;
display: flex;
align-items: center;
justify-content: space-between;
.price {
display: flex;
align-items: flex-end;
.i,
.num {
font-weight: bold;
font-size: 32rpx;
color: #333333;
}
.i {
position: relative;
bottom: 4upx;
}
.price {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: bold;
font-size: 36rpx;
color: #333333;
}
.originalprice {
margin-left: 10rpx;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 20rpx;
text-decoration: line-through;
}
.unit {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 36rpx;
color: #333333;
}
.lineThrough {
font-weight: normal;
text-decoration: line-through;
color: #999 !important;
font-size: 24rpx !important;
}
}
.sku-wrap {
padding: 6upx 16upx;
background-color: #ffd100;
border-radius: 12upx;
display: flex;
align-items: center;
justify-content: center;
position: relative;
.t {
font-size: 24upx;
font-weight: bold;
}
.dot {
display: flex;
align-items: center;
justify-content: center;
font-size: 20upx;
position: absolute;
padding: 2upx 12upx;
border-radius: 8upx;
background-color: #eb5232;
color: #fff;
position: absolute;
top: -14upx;
right: -8upx;
}
}
.operation-wrap {
display: flex;
align-items: center;
.num {
font-size: 32upx;
padding: 0 16upx;
}
.btn {
position: relative;
display: flex;
align-items: center;
justify-content: center;
position: relative;
.btnClick {
width: 100rpx;
height: 100rpx;
position: absolute;
// bottom: 0;
}
.btnClick.l {
right: 0;
}
.btnClick.r {
left: 0;
}
}
}
}
}
}
}
</style>

File diff suppressed because it is too large Load Diff

View File

@ -166,7 +166,7 @@
params.shopId = this.shopId;
}
let res = await this.api.conponList(params)
if (res.code == 0) {
if (res) {
console.log(res)
let list = [];
if (this.type == 'confirm_order_coupon' || this.type == 'orderInfo_coupon') {
@ -331,7 +331,7 @@
} else {
uni.pro.navigateTo('/pages/order_food/order_food', {
uni.pro.navigateTo('/pages/product/index', {
shopId: item.shopId
})
}

View File

@ -9,7 +9,7 @@
<image class="my_info_left_head" :src="userInfo.headImg" mode="aspectFill"></image>
<view class="name">{{userInfo.nickName || '无'}}</view>
</view>
<image class="my_info_right_qr" @click="clickEvent" v-if="shopInfo.isVip!=0"
<image class="my_info_right_qr" @click="clickEvent" v-if="userInfo.isVip!=0"
:src="'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/my_qRcode.png'" mode="aspectFill">
</image>
<view class="my_info_right" @click="clickEvent" v-else>
@ -21,11 +21,26 @@
<view class="my_item my_assets">
<view class="my_item_title">我的资产</view>
<view class="my_assets_list">
<view class="my_list_item" @click="clickTo(item,index)" v-for="(item,index) in myAssetsList"
:key="index">
<image class="my_list_item_icon" :src="item.icon" mode="aspectFill"></image>
<view class="my_list_item_name">{{item.name}}</view>
<view class="my_list_item_num">{{item.num || '**'}}</view>
<view class="my_list_item">
<image class="my_list_item_icon"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/storedValue.png" mode="aspectFill">
</image>
<view class="my_list_item_name">储值</view>
<view class="my_list_item_num">{{userInfo.assetsSummary.amount || '0'}}</view>
</view>
<view class="my_list_item">
<image class="my_list_item_icon"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/points.png">
</image>
<view class="my_list_item_name">积分</view>
<view class="my_list_item_num">{{userInfo.assetsSummary.couponNum ||'0'}}</view>
</view>
<view class="my_list_item">
<image class="my_list_item_icon"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/coupon.png">
</image>
<view class="my_list_item_name">优惠券</view>
<view class="my_list_item_num">{{userInfo.assetsSummary.points ||'0'}}</view>
</view>
</view>
</view>
@ -33,8 +48,8 @@
<view class="my_item my_fun">
<view class="my_item_title">我的功能</view>
<view class="my_fun_list">
<view class="my_list_item" @click="clickTo(item,index)" v-for="(item,index) in myFunList"
:key="index">
<view class="my_list_item" v-for="(item,index) in myFunList" :key="index"
@click="clickTo(item,index)">
<view class="my_list_item_left">
<image class="my_list_item_icon" :src="item.icon" mode="aspectFill"></image>
<view class="my_list_item_name">{{item.name}}</view>
@ -63,28 +78,10 @@
onReady,
onShow
} from '@dcloudio/uni-app'
const myAssetsList = ref([
[{
name: "储值",
type: "recharge",
num: 0,
icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/storedValue.png"
},
{
name: "积分",
type: "points",
num: 0,
icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/points.png"
},
{
name: "优惠券",
type: "my_coupon",
num: 0,
icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/coupon.png"
},
// { name: "", type: "", num: 0, icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/equityCard.png"}
]
])
import {
productStore
} from '@/stores/user.js';
const store = productStore();
const myFunList = ref([{
name: "我的优惠券",
type: "my_coupon",
@ -108,15 +105,40 @@
},
// { name: "", type: "", icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/inRegard.png"},
])
const shopInfo = reactive({
isVip: 0
})
const userInfo = reactive({
nickName: '无名',
headImg: 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/my_member.png'
})
const teblist = ref([])
const shopExtend = ref(null)
const userInfo = ref({
headImg: '',
nickName: '',
isVip: '',
assetsSummary: {
amount: 0,
couponNum: 0,
points: 2
}
})
const clickEvent = () => {
if (uni.cache.get('shopId') && uni.cache.get('token')) {
if (this.userInfo.isVip == 0) {
uni.pro.navigateTo('member/memberdetails', {
shopId: uni.cache.get('shopId')
})
} else {
uni.navigateTo({
url: '/pages/pay_code/pay_code?userInfo=' + JSON.stringify(this.userInfo)
})
}
} else {
uni.pro.navigateTo('member/list', {
type: 'user_payCode'
})
}
}
onShow(async () => {
await store.actionsAPIuser()
userInfo.value = uni.cache.get('userInfo')
console.log(userInfo.value, 11)
})
</script>
<style scoped lang="scss">

View File

@ -13,7 +13,8 @@ export const useNavbarStore = defineStore('navbar', {
isTransparent: false,
height: 0,
hasPlaceholder: true,
scrollTop: 0 //滚动高度
scrollTop: 0 ,//滚动高度
screenHeight:375
}),
actions: {
updateNavbarConfig(config) {
@ -23,21 +24,21 @@ export const useNavbarStore = defineStore('navbar', {
uni.getSystemInfo({
success: (res) => {
const statusBarHeight = res.statusBarHeight;
// 总高度
this.screenHeight = res.screenHeight
let navBarHeight;
// 微信小程序的特殊处理
if (res.platform === 'weapp') {
if (res.uniPlatform === 'mp-weixin' || res.uniPlatform === 'mp-alipay') {
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
const topGap = menuButtonInfo.top - statusBarHeight;
const bottomGap = statusBarHeight + menuButtonInfo.height + topGap * 2 - (
menuButtonInfo.top + menuButtonInfo.height);
navBarHeight = menuButtonInfo.height + topGap + bottomGap;
navBarHeight = menuButtonInfo.height + topGap + bottomGap - 4;
} else if (uni.getSystemInfoSync().platform === 'ios') {
navBarHeight = 44;
} else {
navBarHeight = 48;
}
this.height = statusBarHeight + navBarHeight;
},
fail: (err) => {

View File

@ -1,88 +0,0 @@
import {
defineStore
} from 'pinia';
import {
ref
} from 'vue';
import {
APIcustomlogin
} from '@/common/api/api.js'
export const Storelogin = defineStore('login', {
state: () => ({
token: '',
miniAppOpenId: '',
userInfo: ''
}),
actions: {
actionslogin() {
return new Promise((resolve, reject) => {
// #ifdef MP-WEIXIN
uni.login({
provider: 'weixin',
success: (data) => {
// 微信小程序环境
uni.getUserInfo({
provider: 'weixin',
success: async (infoRes) => {
let res = await APIcustomlogin({
code: data.code, //临时登录凭证
rawData: infoRes.rawData,
source: 'wechat'
})
if (res.code == 0) {
this.token = res.data.token
this.miniAppOpenId = res.data.userInfo
.miniAppOpenId
this.userInfo = res.data.userInfo
uni.cache.set('token', res.data.token);
uni.cache.set('miniAppOpenId', res.data
.userInfo
.miniAppOpenId)
uni.cache.set('userInfo', res.data
.userInfo);
}
resolve(true);
},
fail: (err) => {
reject(false);
}
});
}
});
// #endif
// #ifdef MP-ALIPAY
my.getAuthCode({
scopes: 'auth_base',
success: async (data) => {
console.log(data)
// 支付宝小程序环境
// my.getAuthUserInfo({
// success: async (infoRes) => {
let res = await APIcustomlogin({
code: data.authCode, //临时登录凭证
// rawData: JSON.stringify(infoRes),
source: 'alipay'
})
if (res.code == 0) {
this.token = res.data.token
this.miniAppOpenId = res.data.userInfo.miniAppOpenId
this.userInfo = res.data.userInfo
uni.cache.set('token', res.data.token);
uni.cache.set('miniAppOpenId', res.data.userInfo
.miniAppOpenId)
uni.cache.set('userInfo', res.data.userInfo);
resolve(true);
}
},
fail: (err) => {
reject(false);
}
});
}
});
// #endif
}).catch((e) => {});
}
}
});

230
stores/user.js Normal file
View File

@ -0,0 +1,230 @@
import {
defineStore
} from 'pinia';
import {
ref
} from 'vue';
import {
APIuserlogin,
APIuser
} from '@/common/api/api.js'
import {
APIproductqueryShop,
APIshopUserInfo
} from '@/common/api/product/product.js'
export const Storelogin = defineStore('login', {
state: () => ({
token: '',
miniAppOpenId: '',
userInfo: ''
}),
actions: {
actionslogin() {
return new Promise(async (resolve, reject) => {
// #ifdef MP-WEIXIN
uni.login({
provider: 'weixin',
success: (data) => {
// 微信小程序环境
uni.getUserInfo({
provider: 'weixin',
success: async (infoRes) => {
let res = await APIuserlogin({
code: data.code, //临时登录凭证
rawData: infoRes.rawData,
source: 'wechat'
})
if (res) {
this.token = res.token
this.miniAppOpenId = res.userInfo
.miniAppOpenId
this.userInfo = res.userInfo
uni.cache.set('token', res.token);
uni.cache.set('openId', res
.userInfo
.wechatOpenId)
uni.cache.set('userInfo', res
.userInfo);
}
resolve(true);
},
fail: (err) => {
reject(false);
}
});
}
});
// #endif
// #ifdef MP-ALIPAY
my.getAuthCode({
scopes: 'auth_base',
success: async (data) => {
// 支付宝小程序环境
// my.getAuthUserInfo({
// success: async (infoRes) => {
let res = await APIuserlogin({
code: data.authCode, //临时登录凭证
// rawData: JSON.stringify(infoRes),
source: 'alipay'
})
if (res) {
this.token = res.token
this.miniAppOpenId = res.userInfo.miniAppOpenId
this.userInfo = res.userInfo
uni.cache.set('token', res.token);
uni.cache.set('openId', res.userInfo
.alipayOpenId)
uni.cache.set('userInfo', res.userInfo);
resolve(true);
}
},
fail: () => {
reject(false);
}
})
// #endif
})
}
}
});
export const productStore = defineStore('product', {
actions: {
getQueryString(url, name) { //解码
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
var r = url.substr(1).match(reg)
if (r != null) {
return r[2]
}
return null;
},
// 扫码请求
scanCodeactions() {
return new Promise(async (resolve, reject) => {
// #ifdef APP || MP-WEIXIN || MP-ALIPAY
uni.scanCode({
success: async (res) => {
let tableCode = this.getQueryString(
decodeURIComponent(res
.result),
'code')
// 储存卓玛
uni.cache.set('tableCode', tableCode)
if (tableCode) {
let data = await this.actionsproductqueryShop()
// -4请求登录
const store = Storelogin()
if (data.code == '-4') {
if (await store.actionslogin()) {
// 成功 接着在调用
await this.actionsproductqueryShop()
}
}
if (uni.cache.get('productInfo')
.shopTableInfo && !uni
.cache.get('productInfo')
.shopTableInfo
.choseCount) {
uni.pro.navigateTo(
'/pagesOrder/orderAMeal/index', {
tableCode: tableCode,
shopId: uni.cache.get(
'shopId'),
})
} else {
uni.pro.navigateTo(
'product/index', {
tableCode: tableCode,
})
}
}
},
fail: (res) => {
console.log(111)
console.log(res)
}
});
// #endif
// #ifdef H5
if (uni.cache.get('tableCode')) {
let data = await this.actionsproductqueryShop()
// -4请求登录
const store = Storelogin()
if (data.code == '-4') {
if (await store.actionslogin()) {
// 成功 接着在调用
await this.actionsproductqueryShop()
}
}
if (uni.cache.get('productInfo').shopTableInfo && !uni
.cache.get('productInfo').shopTableInfo.choseCount) {
uni.pro.navigateTo('/pagesOrder/orderAMeal/index', {
tableCode: uni.cache.get('tableCode'),
shopId: uni.cache.get('shopId'),
})
} else {
uni.pro.navigateTo('product/index', {
tableCode: uni.cache.get('tableCode'),
})
}
}
// #endif
})
},
// /通过桌码获取店铺信息
actionsproductqueryShop() {
return new Promise(async (resolve, reject) => {
try {
let res = await APIproductqueryShop({
tableCode: uni.cache.get('tableCode'),
})
// 店铺信息
uni.cache.set('shopTable', res.shopTable)
// 台桌信息
uni.cache.set('shopInfo', res.shopInfo)
uni.cache.set('shopId', res.shopTable.shopId)
// 当前用户距离店铺的米数
uni.cache.set('distance', res.distance)
resolve(res)
} catch (e) {
reject(false)
}
})
},
// 获取店铺会员信息
actionsproductqueryProduct() {
return new Promise(async (resolve, reject) => {
try {
let res = await APIshopUserInfo({
"shopId": uni.cache.get('shopId'),
"userId": uni.cache.get('userInfo').id
})
uni.cache.set('ShopUser', res)
resolve(true)
} catch (e) {
reject(false)
}
})
},
// 用户信息获取
actionsAPIuser() {
return new Promise(async (resolve, reject) => {
try {
let res = await APIuser()
uni.cache.set('userInfo', res);
resolve(true)
} catch (e) {
reject(false)
}
})
}
}
});

View File

@ -9,7 +9,7 @@ export default defineConfig({
hmr: true,
proxy: {
'/api': {
target: 'https://cashier.sxczgkj.cn',
target: 'https://tapi.cashier.sxczgkj.cn',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, ''),
secure: false