@@ -0,0 +1,12 @@ | |||
# http://editorconfig.org | |||
root = true | |||
[*] | |||
indent_style = space | |||
indent_size = 2 | |||
charset = utf-8 | |||
trim_trailing_whitespace = true | |||
insert_final_newline = true | |||
[*.md] | |||
trim_trailing_whitespace = false |
@@ -0,0 +1,7 @@ | |||
{ | |||
"extends": ["taro/react"], | |||
"rules": { | |||
"react/jsx-uses-react": "off", | |||
"react/react-in-jsx-scope": "off" | |||
} | |||
} |
@@ -0,0 +1,9 @@ | |||
dist/ | |||
deploy_versions/ | |||
.temp/ | |||
.rn_temp/ | |||
node_modules/ | |||
.DS_Store | |||
/.idea/ | |||
/yarn.lock | |||
/.swc/plugins/v4 |
@@ -0,0 +1,10 @@ | |||
registry=https://registry.npmmirror.com | |||
disturl=https://npm.taobao.org/dist | |||
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/ | |||
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/ | |||
electron_mirror=https://npm.taobao.org/mirrors/electron/ | |||
chromedriver_cdnurl=https://npm.taobao.org/mirrors/chromedriver | |||
operadriver_cdnurl=https://npm.taobao.org/mirrors/operadriver | |||
selenium_cdnurl=https://npm.taobao.org/mirrors/selenium | |||
node_inspector_cdnurl=https://npm.taobao.org/mirrors/node-inspector | |||
fsevents_binary_host_mirror=http://npm.taobao.org/mirrors/fsevents/ |
@@ -0,0 +1,127 @@ | |||
木兰宽松许可证, 第2版 | |||
木兰宽松许可证, 第2版 | |||
2020年1月 http://license.coscl.org.cn/MulanPSL2 | |||
您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束: | |||
0. 定义 | |||
“软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。 | |||
“贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。 | |||
“贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。 | |||
“法人实体”是指提交贡献的机构及其“关联实体”。 | |||
“关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。 | |||
1. 授予版权许可 | |||
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。 | |||
2. 授予专利许可 | |||
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。 | |||
3. 无商标许可 | |||
“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。 | |||
4. 分发限制 | |||
您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。 | |||
5. 免责声明与责任限制 | |||
“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。 | |||
6. 语言 | |||
“本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。 | |||
条款结束 | |||
如何将木兰宽松许可证,第2版,应用到您的软件 | |||
如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步: | |||
1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字; | |||
2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中; | |||
3, 请将如下声明文本放入每个源文件的头部注释中。 | |||
Copyright (c) [Year] [name of copyright holder] | |||
[Software Name] is licensed under Mulan PSL v2. | |||
You can use this software according to the terms and conditions of the Mulan PSL v2. | |||
You may obtain a copy of Mulan PSL v2 at: | |||
http://license.coscl.org.cn/MulanPSL2 | |||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | |||
See the Mulan PSL v2 for more details. | |||
Mulan Permissive Software License,Version 2 | |||
Mulan Permissive Software License,Version 2 (Mulan PSL v2) | |||
January 2020 http://license.coscl.org.cn/MulanPSL2 | |||
Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions: | |||
0. Definition | |||
Software means the program and related documents which are licensed under this License and comprise all Contribution(s). | |||
Contribution means the copyrightable work licensed by a particular Contributor under this License. | |||
Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. | |||
Legal Entity means the entity making a Contribution and all its Affiliates. | |||
Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. | |||
1. Grant of Copyright License | |||
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. | |||
2. Grant of Patent License | |||
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. | |||
3. No Trademark License | |||
No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4. | |||
4. Distribution Restriction | |||
You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. | |||
5. Disclaimer of Warranty and Limitation of Liability | |||
THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |||
6. Language | |||
THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL. | |||
END OF THE TERMS AND CONDITIONS | |||
How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software | |||
To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps: | |||
i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner; | |||
ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package; | |||
iii Attach the statement to the appropriate annotated syntax at the beginning of each source file. | |||
Copyright (c) [Year] [name of copyright holder] | |||
[Software Name] is licensed under Mulan PSL v2. | |||
You can use this software according to the terms and conditions of the Mulan PSL v2. | |||
You may obtain a copy of Mulan PSL v2 at: | |||
http://license.coscl.org.cn/MulanPSL2 | |||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | |||
See the Mulan PSL v2 for more details. |
@@ -0,0 +1,22 @@ | |||
// babel-preset-taro 更多选项和默认值: | |||
// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md | |||
module.exports = { | |||
presets: [ | |||
['taro', { | |||
framework: 'preact', | |||
ts: true | |||
} | |||
] | |||
], | |||
plugins: [ | |||
[ | |||
'import', | |||
{ | |||
libraryName: 'ossaui', | |||
customName: (name) => `ossaui/lib/components/${name.replace(/^os-/, '')}`, | |||
customStyleName: (name) => `ossaui/dist/style/components/${name.replace(/^os-/, '')}.scss` | |||
}, | |||
'ossaui' | |||
] | |||
] | |||
} |
@@ -0,0 +1,11 @@ | |||
module.exports = { | |||
env: { | |||
NODE_ENV: '"development"', | |||
AMAP_KEY: '"1b26f3b95380c5584ed0107125911c64"', | |||
CLOUD_ID: '"cloud1-1g448gy3f05b503a"', | |||
SERVER: '"https://wechat.junmukeji.cn:5506"', | |||
}, | |||
defineConstants: {}, | |||
mini: {}, | |||
h5: {} | |||
} |
@@ -0,0 +1,81 @@ | |||
import path from "path"; | |||
const config = { | |||
projectName: 'weighing-platform', | |||
date: '2022-3-30', | |||
designWidth: 750, | |||
deviceRatio: { | |||
640: 2.34 / 2, | |||
750: 1, | |||
828: 1.81 / 2 | |||
}, | |||
sourceRoot: 'src', | |||
outputRoot: 'dist', | |||
plugins: [], | |||
defineConstants: {}, | |||
copy: { | |||
patterns: [ | |||
], | |||
options: {} | |||
}, | |||
framework: 'preact', | |||
// compiler: { | |||
// type: 'webpack5', | |||
// prebundle: { | |||
// exclude: ['ossaui'] | |||
// } | |||
// }, | |||
mini: { | |||
postcss: { | |||
pxtransform: { | |||
enable: true, | |||
config: {} | |||
}, | |||
url: { | |||
enable: true, | |||
config: { | |||
limit: 1024 // 设定转换尺寸上限 | |||
} | |||
}, | |||
cssModules: { | |||
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true | |||
config: { | |||
namingPattern: 'module', // 转换模式,取值为 global/module | |||
generateScopedName: '[name]__[local]___[hash:base64:5]' | |||
} | |||
} | |||
} | |||
}, | |||
h5: { | |||
publicPath: '/', | |||
staticDirectory: 'static', | |||
postcss: { | |||
autoprefixer: { | |||
enable: true, | |||
config: {} | |||
}, | |||
cssModules: { | |||
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true | |||
config: { | |||
namingPattern: 'module', // 转换模式,取值为 global/module | |||
generateScopedName: '[name]__[local]___[hash:base64:5]' | |||
} | |||
} | |||
} | |||
}, | |||
alias: { | |||
'@/utils': path.resolve(__dirname, '..', 'src/utils'), | |||
'@/components': path.resolve(__dirname, '..', 'src/components'), | |||
'@/assets': path.resolve(__dirname, '..', 'src/assets'), | |||
'@/api': path.resolve(__dirname, '..', 'src/api'), | |||
} | |||
} | |||
module.exports = function (merge) { | |||
if (process.env.NODE_ENV === 'development') { | |||
return merge({}, config, require('./dev')) | |||
} | |||
return merge({}, config, require('./prod')) | |||
} |
@@ -0,0 +1,20 @@ | |||
module.exports = { | |||
env: { | |||
NODE_ENV: '"production"', | |||
AMAP_KEY: '"1b26f3b95380c5584ed0107125911c64"', | |||
CLOUD_ID: '"cloud1-1g448gy3f05b503a"', | |||
SERVER: '"http://kitchen.test1.com"', | |||
}, | |||
defineConstants: {}, | |||
mini: {}, | |||
h5: { | |||
/** | |||
* 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。 | |||
* 参考代码如下: | |||
* webpackChain (chain) { | |||
* chain.plugin('analyzer') | |||
* .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, []) | |||
* } | |||
*/ | |||
} | |||
} |
@@ -0,0 +1,16 @@ | |||
declare module '*.png'; | |||
declare module '*.gif'; | |||
declare module '*.jpg'; | |||
declare module '*.jpeg'; | |||
declare module '*.svg'; | |||
declare module '*.css'; | |||
declare module '*.less'; | |||
declare module '*.scss'; | |||
declare module '*.sass'; | |||
declare module '*.styl'; | |||
declare namespace NodeJS { | |||
interface ProcessEnv { | |||
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd' | |||
} | |||
} |
@@ -0,0 +1,69 @@ | |||
{ | |||
"name": "wisdom-runway-app", | |||
"version": "1.0.0", | |||
"private": true, | |||
"description": "", | |||
"templateInfo": { | |||
"name": "default", | |||
"typescript": true, | |||
"css": "sass" | |||
}, | |||
"scripts": { | |||
"build:weapp": "SET NODE_OPTIONS=--openssl-legacy-provider && taro build --type weapp", | |||
"build:swan": "taro build --type swan", | |||
"build:alipay": "taro build --type alipay", | |||
"build:tt": "taro build --type tt", | |||
"build:h5": "taro build --type h5", | |||
"build:rn": "taro build --type rn", | |||
"build:qq": "taro build --type qq", | |||
"build:jd": "taro build --type jd", | |||
"build:quickapp": "taro build --type quickapp", | |||
"dev:weapp": "set NODE_ENV=production && npm run build:weapp -- --watch", | |||
"dev:swan": "npm run build:swan -- --watch", | |||
"dev:alipay": "npm run build:alipay -- --watch", | |||
"dev:tt": "npm run build:tt -- --watch", | |||
"dev:h5": "npm run build:h5 -- --watch", | |||
"dev:rn": "npm run build:rn -- --watch", | |||
"dev:qq": "npm run build:qq -- --watch", | |||
"dev:jd": "npm run build:jd -- --watch", | |||
"dev:quickapp": "npm run build:quickapp -- --watch" | |||
}, | |||
"browserslist": [ | |||
"last 3 versions", | |||
"Android >= 4.1", | |||
"ios >= 8" | |||
], | |||
"author": "", | |||
"dependencies": { | |||
"@babel/runtime": "^7.7.7", | |||
"@tarojs/components": "3.5.9", | |||
"@tarojs/plugin-framework-react": "3.5.7", | |||
"@tarojs/plugin-platform-weapp": "3.5.9", | |||
"@tarojs/react": "3.5.9", | |||
"@tarojs/runtime": "3.5.9", | |||
"@tarojs/taro": "3.5.9", | |||
"babel-plugin-import": "^1.13.8", | |||
"js-md5": "^0.8.3", | |||
"moment": "^2.29.4", | |||
"preact": "^10.11.3", | |||
"react": "^17.0.0", | |||
"react-dom": "^17.0.0" | |||
}, | |||
"devDependencies": { | |||
"@babel/core": "^7.8.0", | |||
"@tarojs/mini-runner": "3.5.9", | |||
"@tarojs/webpack-runner": "3.5.9", | |||
"@types/react": "^17.0.2", | |||
"@types/webpack-env": "^1.13.6", | |||
"@typescript-eslint/eslint-plugin": "^4.15.1", | |||
"@typescript-eslint/parser": "^4.15.1", | |||
"babel-preset-taro": "3.5.9", | |||
"eslint": "^6.8.0", | |||
"eslint-config-taro": "3.5.9", | |||
"eslint-plugin-import": "^2.12.0", | |||
"eslint-plugin-react": "^7.8.2", | |||
"eslint-plugin-react-hooks": "^4.2.0", | |||
"stylelint": "9.3.0", | |||
"typescript": "^4.1.0" | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
{ | |||
"miniprogramRoot": "./dist", | |||
"projectname": "weighing-platform", | |||
"description": "", | |||
"appid": "wx37fa34ae664500d2", | |||
"setting": { | |||
"urlCheck": true, | |||
"es6": false, | |||
"postcss": false, | |||
"minified": false | |||
}, | |||
"compileType": "miniprogram", | |||
"cloudfunctionRoot": "cloud/" | |||
} |
@@ -0,0 +1,9 @@ | |||
{ | |||
"miniprogramRoot": "./", | |||
"projectname": "wisdom-runway-app", | |||
"appid": "touristappid", | |||
"setting": { | |||
"es6": false, | |||
"minified": false | |||
} | |||
} |
@@ -0,0 +1,91 @@ | |||
import Taro from '@tarojs/taro'; | |||
import { uShowToast, wechatLogin } from "@/utils/index"; | |||
import { md5 } from 'js-md5'; | |||
import { login } from './server' | |||
// api请求封装 | |||
const httpRequest = function (url, params, method = 'GET', isShowLoading = true, isLoginApi = false, isWechatServer = false) { | |||
if (isShowLoading) { | |||
Taro.showToast({ | |||
title: '加载中', | |||
icon: 'loading', | |||
mask: true, | |||
duration: 2000 | |||
}) | |||
isShowLoading = true | |||
} | |||
let path = process.env.SERVER; | |||
const accountInfo = Taro.getAccountInfoSync(); | |||
// console.log(accountInfo.miniProgram.envVersion ); | |||
// 根据环境切换接口地址 | |||
if (accountInfo.miniProgram.envVersion === 'develop') { | |||
path = 'https://groupmeal.black-pa.com/order' | |||
} | |||
else if (accountInfo.miniProgram.envVersion === 'trial') { | |||
path = 'https://groupmeal.black-pa.com/order' | |||
} else { | |||
path = 'https://groupmeal.black-pa.com/order' | |||
} | |||
const tablekey = '26dc841d-d945-4e1e-968b-cc34a85cedb9' | |||
const header = { 'content-type': 'application/json' }; | |||
header['AppId'] = accountInfo.miniProgram.appId; | |||
header['key'] = tablekey | |||
// let stringA=""; | |||
// if (params) { | |||
// Object.keys(params).sort().map((key)=>{ | |||
// console.log(key,params[key]); | |||
// let stringB = `${key}` | |||
// if (stringA) { | |||
// stringA = stringA +"&"+ stringB | |||
// }else{ | |||
// stringA = stringA + stringB | |||
// } | |||
// }) | |||
// const stringSignTemp=stringA+"&key="+tablekey | |||
// console.log('stringSignTemp',stringSignTemp); | |||
// const stringSign = md5(stringSignTemp.toLocaleUpperCase()).toLocaleUpperCase() | |||
// header['sign']= stringSign | |||
// } | |||
return new Promise((resolve, reject) => { | |||
if (!isLoginApi) { | |||
header['Authorization'] = `Bearer ${Taro.getStorageSync("token")}`; | |||
} | |||
Taro.request({ | |||
url: path + url, | |||
data: params, | |||
method: method, | |||
header, | |||
}).then((res) => { | |||
if (isShowLoading) { | |||
Taro.hideToast(); | |||
} | |||
if (isLoginApi) { | |||
Taro.setStorageSync("token", res.header['access-token']); | |||
} | |||
switch (res.statusCode) { | |||
case 200: | |||
resolve(res.data); | |||
break; | |||
case 401: | |||
// Taro.reLaunch({ url: '/pages/login/index' }); | |||
// if (!isLoginApi) { | |||
// console.log('401'); | |||
// } | |||
break; | |||
default: | |||
uShowToast('系统异常,请联系客服') | |||
reject(); | |||
break; | |||
} | |||
}).catch(err => { | |||
console.log(err); | |||
uShowToast('当前网络较差,系统尝试再次请求数据!') | |||
reject(err) | |||
}) | |||
}) | |||
} | |||
export default httpRequest |
@@ -0,0 +1,41 @@ | |||
import httpRequest from './request'; | |||
//获取openId | |||
export const wechatOpenId = (params: any) => httpRequest('/api/wechat/wxlogin', params, 'POST', true, false, true); | |||
//微信支付 | |||
export const wechatPay = (params: any) => httpRequest(`/api/wechat/wechatpay/${params}`, params, 'POST', true,false, true); | |||
//登录 | |||
export const login = (params) => httpRequest('/api/account/login', params, 'POST', true, true); | |||
//根据token获取用户信息 | |||
export const getUserinfo = () => httpRequest('/api/account/userinfo') | |||
/** | |||
* 获取用户餐盘列表 | |||
*/ | |||
export const getOrderInf = (requestid: string, storeid: string) => httpRequest(`/order/order/orderantusericard/${requestid}/${storeid}`, null, 'GET') | |||
//获取用户信息 | |||
export const getUserOfOpenId = (openid) => httpRequest(`/kitchen/api/member-helper/memberinfobywechat/${openid}`, null, 'POST', true, true); | |||
//创建主订单和用户IC卡关系 | |||
export const orderantusericard =(params)=> httpRequest('/order/order/orderantusericard', params, 'POST', true, true); | |||
//增加用户 | |||
export const insertOrUpdateMember=(params) =>httpRequest('/kitchen/api/member-helper/orupdatememberinfobywechat', params, 'POST', true, true); | |||
//查询详情 | |||
export const getOrderOfOrderNum=(orderid)=>httpRequest(`/order/order/fullorderbynumber/${orderid}`, null, 'GET') | |||
//更新订单 | |||
export const updateOrderStatus=(params)=>httpRequest(`/order/order/orderupstatus`, params, 'POST', true, true); | |||
//获取我的订单 | |||
export const getOrderPage=(params)=>httpRequest(`/order/order/fullorder`, params, 'POST', true, true); | |||
//新获取我的托盘信息 | |||
export const GetWeighOrderByOpenId=(params)=>httpRequest('/api/ExternalPlatform/WeighOrder/GetWeighOrderByOpenId',params,'POST',false,true); | |||
//创建主订单和用户IC卡关系 | |||
export const CreateWeighOrder =(params)=> httpRequest('/api/ExternalPlatform/WeighOrder/CreateWeighOrder', params, 'POST', true, true); | |||
//添加新的餐盘 | |||
export const AddDiningPlate =(params)=> httpRequest('/api/ExternalPlatform/WeighOrder/AddWeighOrderDiningPlate', params, 'POST', true, true); | |||
//订单支付完成 | |||
export const UpdateWeighOrderStates =(params)=>httpRequest('/api/ExternalPlatform/WeighOrder/UpdateWeighOrderStates', params, 'POST', true, true); | |||
//获取本人订单 | |||
export const GetWeighOrderPageByOpenId=(params)=>httpRequest('/api/ExternalPlatform/WeighOrder/GetWeighOrderPageByOpenId', params, 'POST', true, true); | |||
@@ -0,0 +1,15 @@ | |||
export default { | |||
pages: [ | |||
'pages/index/index', | |||
'pages/tray/index', | |||
'pages/tray/list/index', | |||
], | |||
window: { | |||
backgroundTextStyle: 'light', | |||
navigationBarBackgroundColor: '#fff', | |||
navigationBarTitleText: '', | |||
navigationBarTextStyle: 'black' | |||
}, | |||
} |
@@ -0,0 +1,70 @@ | |||
$fontSize: 30px; | |||
$fontColor: #333333; | |||
/** | |||
兼容苹果底部横杠视图 | |||
*/ | |||
.content { | |||
height: calc(100vh - constant(safe-area-inset-bottom)); | |||
height: calc(100vh - env(safe-area-inset-bottom)); | |||
position: relative; | |||
overflow-y: scroll; | |||
font-size: $fontSize; | |||
color: $fontColor; | |||
} | |||
/** | |||
tabBar | |||
*/ | |||
.content-tabBar { | |||
height: 100vh; | |||
position: relative; | |||
overflow-y: scroll; | |||
font-size: $fontSize; | |||
color: $fontColor; | |||
} | |||
image { | |||
width: 100%; | |||
height: 100%; | |||
} | |||
.foot-submit-btn { | |||
height: 100px; | |||
background-repeat: no-repeat; | |||
background-size: 94% 100%; | |||
background-position: center; | |||
color: #fff; | |||
text-align: center; | |||
display: flex; | |||
justify-content: center; | |||
line-height: 100px; | |||
image { | |||
width: 50px; | |||
padding-top: 25px; | |||
height: 50px; | |||
padding-right: 20px; | |||
} | |||
} | |||
.foot-back-btn { | |||
height: 100px; | |||
background-repeat: no-repeat; | |||
background-size: 94% 100%; | |||
background-position: center; | |||
color: #C073F1; | |||
text-align: center; | |||
display: flex; | |||
justify-content: center; | |||
line-height: 100px; | |||
image { | |||
width: 50px; | |||
padding-top: 25px; | |||
height: 50px; | |||
padding-right: 20px; | |||
} | |||
} |
@@ -0,0 +1,51 @@ | |||
import { Component } from 'react' | |||
import Taro from "@tarojs/taro"; | |||
import './app.scss' | |||
import './assets/iconfont/iconfont.scss'; | |||
class App extends Component { | |||
componentDidMount() { | |||
// 获取小程序更新机制兼容 | |||
if (Taro.canIUse('getUpdateManager')) { | |||
const updateManager = Taro.getUpdateManager() | |||
updateManager.onCheckForUpdate(function (res) { | |||
// 请求完新版本信息的回调 | |||
console.log('是否有新版本', res.hasUpdate) | |||
}) | |||
updateManager.onUpdateReady(function () { | |||
Taro.showModal | |||
({ | |||
title: '更新提示', | |||
content: '新版本已经准备好,立即重启应用!', | |||
showCancel: false, | |||
success: function () { | |||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 | |||
updateManager.applyUpdate() | |||
} | |||
}) | |||
}) | |||
updateManager.onUpdateFailed(function () { | |||
// 新的版本下载失败 | |||
Taro.showModal({ | |||
title: '已经有新版本了哟~', | |||
showCancel: false, | |||
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~', | |||
}) | |||
}) | |||
} else { | |||
// 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示 | |||
Taro.showModal({ | |||
title: '提示', | |||
showCancel: false, | |||
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' | |||
}) | |||
} | |||
} | |||
// this.props.children 是将要会渲染的页面 | |||
render() { | |||
return this.props.children | |||
} | |||
} | |||
export default App |
@@ -0,0 +1,19 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> | |||
<meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport"> | |||
<meta name="apple-mobile-web-app-capable" content="yes"> | |||
<meta name="apple-touch-fullscreen" content="yes"> | |||
<meta name="format-detection" content="telephone=no,address=no"> | |||
<meta name="apple-mobile-web-app-status-bar-style" content="white"> | |||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" > | |||
<title></title> | |||
<script> | |||
!function(x){function w(){var v,u,t,tes,s=x.document,r=s.documentElement,a=r.getBoundingClientRect().width;if(!v&&!u){var n=!!x.navigator.appVersion.match(/AppleWebKit.*Mobile.*/);v=x.devicePixelRatio;tes=x.devicePixelRatio;v=n?v:1,u=1/v}if(a>=640){r.style.fontSize="40px"}else{if(a<=320){r.style.fontSize="20px"}else{r.style.fontSize=a/320*20+"px"}}}x.addEventListener("resize",function(){w()});w()}(window); | |||
</script> | |||
</head> | |||
<body> | |||
<div id="app"></div> | |||
</body> | |||
</html> |
@@ -0,0 +1,4 @@ | |||
export default { | |||
navigationBarTitleText: '', | |||
navigationBarBackgroundColor:'#D7EEFA' | |||
} |
@@ -0,0 +1,68 @@ | |||
/* 引导页组件 intro.wxss */ | |||
.container { /* 引导页容器 */ | |||
display: flex; | |||
flex-direction: column; | |||
justify-content: center; | |||
align-items: center; | |||
width: 100%; | |||
height: 100%; | |||
position: fixed; | |||
top: 0; | |||
left: 0; | |||
z-index: 1000; | |||
} | |||
.swiper-container { /* 引导页开关 */ | |||
width: 100%; | |||
height: 100%; | |||
} | |||
.hide { /* 引导页隐藏状态 */ | |||
display: none; | |||
} | |||
.btn-skip { /* 跳过按钮 */ | |||
position: absolute; | |||
bottom: 30px; | |||
right: 30px; | |||
padding: 10px 20px; | |||
font-size: 24px; | |||
color: #fff; | |||
background-color: #000; | |||
border-radius: 5px; | |||
} | |||
.btn-skip:hover { | |||
background-color: #333; | |||
} | |||
/* 引导页子组件 */ | |||
.intro { | |||
display: flex; | |||
flex-direction: column; | |||
justify-content: center; | |||
align-items: center; | |||
width: 100%; | |||
height: 100%; | |||
} | |||
.intro-page{ | |||
width: 100%; | |||
height: 100%; | |||
position: relative; | |||
} | |||
.intro-image { | |||
width: 100%; | |||
height: 100%; | |||
} | |||
.intro-content{ | |||
position: absolute; | |||
width: 200px; | |||
height: 200px; | |||
top: 48px; | |||
color: white; | |||
} | |||
.intro-text { | |||
margin-top: 20px; | |||
font-size: 28px; | |||
color: #000; | |||
} |
@@ -0,0 +1,79 @@ | |||
/* eslint-disable react/jsx-indent-props */ | |||
/* eslint-disable react/no-unused-state */ | |||
/* eslint-disable jsx-quotes */ | |||
import { Component } from "react"; | |||
import Taro from "@tarojs/taro"; | |||
import { View, Image, Button,Swiper, SwiperItem } from "@tarojs/components"; | |||
import { wechatOpenId } from '@/api/server' | |||
import { goToPages, uShowToast } from "@/utils/index"; | |||
import "./index.scss"; | |||
export default class Index extends Component< | |||
any | |||
> { | |||
constructor(props) { | |||
super(props); | |||
this.state = { | |||
}; | |||
} | |||
componentDidMount() { | |||
Taro.hideHomeButton() | |||
var openId = Taro.getStorageSync('openId') | |||
if (!openId) { | |||
Taro.login({ | |||
success: (res: any) => { | |||
var jsonData = { | |||
code: res.code | |||
} | |||
wechatOpenId(jsonData).then((res_open: any) => { | |||
if (res_open.statusCode===200) { | |||
Taro.setStorageSync("openId", res_open.data.openId) | |||
console.log("openId",res_open.data.openId); | |||
goToPages('/pages/tray/index') | |||
}else{ | |||
uShowToast('openId未获取,重新获取') | |||
} | |||
}) | |||
} | |||
}) //重新登录 | |||
}else{ | |||
goToPages('/pages/tray/index',null,'reLaunch') | |||
} | |||
} | |||
componentDidShow() { | |||
} | |||
render() { | |||
return ( | |||
<View className="container"> | |||
<Swiper className="swiper-container" autoplay> | |||
<SwiperItem className="SwiperItem"> | |||
<View className="bg-intro1"></View> | |||
<View className="intro-page"> | |||
<Image src={'http://weigh-applet.oss-cn-beijing.aliyuncs.com/image/01.png'} mode="aspectFill" className="intro-image"></Image> | |||
<View className="intro-content">欢迎来到海科机械!</View> | |||
</View> | |||
</SwiperItem> | |||
<SwiperItem className="SwiperItem"> | |||
<View className="bg-intro2"></View> | |||
<View className="intro-page"> | |||
<Image src={'http://weigh-applet.oss-cn-beijing.aliyuncs.com/image/02.png'} mode='aspectFill' className="intro-image"></Image> | |||
<View className="intro-content">更多精彩你尽情探索吧!</View> | |||
</View> | |||
</SwiperItem> | |||
</Swiper> | |||
<Button className="btn-skip" onClick={() => { | |||
goToPages('/pages/tray/index',null,'redirectTo') | |||
}} | |||
>跳过</Button> | |||
</View> | |||
); | |||
} | |||
} |
@@ -0,0 +1,3 @@ | |||
export default { | |||
navigationBarTitleText: '' | |||
} |
@@ -0,0 +1,108 @@ | |||
@import "src/app.scss"; | |||
.home { | |||
height: calc(50vh - 10px); | |||
width: 80%; | |||
padding: 40px; | |||
margin: auto; | |||
margin-top: 60px; | |||
position: relative; | |||
} | |||
.logo{ | |||
width: 248px; | |||
height: 92px; | |||
margin-bottom: 40px; | |||
background-size: 100% 100%; | |||
} | |||
.logo-title{ | |||
color: #000; | |||
font-size: 50px; | |||
margin-bottom: 40px; | |||
} | |||
.titel-content{ | |||
font-size: 28px; | |||
text-align: left; | |||
padding: 2px 40px; | |||
color: rgb(177, 173, 173); | |||
line-height:50px | |||
} | |||
.form-line{ | |||
height: 1px; | |||
width: 100%; | |||
margin: auto; | |||
border-bottom: 1px solid #E6E6E6; | |||
opacity: 0.5; | |||
} | |||
.form-item{ | |||
display: flex; | |||
flex-direction: column; | |||
font-size: 32px; | |||
font-weight: 400; | |||
font-family: PingFang SC; | |||
color: #000; | |||
view{ | |||
margin: 15px 1px; | |||
} | |||
} | |||
.form-button{ | |||
padding: 0; | |||
width: 100px; | |||
height: 100px; | |||
} | |||
.form-avatar{ | |||
width: 100%; | |||
height: 100%; | |||
} | |||
.flolayoutButton{ | |||
position: absolute; | |||
padding: 0px; | |||
width: 90%; | |||
height: 91px; | |||
background: #56BE69; | |||
box-shadow: 0px 0px 43px 0px rgba(86,190,105,0.3); | |||
border-radius: 4px; | |||
text-align: center; | |||
line-height: 90px; | |||
color: white; | |||
font-weight: bold; | |||
font-size: 32px; | |||
margin: auto; | |||
left: 0; | |||
right: 0; | |||
bottom: 70px; | |||
} | |||
.floatContent{ | |||
position: relative; | |||
height: 100%; | |||
} | |||
.tooltip{ | |||
display: flex; | |||
position: fixed; | |||
align-items: center; | |||
justify-content: center; | |||
height: 34px; | |||
width: 170px; | |||
background-color: #000; | |||
color: #fff; | |||
visibility: hidden; | |||
z-index: 100; | |||
border-radius: 6px; | |||
font-size: 12px; | |||
} | |||
// 制作三角箭头 | |||
.tooltip::after { | |||
content: " "; | |||
position: absolute; | |||
top: 100%; /* At the bottom of the tooltip */ | |||
left: 50%; | |||
margin-left: -5px; | |||
border-width: 5px; | |||
border-style: solid; | |||
border-color: black transparent transparent transparent; | |||
} |
@@ -0,0 +1,44 @@ | |||
import { Component } from "react"; | |||
import Taro from "@tarojs/taro"; | |||
import { View, Image, Button, Input, Form } from "@tarojs/components"; | |||
import {login,getUserinfo} from '@/api/server' | |||
import { goToPages, uShowToast, wechatLogin } from "@/utils/index"; | |||
import "./index.scss"; | |||
interface loginDto { | |||
phone: string; | |||
password: string; | |||
} | |||
export default class Index extends Component< | |||
any, | |||
{ | |||
phone: string; | |||
password: string; | |||
} | |||
> { | |||
constructor(props) { | |||
super(props); | |||
this.state = { | |||
phone: 'admin', | |||
password: '123456' | |||
}; | |||
} | |||
componentDidMount() { | |||
// getUserinfo().then((res)=>{ | |||
// Taro.switchTab({url: '/pages/index/index'}); | |||
// }) | |||
Taro.hideHomeButton() | |||
} | |||
componentDidShow() { | |||
} | |||
render() { | |||
return ( | |||
<View className='home'> | |||
登录页 | |||
</View> | |||
); | |||
} | |||
} |
@@ -0,0 +1,3 @@ | |||
export default { | |||
navigationBarTitleText: '称重点餐' | |||
} |
@@ -0,0 +1,299 @@ | |||
@import "src/app.scss"; | |||
.home { | |||
display: flex; | |||
flex-direction: column; | |||
height: 90vh; | |||
overflow: hidden; | |||
box-sizing: border-box; | |||
justify-content: space-between; | |||
} | |||
.top-box { | |||
margin: 20px; | |||
display: flex; | |||
padding-top: 20px; | |||
flex-direction: column; | |||
align-items: center; | |||
justify-content: center; | |||
height: 300rpx; | |||
border-radius: 10rpx; | |||
background: linear-gradient(rgb(152, 198, 63), rgb(135, 213, 99)); | |||
color: #FFF; | |||
} | |||
.center-box { | |||
flex: 3; | |||
} | |||
.down-box { | |||
flex: 1; | |||
display: flex; | |||
flex-direction: row; | |||
justify-content: space-between; | |||
} | |||
.down1-box{ | |||
height: 100px; | |||
display: flex; | |||
flex-direction: row; | |||
justify-content: space-between; | |||
} | |||
.scroll{ | |||
height: calc(100vh - 630px); | |||
padding-bottom: 120px; | |||
} | |||
.tray-button { | |||
display: flex; | |||
flex-direction: row; | |||
justify-content: center; | |||
margin: 40px 50px; | |||
border-radius: 30px; | |||
color: #FFF; | |||
height: 190px; | |||
width: 250px; | |||
align-items: center; | |||
} | |||
.tray-button-bg-saoyisao { | |||
background-color: rgb(40 158 112); | |||
} | |||
.tray-button-bg-order { | |||
background-color: #367e8c; | |||
} | |||
.tray-button-01 { | |||
background-image: url('http://weigh-applet.oss-cn-beijing.aliyuncs.com/image/saoyisao.png'); | |||
background-repeat: no-repeat; | |||
background-size: 100% 100%; | |||
background-position: center; | |||
color: #FFF; | |||
height: 32px; | |||
width: 32px; | |||
margin-right: 20px; | |||
opacity: 0.4; | |||
} | |||
.tray-tuopan { | |||
background-image: url('http://weigh-applet.oss-cn-beijing.aliyuncs.com/image/dinner.jpg'); | |||
background-repeat: no-repeat; | |||
background-size: 100% 100%; | |||
background-position: center; | |||
height: 400px; | |||
width: 95vw; | |||
} | |||
.tary-tuopan-title { | |||
color: rgb(100, 98, 98); | |||
margin: 20px 20px; | |||
} | |||
.tary-tuopan-remark { | |||
text-align: center; | |||
color: rgb(100, 98, 98); | |||
} | |||
.service-plate-card { | |||
margin: 20px; | |||
display: flex; | |||
flex-direction: column; | |||
border-radius: 20rpx; | |||
background-color: #f4f4f4; | |||
margin-bottom: 20rpx; | |||
align-items: left; | |||
padding: 30px; | |||
min-height: 150px; | |||
} | |||
.service-plate-item { | |||
display: flex; | |||
flex: 1; | |||
align-items: left; | |||
border-bottom: 2px dotted rgb(199, 197, 197); | |||
.service-plate-left { | |||
display: flex; | |||
align-items: center; | |||
justify-content: center; | |||
width: 40rpx; | |||
height: 40rpx; | |||
background-color: rgb(154, 196, 60); | |||
color: #FFF; | |||
border-radius: 50%; | |||
margin-right: 20rpx; | |||
.iconfont { | |||
font-size: 36rpx; | |||
} | |||
} | |||
.service-plate-center { | |||
flex-grow: 1; | |||
font-size: 28rpx; | |||
.service-plate-name { | |||
margin-bottom: 10rpx; | |||
overflow: hidden; | |||
text-overflow: ellipsis; | |||
white-space: nowrap; | |||
min-width: 100px; | |||
} | |||
.service-plate-desc { | |||
color: #999; | |||
} | |||
} | |||
.service-plate-right { | |||
display: flex; | |||
align-items: center; | |||
justify-content: center; | |||
border-radius: 30rpx; | |||
width: 150rpx; | |||
height: 60rpx; | |||
background-color: rgb(96, 159, 112); | |||
color: #FFF; | |||
font-size: 28rpx; | |||
} | |||
} | |||
.service-plate-right { | |||
flex: 5; | |||
} | |||
.empty-service { | |||
text-align: center; | |||
.empty-image { | |||
width: 500rpx; | |||
height: 300rpx; | |||
transform: rotate(-15deg); | |||
} | |||
.empty-text { | |||
position: relative; | |||
z-index: 10; | |||
top: -30rpx; | |||
font-size: 28rpx; | |||
color: #999; | |||
} | |||
} | |||
.order-detail-container { | |||
box-sizing: border-box; | |||
background-color: #F8F8F8; | |||
.food-card { | |||
.store-info { | |||
display: grid; | |||
grid-template-columns: 0rpx 1fr; | |||
grid-template-rows: 50rpx; | |||
grid-column-gap: 20rpx; | |||
align-items: center; | |||
font-size: 28rpx; | |||
.store-face { | |||
width: 40rpx; | |||
height: 40rpx; | |||
background-color: rgb(250, 252, 251); | |||
color: #FFF; | |||
border-radius: 50%; | |||
line-height: 80rpx; | |||
.iconfont { | |||
justify-content: center; | |||
font-size: 40rpx; | |||
} | |||
} | |||
.store-name { | |||
color: #999; | |||
} | |||
} | |||
.food-list-card { | |||
font-size: 28rpx; | |||
.foot-list-item { | |||
display: grid; | |||
grid-template-columns: 180rpx 180rpx 166rpx 1fr; | |||
grid-template-rows: 80rpx; | |||
align-items: center; | |||
justify-items: start; | |||
.food-item-total { | |||
justify-self: end; | |||
} | |||
} | |||
.sum-total { | |||
text-align: end; | |||
display: flex; | |||
flex-direction: row; | |||
justify-content: flex-end; | |||
} | |||
} | |||
} | |||
.order-info { | |||
background-color: #FFF; | |||
margin: 30rpx 0; | |||
padding: 30rpx; | |||
border-radius: 10rpx; | |||
font-size: 28rpx; | |||
.order-info-item { | |||
display: grid; | |||
grid-template-columns: 200rpx 1fr; | |||
grid-template-rows: 80rpx; | |||
align-items: center; | |||
.order-info-suffix { | |||
justify-self: end; | |||
color: #999; | |||
} | |||
} | |||
} | |||
} | |||
.payOrder { | |||
width: 100%; | |||
position: absolute; | |||
display: flex; | |||
bottom: 0; | |||
height: 10vh; | |||
flex-direction: row; | |||
align-items: center; | |||
background-color: #f4f4f4; | |||
.price { | |||
margin: 5vw; | |||
display: flex; | |||
flex-direction: row; | |||
} | |||
.priceText { | |||
font-weight: bold; | |||
color: red; | |||
font-size: 5vw; | |||
} | |||
.button { | |||
position: absolute; | |||
right: 0; | |||
margin: 5vw; | |||
display: flex; | |||
align-items: center; | |||
justify-content: center; | |||
border-radius: 15rpx; | |||
width: 150rpx; | |||
height: 60rpx; | |||
background-color: rgb(96, 159, 112); | |||
color: #FFF; | |||
font-size: 28rpx; | |||
} | |||
} |
@@ -0,0 +1,384 @@ | |||
/* eslint-disable react/no-unused-state */ | |||
import { Component } from "react"; | |||
import Taro from "@tarojs/taro"; | |||
import { ScrollView, View } from "@tarojs/components"; | |||
import { AddDiningPlate, CreateWeighOrder, GetWeighOrderByOpenId, UpdateWeighOrderStates,wechatPay } from '@/api/server' | |||
import { goToPages, uShowToast } from "@/utils/index"; | |||
import "./index.scss"; | |||
interface ServerListDto { | |||
serviceList: serviceDto[], | |||
intervalId:any, | |||
openId: any, | |||
no:number, | |||
orderInfo: { | |||
goodsInfo:[], | |||
id:string, | |||
totalAmount:number, | |||
orderNumber:string | |||
}, | |||
storeId: any, | |||
} | |||
interface serviceDto { | |||
orderId: any; | |||
chipCode: string, | |||
userName: string, | |||
code: string, | |||
goodsInfo: [], | |||
qrCode:string, | |||
isPay:boolean, | |||
no:string | |||
} | |||
export default class Index extends Component< | |||
any, ServerListDto | |||
> { | |||
constructor(props) { | |||
super(props); | |||
this.state = { | |||
serviceList: [], | |||
intervalId:null, | |||
no:0, | |||
orderInfo: { | |||
goodsInfo:[], | |||
id:'', | |||
totalAmount:0, | |||
orderNumber:'' | |||
}, | |||
openId: Taro.getStorageSync('openId'), | |||
//openId: 'o4Uui64yhBNjfoyWpbCX7Q068VVs', | |||
storeId: '48e04c5e-5144-44d8-b087-465153884e64' | |||
}; | |||
} | |||
componentDidMount() { | |||
Taro.hideHomeButton() | |||
this.GetQrcode() | |||
// 设置定时器 | |||
setTimeout(() => { | |||
if (this.state.serviceList.length>0) { | |||
this.startInterval() | |||
} | |||
}, 2000); | |||
} | |||
startInterval = () => { | |||
console.log('开启轮询'); | |||
this.GetQrcode() | |||
const intervalId = setInterval(() => { | |||
this.GetQrcode() | |||
}, 8000); | |||
this.setState({ intervalId }); | |||
}; | |||
stopInterval = () => { | |||
if (this.state.intervalId) { | |||
clearInterval(this.state.intervalId); | |||
this.setState({ intervalId: null}); | |||
} | |||
}; | |||
GetQrcode() { | |||
const jsonData = { | |||
openId: this.state.openId, | |||
} | |||
if (!this.state.openId) { | |||
uShowToast('openId未获取,重新获取') | |||
setTimeout(() => { | |||
goToPages('/pages/index/index',null,'reLaunch') | |||
}, 1500); | |||
}else{ | |||
GetWeighOrderByOpenId(jsonData).then((res) => { | |||
console.log('获取当前订单', res); | |||
if (res.statusCode === 200) { | |||
res.data.diningPlateInfo.map((item)=>{ | |||
const p1 = item.qrCode.split("HK"); | |||
item.no = p1[1] | |||
item.isPay=item.qrCode.includes("true") | |||
}) | |||
const obj = JSON.parse(JSON.stringify(res.data.diningPlateInfo)); | |||
this.setState({ serviceList: obj, orderInfo: res.data }) | |||
}else{ | |||
this.setState({ serviceList: [], orderInfo:{ goodsInfo:[], | |||
id:'', | |||
totalAmount:0 | |||
,orderNumber:''} }) | |||
} | |||
}) | |||
} | |||
} | |||
componentDidShow(options) { | |||
} | |||
onConfirmPayment = async (orderNumber,totalAmount) => { | |||
const orderCode = this.state.serviceList[0]; | |||
if (totalAmount<=0) { | |||
UpdateWeighOrderStates({ orderId: this.state.orderInfo.id, payStates: 1, states: 1 }).then((res: any) => { | |||
if (res.statusCode === 200) { | |||
this.stopInterval() | |||
uShowToast('订单完成') | |||
} | |||
setTimeout(() => { | |||
this.GetQrcode() | |||
}, 2000); | |||
}) | |||
} | |||
else if (!orderCode.isPay) { | |||
Taro.showModal({ | |||
title: '提示', | |||
content: '当前使用的免费餐盘,直接结算!', | |||
success: (res)=> { | |||
if (res.confirm) { | |||
UpdateWeighOrderStates({ orderId: this.state.orderInfo.id, payStates: 1, states: 1 }).then((res: any) => { | |||
if (res.statusCode === 200) { | |||
this.stopInterval() | |||
uShowToast('订单完成') | |||
} | |||
setTimeout(() => { | |||
this.GetQrcode() | |||
}, 2000); | |||
}) | |||
} else if (res.cancel) { | |||
console.log('用户点击取消') | |||
} | |||
} | |||
}) | |||
} | |||
else{ | |||
wechatPay(orderNumber).then((res)=>{ | |||
if (res.statusCode === 200) { | |||
Taro.requestPayment(res.data) | |||
.then((success) => { | |||
// this.paySuccess(res.data, params.hasHandRing); | |||
uShowToast('订单完成') | |||
UpdateWeighOrderStates({ orderId: this.state.orderInfo.id, payStates: 1, states: 1 }).then((res: any) => { | |||
if (res.statusCode === 200) { | |||
this.stopInterval() | |||
uShowToast('订单完成') | |||
} | |||
setTimeout(() => { | |||
this.GetQrcode() | |||
}, 2000); | |||
}) | |||
}) | |||
.catch(() => { | |||
uShowToast("支付未成功"); | |||
}); | |||
} | |||
}) | |||
} | |||
} | |||
addPlate = async (code: any) => { | |||
try { | |||
const p1 = code.split("?"); | |||
const p2 = p1[1].split("&"); | |||
const p3 = p2[0].split("="); | |||
console.log(p2[0]); | |||
this.setState({no:p3[1]}) | |||
if (!this.state.openId) { | |||
uShowToast('openId未获取,重新获取') | |||
setTimeout(() => { | |||
goToPages('/pages/index/index',null,'reLaunch') | |||
}, 1500); | |||
} | |||
if (this.state.serviceList.length <= 0) { | |||
CreateWeighOrder({ | |||
qrCode: code, | |||
createId: this.state.openId, | |||
}).then((res) => { | |||
if (res.statusCode === 200) { | |||
this.startInterval() | |||
} else { | |||
uShowToast(res.errors); | |||
} | |||
}); | |||
} else { | |||
const isFalse = this.state.serviceList[0].qrCode.includes(p2[0]); | |||
// console.log('isFalse',p2[0]); | |||
// console.log('isFalse',this.state.serviceList[0].qrCode,isFalse); | |||
if (!isFalse) { | |||
uShowToast('免费餐盘和付费餐盘不能混用!'); | |||
return; | |||
} | |||
AddDiningPlate({ | |||
qrCode: code, | |||
orderId: this.state.serviceList[0].orderId | |||
}).then((res: any) => { | |||
if (res.statusCode === 200) { | |||
this.GetQrcode() | |||
} else { | |||
uShowToast(res.errors); | |||
} | |||
}) | |||
} | |||
} catch (error) { | |||
uShowToast('请扫描正确的二维码!') | |||
return; | |||
} | |||
} | |||
render() { | |||
const { serviceList, orderInfo } = this.state | |||
return ( | |||
<View className='home'> | |||
<View className='top-box'> | |||
海科欢迎您 | |||
<View className='down-box'> | |||
<View className='tray-button tray-button-bg-saoyisao' onClick={() => { | |||
Taro.scanCode({ | |||
success: (res) => { | |||
const qrCode = res.result; | |||
this.addPlate(qrCode) | |||
} | |||
}) | |||
}}> | |||
<View>扫一扫</View> | |||
</View> | |||
<View className='tray-button tray-button-bg-order' onClick={() => { | |||
goToPages(`/pages/tray/list/index`) | |||
}}> | |||
<View>我的订单</View> | |||
</View> | |||
</View> | |||
</View> | |||
<View className='center-box'> | |||
<View className="down1-box"> | |||
<View className='tary-tuopan-title'>当前绑定托盘</View> | |||
<View className='tary-tuopan-title' onClick={()=>{ | |||
this.GetQrcode(); | |||
}}>当前状态:{this.state.intervalId?"自动监测":"手动刷新"}</View> | |||
</View> | |||
{/* 区域 */} | |||
<ScrollView className="scroll" scrollY> | |||
{serviceList.length <= 0 ? | |||
<View className='tray-tuopan-box'> | |||
<View className='tray-tuopan'> | |||
</View> | |||
<View className='tary-tuopan-remark'>当前未绑定托盘,请扫码绑定</View> | |||
</View> | |||
: | |||
serviceList.map((item, index) => ( | |||
<View key={index} className='service-plate-card'> | |||
<View className='service-plate-item'> | |||
<View className='service-plate-left'> | |||
</View> | |||
<View className='service-plate-center'> | |||
<View className='service-plate-name'> | |||
No.{item.no} | |||
</View> | |||
<View className='service-plate-desc'> | |||
{item.userName} | |||
</View> | |||
</View> | |||
{/* <View className='service-plate-right' onClick={() => { | |||
goToPages(`/pages/tray/detail/index?orderid=${item.orderId}`) | |||
}} | |||
> | |||
详情 | |||
</View> */} | |||
</View> | |||
<View className="service-plate-right"> | |||
<View className='order-detail-container'> | |||
<View className='food-card'> | |||
<View className='food-list-card'> | |||
<View className='foot-list-item' > | |||
<View className='food-item-name'> | |||
商品名称 | |||
</View> | |||
<View className='food-item-weight'> | |||
重量(g) | |||
</View> | |||
<View className='food-item-price'> | |||
单价 | |||
</View> | |||
<View className='food-item-total'> | |||
金额(元) | |||
</View> | |||
</View> | |||
{item.goodsInfo ? | |||
item.goodsInfo.map((item: any) => ( | |||
<View className='foot-list-item' > | |||
<View className='food-item-name'> | |||
{item.goodsName} | |||
</View> | |||
<View className='food-item-weight'> | |||
{item.goodsWeight} | |||
</View> | |||
<View className='food-item-price'> | |||
{item.price} | |||
</View> | |||
<View className='food-item-total'> | |||
{item.totalAmount} | |||
</View> | |||
</View> | |||
)) | |||
: ""} | |||
</View> | |||
</View> | |||
</View> | |||
</View> | |||
</View> | |||
)) | |||
} | |||
</ScrollView> | |||
</View> | |||
<View> | |||
{orderInfo.id ? | |||
<View className='payOrder'> | |||
<View className='price'> | |||
总价:¥ | |||
<View className='priceText'> | |||
{orderInfo.totalAmount} | |||
</View> | |||
</View> | |||
<View className='button' onClick={() => { | |||
if (orderInfo) { | |||
this.onConfirmPayment(orderInfo.orderNumber,orderInfo.totalAmount) | |||
} | |||
}} > | |||
确认支付 | |||
</View> | |||
</View> | |||
:""} | |||
</View> | |||
{/* <View className='down-box'> | |||
<View className='tray-button tray-button-bg-saoyisao' onClick={() => { | |||
Taro.scanCode({ | |||
success: (res) => { | |||
const qrCode = res.result; | |||
this.addPlate(qrCode) | |||
} | |||
}) | |||
}}> | |||
<View>扫一扫</View> | |||
</View> | |||
<View className='tray-button tray-button-bg-order' onClick={() => { | |||
goToPages(`/pages/tray/list/index`) | |||
}}> | |||
<View>我的订单</View> | |||
</View> | |||
</View> */} | |||
</View> | |||
); | |||
} | |||
} |
@@ -0,0 +1,3 @@ | |||
export default { | |||
navigationBarTitleText: '订单详情' | |||
} |
@@ -0,0 +1,196 @@ | |||
.order-container { | |||
display: flex; | |||
flex-direction: column; | |||
width: 100vw; | |||
height: 100vh; | |||
padding: 20rpx ; | |||
box-sizing: border-box; | |||
background-color: #dedede; | |||
.order-navbar { | |||
flex-shrink: 0; | |||
display: flex; | |||
align-items: center; | |||
background-color: rgb(120, 187, 99); | |||
color: #FFF; | |||
width: 100%; | |||
height: 80px; | |||
border-radius: 100px; | |||
font-size: 28px; | |||
box-sizing: border-box; | |||
margin-bottom: 20px; | |||
.order-navbar-item { | |||
display: flex; | |||
align-items: center; | |||
justify-content: center; | |||
width: 50%; | |||
height: 90%; | |||
padding: 0 50px; | |||
} | |||
.activity { | |||
transition: all 0.5s; | |||
background-color: #FFF; | |||
color: rgb(120, 187, 99); | |||
border-radius: 100px; | |||
} | |||
} | |||
} | |||
.order-list-box { | |||
overflow: auto; | |||
flex: 1; | |||
font-size: 28rpx; | |||
} | |||
.service-plate-card { | |||
margin: 20px; | |||
display: flex; | |||
flex-direction: column; | |||
border-radius: 20rpx; | |||
background-color: #f5f0f0; | |||
margin-bottom: 20rpx; | |||
align-items: left; | |||
padding: 30px; | |||
min-height: 150px; | |||
} | |||
.oli-money { | |||
font-size: 28rpx; | |||
color: #999; | |||
margin-top: 10rpx; | |||
padding-top: 10px; | |||
//border-top: 2rpx dotted rgb(199, 197, 197); | |||
text-align: end; | |||
} | |||
.service-plate-item { | |||
display: flex; | |||
flex: 1; | |||
align-items: left; | |||
//border-bottom: 2px dotted rgb(199, 197, 197); | |||
.service-plate-left { | |||
display: flex; | |||
align-items: center; | |||
justify-content: center; | |||
.iconfont { | |||
font-size: 36rpx; | |||
} | |||
} | |||
.service-plate-center { | |||
flex-grow: 1; | |||
font-size: 28rpx; | |||
.service-plate-name { | |||
margin-bottom: 10rpx; | |||
overflow: hidden; | |||
text-overflow: ellipsis; | |||
white-space: nowrap; | |||
min-width: 100px; | |||
font-size: 24px; | |||
color: #999; | |||
} | |||
.service-plate-desc { | |||
color: #999; | |||
font-size: 24px; | |||
margin-bottom: 10px; | |||
} | |||
} | |||
.service-plate-right { | |||
display: flex; | |||
align-items: center; | |||
justify-content: center; | |||
border-radius: 30rpx; | |||
width: 150rpx; | |||
height: 60rpx; | |||
background-color: rgb(96, 159, 112); | |||
color: #FFF; | |||
font-size: 28rpx; | |||
} | |||
} | |||
.order-detail-container { | |||
box-sizing: border-box; | |||
background-color: #f5f0f0; | |||
.food-card { | |||
border: 3rpx solid #e2dfdf; | |||
padding: 20rpx; | |||
margin-top: 10px; | |||
.store-info { | |||
display: grid; | |||
grid-template-columns: 0rpx 1fr; | |||
grid-template-rows: 50rpx; | |||
grid-column-gap: 20rpx; | |||
align-items: center; | |||
font-size: 28rpx; | |||
.store-face { | |||
width: 40rpx; | |||
height: 40rpx; | |||
background-color: rgb(250, 252, 251); | |||
color: #FFF; | |||
border-radius: 50%; | |||
line-height: 80rpx; | |||
.iconfont { | |||
justify-content: center; | |||
font-size: 40rpx; | |||
} | |||
} | |||
.store-name { | |||
color: #999; | |||
} | |||
} | |||
.food-list-card { | |||
font-size: 28rpx; | |||
background-color: #f5f0f0; | |||
.foot-list-item { | |||
display: grid; | |||
grid-template-columns: 180rpx 140rpx 120rpx 120rpx; | |||
grid-template-rows: 80px; | |||
font-size: 25rpx; | |||
align-items: center; | |||
justify-items: start; | |||
.food-item-total { | |||
justify-self: end; | |||
} | |||
} | |||
.sum-total { | |||
text-align: end; | |||
display: flex; | |||
flex-direction: row; | |||
justify-content: flex-end; | |||
} | |||
} | |||
} | |||
.order-info { | |||
background-color: #FFF; | |||
margin: 30rpx 0; | |||
padding: 30rpx; | |||
border-radius: 10rpx; | |||
font-size: 28rpx; | |||
.order-info-item { | |||
display: grid; | |||
grid-template-columns: 200rpx 1fr; | |||
grid-template-rows: 80rpx; | |||
align-items: center; | |||
.order-info-suffix { | |||
justify-self: end; | |||
color: #999; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,181 @@ | |||
/* eslint-disable react/no-unused-state */ | |||
import { Component } from "react"; | |||
import Taro from "@tarojs/taro"; | |||
import { View, ScrollView } from "@tarojs/components"; | |||
import { GetWeighOrderPageByOpenId } from '@/api/server' | |||
import { goToPages, uShowToast, scrollToLower } from "@/utils/index"; | |||
import "./index.scss"; | |||
import moment from "moment"; | |||
export default class Index extends Component< | |||
any, { openId: any, pageNo: number, pageSize: number, refresher: boolean, total: number, orderDetail: any[], payOrder: number, orderStatus: any } | |||
> { | |||
constructor(props) { | |||
super(props); | |||
this.state = { | |||
orderDetail: [], | |||
openId: Taro.getStorageSync('openId'), | |||
pageNo: 1, | |||
pageSize: 5, | |||
refresher: false, | |||
total: 0, | |||
payOrder: 1, | |||
orderStatus: null | |||
}; | |||
} | |||
componentDidMount() { | |||
this.getOrderData(true) | |||
} | |||
componentDidShow() { | |||
} | |||
onScrollToLower = () => { | |||
console.log('触底') | |||
scrollToLower(this.state.total, this.state.pageNo, this.state.pageSize).then((res) => { | |||
this.setState({ pageNo: res.pageNo }, () => this.getOrderData()); | |||
}); | |||
} | |||
onRefresherRefresh = () => { | |||
this.setState({ pageNo: 1 }, () => { | |||
this.getOrderData(true); | |||
}) | |||
} | |||
getOrderData= async (isFresher?: boolean | undefined)=> { | |||
let orderJson = { | |||
current: this.state.pageNo, | |||
pageSize: this.state.pageSize, | |||
states: this.state.orderStatus, | |||
openId: Taro.getStorageSync('openId'), | |||
//openId:'o4Uui64yhBNjfoyWpbCX7Q068VVs' | |||
} | |||
//获取订单信息 | |||
const orderInf =await GetWeighOrderPageByOpenId(orderJson) | |||
if (isFresher) { | |||
this.setState({refresher: false, total: orderInf.data.total, orderDetail: orderInf.data.data || [], pageNo: orderInf.data.current}) | |||
} else { | |||
this.setState({ | |||
total: orderInf.data.total, | |||
orderDetail: this.state.orderDetail.concat(orderInf.data.data || []), | |||
pageNo: orderInf.data.current | |||
}) | |||
} | |||
} | |||
changeOrderStatus(status: any) { | |||
this.setState({ orderStatus: status,pageNo:1 }, () => { | |||
this.getOrderData(true) | |||
}) | |||
} | |||
render() { | |||
const { orderStatus, orderDetail } = this.state | |||
console.log('orderDetail', orderDetail); | |||
return ( | |||
<View className='order-container'> | |||
<View className='order-navbar'> | |||
<View className={orderStatus == null ? "order-navbar-item activity" : "order-navbar-item"} onClick={() => this.changeOrderStatus(null)}> | |||
全部订单 | |||
</View> | |||
<View className={orderStatus == 1 ? "order-navbar-item activity" : "order-navbar-item"} onClick={() => this.changeOrderStatus(1)}> | |||
已完成 | |||
</View> | |||
</View> | |||
<ScrollView className='order-list-box' scrollY | |||
refresherThreshold={100} | |||
refresherEnabled | |||
onRefresherPulling={() => this.setState({ refresher: true })} | |||
refresherTriggered={this.state.refresher} | |||
refresherBackground='#dedede' | |||
onRefresherRefresh={this.onRefresherRefresh} | |||
onScrollToLower={this.onScrollToLower} | |||
> | |||
{orderDetail.map((item: any, index) => ( | |||
<View key={index} className='service-plate-card'> | |||
<View className='service-plate-item'> | |||
<View className='service-plate-left'> | |||
</View> | |||
<View className='service-plate-center'> | |||
<View className='service-plate-name'> | |||
订单类型:{item.isFree?'免费':'收费'} | |||
</View> | |||
<View className='service-plate-name'> | |||
订单状态:{item.states > 0 ? <>已完成</> : <>未支付</>} | |||
</View> | |||
<View className='service-plate-desc'> | |||
订单时间:{moment(item.createAt).format('YYYY-MM-DD HH:mm:ss')} | |||
</View> | |||
<View className='service-plate-name'> | |||
订单编号:{item.id} | |||
</View> | |||
</View> | |||
{/* <View className='service-plate-right' onClick={() => { | |||
goToPages(`/pages/tray/detail/index?orderid=${item.orderId}`) | |||
}} | |||
> | |||
详情 | |||
</View> */} | |||
</View> | |||
<View className="service-plate-right"> | |||
<View className='order-detail-container'> | |||
{item.diningPlateInfo? | |||
item.diningPlateInfo.map((dining)=>( | |||
<View className='food-card'> | |||
<>餐盘号:{dining.qrCode.split("HK")[1]}</> | |||
<View className='food-list-card'> | |||
<View className='foot-list-item' > | |||
<View className='food-item-name'> | |||
商品名称 | |||
</View> | |||
<View className='food-item-weight'> | |||
重量(g) | |||
</View> | |||
<View className='food-item-price'> | |||
单价 | |||
</View> | |||
<View className='food-item-total'> | |||
金额(元) | |||
</View> | |||
</View> | |||
{dining.goodsInfo ? | |||
dining.goodsInfo.map((item: any) => ( | |||
<View className='foot-list-item' > | |||
<View className='food-item-name'> | |||
{item.goodsName} | |||
</View> | |||
<View className='food-item-weight'> | |||
{item.goodsWeight} | |||
</View> | |||
<View className='food-item-price'> | |||
{item.price} | |||
</View> | |||
<View className='food-item-total'> | |||
{item.totalAmount} | |||
</View> | |||
</View> | |||
)) | |||
: ""} | |||
</View> | |||
</View> | |||
)) :"" | |||
} | |||
</View> | |||
</View> | |||
<View className='oli-money'> | |||
订单金额: ¥{item.totalAmount} </View> | |||
</View> | |||
))} | |||
<View> | |||
</View> | |||
</ScrollView> | |||
</View> | |||
); | |||
} | |||
} |
@@ -0,0 +1,109 @@ | |||
import Taro from '@tarojs/taro'; | |||
import {getUserinfo} from '@/api/server' | |||
export const getUserInfo = async () => { | |||
return new Promise<any>(async (resolve, reject) => { | |||
const userInfo = await getUserinfo(); | |||
if (userInfo.statusCode = 200) { | |||
resolve(userInfo.data) | |||
} else { | |||
reject('网络连接中断,请尝试刷新小程序'); | |||
} | |||
}) | |||
} | |||
export const uShowToast = (title: string, icon?: 'success' | 'loading' | 'none') => { | |||
Taro.showToast({ | |||
title, | |||
icon: icon || 'none', | |||
mask: true, | |||
duration: 3000, | |||
}) | |||
} | |||
export const goToPages = (url, options?, type?: 'switchTab' | 'reLaunch' | 'redirectTo') => { | |||
if (false) { | |||
// wechatLogin().then(code => { | |||
// login({ code: code }).then(res => { | |||
// global.token = res.data; | |||
// if (type) { | |||
// switch (type) { | |||
// case "switchTab": | |||
// Taro.switchTab({ url }) | |||
// break; | |||
// case "reLaunch": | |||
// Taro.reLaunch({ url }) | |||
// break; | |||
// case "redirectTo": | |||
// Taro.redirectTo({ url }) | |||
// break; | |||
// } | |||
// } else { | |||
// Taro.navigateTo({ url, ...options }); | |||
// } | |||
// }); | |||
// }) | |||
} else { | |||
if (type) { | |||
switch (type) { | |||
case "switchTab": | |||
Taro.switchTab({ url }) | |||
break; | |||
case "reLaunch": | |||
Taro.reLaunch({ url }) | |||
break; | |||
case "redirectTo": | |||
Taro.redirectTo({ url }) | |||
break; | |||
} | |||
} else { | |||
Taro.navigateTo({ url, ...options }); | |||
} | |||
} | |||
} | |||
/** | |||
* 获取微信登录code | |||
*/ | |||
export const wechatLogin = () => { | |||
return new Promise<string>(resolve => { | |||
Taro.login().then(res => { | |||
resolve(res.code) | |||
}) | |||
}) | |||
} | |||
/** | |||
* 是否是图片 | |||
*/ | |||
export const isImg=(url)=>{ | |||
//获取最后一个.的位置 | |||
var index = url.lastIndexOf(".") | |||
//获取后缀 | |||
var ext = url.substring(index + 1) | |||
// 进行判断 | |||
return ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'psd', 'svg', 'tiff'].indexOf(ext.toLowerCase()) !== -1 | |||
} | |||
/** | |||
* 计算下拉是否加载下一页 | |||
* @param total | |||
* @param pageNum | |||
*/ | |||
export const scrollToLower = (total, pageNo, pageSize = 10) => { | |||
return new Promise<{ pageNo: number, pageSize: number }>((resolve) => { | |||
// 计算当前有多少页数 | |||
let pageTotal = Math.ceil(total / pageSize); | |||
// newpageNo 需要传递给后端的 pageNo | |||
let newPageNo = pageNo + 1 | |||
// 如果 newpageNo 大于了当前的总页数,说明数据加载完毕 | |||
console.log('1111',newPageNo,pageNo,pageTotal); | |||
if (newPageNo > pageTotal) { | |||
return false | |||
} else { | |||
resolve({ | |||
pageNo: newPageNo, | |||
pageSize: pageSize | |||
}) | |||
} | |||
}) | |||
} |
@@ -0,0 +1,46 @@ | |||
{ | |||
"compilerOptions": { | |||
"target": "es2017", | |||
"module": "commonjs", | |||
"removeComments": false, | |||
"preserveConstEnums": true, | |||
"moduleResolution": "node", | |||
"experimentalDecorators": true, | |||
"noImplicitAny": false, | |||
"allowSyntheticDefaultImports": true, | |||
"outDir": "lib", | |||
"noUnusedLocals": true, | |||
"noUnusedParameters": true, | |||
"strictNullChecks": true, | |||
"sourceMap": true, | |||
"baseUrl": ".", | |||
"rootDir": ".", | |||
"jsx": "react-jsx", | |||
"allowJs": true, | |||
"resolveJsonModule": true, | |||
"typeRoots": [ | |||
"node_modules/@types", | |||
"global.d.ts" | |||
], | |||
"paths": { | |||
"@/utils/*": [ | |||
"src/utils/*" | |||
], | |||
"@/assets/*": [ | |||
"src/assets/*" | |||
], | |||
"@/components/*": [ | |||
"src/components/*" | |||
], | |||
"@/api/*": [ | |||
"src/api/*" | |||
] | |||
}, | |||
"skipLibCheck": true | |||
}, | |||
"exclude": [ | |||
"node_modules", | |||
"dist" | |||
], | |||
"compileOnSave": false | |||
} |