├── back-end-python ├── .idea │ ├── .gitignore │ ├── misc.xml │ ├── inspectionProfiles │ │ └── profiles_settings.xml │ ├── modules.xml │ └── back-end-python.iml └── seproject_app │ ├── __init__.py │ ├── __pycache__ │ ├── crud.cpython-310.pyc │ ├── main.cpython-310.pyc │ ├── models.cpython-310.pyc │ ├── __init__.cpython-310.pyc │ ├── database.cpython-310.pyc │ └── schemas.cpython-310.pyc │ ├── data │ ├── __pycache__ │ │ └── data.cpython-310.pyc │ └── data.py │ ├── database.py │ ├── models.py │ ├── schemas.py │ ├── crud.py │ └── main.py ├── front-end-WeChat-applet ├── component │ └── model │ │ ├── model.json │ │ ├── model.wxml │ │ ├── model.js │ │ └── model.wxss ├── pages │ ├── check │ │ ├── check.json │ │ ├── check.wxml │ │ ├── check.js │ │ └── check.wxss │ ├── food │ │ ├── food.json │ │ ├── food.wxml │ │ ├── food.js │ │ └── food.wxss │ ├── order │ │ ├── order.json │ │ ├── order.wxml │ │ ├── order.wxss │ │ └── order.js │ ├── Aboutus │ │ ├── Aboutus.js │ │ ├── Aboutus.json │ │ ├── Aboutus.wxml │ │ └── Aboutus.wxss │ ├── AllOrder │ │ ├── AllOrder.json │ │ ├── AllOrder.wxml │ │ ├── AllOrder.js │ │ └── AllOrder.wxss │ ├── comment │ │ ├── comment.json │ │ ├── comment.wxml │ │ ├── comment.wxss │ │ └── comment.js │ ├── personal │ │ ├── personal.json │ │ ├── personal.js │ │ ├── personal.wxml │ │ └── personal.wxss │ ├── paySuccess │ │ ├── paySuccess.json │ │ ├── paySuccess.wxml │ │ ├── paySuccess.wxss │ │ └── paySuccess.js │ └── home │ │ ├── home.json │ │ ├── home.wxml │ │ ├── home.wxss │ │ └── home.js ├── images │ ├── home.png │ ├── jie.jpg │ ├── logo.jpg │ ├── ping.jpg │ ├── camera.png │ ├── check.jpg │ ├── delete.png │ ├── fankui.jpg │ ├── hback.jpg │ ├── home-1.png │ ├── logos.png │ ├── minute.png │ ├── oback.jpg │ ├── order.png │ ├── pback.jpg │ ├── add-icon.png │ ├── comment-1.png │ ├── comment.png │ ├── delete1.png │ ├── oback123.jpg │ ├── personal.png │ ├── shopicon.png │ ├── star_off.png │ ├── star_on.png │ ├── personal-1.png │ ├── radio_none.png │ └── radio_show.png ├── sitemap.json ├── app.wxss ├── app.js ├── utils │ └── util.js ├── .eslintrc.js ├── app.json ├── project.private.config.json └── project.config.json ├── 期末展示.pptx ├── 讨论题.docx ├── 需求规约 .pdf ├── README.md ├── 概要设计规约.pdf ├── 详细设计规约.pdf └── 需求分析规约.pdf /back-end-python/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # 默认忽略的文件 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/component/model/model.json: -------------------------------------------------------------------------------- 1 | { 2 | "component": true 3 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/check/check.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/food/food.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/order/order.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/Aboutus/Aboutus.js: -------------------------------------------------------------------------------- 1 | // pages/Aboutus/Aboutus.js 2 | Page({}) -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/Aboutus/Aboutus.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/AllOrder/AllOrder.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/comment/comment.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/personal/personal.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/paySuccess/paySuccess.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": {} 3 | } -------------------------------------------------------------------------------- /期末展示.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/期末展示.pptx -------------------------------------------------------------------------------- /讨论题.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/讨论题.docx -------------------------------------------------------------------------------- /需求规约 .pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/需求规约 .pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Campus-online-ordering-system 2 | 校园线上点餐系统——前端原生微信小程序,后端python的fastapi框架,数据库mysql 3 | -------------------------------------------------------------------------------- /概要设计规约.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/概要设计规约.pdf -------------------------------------------------------------------------------- /详细设计规约.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/详细设计规约.pdf -------------------------------------------------------------------------------- /需求分析规约.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/需求分析规约.pdf -------------------------------------------------------------------------------- /back-end-python/seproject_app/__init__.py: -------------------------------------------------------------------------------- 1 | # __init__.py文件只是一个空文件,但它告诉Python把seproject_app作为一个模块来使用 2 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/home/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "usingComponents": { 3 | "model": "/component/model/model" 4 | } 5 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/home.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/jie.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/jie.jpg -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/logo.jpg -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/ping.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/ping.jpg -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/camera.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/check.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/check.jpg -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/delete.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/fankui.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/fankui.jpg -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/hback.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/hback.jpg -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/home-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/home-1.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/logos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/logos.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/minute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/minute.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/oback.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/oback.jpg -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/order.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/order.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/pback.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/pback.jpg -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/add-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/add-icon.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/comment-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/comment-1.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/comment.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/delete1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/delete1.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/oback123.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/oback123.jpg -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/personal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/personal.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/shopicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/shopicon.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/star_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/star_off.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/star_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/star_on.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/personal-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/personal-1.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/radio_none.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/radio_none.png -------------------------------------------------------------------------------- /front-end-WeChat-applet/images/radio_show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/front-end-WeChat-applet/images/radio_show.png -------------------------------------------------------------------------------- /back-end-python/seproject_app/__pycache__/crud.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/back-end-python/seproject_app/__pycache__/crud.cpython-310.pyc -------------------------------------------------------------------------------- /back-end-python/seproject_app/__pycache__/main.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/back-end-python/seproject_app/__pycache__/main.cpython-310.pyc -------------------------------------------------------------------------------- /back-end-python/seproject_app/__pycache__/models.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/back-end-python/seproject_app/__pycache__/models.cpython-310.pyc -------------------------------------------------------------------------------- /back-end-python/seproject_app/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/back-end-python/seproject_app/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /back-end-python/seproject_app/__pycache__/database.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/back-end-python/seproject_app/__pycache__/database.cpython-310.pyc -------------------------------------------------------------------------------- /back-end-python/seproject_app/__pycache__/schemas.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/back-end-python/seproject_app/__pycache__/schemas.cpython-310.pyc -------------------------------------------------------------------------------- /back-end-python/seproject_app/data/__pycache__/data.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wu-hao-ze/Campus-online-ordering-system/HEAD/back-end-python/seproject_app/data/__pycache__/data.cpython-310.pyc -------------------------------------------------------------------------------- /back-end-python/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/sitemap.json: -------------------------------------------------------------------------------- 1 | { 2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", 3 | "rules": [ 4 | { 5 | "action": "allow", 6 | "page": "*" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /back-end-python/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/app.wxss: -------------------------------------------------------------------------------- 1 | /**app.wxss**/ 2 | .container { 3 | height: 100%; 4 | display: flex; 5 | flex-direction: column; 6 | align-items: center; 7 | justify-content: space-between; 8 | padding: 200rpx 0; 9 | box-sizing: border-box; 10 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/Aboutus/Aboutus.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 同济 6 | 7 | 8 | whz制作 9 | 2022-12-14 10 | -------------------------------------------------------------------------------- /back-end-python/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /back-end-python/.idea/back-end-python.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/app.js: -------------------------------------------------------------------------------- 1 | // app.js 2 | App({ 3 | onLaunch() { 4 | // 展示本地存储能力 5 | const logs = wx.getStorageSync('logs') || [] 6 | logs.unshift(Date.now()) 7 | wx.setStorageSync('logs', logs) 8 | 9 | // 登录 10 | wx.login({ 11 | success: res => { 12 | // 发送 res.code 到后台换取 openId, sessionKey, unionId 13 | } 14 | }) 15 | }, 16 | globalData: { 17 | userInfo: null 18 | } 19 | }) 20 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/Aboutus/Aboutus.wxss: -------------------------------------------------------------------------------- 1 | .background { 2 | width: 100%; 3 | height: 100%; 4 | position: fixed; 5 | z-index: -1; 6 | } 7 | 8 | .tongji { 9 | padding-top: 90rpx; 10 | padding-left: 200rx; 11 | z-index: 1; 12 | text-align: center; 13 | font-size: 80rpx; 14 | font-family: STxingkai; 15 | } 16 | 17 | .do { 18 | padding-top: 500rpx; 19 | padding-left: 200rx; 20 | text-align: center; 21 | font-size: 50rpx; 22 | font-family: STxingkai; 23 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/utils/util.js: -------------------------------------------------------------------------------- 1 | const formatTime = date => { 2 | const year = date.getFullYear() 3 | const month = date.getMonth() + 1 4 | const day = date.getDate() 5 | const hour = date.getHours() 6 | const minute = date.getMinutes() 7 | const second = date.getSeconds() 8 | return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}` 9 | } 10 | 11 | const formatNumber = n => { 12 | n = n.toString() 13 | return n[1] ? n : `0${n}` 14 | } 15 | 16 | module.exports = { 17 | formatTime 18 | } 19 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/paySuccess/paySuccess.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 支付成功 9 | 10 | 取餐号:{{orderid}} 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /back-end-python/seproject_app/data/data.py: -------------------------------------------------------------------------------- 1 | type = "mysql+pymysql" 2 | username = "root" 3 | password = "123456" 4 | ipaddrsss = "127.0.0.1" 5 | port = 3306 6 | schema = "seproject" 7 | 8 | SQLALCHEMY_DATABASE_URL = f"{type}://{username}:{password}@{ipaddrsss}:{port}/{schema}" 9 | imgprefix = "http://127.0.0.1:8000/source/" 10 | testopenid = "oxxHL5GS26iMW6iSMzfoLjXk1luw" 11 | imgpath = "../wxfile/source/seproject/" 12 | 13 | wxurl = "https://api.weixin.qq.com/sns/jscode2session" 14 | wxappid = "wx27cc35bd452e6ec4" 15 | wxsecret = "11dcbb7eb2d66961d8efe970de02c2fa" 16 | 17 | # 在终端中通过uvicorn启动 18 | # uvicorn seproject_app.main:app --reload -------------------------------------------------------------------------------- /front-end-WeChat-applet/.eslintrc.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Eslint config file 3 | * Documentation: https://eslint.org/docs/user-guide/configuring/ 4 | * Install the Eslint extension before using this feature. 5 | */ 6 | module.exports = { 7 | env: { 8 | es6: true, 9 | browser: true, 10 | node: true, 11 | }, 12 | ecmaFeatures: { 13 | modules: true, 14 | }, 15 | parserOptions: { 16 | ecmaVersion: 2018, 17 | sourceType: 'module', 18 | }, 19 | globals: { 20 | wx: true, 21 | App: true, 22 | Page: true, 23 | getCurrentPages: true, 24 | getApp: true, 25 | Component: true, 26 | requirePlugin: true, 27 | requireMiniProgram: true, 28 | }, 29 | // extends: 'eslint:recommended', 30 | rules: {}, 31 | } 32 | -------------------------------------------------------------------------------- /back-end-python/seproject_app/database.py: -------------------------------------------------------------------------------- 1 | # database.py文件创建与数据库的连接 2 | from sqlalchemy import create_engine 3 | from sqlalchemy.ext.declarative import declarative_base 4 | from sqlalchemy.orm import sessionmaker 5 | 6 | from .data.data import SQLALCHEMY_DATABASE_URL 7 | 8 | # 数据库访问地址,这部分移到data.py中了 9 | # SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db" 10 | # SQLALCHEMY_DATABASE_URL = "mysql+pymysql://user:password@127.0.0.1:3306/db" 11 | #使用pymysql作为驱动,db是数据库名称 12 | 13 | # 启动引擎 14 | engine = create_engine( 15 | SQLALCHEMY_DATABASE_URL, 16 | encoding="utf-8", 17 | echo=True 18 | ) 19 | 20 | # 启动会话 21 | SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) 22 | 23 | # 返回一个类,后续作为数据库模型的基类(ORM模型) 24 | Base = declarative_base() 25 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/home/home.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | {{item.shopText}} 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/check/check.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{shopcomment.orderShop}}的订单 7 | 8 | 9 | 下单菜品: 10 | 11 | {{shopcomment.orderDesc}} 12 | 13 | 14 | 15 | 16 | 您的评价 17 | 18 | 19 | {{text}} 20 | 21 | 商家回复评价 22 | 23 | 商家未回复 24 | {{store_text}} 25 | {{time}} 26 | 27 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/AllOrder/AllOrder.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 总价:{{item.orderPrice}}元 16 | 17 | 已评价 18 | 未评价 19 | 20 | 21 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/component/model/model.wxml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/comment/comment.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 交易评分: 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | {{score_text}} 19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 |
-------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/AllOrder/AllOrder.js: -------------------------------------------------------------------------------- 1 | // pages/AllOrder/AllOrder.js 2 | Page({ 3 | /** 4 | * 页面的初始数据 5 | */ 6 | data: { 7 | orderList: [], 8 | }, 9 | 10 | getComment(e) { 11 | var shopcomment = JSON.stringify(e.currentTarget.dataset.item); 12 | wx.setStorageSync("shopcomment", shopcomment); 13 | if (!e.currentTarget.dataset.item.orderComment) { 14 | wx.navigateTo({ 15 | url: '../comment/comment' 16 | }) 17 | } 18 | else { 19 | wx.navigateTo({ 20 | url: '../check/check' 21 | }) 22 | } 23 | }, 24 | 25 | /** 26 | * 生命周期函数--监听页面显示 27 | */ 28 | onShow: function () { 29 | var that = this 30 | wx.request({ 31 | url: 'http://127.0.0.1:8000/api/seproject/getAllOrders', 32 | header: { 33 | 'cookie': wx.getStorageSync('set-cookie') 34 | }, 35 | success: function (res) { 36 | console.log(res.cookie) 37 | that.setData({ 38 | orderList: res.data.data, 39 | }) 40 | } 41 | }) 42 | }, 43 | }) -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/personal/personal.js: -------------------------------------------------------------------------------- 1 | // pages/personal/personal.js 2 | Page({ 3 | 4 | /** 5 | * 页面的初始数据 6 | */ 7 | data: { 8 | 9 | }, 10 | Aboutus(e) { 11 | wx.navigateTo({ 12 | url: '../Aboutus/Aboutus', 13 | }) 14 | }, 15 | /** 16 | * 生命周期函数--监听页面加载 17 | */ 18 | onLoad: function (options) { 19 | }, 20 | 21 | /** 22 | * 生命周期函数--监听页面初次渲染完成 23 | */ 24 | onReady: function () { 25 | 26 | }, 27 | 28 | /** 29 | * 生命周期函数--监听页面显示 30 | */ 31 | onShow: function () { 32 | 33 | }, 34 | 35 | /** 36 | * 生命周期函数--监听页面隐藏 37 | */ 38 | onHide: function () { 39 | 40 | }, 41 | 42 | /** 43 | * 生命周期函数--监听页面卸载 44 | */ 45 | onUnload: function () { 46 | 47 | }, 48 | 49 | /** 50 | * 页面相关事件处理函数--监听用户下拉动作 51 | */ 52 | onPullDownRefresh: function () { 53 | 54 | }, 55 | 56 | /** 57 | * 页面上拉触底事件的处理函数 58 | */ 59 | onReachBottom: function () { 60 | 61 | }, 62 | 63 | /** 64 | * 用户点击右上角分享 65 | */ 66 | onShareAppMessage: function () { 67 | 68 | } 69 | }) -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/check/check.js: -------------------------------------------------------------------------------- 1 | // pages/check/check.js 2 | Page({ 3 | 4 | /** 5 | * 页面的初始数据 6 | */ 7 | data: { 8 | shopcomment: {}, 9 | text: "", 10 | score: 0, 11 | time: "", 12 | store_text: "" 13 | }, 14 | back: function (e) { 15 | wx.switchTab({ 16 | url: '../AllOrder/AllOrder' 17 | }) 18 | }, 19 | 20 | /** 21 | * 生命周期函数--监听页面加载 22 | */ 23 | onLoad: function (options) { 24 | var shopcomment = JSON.parse(wx.getStorageSync("shopcomment")); 25 | this.setData({ 26 | shopcomment: shopcomment, 27 | }) 28 | console.log(shopcomment) 29 | var that = this 30 | wx.request({ 31 | url: 'http://127.0.0.1:8000/api/seproject/getComment', 32 | method: "GET", 33 | data: { 34 | order_id: that.data.shopcomment.order_id, 35 | }, 36 | success: function (res) { 37 | console.log(res) 38 | that.setData({ 39 | text: res.data.data.user_text, 40 | score: res.data.data.user_score, 41 | time: res.data.data.user_time, 42 | store_text: res.data.data.store_text 43 | }) 44 | } 45 | }) 46 | }, 47 | }) -------------------------------------------------------------------------------- /front-end-WeChat-applet/component/model/model.js: -------------------------------------------------------------------------------- 1 | /** 2 | * > 组件名:mask-alert 3 | * > 调用方式第一步:JSON引入"model":"../components/model/model" 4 | * > 调用方式第二步:页面引入 5 | 0 */ 6 | Component({ 7 | properties: { 8 | modalStart: { 9 | type: Boolean, 10 | value: false 11 | }, 12 | }, 13 | /** 14 | * 注意:diffid[1:成功中奖弹窗;2:未中奖弹窗;] 15 | */ 16 | data: { 17 | logo: "../../images/logos.png" 18 | }, 19 | methods: { 20 | /** 21 | * 取消事件 22 | */ 23 | getCance: function () { 24 | console.log("getCance"); 25 | this.setData({ 26 | modalStart: false 27 | }) 28 | 29 | }, 30 | getse() { 31 | this.setData({ 32 | modalStart: false, 33 | }) 34 | }, 35 | /** 36 | * 组件中传值 37 | */ 38 | getOenMask(res) { 39 | wx.setStorageSync("userinfo", res.detail.userInfo); 40 | var sessionKey = wx.getStorageSync("sessionKey"); 41 | console.log("res", res.detail.userInfo); 42 | return; 43 | }, 44 | // 显示 45 | getShow(res) { 46 | console.log("获取==>", res); 47 | this.setData({ 48 | modalStart: true 49 | }) 50 | }, 51 | } 52 | }) -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/paySuccess/paySuccess.wxss: -------------------------------------------------------------------------------- 1 | .background { 2 | width: 100%; 3 | height: 100%; 4 | position: fixed; 5 | z-index: -1; 6 | } 7 | 8 | .paycont { 9 | position: relative; 10 | width: 100%; 11 | height: 100vh; 12 | } 13 | 14 | .payimgView { 15 | position: relative; 16 | width: 100%; 17 | text-align: center; 18 | top: 50rpx; 19 | height: 300rpx; 20 | padding-top: 50rpx; 21 | } 22 | 23 | .pay_icon { 24 | width: 120rpx; 25 | position: relative; 26 | margin: 30rpx 0px; 27 | height: 150rpx; 28 | text-align: center; 29 | display: inline-block; 30 | } 31 | 32 | .paytext { 33 | position: relative; 34 | width: 100%; 35 | text-align: center; 36 | font-size: 50rpx; 37 | font-family: STxingkai; 38 | } 39 | 40 | .backVIew { 41 | position: relative; 42 | text-align: center; 43 | top: 20%; 44 | width: 100%; 45 | } 46 | 47 | /* 。back_index{} */ 48 | .back_index { 49 | position: relative; 50 | margin: 0 auto; 51 | border-radius: 25rpx; 52 | width: 400rpx; 53 | color: rgba(255, 255, 255, 0.74); 54 | height: 100rpx; 55 | line-height: 100rpx; 56 | background: #FB990A; 57 | font-size: 50rpx; 58 | font-family: STxingkai; 59 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/personal/personal.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 我的订单 17 | 18 | 19 | 20 | 订单以及评价 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/check/check.wxss: -------------------------------------------------------------------------------- 1 | .background { 2 | width: 100%; 3 | height: 100%; 4 | position: fixed; 5 | z-index: -1; 6 | } 7 | 8 | .release { 9 | font-family: STxingkai; 10 | color: #fff; 11 | background: #f95807; 12 | margin: 0 10%; 13 | width: 80%; 14 | height: 80rpx; 15 | line-height: 80rpx; 16 | position: fixed; 17 | } 18 | 19 | .body { 20 | font-family: STkaiti; 21 | color: rgb(15, 10, 3); 22 | } 23 | 24 | .rightup { 25 | padding-top: 30rpx; 26 | text-align: center; 27 | font-size: 60rpx; 28 | } 29 | 30 | .order { 31 | padding-top: 30rpx; 32 | padding-left: 10rpx; 33 | text-align: center; 34 | font-size: 38rpx; 35 | } 36 | 37 | .mark { 38 | padding-top: 100rpx; 39 | text-align: center; 40 | font-size: 50rpx; 41 | } 42 | 43 | .pingjia { 44 | text-align: center; 45 | padding-bottom: 100rpx; 46 | } 47 | 48 | .mark_shop { 49 | margin-top: 50rpx; 50 | text-align: center; 51 | font-size: 50rpx; 52 | } 53 | 54 | .no { 55 | text-align: center; 56 | padding-bottom: 10rpx; 57 | } 58 | 59 | .yes { 60 | text-align: center; 61 | padding-bottom: 10rpx; 62 | } 63 | 64 | .time { 65 | padding-top: 20rpx; 66 | padding-bottom: 50rpx; 67 | text-align: center; 68 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/paySuccess/paySuccess.js: -------------------------------------------------------------------------------- 1 | // pages/paySuccess/paySuccess.js 2 | Page({ 3 | 4 | /** 5 | * 页面的初始数据 6 | */ 7 | data: { 8 | pay_icon: "../../images/order.png", 9 | orderid: 0 10 | }, 11 | 12 | /** 13 | * 生命周期函数--监听页面加载 14 | */ 15 | onLoad: function (options) { 16 | console.log(options.orderid) 17 | this.setData({ 18 | orderid: options.orderid, 19 | }) 20 | 21 | }, 22 | /**返回首页 */ 23 | getback() { 24 | wx.reLaunch({ 25 | url: '../home/home', 26 | }) 27 | }, 28 | 29 | /** 30 | * 生命周期函数--监听页面初次渲染完成 31 | */ 32 | onReady: function () { 33 | 34 | }, 35 | 36 | /** 37 | * 生命周期函数--监听页面显示 38 | */ 39 | onShow: function () { 40 | 41 | }, 42 | 43 | /** 44 | * 生命周期函数--监听页面隐藏 45 | */ 46 | onHide: function () { 47 | 48 | }, 49 | 50 | /** 51 | * 生命周期函数--监听页面卸载 52 | */ 53 | onUnload: function () { 54 | 55 | }, 56 | 57 | /** 58 | * 页面相关事件处理函数--监听用户下拉动作 59 | */ 60 | onPullDownRefresh: function () { 61 | 62 | }, 63 | 64 | /** 65 | * 页面上拉触底事件的处理函数 66 | */ 67 | onReachBottom: function () { 68 | 69 | }, 70 | 71 | /** 72 | * 用户点击右上角分享 73 | */ 74 | onShareAppMessage: function () { 75 | 76 | } 77 | }) -------------------------------------------------------------------------------- /front-end-WeChat-applet/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/home/home", 4 | "pages/personal/personal", 5 | "pages/comment/comment", 6 | "pages/food/food", 7 | "pages/order/order", 8 | "pages/paySuccess/paySuccess", 9 | "pages/AllOrder/AllOrder", 10 | "pages/Aboutus/Aboutus", 11 | "pages/check/check" 12 | ], 13 | "window": { 14 | "backgroundTextStyle": "dark", 15 | "navigationBarBackgroundColor": "#eeeeee", 16 | "navigationBarTitleText": "同济", 17 | "navigationBarTextStyle": "black", 18 | "enablePullDownRefresh": true, 19 | "backgroundColor": "#eeeeee" 20 | }, 21 | "tabBar": { 22 | "borderStyle": "white", 23 | "backgroundColor": "#eeeeee", 24 | "list": [ 25 | { 26 | "pagePath": "pages/home/home", 27 | "iconPath": "images/home.png", 28 | "text": "Home", 29 | "selectedIconPath": "images/home-1.png" 30 | }, 31 | { 32 | "pagePath": "pages/AllOrder/AllOrder", 33 | "iconPath": "images/comment.png", 34 | "text": "Order", 35 | "selectedIconPath": "images/comment-1.png" 36 | }, 37 | { 38 | "pagePath": "pages/personal/personal", 39 | "iconPath": "images/personal.png", 40 | "text": "Personal", 41 | "selectedIconPath": "images/personal-1.png" 42 | } 43 | ] 44 | }, 45 | "sitemapLocation": "sitemap.json" 46 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/project.private.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "setting": { 3 | "compileHotReLoad": true 4 | }, 5 | "condition": { 6 | "miniprogram": { 7 | "list": [ 8 | { 9 | "name": "", 10 | "pathName": "pages/personal/personal", 11 | "query": "", 12 | "scene": null 13 | }, 14 | { 15 | "name": "", 16 | "pathName": "pages/Aboutus/Aboutus", 17 | "query": "", 18 | "scene": null 19 | }, 20 | { 21 | "name": "", 22 | "pathName": "pages/paySuccess/paySuccess", 23 | "query": "", 24 | "scene": null 25 | }, 26 | { 27 | "name": "", 28 | "pathName": "pages/order/order", 29 | "query": "", 30 | "scene": null 31 | }, 32 | { 33 | "name": "", 34 | "pathName": "pages/AllOrder/AllOrder", 35 | "query": "", 36 | "scene": null 37 | }, 38 | { 39 | "name": "", 40 | "pathName": "pages/comment/comment", 41 | "query": "", 42 | "scene": null 43 | }, 44 | { 45 | "name": "", 46 | "pathName": "pages/check/check", 47 | "query": "", 48 | "scene": null 49 | } 50 | ] 51 | } 52 | }, 53 | "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", 54 | "projectname": "front-end-WeChat-applet" 55 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/home/home.wxss: -------------------------------------------------------------------------------- 1 | .index_cont { 2 | position: relative; 3 | width: 100%; 4 | height: 100%; 5 | } 6 | 7 | .background { 8 | width: 100%; 9 | height: 100%; 10 | position: fixed; 11 | z-index: -1; 12 | } 13 | 14 | .shoplist { 15 | position: relative; 16 | width: 100%; 17 | height: 230rpx; 18 | 19 | } 20 | 21 | .shopLeft { 22 | position: absolute; 23 | width: 32%; 24 | height: 100%; 25 | left: 0; 26 | } 27 | 28 | .shopRight { 29 | position: absolute; 30 | width: 68%; 31 | text-align: left; 32 | height: 100%; 33 | border-bottom: 1rpx solid #ddd; 34 | right: 0; 35 | } 36 | 37 | .shopImg { 38 | position: absolute; 39 | width: 175rpx; 40 | height: 175rpx; 41 | left: 30rpx; 42 | top: 25rpx; 43 | border: 1rpx solid #ddd; 44 | } 45 | 46 | .shopName { 47 | position: relative; 48 | width: 300rpx; 49 | overflow: hidden; 50 | text-overflow: ellipsis; 51 | white-space: nowrap; 52 | display: inline-block; 53 | height: 40rpx; 54 | font-weight: bolder; 55 | font-size: 30rpx; 56 | line-height: 40rpx; 57 | padding-top: 30rpx; 58 | margin-bottom: 10rpx; 59 | color: #e23c13; 60 | } 61 | 62 | .shopTest { 63 | position: absolute; 64 | right: 0; 65 | overflow: hidden; 66 | text-overflow: ellipsis; 67 | white-space: nowrap; 68 | width: 200rpx; 69 | text-align: center; 70 | font-size: 26rpx; 71 | color: #e96682; 72 | top: 0; 73 | height: 40rpx; 74 | line-height: 40rpx; 75 | padding-top: 30rpx; 76 | 77 | } 78 | 79 | .shopDesc { 80 | position: relative; 81 | width: 500rpx; 82 | /* display: inline-block; */ 83 | /* height: 40rpx; */ 84 | /* line-height: 40rpx; */ 85 | display: -webkit-box; 86 | -webkit-box-orient: vertical; 87 | -webkit-line-clamp: 3; 88 | overflow: hidden; 89 | font-size: 28rpx; 90 | color: rgb(55, 89, 161); 91 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/comment/comment.wxss: -------------------------------------------------------------------------------- 1 | .background { 2 | width: 100%; 3 | height: 100%; 4 | position: fixed; 5 | z-index: -1; 6 | } 7 | 8 | .contains { 9 | font-family: STxingkai; 10 | color: rgb(209, 27, 233); 11 | font-size: 35rpx; 12 | /* margin: 15rpx; */ 13 | } 14 | 15 | .release { 16 | font-family: STxingkai; 17 | color: #fff; 18 | background: #f95807; 19 | margin: 0 9%; 20 | width: 80%; 21 | height: 80rpx; 22 | line-height: 80rpx; 23 | position: fixed; 24 | } 25 | 26 | .score { 27 | height: 150rpx; 28 | display: flex; 29 | flex-direction: row; 30 | align-items: center; 31 | justify-content: space-between; 32 | } 33 | 34 | .score-left { 35 | display: flex; 36 | flex-direction: row; 37 | align-items: center; 38 | font-size: 50rpx; 39 | width: 50%; 40 | justify-content: center; 41 | } 42 | 43 | .score-left image { 44 | height: 100rpx; 45 | width: 100rpx; 46 | } 47 | 48 | .score-right { 49 | height: 100rpx; 50 | display: flex; 51 | flex-direction: row; 52 | align-items: center; 53 | width: 90%; 54 | } 55 | 56 | .score-right image { 57 | width: 40rpx; 58 | height: 40rpx; 59 | margin-right: 12rpx; 60 | } 61 | 62 | .score_text { 63 | font-family: STxingkai; 64 | width: 150rpx; 65 | text-align: center; 66 | color: #3055cf; 67 | } 68 | 69 | .textarea { 70 | position: relative; 71 | /* margin-top: 20rpx; */ 72 | height: 400rpx; 73 | width: 90%; 74 | padding-left: 50rpx; 75 | /* border-bottom: 1rpx #e6e6e6 solid; */ 76 | } 77 | 78 | .textarea textarea { 79 | height: 200rpx; 80 | width: 95%; 81 | border: 1rpx solid #09e464; 82 | border-radius: 15rpx; 83 | color: rgb(2, 14, 13); 84 | font-size: 40rpx; 85 | font-family: STxingkai; 86 | } 87 | 88 | .textarea-text { 89 | color: rgb(2, 14, 13); 90 | font-size: 34rpx; 91 | } 92 | 93 | .textarea .title { 94 | margin: 10rpx 0; 95 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/AllOrder/AllOrder.wxss: -------------------------------------------------------------------------------- 1 | .index_cont { 2 | position: relative; 3 | width: 100%; 4 | height: 100%; 5 | } 6 | 7 | .background { 8 | width: 100%; 9 | height: 100%; 10 | position: fixed; 11 | z-index: -1; 12 | } 13 | 14 | .shoplist { 15 | position: relative; 16 | width: 100%; 17 | height: 230rpx; 18 | 19 | } 20 | 21 | .shopLeft { 22 | position: absolute; 23 | width: 32%; 24 | height: 100%; 25 | left: 0; 26 | } 27 | 28 | .shopRight { 29 | position: absolute; 30 | width: 68%; 31 | text-align: left; 32 | height: 100%; 33 | border-bottom: 1rpx solid #ddd; 34 | right: 0; 35 | } 36 | 37 | .shopImg { 38 | position: absolute; 39 | width: 175rpx; 40 | height: 175rpx; 41 | left: 30rpx; 42 | top: 25rpx; 43 | border: 1rpx solid #ddd; 44 | } 45 | 46 | .shopName { 47 | position: relative; 48 | width: 300rpx; 49 | overflow: hidden; 50 | text-overflow: ellipsis; 51 | white-space: nowrap; 52 | display: inline-block; 53 | height: 40rpx; 54 | font-weight: bolder; 55 | font-size: 30rpx; 56 | line-height: 40rpx; 57 | padding-top: 30rpx; 58 | margin-bottom: 10rpx; 59 | } 60 | 61 | .shopTest { 62 | position: absolute; 63 | right: 0; 64 | overflow: hidden; 65 | text-overflow: ellipsis; 66 | white-space: nowrap; 67 | width: 200rpx; 68 | text-align: center; 69 | font-size: 30rpx; 70 | font-weight: 1000; 71 | color: black; 72 | top: 0; 73 | height: 40rpx; 74 | line-height: 40rpx; 75 | padding-top: 30rpx; 76 | 77 | } 78 | 79 | .shopDesc { 80 | position: relative; 81 | width: 500rpx; 82 | display: -webkit-box; 83 | -webkit-box-orient: vertical; 84 | -webkit-line-clamp: 3; 85 | overflow: hidden; 86 | font-size: 28rpx; 87 | } 88 | 89 | .shopping { 90 | position: relative; 91 | width: 500rpx; 92 | padding-top: 10rpx; 93 | display: -webkit-box; 94 | -webkit-box-orient: vertical; 95 | -webkit-line-clamp: 3; 96 | overflow: hidden; 97 | font-size: 28rpx; 98 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件", 3 | "packOptions": { 4 | "ignore": [ 5 | { 6 | "value": ".eslintrc.js", 7 | "type": "file" 8 | } 9 | ], 10 | "include": [] 11 | }, 12 | "setting": { 13 | "urlCheck": false, 14 | "es6": true, 15 | "enhance": true, 16 | "postcss": true, 17 | "preloadBackgroundData": false, 18 | "minified": true, 19 | "newFeature": false, 20 | "coverView": true, 21 | "nodeModules": false, 22 | "autoAudits": false, 23 | "showShadowRootInWxmlPanel": true, 24 | "scopeDataCheck": false, 25 | "uglifyFileName": false, 26 | "checkInvalidKey": true, 27 | "checkSiteMap": true, 28 | "uploadWithSourceMap": true, 29 | "compileHotReLoad": false, 30 | "lazyloadPlaceholderEnable": false, 31 | "useMultiFrameRuntime": true, 32 | "useApiHook": true, 33 | "useApiHostProcess": true, 34 | "babelSetting": { 35 | "ignore": [], 36 | "disablePlugins": [], 37 | "outputPath": "" 38 | }, 39 | "useIsolateContext": false, 40 | "userConfirmedBundleSwitch": false, 41 | "packNpmManually": false, 42 | "packNpmRelationList": [], 43 | "minifyWXSS": true, 44 | "disableUseStrict": false, 45 | "minifyWXML": true, 46 | "showES6CompileOption": false, 47 | "useCompilerPlugins": false, 48 | "ignoreUploadUnusedFiles": true 49 | }, 50 | "compileType": "miniprogram", 51 | "libVersion": "2.19.4", 52 | "projectname": "软工课设", 53 | "appid": "wx27cc35bd452e6ec4", 54 | "condition": { 55 | "search": { 56 | "list": [] 57 | }, 58 | "conversation": { 59 | "list": [] 60 | }, 61 | "game": { 62 | "list": [] 63 | }, 64 | "plugin": { 65 | "list": [] 66 | }, 67 | "gamePlugin": { 68 | "list": [] 69 | }, 70 | "miniprogram": { 71 | "list": [] 72 | } 73 | }, 74 | "editorSetting": { 75 | "tabIndent": "insertSpaces", 76 | "tabSize": 2 77 | } 78 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/order/order.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | {{item.shopname}} 14 | 15 | 16 | 17 | 规格 : {{item.shaopdesc}} 18 | 19 | ¥{{item.price}} 20 | 21 | 22 | 23 | 24 | - 25 | 26 | 27 | + 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 全选 38 | 39 | 合计: 40 | ¥{{totalPrice}} 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 购物车是空的哦~ 49 | 50 | 51 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/component/model/model.wxss: -------------------------------------------------------------------------------- 1 | .mask { 2 | position: fixed; 3 | top: 0; 4 | width: 100%; 5 | z-index: 999; 6 | height: 100vh; 7 | background: rgba(0, 0, 0, 0.6); 8 | } 9 | 10 | .maskView { 11 | position: absolute; 12 | width: 100%; 13 | height: 500rpx; 14 | top: 27%; 15 | z-index: 999; 16 | text-align: center; 17 | } 18 | 19 | .maseViews { 20 | position: relative; 21 | background: #fff; 22 | width: 80%; 23 | display: inline-block; 24 | border-radius: 12rpx; 25 | height: 100%; 26 | text-align: center; 27 | } 28 | 29 | .logo { 30 | position: relative; 31 | display: inline-block; 32 | width: 120rpx; 33 | height: 120rpx; 34 | border-radius: 50%; 35 | margin-top: 25rpx; 36 | } 37 | 38 | .title { 39 | position: relative; 40 | width: 100%; 41 | height: 70rpx; 42 | line-height: 70rpx; 43 | font-weight: bold; 44 | text-align: center; 45 | font-size: 32rpx; 46 | } 47 | 48 | .submitView { 49 | position: absolute; 50 | width: 100%; 51 | height: 90rpx; 52 | bottom: 20rpx; 53 | line-height: 90rpx; 54 | } 55 | 56 | .desction { 57 | position: relative; 58 | width: 100%; 59 | background: #fff; 60 | font-size: 26rpx; 61 | color: #999; 62 | text-align: center; 63 | margin: 0 auto; 64 | } 65 | 66 | .cance { 67 | position: absolute; 68 | width: 200rpx; 69 | height: 80rpx; 70 | left: 58rpx; 71 | line-height: 80rpx; 72 | /* background: #FF6E00; */ 73 | border: 1rpx solid #999; 74 | text-align: center; 75 | color: #000; 76 | border-radius: 12rpx; 77 | font-size: 30rpx; 78 | } 79 | 80 | .authorize { 81 | position: relative; 82 | width: 100%; 83 | height: 90rpx; 84 | font-weight: bold; 85 | line-height: 90rpx; 86 | text-align: center; 87 | border-bottom: 1rpx solid #D6D6D6; 88 | } 89 | 90 | .success { 91 | position: absolute; 92 | width: 200rpx !important; 93 | height: 80rpx; 94 | line-height: 80rpx; 95 | border: 1rpx solid #ff6e00; 96 | right: 58rpx; 97 | background: #ff6e00; 98 | color: #fff; 99 | padding: 0; 100 | text-align: center; 101 | border-radius: 12rpx; 102 | font-size: 30rpx; 103 | } 104 | 105 | .cover-view { 106 | display: block; 107 | line-height: 1.2; 108 | overflow: hidden; 109 | white-space: nowrap; 110 | pointer-events: auto; 111 | 112 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/personal/personal.wxss: -------------------------------------------------------------------------------- 1 | /* 个人信息 */ 2 | page { 3 | background-color: #eaeaea; 4 | color: #999; 5 | font-size: 26rpx; 6 | } 7 | 8 | .background { 9 | width: 100%; 10 | height: 100%; 11 | position: fixed; 12 | z-index: -1; 13 | } 14 | 15 | .userinfo { 16 | display: flex; 17 | flex-direction: column; 18 | align-items: center; 19 | color: #aaa; 20 | } 21 | 22 | .userinfo-avatar { 23 | width: 200rpx; 24 | height: 200rpx; 25 | margin-top: 50rpx; 26 | border-radius: 50%; 27 | display: flex; 28 | flex-direction: column; 29 | align-items: center; 30 | } 31 | 32 | .name { 33 | margin-top: 20rpx; 34 | margin-bottom: 30rpx; 35 | color: #20080c; 36 | font-size: 40rpx; 37 | } 38 | 39 | /* 历史 */ 40 | .his_info_wrap { 41 | position: relative; 42 | } 43 | 44 | .his_info { 45 | padding-bottom: 20rpx; 46 | width: 95%; 47 | position: absolute; 48 | left: 50%; 49 | top: -20px; 50 | transform: translate(-50%); 51 | } 52 | 53 | .his_content { 54 | background-color: #fff; 55 | padding: 10rpx; 56 | display: flex; 57 | text-align: center; 58 | } 59 | 60 | .his_content navigator { 61 | flex: 1; 62 | } 63 | 64 | .his_num { 65 | color: rgb(227, 230, 71); 66 | } 67 | 68 | /* 订单 */ 69 | .order_content { 70 | background-color: #fff; 71 | margin-top: 40rpx; 72 | padding: 10rpx 10rpx 0 10rpx; 73 | } 74 | 75 | .my_order { 76 | padding: 10rpx; 77 | border-bottom: 1px solid #ccc; 78 | } 79 | 80 | .order_navig { 81 | display: flex; 82 | /* justify-content: center; 83 | align-items: center; */ 84 | text-align: center; 85 | } 86 | 87 | .order_navig navigator { 88 | flex: 1; 89 | padding: 10rpx 0; 90 | } 91 | 92 | /* 地址 */ 93 | .address_content, 94 | .recommend_content { 95 | margin-top: 40rpx; 96 | padding: 20rpx 10rpx; 97 | background-color: #fff; 98 | } 99 | 100 | /* 应用 */ 101 | .app_content { 102 | margin-top: 40rpx; 103 | /* padding: 10rpx; */ 104 | /* background-color: #fff; */ 105 | } 106 | 107 | .app_content .contact { 108 | display: flex; 109 | justify-content: space-between; 110 | } 111 | 112 | .contact, 113 | .idea, 114 | .about { 115 | /* margin-top: 2rpx; */ 116 | background-color: #fff; 117 | padding: 20rpx 10rpx; 118 | border-bottom: 1px solid #ccc; 119 | } 120 | 121 | button { 122 | font-size: 30rpx; 123 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/home/home.js: -------------------------------------------------------------------------------- 1 | var app = new getApp(); 2 | Page({ 3 | 4 | /** 5 | * 页面的初始数据 6 | */ 7 | data: { 8 | // 门店数据 9 | shopid: 0, 10 | shopList: [], 11 | }, 12 | /** 13 | * 生命周期函数--监听页面加载 14 | */ 15 | onLoad: function (options) { 16 | //调用models组件 17 | var userInfo = wx.getStorageSync("userinfo"); 18 | if (!userInfo) { 19 | var modelLogo = this.selectComponent("#Models"); 20 | modelLogo.getShow(); 21 | return; 22 | } 23 | this.setData({ 24 | nickName: userInfo.nickName, 25 | avatarUrl: userInfo.avatarUrl 26 | }) 27 | //登录交互 28 | wx.login({ 29 | success(res) { 30 | if (res.code) { 31 | wx.request({ 32 | success(res) { 33 | if (res.header['set-cookie'] != '') { 34 | wx.setStorageSync('set-cookie', res.header['set-cookie']) 35 | } 36 | }, 37 | url: 'http://127.0.0.1:8000/api/seproject/getOpenid', 38 | data: { 39 | code: res.code 40 | }, 41 | header: { 42 | 'cookie': wx.getStorageSync('set-cookie') 43 | } 44 | }) 45 | } else { 46 | console.log('登录失败!' + res.errMsg) 47 | } 48 | } 49 | }) 50 | var that = this 51 | wx.request({ 52 | url: 'http://127.0.0.1:8000/api/seproject/getStoreInfo', 53 | success: function (res) { 54 | that.setData({ 55 | shopList: res.data.shoplist, 56 | }) 57 | } 58 | }) 59 | }, 60 | /**进入店铺 */ 61 | getOpenShop(e) { 62 | var shopid = e.currentTarget.dataset.item.id; 63 | this.setData({ 64 | shopid: shopid 65 | }) 66 | console.log(this.data.shopid) 67 | wx.navigateTo({ 68 | url: '../food/food?shopid=' + shopid, 69 | }) 70 | }, 71 | 72 | /** 73 | * 生命周期函数--监听页面初次渲染完成 74 | */ 75 | onReady: function () { 76 | 77 | }, 78 | 79 | /** 80 | * 生命周期函数--监听页面显示 81 | */ 82 | onShow: function () { 83 | 84 | }, 85 | 86 | /** 87 | * 生命周期函数--监听页面隐藏 88 | */ 89 | onHide: function () { 90 | 91 | }, 92 | 93 | /** 94 | * 生命周期函数--监听页面卸载 95 | */ 96 | onUnload: function () { 97 | 98 | }, 99 | 100 | /** 101 | * 页面相关事件处理函数--监听用户下拉动作 102 | */ 103 | onPullDownRefresh: function () { 104 | 105 | }, 106 | 107 | /** 108 | * 页面上拉触底事件的处理函数 109 | */ 110 | onReachBottom: function () { 111 | 112 | }, 113 | 114 | /** 115 | * 用户点击右上角分享 116 | */ 117 | onShareAppMessage: function () { 118 | 119 | } 120 | }) -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/food/food.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{totalCount}} 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | {{item.name}} 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | {{food.name}} 31 | {{food.description}} 32 | 33 | ¥{{food.price}} 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | {{food.Count}} 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/comment/comment.js: -------------------------------------------------------------------------------- 1 | // pages/comment/comment.js 2 | Page({ 3 | 4 | /** 5 | * 页面的初始数据 6 | */ 7 | data: { 8 | shopcomment: {}, 9 | default_score: 0, 10 | score: 0, 11 | score_text_arr: ['用餐体验极不愉快', '用餐不如意', '用餐体验一般', '用餐体验较好', 'oh,这是多么美妙的餐馆'], 12 | score_text: "", 13 | score_img_arr: [], 14 | is_upload: false, 15 | time: null, 16 | text: "" 17 | }, 18 | _default_score: function (tauch_score = 0) { 19 | var score_img = []; 20 | var score = 0; 21 | for (let i = 0; i < 5; i++) { 22 | if (i < tauch_score) { 23 | score_img[i] = "../../images/star_on.png" 24 | score = i; 25 | } else { 26 | score_img[i] = "../../images/star_off.png" 27 | } 28 | } 29 | this.setData({ 30 | score_img_arr: score_img, 31 | score_text: this.data.score_text_arr[score] 32 | }); 33 | }, 34 | 35 | onScore: function (e) { 36 | var score = e.currentTarget.dataset.score; 37 | this._default_score(score); 38 | this.setData({ 39 | score: score 40 | }) 41 | }, 42 | 43 | //上传评论 44 | onSubmit: function (e) { 45 | wx.showLoading({ 46 | title: '评价上传中', 47 | }) 48 | var that = this; 49 | var is = false; 50 | var flag = false; 51 | var index = 0; 52 | this.setData({ 53 | text: e.detail.value.text 54 | }) 55 | wx.request({ 56 | url: 'http://127.0.0.1:8000/api/seproject/addComment', 57 | method: "POST", 58 | header: { 59 | 'cookie': wx.getStorageSync('set-cookie') 60 | }, 61 | data: { 62 | order_id: that.data.shopcomment.order_id, 63 | user_text: that.data.text, 64 | user_score: that.data.score 65 | }, 66 | success: res => { 67 | wx.hideLoading(); 68 | setTimeout(function () { 69 | wx.switchTab({ 70 | url: '../AllOrder/AllOrder' 71 | }) 72 | }, 1000) 73 | } 74 | }); 75 | 76 | }, 77 | /** 78 | * 生命周期函数--监听页面加载 79 | */ 80 | onLoad: function (options) { 81 | var shopcomment = JSON.parse(wx.getStorageSync("shopcomment")); 82 | this.setData({ 83 | shopcomment: shopcomment, 84 | }) 85 | this._default_score(this.data.default_score); 86 | }, 87 | /** 88 | * 生命周期函数--监听页面初次渲染完成 89 | */ 90 | onReady: function () { 91 | 92 | }, 93 | 94 | /** 95 | * 生命周期函数--监听页面显示 96 | */ 97 | onShow: function () { 98 | 99 | }, 100 | 101 | /** 102 | * 生命周期函数--监听页面隐藏 103 | */ 104 | onHide: function () { 105 | 106 | }, 107 | 108 | /** 109 | * 生命周期函数--监听页面卸载 110 | */ 111 | onUnload: function () { 112 | 113 | }, 114 | 115 | /** 116 | * 页面相关事件处理函数--监听用户下拉动作 117 | */ 118 | onPullDownRefresh: function () { 119 | 120 | }, 121 | 122 | /** 123 | * 页面上拉触底事件的处理函数 124 | */ 125 | onReachBottom: function () { 126 | 127 | }, 128 | 129 | /** 130 | * 用户点击右上角分享 131 | */ 132 | onShareAppMessage: function () { 133 | 134 | } 135 | }) -------------------------------------------------------------------------------- /back-end-python/seproject_app/models.py: -------------------------------------------------------------------------------- 1 | # models.py文件中是数据库的对应SQLAlchemy模型 2 | # 模型models用于建立供SQLAlchemy模块增删改查使用的对象,继承SQLAlchemy中的数据模型基类,根据项目需求建立数据模型 3 | # FastAPI是一个轻量级的框架,与数据库的通信是通过SQLAlchemy包来实现的 4 | # 如果数据库数据已经存在,可以使用sqlacodegen直接生成每个表的model 5 | # sqlacodegen --outfile=models.py mysql://user:password@127.0.0.1:3306/db 6 | # 如果不指定outfile,则会直接在屏幕上输出 7 | 8 | # 如果数据库数据不存在,则先在数据库中建表,然后通过以下代码对表进行完善 9 | from sqlalchemy import Boolean, Column, DateTime, Float, ForeignKey, Integer, String 10 | from sqlalchemy import CHAR, Column, DateTime, ForeignKey, Index, String 11 | from sqlalchemy.dialects.mysql import INTEGER, LONGTEXT, SMALLINT, TINYINT 12 | from sqlalchemy.orm import relationship 13 | from .database import Base 14 | 15 | class User(Base): 16 | __tablename__ = "user" 17 | 18 | id = Column( 19 | Integer, primary_key=True, index=True, autoincrement=True, nullable=False 20 | ) 21 | open_id = Column(String(40), index=True, nullable=False) 22 | 23 | 24 | class Shop(Base): 25 | __tablename__ = "store" 26 | 27 | id = Column( 28 | Integer, primary_key=True, index=True, autoincrement=True, nullable=False 29 | ) 30 | name = Column(String(40)) 31 | phone = Column(String(40), index=True, nullable=False) 32 | password = Column(String(40), nullable=False) 33 | describe = Column(String(40)) 34 | address = Column(String(40)) 35 | distance = Column(Integer, default=0) 36 | img = Column(String(10000)) 37 | 38 | 39 | class Order_Dish(Base): 40 | __tablename__ = "order-dish" 41 | 42 | order_id = Column(Integer, ForeignKey("order.id"), primary_key=True, nullable=False) 43 | dish_id = Column(Integer, ForeignKey("dish.id"), primary_key=True, nullable=False) 44 | num = Column(Integer, nullable=False) 45 | 46 | 47 | class Dish(Base): 48 | __tablename__ = "dish" 49 | 50 | id = Column( 51 | Integer, primary_key=True, index=True, autoincrement=True, nullable=False 52 | ) 53 | store_id = Column(Integer, ForeignKey("store.id"), nullable=False) 54 | name = Column(String(40)) 55 | flavor = Column(String(40)) 56 | price = Column(Float) 57 | description = Column(String(40)) 58 | icon = Column(String(10000)) 59 | 60 | 61 | class Comment(Base): 62 | __tablename__ = "evaluate" 63 | 64 | order_id = Column( 65 | Integer, ForeignKey("order.id"), primary_key=True, index=True, nullable=False 66 | ) 67 | user_text = Column(String(40)) 68 | store_text = Column(String(40)) 69 | user_time = Column(DateTime) 70 | store_time = Column(DateTime) 71 | user_score = Column(Integer) 72 | 73 | 74 | class Order(Base): 75 | __tablename__ = "order" 76 | 77 | id = Column( 78 | Integer, primary_key=True, index=True, autoincrement=True, nullable=False 79 | ) 80 | store_id = Column(Integer, ForeignKey("store.id"), nullable=False) 81 | user_id = Column(Integer, ForeignKey("user.id"), nullable=False) 82 | price = Column(Float, nullable=False) 83 | 84 | 85 | class Order_Status(Base): 86 | __tablename__ = "order_status" 87 | 88 | order_id = Column( 89 | Integer, ForeignKey("order.id"), primary_key=True, index=True, nullable=False 90 | ) 91 | submit_time = Column(DateTime) 92 | finish_time = Column(DateTime) 93 | status = Column(Boolean, default=False) 94 | comment = Column(Boolean, default=False) 95 | -------------------------------------------------------------------------------- /back-end-python/seproject_app/schemas.py: -------------------------------------------------------------------------------- 1 | # Pydantic可以基于Python的类型提示来进行数据验证。 2 | # 使用schemas.py来保存Pydantic模型,以便和保存SQLAlchemy模型的models.py文件进行区分 3 | # 数据模式schemas是FastAPI模块用于数据传递的对象,通过继承pydantic中的类建立 4 | from datetime import datetime 5 | from typing import Dict, List, Optional 6 | from pydantic import BaseModel 7 | 8 | 9 | class DishBase(BaseModel): 10 | name: str # 菜品名 11 | description: Optional[str] = None 12 | flavor: Optional[str] = None 13 | price: float 14 | 15 | 16 | class DishCreate(DishBase): 17 | # store_id: int # 创建订单的菜品不需要商家id,因为创建菜品的商家唯一确定 18 | pass 19 | 20 | 21 | class DishChange(DishBase): 22 | id: int 23 | 24 | 25 | class Dish(DishBase): 26 | id: int 27 | store_id: int 28 | icon: Optional[str] = None 29 | 30 | class Config: 31 | orm_mode = True 32 | 33 | 34 | class DishOrder(BaseModel): 35 | id: int 36 | num: int 37 | 38 | 39 | class ShopLogin(BaseModel): 40 | phone: str 41 | password: str 42 | 43 | 44 | class ShopBase(BaseModel): 45 | name: str 46 | phone: str 47 | describe: Optional[str] = None 48 | address: Optional[str] = None 49 | 50 | 51 | class ShopCreate(ShopBase): 52 | password: str 53 | 54 | 55 | class Shop(ShopBase): 56 | id: int 57 | img: Optional[str] = None 58 | # is_active: bool 59 | # items: List[Dish] = [] 60 | 61 | class Config: 62 | orm_mode = True 63 | 64 | 65 | class ShopChange(BaseModel): 66 | name: str 67 | password: str 68 | describe: Optional[str] = None 69 | address: Optional[str] = None 70 | 71 | 72 | class UserBase(BaseModel): 73 | pass 74 | 75 | 76 | class UserCreate(UserBase): 77 | openid: str 78 | 79 | 80 | class User(UserBase): 81 | id: int 82 | 83 | class Config: 84 | orm_mode = True 85 | 86 | 87 | class OrderBase(BaseModel): 88 | store_id: int 89 | totalPrice: int = 0 90 | 91 | 92 | class OrderCreate(OrderBase): 93 | countArray: List[DishOrder] 94 | 95 | 96 | class Order(OrderBase): 97 | id: int 98 | shopImg: str 99 | shopName: str 100 | orderDesc: str 101 | orderComment: bool 102 | 103 | 104 | class CommentBase(BaseModel): 105 | order_id: int 106 | user_text: str 107 | user_score: int 108 | 109 | 110 | class CommentCreate(CommentBase): 111 | pass 112 | 113 | 114 | class CommentReply(BaseModel): 115 | order_id: int 116 | store_text: str 117 | 118 | 119 | class Comment(CommentBase): 120 | store_text: Optional[str] = None 121 | store_time: Optional[datetime] = None 122 | user_time: Optional[datetime] = None 123 | 124 | class Config: 125 | orm_mode = True 126 | 127 | 128 | ################### 129 | 130 | 131 | class SimpleReply(BaseModel): 132 | msg: str 133 | 134 | class Config: 135 | orm_mode = True 136 | 137 | 138 | class ShopDict(SimpleReply): 139 | shoplist: List[Dict] 140 | 141 | 142 | class FlavorList(BaseModel): 143 | name: str 144 | foods: List[Dict] 145 | 146 | 147 | class DishDict(SimpleReply): 148 | goods: List[FlavorList] 149 | 150 | 151 | class DishItem(BaseModel): 152 | order_id: int 153 | store_id: int 154 | orderPrice: float 155 | orderShop: str 156 | orderImg: Optional[str] = None 157 | orderDesc: str 158 | orderComment: bool 159 | 160 | 161 | class DishSimply(BaseModel): 162 | num: int 163 | name: str 164 | 165 | 166 | class OrderDict(SimpleReply): 167 | data: List[DishItem] 168 | 169 | 170 | class CommentDict(SimpleReply): 171 | data: Comment 172 | 173 | 174 | class OrderShop(BaseModel): 175 | order_id: int 176 | user_id: int 177 | orderPrice: int 178 | orderDesc: List[DishSimply] 179 | submit_time: datetime 180 | finish_time: Optional[datetime] = None 181 | status: bool 182 | comment: bool 183 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/order/order.wxss: -------------------------------------------------------------------------------- 1 | /* pages/order/order.wxss */ 2 | /* 列表 */ 3 | .background { 4 | width: 100%; 5 | height: 100%; 6 | position: fixed; 7 | z-index: -1; 8 | } 9 | 10 | .list { 11 | position: relative; 12 | width: 100%; 13 | height: 225rpx; 14 | /* background-color: red; */ 15 | border-bottom: 1rpx solid #e9e9e9; 16 | } 17 | 18 | /* 编辑 */ 19 | 20 | .edit { 21 | position: relative; 22 | width: 100%; 23 | height: 80rpx; 24 | line-height: 80rpx; 25 | background-color: #f6f6f6; 26 | } 27 | 28 | /* 删除 */ 29 | 30 | .dele_edit { 31 | position: absolute; 32 | width: 40rpx; 33 | height: 40rpx; 34 | right: 30rpx; 35 | bottom: 25rpx; 36 | } 37 | 38 | /* 编辑标题 */ 39 | 40 | .edit_btn { 41 | position: absolute; 42 | font-size: 26rpx; 43 | color: #888; 44 | right: 30rpx; 45 | } 46 | 47 | /* 单选状态 */ 48 | 49 | .radio_chek { 50 | position: absolute; 51 | left: 30rpx; 52 | top: 70rpx; 53 | width: 40rpx; 54 | height: 40rpx; 55 | } 56 | 57 | /* 列表商品图片 */ 58 | 59 | .list_img { 60 | position: absolute; 61 | top: 20rpx; 62 | left: 100rpx; 63 | width: 144rpx; 64 | height: 144rpx; 65 | } 66 | 67 | /* 列表规格 */ 68 | 69 | .cart_g_name { 70 | position: absolute; 71 | left: 280rpx; 72 | font-size: 26rpx; 73 | overflow: hidden; 74 | text-overflow: ellipsis; 75 | display: -webkit-box; 76 | -webkit-line-clamp: 2; 77 | -webkit-box-orient: vertical; 78 | color: #aaa; 79 | top: 75rpx; 80 | } 81 | 82 | /* 收藏 */ 83 | 84 | .collert { 85 | position: absolute; 86 | font-size: 28rpx; 87 | right: 40rpx; 88 | top: 30rpx; 89 | } 90 | 91 | /* 收藏图标 */ 92 | 93 | .collert_img { 94 | position: relative; 95 | top: 2rpx; 96 | width: 28rpx; 97 | height: 28rpx; 98 | } 99 | 100 | /* 列表商品名称 */ 101 | 102 | .list_name { 103 | position: absolute; 104 | left: 280rpx; 105 | top: 30rpx; 106 | width: 300rpx; 107 | /* background-color: red; */ 108 | font-size: 30rpx; 109 | overflow: hidden; 110 | text-overflow: ellipsis; 111 | white-space: nowrap; 112 | } 113 | 114 | /* 列表商品价格 */ 115 | 116 | .list_price { 117 | position: absolute; 118 | font-size: 32rpx; 119 | color: #d66058; 120 | left: 280rpx; 121 | bottom: 20rpx; 122 | } 123 | 124 | /* 列表商品删除 */ 125 | 126 | .list_del { 127 | position: absolute; 128 | right: 220rpx; 129 | bottom: 20rpx; 130 | width: 40rpx; 131 | height: 40rpx; 132 | line-height: 40rpx; 133 | text-align: center; 134 | font-size: 44rpx; 135 | } 136 | 137 | /* 固定底部 */ 138 | 139 | .cont_bot { 140 | position: fixed; 141 | bottom: 0; 142 | width: 100%; 143 | height: 104rpx; 144 | line-height: 104rpx; 145 | background: #fff; 146 | border-top: 2rpx solid #ebebeb; 147 | } 148 | 149 | /* 全选ICON */ 150 | 151 | .total-select { 152 | position: absolute; 153 | left: 30rpx; 154 | top: 34rpx; 155 | width: 40rpx; 156 | height: 40rpx; 157 | } 158 | 159 | /* 全选标题 */ 160 | 161 | .sel_count_name { 162 | position: absolute; 163 | left: 90rpx; 164 | font-size: 30rpx; 165 | color: #333; 166 | } 167 | 168 | /* 合计金额 */ 169 | 170 | .count_price { 171 | position: absolute; 172 | font-size: 28rpx; 173 | left: 200rpx; 174 | color: #aaa; 175 | } 176 | 177 | .count_price text { 178 | font-size: 34rpx; 179 | color: #d66058; 180 | } 181 | 182 | /* 购物车为空 */ 183 | 184 | .list_none { 185 | padding: 40rpx 0; 186 | color: #999; 187 | text-align: center; 188 | } 189 | 190 | /* 提交 */ 191 | 192 | .submit { 193 | position: absolute; 194 | width: 232rpx; 195 | height: 104rpx; 196 | line-height: 104rpx; 197 | right: 0rpx; 198 | font-size: 30rpx; 199 | text-align: center; 200 | color: #fff; 201 | background-color: #FB990A; 202 | } 203 | 204 | .navigator-hover { 205 | background: none; 206 | } 207 | 208 | /*数量加减*/ 209 | 210 | .carts-num { 211 | position: absolute; 212 | right: 30rpx; 213 | bottom: 18rpx; 214 | background-color: rgb(197, 211, 191); 215 | display: flex; 216 | align-items: center; 217 | text-align: center; 218 | height: 50rpx; 219 | } 220 | 221 | .view_text_center { 222 | border: 1rpx solid #161313; 223 | font-size: 30rpx; 224 | display: inline-block; 225 | color: #333; 226 | height: 50rpx; 227 | line-height: 50rpx; 228 | width: 76rpx; 229 | } 230 | 231 | .carts-num .minus, 232 | .carts-num .plus { 233 | margin: 10rpx; 234 | border: 1rpx solid #131111; 235 | color: #000; 236 | text-align: center; 237 | height: 50rpx; 238 | line-height: 50rpx; 239 | width: 40rpx; 240 | } 241 | 242 | .carts-num .minus { 243 | font-size: 34rpx; 244 | } 245 | 246 | /* .carts-num .minus.disabled{color: red;} */ 247 | 248 | .carts-num .plus { 249 | font-size: 34rpx; 250 | } -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/food/food.js: -------------------------------------------------------------------------------- 1 | Page({ 2 | data: { 3 | shopBase: { 4 | shopicon: "../../images/shopicon.png", 5 | shopAddIcon: "../../images/add-icon.png", 6 | shopMinuteIcon: "../../images/minute.png" 7 | }, 8 | goods: [], 9 | cutab: 0, 10 | scrollTop: 100, 11 | foodCounts: 0, 12 | totalPrice: 0,// 总价格 13 | totalCount: 0, // 总商品数 14 | carArray: [], 15 | fold: true, 16 | toView: "", 17 | parentIndex: 0, 18 | shopid: 0 19 | }, 20 | selectMenu: function (e) { 21 | var index = e.currentTarget.dataset.itemIndex; 22 | this.setData({ 23 | toView: 'order' + index, 24 | cutab: index 25 | }) 26 | console.log(this.data.toView); 27 | }, 28 | //移除商品 29 | decreaseCart: function (e) { 30 | var index = e.currentTarget.dataset.itemIndex; 31 | var parentIndex = e.currentTarget.dataset.parentindex; 32 | this.data.goods.forEach((good) => { 33 | good.foods.forEach((food) => { 34 | if (food.Count > 0) { 35 | this.data.goods[parentIndex].foods[index].Count-- 36 | var mark = 'a' + index + 'b' + parentIndex 37 | var id = this.data.goods[parentIndex].foods[index].id; 38 | var price = this.data.goods[parentIndex].foods[index].price; 39 | var num = this.data.goods[parentIndex].foods[index].Count; 40 | var obj = { price: price, num: num, mark: mark, id: id }; 41 | var carArray1 = this.data.carArray.filter(item => item.mark != mark); 42 | carArray1.push(obj); 43 | console.log(carArray1); 44 | this.setData({ 45 | carArray: carArray1, 46 | goods: this.data.goods 47 | }) 48 | this.calTotalPrice() 49 | } 50 | }) 51 | }) 52 | }, 53 | // 滑动切换tab 54 | onGoodsScroll: function (e) { 55 | console.log(e.detail.scrollTop); 56 | 57 | var scale = e.detail.scrollWidth / 570, 58 | scrollTop = e.detail.scrollTop / scale, 59 | h = 0, 60 | classifySeleted, 61 | len = this.data.goods.length; 62 | this.data.goods.forEach(function (classify, i) { 63 | var _h = 70 + classify.foods.length * (46 * 3 + 20 * 2); 64 | if (scrollTop >= h - 100 / scale) { 65 | classifySeleted = classify.foods[i].id; 66 | console.log(classifySeleted); 67 | } 68 | h += _h; 69 | }); 70 | this.setData({ 71 | cutab: classifySeleted 72 | }); 73 | }, 74 | minueCart(e) { 75 | console.log(e); 76 | var index = e.currentTarget.dataset.itemIndex; 77 | var parentIndex = e.currentTarget.dataset.parentindex; 78 | var mark = 'a' + index + 'b' + parentIndex; 79 | var id = e.currentTarget.dataset.id; 80 | var shopname = e.currentTarget.dataset.shopname; 81 | var shaopdesc = e.currentTarget.dataset.shopdesc; 82 | var icon = e.currentTarget.dataset.icon; 83 | var price = this.data.goods[parentIndex].foods[index].price; 84 | var num = this.data.goods[parentIndex].foods[index].Count; 85 | if (num <= 0) { 86 | return false; 87 | } 88 | // else num大于1 点击减按钮 数量-- 89 | num = num - 1; 90 | this.data.goods[parentIndex].foods[index].Count = num; 91 | var obj = { price: price, num: num, mark: mark, icon: icon, selected: true, shopname: shopname, shaopdesc: shaopdesc, id: id }; 92 | var carArray1 = this.data.carArray.filter(item => item.mark != mark) 93 | if (num > 0) { 94 | carArray1.push(obj) 95 | } 96 | console.log(carArray1); 97 | this.setData({ 98 | carArray: carArray1, 99 | goods: this.data.goods 100 | }) 101 | this.calTotalPrice(); 102 | 103 | }, 104 | //添加到购物车 105 | addCart(e) { 106 | var index = e.currentTarget.dataset.itemIndex; 107 | var parentIndex = e.currentTarget.dataset.parentindex; 108 | this.data.goods[parentIndex].foods[index].Count++; 109 | var mark = 'a' + index + 'b' + parentIndex; 110 | var id = e.currentTarget.dataset.id; 111 | var shopname = e.currentTarget.dataset.shopname; 112 | var shaopdesc = e.currentTarget.dataset.shopdesc; 113 | var price = this.data.goods[parentIndex].foods[index].price; 114 | var icon = e.currentTarget.dataset.icon; 115 | var num = this.data.goods[parentIndex].foods[index].Count; 116 | if (num > 99) { 117 | wx.showModal({ 118 | title: '提示', 119 | content: '亲,最多选购99件哦!', 120 | }) 121 | return; 122 | } 123 | var obj = { price: price, num: num, mark: mark, icon: icon, selected: true, shopname: shopname, shaopdesc: shaopdesc, id: id }; 124 | var carArray1 = this.data.carArray.filter(item => item.mark != mark) 125 | carArray1.push(obj) 126 | console.log(carArray1); 127 | this.setData({ 128 | carArray: carArray1, 129 | goods: this.data.goods 130 | }) 131 | this.calTotalPrice(); 132 | 133 | }, 134 | //计算总价 135 | calTotalPrice: function () { 136 | var carArray = this.data.carArray; 137 | var totalPrice = 0; 138 | var totalCount = 0; 139 | for (var i = 0; i < carArray.length; i++) { 140 | totalPrice += carArray[i].price * carArray[i].num; 141 | totalCount += carArray[i].num 142 | } 143 | this.setData({ 144 | totalPrice: totalPrice, 145 | totalCount: totalCount, 146 | }); 147 | }, 148 | onLoad: function (options) { 149 | console.log(options.shopid) 150 | var that = this 151 | wx.request({ 152 | url: 'http://127.0.0.1:8000/api/seproject/getDishInfo', 153 | data: { 154 | store_id: options.shopid 155 | }, 156 | header: { 157 | 'cookie': wx.getStorageSync('Set-Cookie') 158 | }, 159 | success: function (res) { 160 | console.log(res.data.goods) 161 | that.setData({ 162 | goods: res.data.goods, 163 | shopid: options.shopid 164 | }) 165 | } 166 | }) 167 | }, 168 | onReady: function () { 169 | // 页面渲染完成 170 | }, 171 | onShow: function () { 172 | // 页面显示 173 | }, 174 | // 打开购物车页面 175 | getOpenShop() { 176 | var countArray = JSON.stringify(this.data.carArray); 177 | var shopid = JSON.stringify(this.data.shopid); 178 | wx.setStorageSync("countArray", countArray); 179 | wx.setStorageSync('shopid', shopid) 180 | wx.navigateTo({ 181 | url: '../order/order', 182 | }) 183 | }, 184 | onUnload: function () { 185 | // 页面关闭 186 | } 187 | }) 188 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/order/order.js: -------------------------------------------------------------------------------- 1 | // page/component/new-pages/cart/cart.js 2 | // 默认请求第一页 3 | var numbers = 1; 4 | var bool = true; 5 | Page({ 6 | data: { 7 | show_edit: "block", 8 | edit_name: "编辑", 9 | edit_show: "none", 10 | delete_icon: "../../images/delete.png", 11 | radio_show_Icon: "../../images/radio_show.png", 12 | radio_none_Icon: "../../images/radio_none.png", 13 | // list: [], // 购物车列表 14 | // hasList: false, // 列表是否有数据 15 | // 默认展示数据 16 | hasList: true, 17 | // 商品列表数据 18 | list: [ 19 | ], 20 | // 金额 21 | totalPrice: 0, // 总价,初始为0 22 | // 全选状态 23 | selectAllStatus: true, // 全选状态,默认全选 24 | orderid: 0, 25 | }, 26 | 27 | onShow() { 28 | wx.showToast({ 29 | title: '加载中', 30 | icon: "loading", 31 | duration: 1000 32 | }) 33 | 34 | // 价格方法 35 | this.count_price(); 36 | }, 37 | /** 38 | * 当前商品选中事件 39 | */ 40 | selectList(e) { 41 | var that = this; 42 | // 获取选中的radio索引 43 | var index = e.currentTarget.dataset.index; 44 | // 获取到商品列表数据 45 | var list = that.data.list; 46 | // 默认全选 47 | that.data.selectAllStatus = true; 48 | // 循环数组数据,判断----选中/未选中[selected] 49 | list[index].selected = !list[index].selected; 50 | // 如果数组数据全部为selected[true],全选 51 | for (var i = list.length - 1; i >= 0; i--) { 52 | if (!list[i].selected) { 53 | that.data.selectAllStatus = false; 54 | break; 55 | } 56 | } 57 | // 重新渲染数据 58 | that.setData({ 59 | list: list, 60 | selectAllStatus: that.data.selectAllStatus 61 | }) 62 | // 调用计算金额方法 63 | that.count_price(); 64 | }, 65 | // 编辑 66 | btn_edit: function () { 67 | var that = this; 68 | if (bool) { 69 | that.setData({ 70 | edit_show: "block", 71 | edit_name: "取消", 72 | show_edit: "none" 73 | }) 74 | bool = false; 75 | } else { 76 | that.setData({ 77 | edit_show: "none", 78 | edit_name: "编辑", 79 | show_edit: "block" 80 | }) 81 | bool = true; 82 | } 83 | 84 | }, 85 | /**初始化加载数据 */ 86 | onLoad(res) { 87 | var countArray = JSON.parse(wx.getStorageSync("countArray")); 88 | console.log("countArray", countArray); 89 | if (countArray.length > 0) { 90 | this.setData({ 91 | list: countArray, 92 | hasList: true 93 | }) 94 | console.log(this.data.list) 95 | } else { 96 | this.setData({ 97 | hasList: false 98 | }) 99 | } 100 | }, 101 | // 删除 102 | deletes: function (e) { 103 | var that = this; 104 | // 获取索引 105 | const index = e.currentTarget.dataset.index; 106 | // 获取商品列表数据 107 | let list = this.data.list; 108 | wx.showModal({ 109 | title: '提示', 110 | content: '确认删除吗', 111 | success: function (res) { 112 | if (res.confirm) { 113 | // 删除索引从1 114 | list.splice(index, 1); 115 | // 页面渲染数据 116 | that.setData({ 117 | list: list 118 | }); 119 | // 如果数据为空 120 | if (!list.length) { 121 | that.setData({ 122 | hasList: false 123 | }); 124 | } else { 125 | // 调用金额渲染数据 126 | that.count_price(); 127 | } 128 | } else { 129 | console.log(res); 130 | } 131 | }, 132 | fail: function (res) { 133 | console.log(res); 134 | } 135 | }) 136 | }, 137 | 138 | 139 | 140 | /** 141 | * 购物车全选事件 142 | */ 143 | selectAll(e) { 144 | // 全选ICON默认选中 145 | let selectAllStatus = this.data.selectAllStatus; 146 | // true ----- false 147 | selectAllStatus = !selectAllStatus; 148 | // 获取商品数据 149 | let list = this.data.list; 150 | // 循环遍历判断列表中的数据是否选中 151 | for (let i = 0; i < list.length; i++) { 152 | list[i].selected = selectAllStatus; 153 | } 154 | // 页面重新渲染 155 | this.setData({ 156 | selectAllStatus: selectAllStatus, 157 | list: list 158 | }); 159 | // 计算金额方法 160 | this.count_price(); 161 | }, 162 | /** 163 | * 绑定加数量事件 164 | */ 165 | btn_add(e) { 166 | // 获取点击的索引 167 | const index = e.currentTarget.dataset.index; 168 | // 获取商品数据 169 | let list = this.data.list; 170 | // 获取商品数量 171 | let num = list[index].num; 172 | // 点击递增 173 | num = num + 1; 174 | list[index].num = num; 175 | // 重新渲染 ---显示新的数量 176 | this.setData({ 177 | list: list 178 | }); 179 | // 计算金额方法 180 | this.count_price(); 181 | }, 182 | 183 | /** 184 | * 绑定减数量事件 185 | */ 186 | btn_minus(e) { 187 | // // 获取点击的索引 188 | const index = e.currentTarget.dataset.index; 189 | // const obj = e.currentTarget.dataset.obj; 190 | // console.log(obj); 191 | // 获取商品数据 192 | let list = this.data.list; 193 | // 获取商品数量 194 | let num = list[index].num; 195 | // 判断num小于等于1 return; 点击无效 196 | if (num <= 1) { 197 | return false; 198 | } 199 | // else num大于1 点击减按钮 数量-- 200 | num = num - 1; 201 | list[index].num = num; 202 | // 渲染页面 203 | this.setData({ 204 | list: list 205 | }); 206 | // 调用计算金额方法 207 | this.count_price(); 208 | }, 209 | // 提交订单 210 | btn_submit_order: function () { 211 | // // 调起支付 212 | // wx.requestPayment( 213 | // { 214 | // 'timeStamp': '', 215 | // 'nonceStr': '', 216 | // 'package': '', 217 | // 'signType': 'MD5', 218 | // 'paySign': '', 219 | // 'success': function (res) { }, 220 | // 'fail': function (res) { }, 221 | // 'complete': function (res) { } 222 | // }) 223 | // wx.showModal({ 224 | // title: '提示', 225 | // content: '合计金额-' + that.data.totalPrice + "暂未开发", 226 | // }) 227 | var that = this; 228 | console.log(that.data.totalPrice); 229 | var countArray = JSON.parse(wx.getStorageSync("countArray")); 230 | console.log("countArray", countArray); 231 | var shopid = JSON.parse(wx.getStorageSync("shopid")); 232 | console.log("shopid", shopid); 233 | wx.request({ 234 | url: 'http://127.0.0.1:8000/api/seproject/createOrder', 235 | method: 'POST', 236 | data: { 237 | store_id: shopid, 238 | countArray: countArray 239 | }, 240 | header: { 241 | 'cookie': wx.getStorageSync('set-cookie') 242 | }, 243 | success: function (res) { 244 | var orderid = res.data.order_id; 245 | that.setData({ 246 | orderid: orderid, 247 | }) 248 | console.log(that.data.orderid) 249 | wx.redirectTo({ 250 | url: '../paySuccess/paySuccess?orderid=' + orderid, 251 | }) 252 | } 253 | }) 254 | }, 255 | // 收藏 256 | btn_collert: function () { 257 | wx.showToast({ 258 | title: '收藏暂未开发', 259 | duration: 2000 260 | }) 261 | }, 262 | /** 263 | * 计算总价 264 | */ 265 | count_price() { 266 | // 获取商品列表数据 267 | let list = this.data.list; 268 | // 声明一个变量接收数组列表price 269 | let total = 0; 270 | // 循环列表得到每个数据 271 | for (let i = 0; i < list.length; i++) { 272 | // 判断选中计算价格 273 | if (list[i].selected) { 274 | // 所有价格加起来 count_money 275 | total += list[i].num * list[i].price; 276 | } 277 | } 278 | // 最后赋值到data中渲染到页面 279 | this.setData({ 280 | list: list, 281 | totalPrice: total.toFixed(2) 282 | }); 283 | }, 284 | // 下拉刷新 285 | // onPullDownRefresh: function () { 286 | // // 显示顶部刷新图标 287 | // wx.showNavigationBarLoading(); 288 | // var that = this; 289 | // console.log(that.data.types_id); 290 | // console.log(that.data.sel_name); 291 | // wx.request({ 292 | // url: host + '请求后台数据地址', 293 | // method: "post", 294 | // data: { 295 | // // 刷新显示最新数据 296 | // page: 1, 297 | // }, 298 | // success: function (res) { 299 | // // console.log(res.data.data.datas); 300 | // that.setData({ 301 | // list: res.data.data.datas 302 | // }) 303 | // } 304 | // }) 305 | // // 隐藏导航栏加载框 306 | // wx.hideNavigationBarLoading(); 307 | // // 停止下拉动作 308 | // wx.stopPullDownRefresh(); 309 | // }, 310 | // 加载更多 311 | // onReachBottom: function () { 312 | // var that = this; 313 | // // 显示加载图标 314 | // wx.showLoading({ 315 | // title: '正在加载中...', 316 | // }) 317 | // numbers++; 318 | // // 页数+1 319 | // wx.request({ 320 | // url: host + '后台数据地址', 321 | // method: "post", 322 | // data: { 323 | // // 分页 324 | // page: numbers, 325 | // }, 326 | // // 请求头部 327 | // header: { 328 | // 'content-type': 'application/json' 329 | // }, 330 | // success: function (res) { 331 | // // 回调函数 332 | // var num = res.data.data.datas.length; 333 | // // console.log(num); 334 | // // 判断数据长度如果不等于0,前台展示数据,false显示暂无订单提示信息 335 | // if (res.data.data.status == 0) { 336 | // for (var i = 0; i < res.data.data.datas.length; i++) { 337 | // that.data.list.push(res.data.data.datas[i]); 338 | // } 339 | // // 设置数据 340 | // that.setData({ 341 | // list: that.data.list 342 | // }) 343 | // } else { 344 | // wx.showToast({ title: '没有更多了', icon: 'loading', duration: 2000 }) 345 | // } 346 | // // 隐藏加载框 347 | // wx.hideLoading(); 348 | // } 349 | // }) 350 | // }, 351 | }) -------------------------------------------------------------------------------- /back-end-python/seproject_app/crud.py: -------------------------------------------------------------------------------- 1 | # crud.py文件实现数据库的增删改查操作 2 | import datetime 3 | from typing import List 4 | 5 | from sqlalchemy.orm import Session 6 | 7 | from . import models, schemas 8 | 9 | 10 | def get_shops(db: Session, skip: int = 0, limit: int = 100) -> List[models.Shop]: 11 | return db.query(models.Shop).offset(skip).limit(limit).all() 12 | 13 | 14 | def get_shop_by_phone(db: Session, phone: str) -> models.Shop: 15 | return db.query(models.Shop).filter(models.Shop.phone == phone).first() 16 | 17 | 18 | def get_shop_by_id(db: Session, id: int) -> models.Shop: 19 | return db.query(models.Shop).filter(models.Shop.id == id).first() 20 | 21 | 22 | def get_dishs(db: Session, skip: int = 0, limit: int = 100) -> List[models.Dish]: 23 | return db.query(models.Dish).offset(skip).limit(limit).all() 24 | 25 | 26 | def get_dishs_by_store_id(db: Session, store_id: str) -> List[models.Dish]: 27 | return db.query(models.Dish).filter(models.Dish.store_id == store_id).all() 28 | 29 | 30 | def get_dish_by_id(db: Session, id: int) -> models.Dish: 31 | return db.query(models.Dish).filter(models.Dish.id == id).first() 32 | 33 | 34 | # def get_evaluates(db: Session, skip: int = 0, limit: int = 100) -> List[models.Comment]: 35 | # return db.query(models.Comment).offset(skip).limit(limit).all() 36 | 37 | 38 | # def get_orders(db: Session, skip: int = 0, limit: int = 100) -> List[models.Order]: 39 | # return db.query(models.Order).offset(skip).limit(limit).all() 40 | 41 | 42 | def get_order_by_id(db: Session, id: int) -> models.Order: 43 | return db.query(models.Order).filter(models.Order.id == id).first() 44 | 45 | 46 | # def get_orders_by_store_id(db: Session, store_id: int) -> List[models.Order]: 47 | # return db.query(models.Order).filter(models.Order.store_id == store_id).all() 48 | 49 | 50 | # def get_order_dish(db: Session, skip: int = 0, limit: int = 100) -> List[models.Order_Dish]: 51 | # return db.query(models.Order_Dish).offset(skip).limit(limit).all() 52 | 53 | 54 | # def get_order_status(db: Session, skip: int = 0, limit: int = 100) -> List[models.Order_Status]: 55 | # return db.query(models.Order_Status).offset(skip).limit(limit).all() 56 | 57 | 58 | def get_user_by_openid(db: Session, openid: str) -> models.User: 59 | return db.query(models.User).filter(models.User.open_id == openid).first() 60 | 61 | 62 | def get_comment_by_order_id(db: Session, order_id: int) -> models.Comment: 63 | return db.query(models.Comment).filter(models.Comment.order_id == order_id).first() 64 | 65 | 66 | def get_comments_by_user_id(db: Session, user_id: int) -> List[models.Comment]: 67 | return ( 68 | db.query(models.Comment) 69 | .join(models.Order) 70 | .filter(models.Order.user_id == user_id) 71 | .all() 72 | ) 73 | 74 | 75 | def get_comments_by_store_id(db: Session, store_id: int) -> List[models.Comment]: 76 | return ( 77 | db.query(models.Comment) 78 | .join(models.Order) 79 | .filter(models.Order.store_id == store_id) 80 | .all() 81 | ) 82 | 83 | 84 | def get_orders_by_user_id(db: Session, user_id: int) -> list: 85 | results = ( 86 | db.query( 87 | models.Order.id, 88 | models.Order.store_id, 89 | models.Order.price, 90 | models.Shop.name, 91 | models.Shop.img, 92 | ) 93 | .filter(models.Order.user_id == user_id) 94 | .join(models.Shop) 95 | .all() 96 | ) 97 | ans = [] 98 | for i in results: 99 | sql = """ 100 | SELECT `order-dish`.num, `dish`.name, `order_status`.comment 101 | FROM `order-dish` 102 | INNER JOIN `dish` ON `dish`.id = `order-dish`.dish_id 103 | INNER JOIN `order_status` ON `order_status`.order_id = `order-dish`.order_id 104 | WHERE `order-dish`.order_id = {} 105 | """.format( 106 | i[0] 107 | ) 108 | res = db.execute(sql).fetchall() 109 | s = "" 110 | for j in res: 111 | s += f"{j[1]}×{j[0]}, " 112 | temp = { 113 | "order_id": i[0], 114 | "store_id": i[1], 115 | "orderPrice": i[2], 116 | "orderShop": i[3], 117 | "orderImg": i[4], 118 | "orderDesc": s, 119 | "orderComment": res[0][2], 120 | } 121 | ans.append(temp) 122 | return ans 123 | 124 | 125 | def get_orders_by_store_id(db: Session, store_id: int) -> list: 126 | sql = """ 127 | SELECT `order`.id, `order`.user_id, `order`.price, `order-dish`.num, `dish`.name 128 | FROM `order-dish` 129 | INNER JOIN `order` ON `order`.id = `order-dish`.order_id 130 | INNER JOIN `dish` ON `dish`.id = `order-dish`.dish_id 131 | WHERE `order`.store_id = {} 132 | """.format( 133 | store_id 134 | ) 135 | res = db.execute(sql).fetchall() 136 | ans = [] 137 | order = {} 138 | for i in res: 139 | if i[0] not in order: 140 | order[i[0]] = len(ans) 141 | t = { 142 | "order_id": i[0], 143 | "user_id": i[1], 144 | "orderPrice": i[2], 145 | "orderDesc": [ 146 | { 147 | "num": i[3], 148 | "name": i[4], 149 | } 150 | ], 151 | } 152 | ans.append(t) 153 | else: 154 | t = { 155 | "num": i[3], 156 | "name": i[4], 157 | } 158 | ans[order[i[0]]]["orderDesc"].append(t) 159 | for i in ans: 160 | status = ( 161 | db.query(models.Order_Status) 162 | .filter(models.Order_Status.order_id == i["order_id"]) 163 | .first() 164 | ) 165 | i["submit_time"] = status.submit_time 166 | i["finish_time"] = status.finish_time 167 | i["status"] = status.status 168 | i["comment"] = status.comment 169 | 170 | print(ans) 171 | return ans 172 | 173 | 174 | # def get_comment_by_store_id(db: Session, store_id: int): 175 | # return db.query(models.Order).join(models.Order_Status).filter(models.Order.store_id == store_id) 176 | 177 | 178 | def create_user(db: Session, openid: str) -> models.User: 179 | db_user = models.User(open_id=openid) 180 | db.add(db_user) 181 | db.commit() 182 | db.refresh(db_user) 183 | return db_user 184 | 185 | 186 | def create_order(db: Session, user_id: int, order: schemas.OrderCreate) -> models.Order: 187 | db_order = models.Order( 188 | store_id=order.store_id, user_id=user_id, price=order.totalPrice 189 | ) 190 | db.add(db_order) 191 | db.commit() 192 | db.refresh(db_order) 193 | return db_order.id 194 | 195 | 196 | def create_order_status(db: Session, order_id: int): 197 | db_order_status = models.Order_Status( 198 | order_id=order_id, submit_time=datetime.datetime.now() 199 | ) 200 | db.add(db_order_status) 201 | db.commit() 202 | 203 | 204 | def create_shop(db: Session, shop: schemas.ShopCreate) -> models.Shop: 205 | # fake_hashed_password = shop.password + "notreallyhashed" 206 | db_shop = models.Shop(**shop.dict()) 207 | db.add(db_shop) 208 | db.commit() 209 | db.refresh(db_shop) 210 | return db_shop 211 | 212 | 213 | def create_comment(db: Session, comment: schemas.CommentCreate) -> models.Comment: 214 | db_comment = models.Comment(**comment.dict(), user_time=datetime.datetime.now()) 215 | db.add(db_comment) 216 | db.commit() 217 | db.refresh(db_comment) 218 | change_order_comment(db, comment.order_id) 219 | return db_comment 220 | 221 | 222 | def create_dish(db: Session, dish: schemas.DishCreate, shop_id: int) -> models.Dish: 223 | db_dish = models.Dish(**dish.dict(), store_id=shop_id) 224 | db.add(db_dish) 225 | db.commit() 226 | db.refresh(db_dish) 227 | return db_dish 228 | 229 | 230 | def add_order_dish(db: Session, order_id: int, dishes: List[schemas.DishOrder]): 231 | for i in dishes: 232 | db_order_dish = models.Order_Dish(order_id=order_id, dish_id=i.id, num=i.num) 233 | db.add(db_order_dish) 234 | db.commit() 235 | 236 | 237 | def change_shop_by_id(db: Session, id: int, shop: schemas.ShopChange) -> models.Shop: 238 | db.query(models.Shop).filter(models.Shop.id == id).update(shop.dict()) 239 | db.commit() 240 | return db.query(models.Shop).filter(models.Shop.id == id).first() 241 | 242 | 243 | def change_dish_by_id( 244 | db: Session, dish_id: int, dish: schemas.DishChange 245 | ) -> models.Dish: 246 | db.query(models.Dish).filter(models.Dish.id == dish_id).update(dish.dict()) 247 | db.commit() 248 | return db.query(models.Dish).filter(models.Dish.id == dish_id).first() 249 | 250 | 251 | def change_shop_img(db: Session, shop_id: int, imgaddress: str) -> models.Shop: 252 | db.query(models.Shop).filter(models.Shop.id == shop_id).update({models.Shop.img: imgaddress}) 253 | db.commit() 254 | 255 | 256 | def change_dish_img(db: Session, dish_id: int, imgaddress: str) -> models.Shop: 257 | db.query(models.Dish).filter(models.Dish.id == dish_id).update({models.Dish.icon: imgaddress}) 258 | db.commit() 259 | 260 | 261 | def change_order_status(db: Session, order_id: int): 262 | db.query(models.Order_Status).filter( 263 | models.Order_Status.order_id == order_id 264 | ).update( 265 | { 266 | models.Order_Status.status: (1 - models.Order_Status.status), 267 | models.Order_Status.finish_time: datetime.datetime.now(), 268 | } 269 | ) 270 | db.commit() 271 | 272 | 273 | def change_order_comment(db: Session, order_id: int): 274 | db.query(models.Order_Status).filter( 275 | models.Order_Status.order_id == order_id 276 | ).update({models.Order_Status.comment: (1 - models.Order_Status.comment)}) 277 | db.commit() 278 | 279 | 280 | def change_reply_comment( 281 | db: Session, order_id: int, reply: schemas.CommentReply 282 | ) -> models.Comment: 283 | d = reply.dict() 284 | d["store_time"] = datetime.datetime.now() 285 | db.query(models.Comment).filter(models.Comment.order_id == reply.order_id).update(d) 286 | db.commit() 287 | return ( 288 | db.query(models.Comment) 289 | .filter(models.Comment.order_id == reply.order_id) 290 | .first() 291 | ) 292 | -------------------------------------------------------------------------------- /front-end-WeChat-applet/pages/food/food.wxss: -------------------------------------------------------------------------------- 1 | .container { 2 | width: 100%; 3 | height: 100%; 4 | padding-top: 0; 5 | } 6 | 7 | .head-logo-view { 8 | position: relative; 9 | width: 100%; 10 | height: 604rpx; 11 | text-align: center; 12 | } 13 | 14 | .head-logo-icon { 15 | position: absolute; 16 | width: 420rpx; 17 | height: 406rpx; 18 | display: block; 19 | top: 6%; 20 | left: 22%; 21 | } 22 | 23 | .shop-body { 24 | position: relative; 25 | width: 100%; 26 | height: 500rpx; 27 | } 28 | 29 | .shop-lable-left { 30 | position: absolute; 31 | width: 175rpx; 32 | height: 100%; 33 | left: 0rpx; 34 | background-color: #fff; 35 | } 36 | 37 | .textnums { 38 | position: absolute; 39 | right: 0; 40 | font-size: 24rpx; 41 | width: 35rpx; 42 | height: 35rpx; 43 | line-height: 35rpx; 44 | color: #fff; 45 | background: red; 46 | text-align: center; 47 | border-radius: 50%; 48 | top: -6rpx; 49 | z-index: 2; 50 | } 51 | 52 | .shopimg { 53 | position: relative; 54 | width: 80rpx; 55 | height: 80rpx; 56 | animation: mymoves 3s infinite; 57 | animation-direction: alternate; 58 | animation-timing-function: ease-in-out; 59 | -webkit-animation: mymoves 3s infinite; 60 | -webkit-animation-direction: alternate; 61 | -webkit-animation-timing-function: ease-in-out; 62 | } 63 | 64 | .shopIcon { 65 | position: absolute; 66 | width: 80rpx; 67 | height: 80rpx; 68 | /* background: red; */ 69 | text-align: center; 70 | border-radius: 50%; 71 | left: 30rpx; 72 | bottom: 25%; 73 | z-index: 3; 74 | } 75 | 76 | .shop-lable { 77 | position: relative; 78 | width: 174rpx; 79 | text-align: center; 80 | height: 140rpx; 81 | line-height: 140rpx; 82 | background-color: #fff; 83 | font-size: 26rpx; 84 | font-family: PingFangSC-Regular; 85 | font-weight: 400; 86 | color: rgba(48, 48, 48, 1); 87 | } 88 | 89 | .shop-lable-right { 90 | position: absolute; 91 | right: 0rpx; 92 | width: 74%; 93 | height: 100%; 94 | background-color: #fff; 95 | } 96 | 97 | .shop-base { 98 | position: relative; 99 | width: 100%; 100 | height: 196rpx; 101 | background-color: #fff; 102 | } 103 | 104 | /* pages/goodss/goodss.wxss */ 105 | 106 | .swiper-tab { 107 | width: 100%; 108 | border-bottom: 2rpx solid #777; 109 | text-align: center; 110 | line-height: 80rpx; 111 | position: fixed; 112 | top: 0; 113 | z-index: 2; 114 | background: #fff; 115 | } 116 | 117 | .swiper-tab-list { 118 | font-size: 30rpx; 119 | display: inline-block; 120 | width: 25%; 121 | color: #777; 122 | } 123 | 124 | .on { 125 | color: #da7c0c; 126 | border-bottom: 5rpx solid #da7c0c; 127 | } 128 | 129 | .swiper-box { 130 | display: block; 131 | height: 100%; 132 | width: 100%; 133 | overflow: hidden; 134 | position: relative; 135 | top: 60px; 136 | } 137 | 138 | .swiper-box view { 139 | text-align: center; 140 | } 141 | 142 | /* 首頁商品信息 */ 143 | 144 | /* pages/goodss/goodss.wxss */ 145 | 146 | .swiper-tab { 147 | width: 100%; 148 | border-bottom: 2rpx solid #777; 149 | text-align: center; 150 | line-height: 80rpx; 151 | position: fixed; 152 | top: 0; 153 | z-index: 2; 154 | background: #fff; 155 | } 156 | 157 | .swiper-tab-list { 158 | font-size: 30rpx; 159 | display: inline-block; 160 | width: 25%; 161 | color: #777; 162 | } 163 | 164 | .swiper-box { 165 | display: block; 166 | height: 100%; 167 | width: 100%; 168 | overflow: hidden; 169 | position: relative; 170 | top: 120rpx; 171 | } 172 | 173 | .swiper-box view { 174 | text-align: center; 175 | } 176 | 177 | /* 首頁商品信息 */ 178 | 179 | .goods { 180 | display: flex; 181 | position: relative; 182 | width: 100%; 183 | overflow: hidden; 184 | } 185 | 186 | .goods .menu-wrapper { 187 | flex: 0 0 160rpx; 188 | width: 160rpx; 189 | background-color: #fff; 190 | } 191 | 192 | .goods .menu-wrapper .menu-item { 193 | display: table; 194 | width: 113rpx; 195 | height: 108rpx; 196 | padding: 0 24rpx; 197 | font-weight: bolder; 198 | } 199 | 200 | .goods .menu-wrapper .menu-item:current { 201 | position: relative; 202 | z-index: 10; 203 | margin-top: -2rpx; 204 | 205 | background: #fff; 206 | font-weight: 700; 207 | } 208 | 209 | .goods .menu-wrapper .menu-item:current .text { 210 | border: none; 211 | } 212 | 213 | 214 | .goods .menu-wrapper .menu-item .text { 215 | border: none; 216 | display: table-cell; 217 | width: 113rpx; 218 | text-align: center; 219 | /* background-color: red; */ 220 | vertical-align: middle; 221 | position: relative; 222 | font-size: 24rpx; 223 | } 224 | 225 | .foods-wrapper { 226 | position: absolute; 227 | width: 80%; 228 | right: 0rpx; 229 | /* margin-bottom: 30rpx; */ 230 | background-color: #fff; 231 | flex: 1; 232 | height: 100%; 233 | } 234 | 235 | .title { 236 | /* height: 52rpx; 237 | position: absolute; 238 | width: 100%; 239 | line-height: 55rpx; 240 | left: 15rpx; 241 | font-size: 24rpx; 242 | color: rgb(147, 153, 159); 243 | background: #f3f5f7; */ 244 | position: relative; 245 | width: 100%; 246 | height: 10rpx; 247 | line-height: 10rpx; 248 | } 249 | 250 | .left_menu { 251 | position: relative; 252 | background: #f5f5f5; 253 | /* border-right: 1rpx solid red; */ 254 | } 255 | 256 | .goods .foods-wrapper .food-list .food-item { 257 | display: flex; 258 | /* margin-bottom: 20rpx; */ 259 | padding: 5rpx; 260 | border-bottom: 1rpx solid #ddd; 261 | position: relative; 262 | } 263 | 264 | .goods .foods-wrapper .food-list .food-item:last-child { 265 | border: none; 266 | margin-bottom: 20rpx; 267 | } 268 | 269 | .goods .foods-wrapper .food-list .food-item .icon { 270 | width: 140rpx; 271 | height: 180rpx; 272 | } 273 | 274 | .shop-image { 275 | position: absolute; 276 | left: 15rpx; 277 | top: 19rpx; 278 | width: 150rpx; 279 | height: 150rpx; 280 | } 281 | 282 | .name { 283 | position: absolute; 284 | left: 185rpx; 285 | top: 29rpx; 286 | font-size: 28rpx; 287 | height: 28rpx; 288 | font-family: PingFangSC-Medium; 289 | font-weight: 500; 290 | color: rgba(48, 48, 48, 1); 291 | } 292 | 293 | .desc { 294 | position: absolute; 295 | left: 185rpx; 296 | top: 70rpx; 297 | font-size: 20rpx; 298 | width: 320rpx; 299 | font-family: PingFangSC-Regular; 300 | font-weight: 400; 301 | color: rgba(127, 127, 127, 1); 302 | overflow: hidden; 303 | text-overflow: ellipsis; 304 | display: -webkit-box; 305 | -webkit-line-clamp: 2; 306 | -webkit-box-orient: vertical; 307 | } 308 | 309 | .price { 310 | position: absolute; 311 | width: 210rpx; 312 | height: 40rpx; 313 | line-height: 40rpx; 314 | font-size: 28rpx; 315 | left: 185rpx; 316 | top: 125rpx; 317 | } 318 | 319 | 320 | 321 | /* cartControl 样式 */ 322 | .cartControl { 323 | position: absolute; 324 | width: 150rpx; 325 | height: 40rpx; 326 | line-height: 40rpx; 327 | right: 30rpx; 328 | top: 125rpx; 329 | } 330 | 331 | .icon-jian { 332 | position: absolute; 333 | width: 40rpx; 334 | height: 40rpx; 335 | left: 0rpx; 336 | } 337 | 338 | .cart-count { 339 | position: absolute; 340 | width: 40rpx; 341 | height: 40rpx; 342 | right: 50rpx; 343 | } 344 | 345 | .cart-add { 346 | position: absolute; 347 | width: 40rpx; 348 | height: 40rpx; 349 | right: 0rpx; 350 | } 351 | 352 | 353 | 354 | 355 | .food-cont { 356 | position: relative; 357 | width: 100%; 358 | height: 195rpx; 359 | } 360 | 361 | .food-image { 362 | position: absolute; 363 | left: 20rpx; 364 | width: 140rpx; 365 | height: 180rpx; 366 | top: 6rpx; 367 | border-radius: 4rpx; 368 | } 369 | 370 | .food-name { 371 | position: absolute; 372 | left: 173rpx; 373 | width: 200rpx; 374 | font-size: 28rpx; 375 | top: 5%; 376 | font-family: PingFangSC-Medium; 377 | font-weight: 500; 378 | color: rgba(48, 48, 48, 1); 379 | } 380 | 381 | .food-title { 382 | position: absolute; 383 | left: 173rpx; 384 | font-size: 20rpx; 385 | width: 320rpx; 386 | background-color: #fff; 387 | display: -webkit-box; 388 | -webkit-box-orient: vertical; 389 | -webkit-line-clamp: 3; 390 | overflow: hidden; 391 | top: 25%; 392 | font-family: PingFangSC-Regular; 393 | font-weight: 400; 394 | color: rgba(127, 127, 127, 1); 395 | } 396 | 397 | .food-money { 398 | position: absolute; 399 | left: 173rpx; 400 | width: 235rpx; 401 | font-family: PingFangSC-Semibold; 402 | font-weight: 600; 403 | font-size: 26rpx; 404 | color: rgba(48, 48, 48, 1); 405 | height: 40rpx; 406 | line-height: 40rpx; 407 | top: 68%; 408 | } 409 | 410 | .base-num-money { 411 | position: absolute; 412 | width: 150rpx; 413 | height: 40rpx; 414 | top: 68%; 415 | line-height: 40rpx; 416 | right: 30rpx; 417 | } 418 | 419 | .minus-icon { 420 | position: absolute; 421 | left: 0rpx; 422 | width: 42rpx; 423 | height: 42rpx; 424 | } 425 | 426 | .food-nums { 427 | position: absolute; 428 | right: 50rpx; 429 | width: 50rpx; 430 | font-size: 28rpx; 431 | line-height: 40rpx; 432 | text-align: center; 433 | font-family: PingFangSC-Medium; 434 | font-weight: 500; 435 | color: rgba(48, 48, 48, 1); 436 | } 437 | 438 | .add-icon { 439 | position: absolute; 440 | right: 0rpx; 441 | width: 42rpx; 442 | height: 42rpx; 443 | } 444 | 445 | .shop-bottom { 446 | position: fixed; 447 | z-index: 9; 448 | bottom: 0rpx; 449 | height: 100rpx; 450 | line-height: 100rpx; 451 | width: 100%; 452 | background-color: #23a393; 453 | } 454 | 455 | .shop-icon { 456 | position: absolute; 457 | width: 62rpx; 458 | height: 58rpx; 459 | top: 26%; 460 | left: 62rpx; 461 | } 462 | 463 | .count-money { 464 | position: absolute; 465 | width: 225rpx; 466 | height: 40rpx; 467 | display: inline-block; 468 | left: 140rpx; 469 | font-size: 40rpx; 470 | line-height: 40rpx; 471 | top: 35%; 472 | font-family: PingFangSC-Semibold; 473 | font-weight: 600; 474 | color: rgba(255, 255, 255, 1); 475 | } 476 | 477 | .shop-num { 478 | position: absolute; 479 | width: 40rpx; 480 | height: 40rpx; 481 | line-height: 40rpx; 482 | top: 10%; 483 | left: 12%; 484 | text-align: center; 485 | border-radius: 50%; 486 | font-size: 20rpx; 487 | background-color: red; 488 | color: #fff; 489 | border: 1rpx solid #fff; 490 | } 491 | 492 | .go-shop { 493 | position: absolute; 494 | left: 52%; 495 | width: 84rpx; 496 | height: 40rpx; 497 | font-size: 28rpx; 498 | font-family: PingFangSC-Regular; 499 | font-weight: 400; 500 | color: rgba(255, 255, 255, 1); 501 | line-height: 40rpx; 502 | top: 35%; 503 | } 504 | 505 | .shop-me { 506 | position: absolute; 507 | right: 0rpx; 508 | width: 230rpx; 509 | background-color: #fff; 510 | height: 100rpx; 511 | line-height: 100rpx; 512 | color: #303030; 513 | text-align: center; 514 | background: rgba(255, 255, 255, 1); 515 | box-shadow: 0rpx 2rpx 4rpx 0rpx rgba(127, 127, 127, 1); 516 | } -------------------------------------------------------------------------------- /back-end-python/seproject_app/main.py: -------------------------------------------------------------------------------- 1 | # main.py用来实现api的接口 2 | import os, stat 3 | import shutil 4 | from pathlib import Path 5 | from tempfile import NamedTemporaryFile 6 | from typing import List, Optional 7 | 8 | import requests 9 | from fastapi import Cookie, Depends, FastAPI, HTTPException, Response, responses 10 | from fastapi.datastructures import UploadFile 11 | from fastapi.params import File 12 | from sqlalchemy.orm import Session 13 | 14 | from . import crud, models, schemas 15 | from .data.data import imgprefix, imgpath, testopenid, wxappid, wxsecret, wxurl 16 | from .database import SessionLocal, engine 17 | 18 | # 在数据库中生成表结构 19 | models.Base.metadata.create_all(bind=engine) 20 | 21 | app = FastAPI() 22 | 23 | 24 | def get_db(): 25 | db = SessionLocal() 26 | try: 27 | yield db 28 | finally: 29 | db.close() 30 | 31 | 32 | @app.get( 33 | "/api/seproject/getOpenid", 34 | response_model=schemas.User, 35 | summary="顾客微信登录", 36 | description="通过顾客传入的验证码,借助微信提供的api获取到用户id并进行登录", 37 | tags=["顾客"], 38 | ) 39 | def getid(code: str, db: Session = Depends(get_db)): 40 | url = wxurl 41 | appid = wxappid 42 | secret = wxsecret 43 | params = { 44 | "appid": appid, 45 | "secret": secret, 46 | "js_code": code, 47 | "grant_type": "authorization_code", 48 | } 49 | 50 | data = requests.get(url, params=params).json() 51 | print(data) 52 | if "openid" not in data: 53 | resp = responses.JSONResponse(content=data) 54 | return resp 55 | 56 | openid = data["openid"] 57 | print(data) 58 | db_user = crud.get_user_by_openid(db, openid) 59 | if not db_user: 60 | db_user = crud.create_user(db=db, openid=openid) 61 | 62 | resp = responses.JSONResponse(content={"id": db_user.id}) 63 | resp.set_cookie(key="openid", value=openid) 64 | return resp 65 | 66 | 67 | @app.get( 68 | "/api/seproject/getStoreInfo", 69 | response_model=schemas.ShopDict, 70 | summary="顾客获取店铺信息", 71 | description="返回所有店铺信息", 72 | tags=["顾客"], 73 | ) 74 | def read_shops(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)): 75 | shops = crud.get_shops(db, skip=skip, limit=limit) 76 | l = [] 77 | for i in shops: 78 | d = {"id": i.id, 79 | "shopName": i.name, 80 | "shopDesc": i.describe, 81 | "shopText": "距离{}m".format(i.distance), 82 | "shopImg": f"{i.img}"} 83 | l.append(d) 84 | pass 85 | data = schemas.ShopDict(msg="ok", shoplist=l) 86 | return data 87 | 88 | 89 | @app.get( 90 | "/api/seproject/getDishInfo", 91 | response_model=schemas.DishDict, 92 | summary="顾客获取菜品信息", 93 | description="返回所选中店铺的所有菜品信息按照菜品种类分类", 94 | tags=["顾客"], 95 | ) 96 | def get_dish_info(store_id: int, db: Session = Depends(get_db)): 97 | if not store_id: 98 | raise HTTPException(status_code=422, detail="Missing parameter") 99 | else: 100 | dishs = crud.get_dishs_by_store_id(db, store_id) 101 | data = schemas.DishDict(msg="ok", goods=[]) 102 | h = {} 103 | foodlist = [] 104 | for inx, i in enumerate(dishs): 105 | if not i.flavor in h: 106 | h[i.flavor] = [inx] 107 | else: 108 | h[i.flavor].append(inx) 109 | d = {"name": i.name, 110 | "price": i.price, 111 | "id": i.id, 112 | "description": i.description, 113 | "icon": f"{i.icon}", 114 | "Count": 0} 115 | foodlist.append(d) 116 | temp = [] 117 | for i in h: 118 | d = schemas.FlavorList(name=i, foods=[]) 119 | for j in h[i]: 120 | d.foods.append(foodlist[j]) 121 | temp.append(d) 122 | data.goods = temp 123 | return data 124 | 125 | 126 | @app.post( 127 | "/api/seproject/createOrder", summary="顾客创建订单", description="生成订单", tags=["顾客"] 128 | ) 129 | def create_order( 130 | order: schemas.OrderCreate, 131 | db: Session = Depends(get_db), 132 | openid: Optional[str] = Cookie(None), 133 | ): 134 | if not openid: 135 | raise HTTPException(status_code=401, detail="please login first") 136 | 137 | user = crud.get_user_by_openid(db, openid) 138 | 139 | # 错误检查 140 | price = 0.0 141 | store = crud.get_shop_by_id(db, order.store_id) 142 | if store is None: 143 | raise HTTPException(status_code=404, detail="Shop not found") 144 | for i in order.countArray: 145 | dish = crud.get_dish_by_id(db, i.id) 146 | if dish is None: 147 | raise HTTPException(status_code=404, detail="Dish not found") 148 | if dish.store_id != store.id: 149 | raise HTTPException(status_code=400, detail="Not a dish in this shop") 150 | price += dish.price * i.num 151 | 152 | order.totalPrice = round(price, 2) 153 | # 订单表内加订单 154 | order_id = crud.create_order(db, user.id, order) 155 | # 订单-菜品表加数据 156 | crud.add_order_dish(db, order_id, order.countArray) 157 | # 订单状态表加数据 158 | crud.create_order_status(db, order_id) 159 | data = {"msg": "succeed", "order_id": order_id} 160 | resp = responses.JSONResponse(content=data) 161 | return resp 162 | 163 | 164 | @app.get( 165 | "/api/seproject/getAllOrders", 166 | response_model=schemas.OrderDict, 167 | summary="顾客获取全部订单", 168 | description="返回顾客创建的所有订单", 169 | tags=["顾客"], 170 | ) 171 | def get_all_orders(db: Session = Depends(get_db), openid: Optional[str] = Cookie(None)): 172 | if not openid: 173 | raise HTTPException(status_code=401, detail="please login first") 174 | 175 | user = crud.get_user_by_openid(db, openid) 176 | return schemas.OrderDict( 177 | msg="succeed", data=crud.get_orders_by_user_id(db, user.id) 178 | ) 179 | 180 | 181 | @app.get( 182 | "/api/seproject/getComment", 183 | response_model=schemas.CommentDict, 184 | summary="获取评价", 185 | description="返回所选订单的评价", 186 | tags=["通用"], 187 | ) 188 | def get_comment(order_id: int, db: Session = Depends(get_db)): 189 | if not order_id: 190 | raise HTTPException(status_code=422, detail="Missing parameter") 191 | 192 | db_comment = crud.get_comment_by_order_id(db, order_id) 193 | if not db_comment: 194 | raise HTTPException(status_code=400, detail="Comment not found") 195 | 196 | return schemas.CommentDict(msg="succeed", data=db_comment) 197 | 198 | 199 | @app.post( 200 | "/api/seproject/addComment", 201 | response_model=schemas.SimpleReply, 202 | summary="顾客创建评论", 203 | description="创建评论", 204 | tags=["顾客"], 205 | ) 206 | def create_comment( 207 | comment: schemas.CommentCreate, 208 | db: Session = Depends(get_db), 209 | openid: Optional[str] = Cookie(None), 210 | ): 211 | if not openid: 212 | raise HTTPException(status_code=401, detail="please login first") 213 | 214 | db_comment = crud.get_comment_by_order_id(db, comment.order_id) 215 | if db_comment: 216 | raise HTTPException(status_code=400, detail="Comment already exists") 217 | 218 | db_order = crud.get_order_by_id(db, comment.order_id) 219 | user = crud.get_user_by_openid(db, openid) 220 | if db_order is None: 221 | raise HTTPException(status_code=400, detail="Order not found") 222 | if db_order.user_id != user.id: 223 | raise HTTPException(status_code=400, detail="You have no permission to do this") 224 | 225 | crud.create_comment(db, comment) 226 | return schemas.SimpleReply(msg="succeed") 227 | 228 | 229 | 230 | 231 | 232 | ############################ 233 | # 以下为商家模块 234 | 235 | 236 | # @app.post( 237 | # "/api/seproject/shop/signIn", 238 | # response_model=schemas.Shop, 239 | # summary="商家登录", 240 | # description="商家输入手机号码和密码进行登录", 241 | # tags=["商家"], 242 | # ) 243 | # def signin(shop: schemas.ShopLogin, response: Response, db: Session = Depends(get_db)): 244 | # db_shop = crud.get_shop_by_phone(db, phone=shop.phone) 245 | # if db_shop is None: 246 | # raise HTTPException(status_code=400, detail="Shop not found") 247 | # if db_shop.password != shop.password: 248 | # raise HTTPException(status_code=400, detail="Wrong password, try again") 249 | # if db_shop.img: 250 | # db_shop.img = imgprefix + db_shop.img 251 | # response.set_cookie(key="shopid", value=db_shop.id) 252 | # return db_shop 253 | # 254 | # 255 | # @app.post( 256 | # "/api/seproject/shop/signUp", 257 | # response_model=schemas.Shop, 258 | # summary="商家注册", 259 | # description="商家输入信息进行注册", 260 | # tags=["商家"], 261 | # ) 262 | # def create_shop(shop: schemas.ShopCreate, db: Session = Depends(get_db)): 263 | # db_shop = crud.get_shop_by_phone(db, phone=shop.phone) 264 | # if db_shop: 265 | # raise HTTPException(status_code=400, detail="Phone already registered") 266 | # return crud.create_shop(db=db, shop=shop) 267 | # 268 | # 269 | # @app.post( 270 | # "/api/seproject/shop/changeInfo", 271 | # response_model=schemas.Shop, 272 | # summary="商家修改信息", 273 | # description="商家输入信息进行修改", 274 | # tags=["商家"], 275 | # ) 276 | # def change_shop( 277 | # shop: schemas.ShopChange, 278 | # db: Session = Depends(get_db), 279 | # shopid: Optional[int] = Cookie(None), 280 | # ): 281 | # if not shopid: 282 | # raise HTTPException(status_code=401, detail="please login first") 283 | # 284 | # return crud.change_shop_by_id(db, shopid, shop) 285 | # 286 | # 287 | # @app.post( 288 | # "/api/seproject/shop/createDish", 289 | # response_model=schemas.Dish, 290 | # summary="商家添加菜品", 291 | # description="商家输入菜品信息添加菜品", 292 | # tags=["商家"], 293 | # ) 294 | # def create_dish( 295 | # dish: schemas.DishCreate, 296 | # db: Session = Depends(get_db), 297 | # shopid: Optional[int] = Cookie(None), 298 | # ): 299 | # if not shopid: 300 | # raise HTTPException(status_code=401, detail="please login first") 301 | # return crud.create_dish(db, dish, shopid) 302 | # 303 | # 304 | # @app.get( 305 | # "/api/seproject/shop/getShopDishInfo", 306 | # response_model=List[schemas.Dish], 307 | # summary="商家获取所有菜品信息", 308 | # description="返回所有菜品信息", 309 | # tags=["商家"], 310 | # ) 311 | # def get_shop_dish_info( 312 | # db: Session = Depends(get_db), 313 | # shopid: Optional[int] = Cookie(None), 314 | # ): 315 | # if not shopid: 316 | # raise HTTPException(status_code=401, detail="please login first") 317 | # l = crud.get_dishs_by_store_id(db, shopid) 318 | # for i in l: 319 | # if i.icon: 320 | # i.icon = imgprefix + i.icon 321 | # return l 322 | # 323 | # 324 | # @app.post( 325 | # "/api/seproject/shop/changeShopDishInfo", 326 | # response_model=schemas.Dish, 327 | # summary="商家更改菜品信息", 328 | # description="更改菜品信息", 329 | # tags=["商家"], 330 | # ) 331 | # def change_shop_dish_info( 332 | # dish: schemas.DishChange, 333 | # db: Session = Depends(get_db), 334 | # shopid: Optional[int] = Cookie(None), 335 | # ): 336 | # db_dish = crud.get_dish_by_id(db, dish.id) 337 | # if db_dish is None: 338 | # raise HTTPException(status_code=404, detail="Dish not found") 339 | # if db_dish.store_id != shopid: 340 | # raise HTTPException(status_code=400, detail="You have no permission to do this") 341 | # if not shopid: 342 | # raise HTTPException(status_code=401, detail="please login first") 343 | # 344 | # return crud.change_dish_by_id(db, db_dish.id, dish) 345 | # 346 | # 347 | # @app.get( 348 | # "/api/seproject/shop/changeOrderStatus", 349 | # response_model=schemas.SimpleReply, 350 | # summary="商家修改订单状态", 351 | # description="修改订单状态", 352 | # tags=["商家"], 353 | # ) 354 | # def change_order_status( 355 | # order_id: int, 356 | # db: Session = Depends(get_db), 357 | # shopid: Optional[int] = Cookie(None), 358 | # ): 359 | # if not shopid: 360 | # raise HTTPException(status_code=401, detail="please login first") 361 | # db_order = crud.get_order_by_id(db, order_id) 362 | # if db_order is None: 363 | # raise HTTPException(status_code=404, detail="Order not found") 364 | # if db_order.store_id != shopid: 365 | # raise HTTPException(status_code=400, detail="You have no permission to do this") 366 | # crud.change_order_status(db, order_id) 367 | # return schemas.SimpleReply(msg="succeed") 368 | # 369 | # 370 | # @app.get( 371 | # "/api/seproject/shop/getShopOrder", 372 | # response_model=List[schemas.OrderShop], 373 | # summary="商家获取所有订单", 374 | # description="返回该商家的所有订单", 375 | # tags=["商家"], 376 | # ) 377 | # def get_shop_order( 378 | # db: Session = Depends(get_db), 379 | # shopid: Optional[int] = Cookie(None), 380 | # ): 381 | # if not shopid: 382 | # raise HTTPException(status_code=401, detail="please login first") 383 | # return crud.get_orders_by_store_id(db, shopid) 384 | # 385 | # 386 | # @app.get( 387 | # "/api/seproject/shop/getShopComment", 388 | # response_model=List[schemas.Comment], 389 | # summary="商家获取所有评价", 390 | # description="返回商家的所有评价", 391 | # tags=["商家"], 392 | # ) 393 | # def get_shop_comment( 394 | # db: Session = Depends(get_db), 395 | # shopid: Optional[int] = Cookie(None), 396 | # ): 397 | # if not shopid: 398 | # raise HTTPException(status_code=401, detail="please login first") 399 | # return crud.get_comments_by_store_id(db, shopid) 400 | # 401 | # 402 | # @app.post( 403 | # "/api/seproject/shop/replyComment", 404 | # response_model=schemas.Comment, 405 | # summary="商家回复评论", 406 | # description="回复评论", 407 | # tags=["商家"], 408 | # ) 409 | # def reply_comment( 410 | # comment: schemas.CommentReply, 411 | # db: Session = Depends(get_db), 412 | # shopid: Optional[int] = Cookie(None), 413 | # ): 414 | # if not shopid: 415 | # raise HTTPException(status_code=401, detail="please login first") 416 | # 417 | # db_comment = crud.get_comment_by_order_id(db, comment.order_id) 418 | # if db_comment is None: 419 | # raise HTTPException(status_code=404, detail="Comment not found") 420 | # 421 | # db_order = crud.get_order_by_id(db, db_comment.order_id) 422 | # db_shop = crud.get_shop_by_id(db, shopid) 423 | # if db_order is None: 424 | # raise HTTPException(status_code=400, detail="Order not found") 425 | # if db_order.store_id != db_shop.id: 426 | # raise HTTPException(status_code=400, detail="You have no permission to do this") 427 | # 428 | # return crud.change_reply_comment(db, db_order.id, comment) 429 | # 430 | # 431 | # @app.post( 432 | # "/api/seproject/shop/upLoadImg", 433 | # response_model=schemas.SimpleReply, 434 | # summary="商家上传图片", 435 | # description="上传图片,type为1时上传的是店铺图片,为2时是菜品图片,此时菜品id为必填", 436 | # tags=["商家"], 437 | # ) 438 | # def upload_image( 439 | # type: int, 440 | # dish_id: Optional[int] = None, 441 | # file: UploadFile = File(...), 442 | # db: Session = Depends(get_db), 443 | # shopid: Optional[int] = Cookie(None), 444 | # ): 445 | # if not shopid: 446 | # raise HTTPException(status_code=401, detail="please login first") 447 | # if type == 1: 448 | # add = "storeImg/" 449 | # elif type != 2: 450 | # raise HTTPException(status_code=422, detail="Unknown type") 451 | # else: 452 | # if dish_id is None: 453 | # raise HTTPException(status_code=422, detail="Missing parameter") 454 | # db_dish = crud.get_dish_by_id(db, dish_id) 455 | # if db_dish.store_id != shopid: 456 | # raise HTTPException(status_code=400, detail="You have no permission to do this") 457 | # add = "dishImg/" 458 | # 459 | # save_dir = imgpath + add 460 | # if not os.path.exists(save_dir): 461 | # os.mkdir(save_dir) 462 | # 463 | # try: 464 | # suffix = Path(file.filename).suffix 465 | # with NamedTemporaryFile(delete=False, suffix=suffix, dir=save_dir) as tmp: 466 | # shutil.copyfileobj(file.file, tmp) 467 | # os.chmod(tmp.name, stat.S_IRWXO + stat.S_IRWXG + stat.S_IRWXU) 468 | # tmp_file_name = Path(tmp.name).name 469 | # finally: 470 | # file.file.close() 471 | # 472 | # if type == 1: 473 | # crud.change_shop_img(db, shopid, add + tmp_file_name) 474 | # else: 475 | # crud.change_dish_img(db, dish_id, add + tmp_file_name) 476 | # 477 | # return schemas.SimpleReply(msg = "succeed") 478 | --------------------------------------------------------------------------------