diff --git a/api/upload.js b/api/upload.js index 4e28551..2e239c8 100755 --- a/api/upload.js +++ b/api/upload.js @@ -1,5 +1,11 @@ import request from '@/utils/request' - +import http from '@/websoft/api/index.js' +import { + fileUrl +} from '@/config.js'; +import storage from '@/utils/storage' +import dayjs from "dayjs" +import appConfig from '@/config.js' // api地址 const api = { image: 'upload/image' @@ -16,3 +22,49 @@ export const image = files => { .catch(reject) }) } + + +export const uploadFile = async ({filePath}) => { + + // 获取临时凭证 + let sts = storage.get('sts'); + if(!sts){ + const stsRes = await http.get('/oss/getPostForm') + console.log('stsRes: ',stsRes); + sts = stsRes.data + storage.set('sts', sts, 60) + } + const {polocyBase64,signature} = sts; + var suffix = filePath.substring(filePath.lastIndexOf(".")); //.txt + const fileName = dayjs().format('YYYYMMDD') + '/'+ uni.$u.guid() + suffix; + return new Promise((reso, rej) => { + uni.uploadFile({ + url: appConfig.fileUrl, // 开发者服务器的URL。 + filePath: filePath, + name: 'file', // 必须填file。 + formData: { + key: fileName, + 'policy': polocyBase64, + 'OSSAccessKeyId': 'LTAI5tSZ62sPCvUsLRDDf7fH', + 'success_action_status': '200', //让服务端返回200,不然,默认会返回204 + 'signature': signature, + // 'x-oss-security-token': this.stsToken, + }, + success: (res) => { + const webUrl = appConfig.fileUrl + '/' + fileName; + reso({data: {url: webUrl,thumb: webUrl}}) + }, + fail: err => { + rej(err) + } + }); + }) + + +} + +export const getTempOssToken = () => http.get('/oss/getTempToken') +export default { + uploadFile, + getTempOssToken +} \ No newline at end of file diff --git a/config.js b/config.js index 391541d..bd5ce00 100755 --- a/config.js +++ b/config.js @@ -1,15 +1,13 @@ module.exports = { // 系统名称 name: "云芯威BMS", - // 生产环境 - // apiUrl: "https://server.gxwebsoft.com/api", - // apiUrl: "https://open.gxwebsoft.com/api", - // 开发环境 - // apiUrl: "http://127.0.0.1:8081/api", - apiUrl: "http://127.0.0.1:9090/api", - // apiUrl: "http://chatgpt.wsdns.cn/api", + + // apiUrl: "https://yxw.wsdns.cn/api", // 生产环境 + apiUrl: "http://127.0.0.1:9090/api", // 开发环境 + // apiUrl: "http://1.14.132.108:10050/api", uploadUrl: 'https://file.wsdns.cn', - fileUrl: 'https://file.wsdns.cn', + + fileUrl: 'https://oss-yunxinwei.oss-cn-shenzhen.aliyuncs.com', // 应用ID appId: 6, // 应用秘钥 diff --git a/manifest.json b/manifest.json index 868b191..f4b1337 100755 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name" : "萤火商城2.0", - "appid" : "__UNI__73499CF", + "appid" : "__UNI__C024D17", "description" : "萤火商城V2.0,是2021年全新推出的一款轻量级、高性能、前后端分离的电商系统", "versionName" : "2.0.6", "versionCode" : 206, diff --git a/node_modules/@dcloudio/types/package.json b/node_modules/@dcloudio/types/package.json index 4a7928d..2717baa 100644 --- a/node_modules/@dcloudio/types/package.json +++ b/node_modules/@dcloudio/types/package.json @@ -1,14 +1,45 @@ { + "_args": [ + [ + "@dcloudio/types@2.6.12", + "E:\\202308\\yunxinwei-uniapp" + ] + ], + "_from": "@dcloudio/types@2.6.12", + "_id": "@dcloudio/types@2.6.12", + "_inBundle": false, + "_integrity": "sha512-mrCMwcINy1IFjU9VUqLeWBkj404yWs5paLDttBcA+eqUjanuUQbBcTVPqlrGgkyzLXDcV2oDDZRSNxNpXi4kMQ==", + "_location": "/@dcloudio/types", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "@dcloudio/types@2.6.12", "name": "@dcloudio/types", - "version": "2.6.12", - "description": "uni-app types", - "typings": "index.d.ts", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "fxy060608", - "license": "Apache-2.0", - "devDependencies": { - "vue": "^2.6.10" - } + "escapedName": "@dcloudio%2ftypes", + "scope": "@dcloudio", + "rawSpec": "2.6.12", + "saveSpec": null, + "fetchSpec": "2.6.12" + }, + "_requiredBy": [ + "/luch-request" + ], + "_resolved": "https://registry.npmjs.org/@dcloudio/types/-/types-2.6.12.tgz", + "_spec": "2.6.12", + "_where": "E:\\202308\\yunxinwei-uniapp", + "author": { + "name": "fxy060608" + }, + "description": "uni-app types", + "devDependencies": { + "vue": "^2.6.10" + }, + "license": "Apache-2.0", + "name": "@dcloudio/types", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "typings": "index.d.ts", + "version": "2.6.12" } diff --git a/node_modules/commander/package.json b/node_modules/commander/package.json index 23df91c..1b59a69 100644 --- a/node_modules/commander/package.json +++ b/node_modules/commander/package.json @@ -1,13 +1,66 @@ { - "name": "commander" - , "version": "1.1.1" - , "description": "the complete solution for node.js command-line programs" - , "keywords": ["command", "option", "parser", "prompt", "stdin"] - , "author": "TJ Holowaychuk " - , "repository": { "type": "git", "url": "https://github.com/visionmedia/commander.js.git" } - , "dependencies": { "keypress": "0.1.x"} - , "devDependencies": { "should": ">= 0.0.1" } - , "scripts": { "test": "make test" } - , "main": "index" - , "engines": { "node": ">= 0.6.x" } + "_args": [ + [ + "commander@1.1.1", + "E:\\202308\\yunxinwei-uniapp" + ] + ], + "_development": true, + "_from": "commander@1.1.1", + "_id": "commander@1.1.1", + "_inBundle": false, + "_integrity": "sha512-71Rod2AhcH3JhkBikVpNd0pA+fWsmAaVoti6OR38T76chA7vE3pSerS0Jor4wDw+tOueD2zLVvFOw5H0Rcj7rA==", + "_location": "/commander", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "commander@1.1.1", + "name": "commander", + "escapedName": "commander", + "rawSpec": "1.1.1", + "saveSpec": null, + "fetchSpec": "1.1.1" + }, + "_requiredBy": [ + "/js" + ], + "_resolved": "https://registry.npmmirror.com/commander/-/commander-1.1.1.tgz", + "_spec": "1.1.1", + "_where": "E:\\202308\\yunxinwei-uniapp", + "author": { + "name": "TJ Holowaychuk", + "email": "tj@vision-media.ca" + }, + "bugs": { + "url": "https://github.com/visionmedia/commander.js/issues" + }, + "dependencies": { + "keypress": "0.1.x" + }, + "description": "the complete solution for node.js command-line programs", + "devDependencies": { + "should": ">= 0.0.1" + }, + "engines": { + "node": ">= 0.6.x" + }, + "homepage": "https://github.com/visionmedia/commander.js#readme", + "keywords": [ + "command", + "option", + "parser", + "prompt", + "stdin" + ], + "main": "index", + "name": "commander", + "repository": { + "type": "git", + "url": "git+https://github.com/visionmedia/commander.js.git" + }, + "scripts": { + "test": "make test" + }, + "version": "1.1.1" } diff --git a/node_modules/js-md5/package.json b/node_modules/js-md5/package.json index 4957514..0b8a0bd 100644 --- a/node_modules/js-md5/package.json +++ b/node_modules/js-md5/package.json @@ -1,8 +1,41 @@ { - "name": "js-md5", - "version": "0.7.3", + "_args": [ + [ + "js-md5@0.7.3", + "E:\\202308\\yunxinwei-uniapp" + ] + ], + "_development": true, + "_from": "js-md5@0.7.3", + "_id": "js-md5@0.7.3", + "_inBundle": false, + "_integrity": "sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ==", + "_location": "/js-md5", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "js-md5@0.7.3", + "name": "js-md5", + "escapedName": "js-md5", + "rawSpec": "0.7.3", + "saveSpec": null, + "fetchSpec": "0.7.3" + }, + "_requiredBy": [ + "#DEV:/" + ], + "_resolved": "https://registry.npmmirror.com/js-md5/-/js-md5-0.7.3.tgz", + "_spec": "0.7.3", + "_where": "E:\\202308\\yunxinwei-uniapp", + "author": { + "name": "Chen, Yi-Cyuan", + "email": "emn178@gmail.com" + }, + "bugs": { + "url": "https://github.com/emn178/js-md5/issues" + }, "description": "A simple MD5 hash function for JavaScript supports UTF-8 encoding.", - "main": "src/md5.js", "devDependencies": { "expect.js": "~0.3.1", "jsdoc": "^3.4.0", @@ -12,18 +45,7 @@ "uglify-js": "^3.1.9", "webworker-threads": "^0.7.11" }, - "scripts": { - "test": "nyc mocha tests/node-test.js", - "report": "nyc --reporter=html --reporter=text mocha tests/node-test.js", - "coveralls": "nyc report --reporter=text-lcov | coveralls", - "doc": "rm -rf doc;jsdoc src README.md -d doc", - "compress": "uglifyjs src/md5.js -c -m eval --comments --output build/md5.min.js", - "build": "npm run-script compress;npm run-script doc" - }, - "repository": { - "type": "git", - "url": "https://github.com/emn178/js-md5.git" - }, + "homepage": "https://github.com/emn178/js-md5", "keywords": [ "md5", "hash", @@ -32,14 +54,24 @@ "HMAC" ], "license": "MIT", - "author": "Chen, Yi-Cyuan ", - "homepage": "https://github.com/emn178/js-md5", - "bugs": { - "url": "https://github.com/emn178/js-md5/issues" - }, + "main": "src/md5.js", + "name": "js-md5", "nyc": { "exclude": [ "tests" ] - } + }, + "repository": { + "type": "git", + "url": "git+https://github.com/emn178/js-md5.git" + }, + "scripts": { + "build": "npm run-script compress;npm run-script doc", + "compress": "uglifyjs src/md5.js -c -m eval --comments --output build/md5.min.js", + "coveralls": "nyc report --reporter=text-lcov | coveralls", + "doc": "rm -rf doc;jsdoc src README.md -d doc", + "report": "nyc --reporter=html --reporter=text mocha tests/node-test.js", + "test": "nyc mocha tests/node-test.js" + }, + "version": "0.7.3" } diff --git a/node_modules/js/package.json b/node_modules/js/package.json index 09f994c..3aa8895 100644 --- a/node_modules/js/package.json +++ b/node_modules/js/package.json @@ -1,12 +1,44 @@ { - "name": "js", - "description": "A better `node -p`.", - "author": "Marco Aurelio ", - "version": "0.1.0", + "_args": [ + [ + "js@0.1.0", + "E:\\202308\\yunxinwei-uniapp" + ] + ], + "_development": true, + "_from": "js@0.1.0", + "_id": "js@0.1.0", + "_inBundle": false, + "_integrity": "sha512-ZBbGYOpact8QAH9RprFWL4RAESYwbDodxiuDjOnzwzzk9pBzKycoifGuUrHHcDixE/eLMKPHRaXenTgu1qXBqA==", + "_location": "/js", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "js@0.1.0", + "name": "js", + "escapedName": "js", + "rawSpec": "0.1.0", + "saveSpec": null, + "fetchSpec": "0.1.0" + }, + "_requiredBy": [ + "#DEV:/" + ], + "_resolved": "https://registry.npmmirror.com/js/-/js-0.1.0.tgz", + "_spec": "0.1.0", + "_where": "E:\\202308\\yunxinwei-uniapp", + "author": { + "name": "Marco Aurelio", + "email": "thecoreh@gmail.com" + }, "bin": { - "js": "./bin/js" + "js": "bin/js" }, "dependencies": { "commander": "~1.1.1" - } -} \ No newline at end of file + }, + "description": "A better `node -p`.", + "name": "js", + "version": "0.1.0" +} diff --git a/node_modules/keypress/package.json b/node_modules/keypress/package.json index a527801..55bbf1e 100644 --- a/node_modules/keypress/package.json +++ b/node_modules/keypress/package.json @@ -1,20 +1,57 @@ { - "name": "keypress", - "version": "0.1.0", + "_args": [ + [ + "keypress@0.1.0", + "E:\\202308\\yunxinwei-uniapp" + ] + ], + "_development": true, + "_from": "keypress@0.1.0", + "_id": "keypress@0.1.0", + "_inBundle": false, + "_integrity": "sha512-x0yf9PL/nx9Nw9oLL8ZVErFAk85/lslwEP7Vz7s5SI1ODXZIgit3C5qyWjw4DxOuO/3Hb4866SQh28a1V1d+WA==", + "_location": "/keypress", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "keypress@0.1.0", + "name": "keypress", + "escapedName": "keypress", + "rawSpec": "0.1.0", + "saveSpec": null, + "fetchSpec": "0.1.0" + }, + "_requiredBy": [ + "/commander" + ], + "_resolved": "https://registry.npmmirror.com/keypress/-/keypress-0.1.0.tgz", + "_spec": "0.1.0", + "_where": "E:\\202308\\yunxinwei-uniapp", + "author": { + "name": "Nathan Rajlich", + "email": "nathan@tootallnate.net", + "url": "http://tootallnate.net" + }, + "bugs": { + "url": "https://github.com/TooTallNate/keypress/issues" + }, "description": "Make any Node ReadableStream emit \"keypress\" events", - "author": "Nathan Rajlich (http://tootallnate.net)", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "git://github.com/TooTallNate/keypress.git" - }, + "homepage": "https://github.com/TooTallNate/keypress#readme", "keywords": [ "keypress", "readline", "core" ], - "license": "MIT" + "license": "MIT", + "main": "index.js", + "name": "keypress", + "repository": { + "type": "git", + "url": "git://github.com/TooTallNate/keypress.git" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "version": "0.1.0" } diff --git a/node_modules/luch-request/package.json b/node_modules/luch-request/package.json index b6908a4..e94ebc2 100644 --- a/node_modules/luch-request/package.json +++ b/node_modules/luch-request/package.json @@ -1,68 +1,38 @@ { - "name": "luch-request", - "version": "3.0.8", - "description": "基于Promise实现uni-app request 请求插件", - "keywords": [ - "uni-app", - "request", - "Promise", - "luch", - "luch-request" + "_args": [ + [ + "luch-request@3.0.8", + "E:\\202308\\yunxinwei-uniapp" + ] ], - "main": "src/lib/luch-request.js", - "scripts": { - "dev": "rollup -c", - "watch": "rollup -c -w", - "build": "rimraf DCloud && rollup -c --environment NODE_ENV:production", - "zipD": "node node/zipDCloudPlugin.js && node node/zipDCloudDemo.js", - "docs": "vuepress dev docs", - "docs:build": "vuepress build docs", - "changelog": "conventional-changelog -p angular -i CHANGELOG.md -w -r 0", - "pub": "npm publish && cnpm sync luch-request", - "pub:alpha": "npm publish --tag=alpha && cnpm sync luch-request", - "test": "echo \"Error: no test specified\" && exit 1" + "_from": "luch-request@3.0.8", + "_id": "luch-request@3.0.8", + "_inBundle": false, + "_integrity": "sha512-5ZVp1y4tFaizbGMOuQwbeyfHnf4PhQAwQ3S1Fm1tS7juMoB14pXslxWriElhiSq6ytYYW0KVC8RShfHiNujFcQ==", + "_location": "/luch-request", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "luch-request@3.0.8", + "name": "luch-request", + "escapedName": "luch-request", + "rawSpec": "3.0.8", + "saveSpec": null, + "fetchSpec": "3.0.8" }, - "repository": { - "type": "git", - "url": "https://github.com/lei-mu/luch-request.git" + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/luch-request/-/luch-request-3.0.8.tgz", + "_spec": "3.0.8", + "_where": "E:\\202308\\yunxinwei-uniapp", + "author": { + "name": "luch" }, - "author": "luch", - "license": "MIT", "bugs": { "url": "https://github.com/lei-mu/luch-request/issues" }, - "homepage": "https://www.quanzhan.co/luch-request/", - "devDependencies": { - "@babel/core": "^7.9.0", - "@babel/plugin-proposal-class-properties": "^7.8.3", - "@babel/plugin-transform-arrow-functions": "^7.8.3", - "@babel/preset-env": "^7.9.5", - "@vuepress/plugin-active-header-links": "^1.5.0", - "@vuepress/plugin-pwa": "^1.5.2", - "archiver": "^4.0.1", - "babel-eslint": "^10.1.0", - "babel-preset-es2015": "^6.24.1", - "commitizen": "^4.2.4", - "conventional-changelog-cli": "^2.1.1", - "cz-conventional-changelog": "^3.2.0", - "eslint": "^6.8.0", - "grunt": "^1.1.0", - "grunt-babel": "^8.0.0", - "load-grunt-tasks": "^5.1.0", - "node-zip": "^1.1.1", - "rollup-plugin-babel": "^4.4.0", - "rollup-plugin-commonjs": "^10.1.0", - "rollup-plugin-copy": "^3.3.0", - "rollup-plugin-eslint": "^7.0.0", - "rollup-plugin-json": "^4.0.0", - "rollup-plugin-live-server": "^1.0.3", - "rollup-plugin-node-resolve": "^5.2.0", - "rollup-plugin-replace": "^2.2.0", - "rollup-plugin-uglify": "^6.0.4", - "rollup-plugin-zip": "^1.0.0", - "validate-commit-msg": "^2.14.0", - "vuepress": "^1.4.1" - }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog" @@ -102,5 +72,65 @@ }, "dependencies": { "@dcloudio/types": "^2.0.16" - } + }, + "description": "基于Promise实现uni-app request 请求插件", + "devDependencies": { + "@babel/core": "^7.9.0", + "@babel/plugin-proposal-class-properties": "^7.8.3", + "@babel/plugin-transform-arrow-functions": "^7.8.3", + "@babel/preset-env": "^7.9.5", + "@vuepress/plugin-active-header-links": "^1.5.0", + "@vuepress/plugin-pwa": "^1.5.2", + "archiver": "^4.0.1", + "babel-eslint": "^10.1.0", + "babel-preset-es2015": "^6.24.1", + "commitizen": "^4.2.4", + "conventional-changelog-cli": "^2.1.1", + "cz-conventional-changelog": "^3.2.0", + "eslint": "^6.8.0", + "grunt": "^1.1.0", + "grunt-babel": "^8.0.0", + "load-grunt-tasks": "^5.1.0", + "node-zip": "^1.1.1", + "rollup-plugin-babel": "^4.4.0", + "rollup-plugin-commonjs": "^10.1.0", + "rollup-plugin-copy": "^3.3.0", + "rollup-plugin-eslint": "^7.0.0", + "rollup-plugin-json": "^4.0.0", + "rollup-plugin-live-server": "^1.0.3", + "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-replace": "^2.2.0", + "rollup-plugin-uglify": "^6.0.4", + "rollup-plugin-zip": "^1.0.0", + "validate-commit-msg": "^2.14.0", + "vuepress": "^1.4.1" + }, + "homepage": "https://www.quanzhan.co/luch-request/", + "keywords": [ + "uni-app", + "request", + "Promise", + "luch", + "luch-request" + ], + "license": "MIT", + "main": "src/lib/luch-request.js", + "name": "luch-request", + "repository": { + "type": "git", + "url": "git+https://github.com/lei-mu/luch-request.git" + }, + "scripts": { + "build": "rimraf DCloud && rollup -c --environment NODE_ENV:production", + "changelog": "conventional-changelog -p angular -i CHANGELOG.md -w -r 0", + "dev": "rollup -c", + "docs": "vuepress dev docs", + "docs:build": "vuepress build docs", + "pub": "npm publish && cnpm sync luch-request", + "pub:alpha": "npm publish --tag=alpha && cnpm sync luch-request", + "test": "echo \"Error: no test specified\" && exit 1", + "watch": "rollup -c -w", + "zipD": "node node/zipDCloudPlugin.js && node node/zipDCloudDemo.js" + }, + "version": "3.0.8" } diff --git a/package-lock.json b/package-lock.json index 2cf6452..c48802e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,67 +1,6 @@ { - "name": "yunxinwei-app", - "lockfileVersion": 2, "requires": true, - "packages": { - "": { - "dependencies": { - "luch-request": "^3.0.8" - }, - "devDependencies": { - "js": "^0.1.0", - "js-md5": "^0.7.3" - } - }, - "node_modules/@dcloudio/types": { - "version": "2.6.12", - "resolved": "https://registry.npmjs.org/@dcloudio/types/-/types-2.6.12.tgz", - "integrity": "sha512-mrCMwcINy1IFjU9VUqLeWBkj404yWs5paLDttBcA+eqUjanuUQbBcTVPqlrGgkyzLXDcV2oDDZRSNxNpXi4kMQ==" - }, - "node_modules/commander": { - "version": "1.1.1", - "resolved": "https://registry.npmmirror.com/commander/-/commander-1.1.1.tgz", - "integrity": "sha512-71Rod2AhcH3JhkBikVpNd0pA+fWsmAaVoti6OR38T76chA7vE3pSerS0Jor4wDw+tOueD2zLVvFOw5H0Rcj7rA==", - "dev": true, - "dependencies": { - "keypress": "0.1.x" - }, - "engines": { - "node": ">= 0.6.x" - } - }, - "node_modules/js": { - "version": "0.1.0", - "resolved": "https://registry.npmmirror.com/js/-/js-0.1.0.tgz", - "integrity": "sha512-ZBbGYOpact8QAH9RprFWL4RAESYwbDodxiuDjOnzwzzk9pBzKycoifGuUrHHcDixE/eLMKPHRaXenTgu1qXBqA==", - "dev": true, - "dependencies": { - "commander": "~1.1.1" - }, - "bin": { - "js": "bin/js" - } - }, - "node_modules/js-md5": { - "version": "0.7.3", - "resolved": "https://registry.npmmirror.com/js-md5/-/js-md5-0.7.3.tgz", - "integrity": "sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ==", - "dev": true - }, - "node_modules/keypress": { - "version": "0.1.0", - "resolved": "https://registry.npmmirror.com/keypress/-/keypress-0.1.0.tgz", - "integrity": "sha512-x0yf9PL/nx9Nw9oLL8ZVErFAk85/lslwEP7Vz7s5SI1ODXZIgit3C5qyWjw4DxOuO/3Hb4866SQh28a1V1d+WA==", - "dev": true - }, - "node_modules/luch-request": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/luch-request/-/luch-request-3.0.8.tgz", - "integrity": "sha512-5ZVp1y4tFaizbGMOuQwbeyfHnf4PhQAwQ3S1Fm1tS7juMoB14pXslxWriElhiSq6ytYYW0KVC8RShfHiNujFcQ==", - "dependencies": { - "@dcloudio/types": "^2.0.16" - } - } - }, + "lockfileVersion": 1, "dependencies": { "@dcloudio/types": { "version": "2.6.12", @@ -77,6 +16,11 @@ "keypress": "0.1.x" } }, + "dayjs": { + "version": "1.11.10", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", + "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" + }, "js": { "version": "0.1.0", "resolved": "https://registry.npmmirror.com/js/-/js-0.1.0.tgz", diff --git a/package.json b/package.json index 550fa31..cb97860 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "dependencies": { + "dayjs": "^1.11.10", "luch-request": "^3.0.8" }, "devDependencies": { diff --git a/package/user/equipment/detail.vue b/package/user/equipment/detail.vue index 5cd55bf..3d293a6 100755 --- a/package/user/equipment/detail.vue +++ b/package/user/equipment/detail.vue @@ -8,6 +8,12 @@ + + {{ form.workingStatus }} + + + {{ form.bms }} + {{ form.surplusPower }} @@ -20,21 +26,21 @@ {{ form.gsm }} - + + - + 电芯电压 diff --git a/package/user/equipment/operation.vue b/package/user/equipment/operation.vue index 432ac4e..816c857 100755 --- a/package/user/equipment/operation.vue +++ b/package/user/equipment/operation.vue @@ -26,6 +26,7 @@ + 确定更换电池 @@ -425,6 +426,7 @@ padding: 0 10rpx; border: 1rpx solid #eee; font-size: 24rpx; + display: flex; .image { display: block; diff --git a/pages/equipment/equipment.vue b/pages/equipment/equipment.vue index bdee3c4..382117e 100644 --- a/pages/equipment/equipment.vue +++ b/pages/equipment/equipment.vue @@ -6,17 +6,17 @@ {{ record.equipmentName }} - 电池型号:{{ record.batteryModel }} - 电池编号:{{ record.equipmentCode }} - 是否激活:{{ record.isCtive == 0 ? '已激活' : '未激活' }} - BMS:{{ record.bms }} - 工作状态:{{ record.workingStatus }} - 租赁状态:{{ record.leaseStatus }} - 电池状态:{{ record.batteryStatus }} - 电池电量:{{ record.batteryPower }} - 是否在线:{{ record.isOnline }} - 总电压:{{ record.totalVoltage }} - 剩余容量:{{ record.surplusCapacity }} + 电池型号:{{ record.batteryModel || '' }} + 电池编号:{{ record.equipmentCode || '' }} + 是否激活:{{ record.isCtive || '' }} + BMS:{{ record.bms || ''}} + 设备状态:{{ record.workingStatus || ''}} + 租赁状态:{{ record.userId > 0?'在租': '闲置' }} + 电池状态:{{ record.batteryStatus || '' }} + 电池电量:{{ record.batteryPower || '' }} + 是否在线:{{ record.isOnline || '' }} + 总电压:{{ record.totalVoltage || '' }} + 剩余容量:{{ record.surplusCapacity || '' }} @@ -27,6 +27,12 @@ 立即购买 + + + 更换电池 + + + @@ -34,6 +40,8 @@ 返回首页 + + @@ -46,6 +54,7 @@ import { addOrder } from '@/websoft/api/order.js' import { createOrderNo } from '@/utils/util.js' import store from '../../store'; + import * as EquipmentApi from '@/websoft/api/equipment.js' export default { components: { // Search @@ -68,11 +77,16 @@ batteryDeposit: 300, batteryInsurance: 0 }, - + showEquipments: false, + equipments: [ + + ], + orderId: null } }, onLoad(option) { const app = this + app.getMyEquipments() // 记录当前选择的门店ID console.log("option: ",option); app.equipmentId = Number(option.equipmentId) @@ -92,6 +106,13 @@ console.log("res2222: ", app.record); }) }, + getMyEquipments() { + const app = this + EquipmentApi.pageEquipment({userId: uni.getStorageSync('userId')}).then(res => { + console.log("res: ",res); + app.equipments = res.data.list + }) + }, gohome(){ uni.reLaunch({ url: '/pages/index/index' @@ -156,7 +177,57 @@ const app = this const { equipmentId } = this this.$navTo('pages/merchant/merchant', { equipmentId }) - } + }, + onReplace() { + console.log("点击更换电池"); + const app = this + if(this.record.userId > 0) { + uni.showToast({ + title: '该电池已经被别人租走了', + icon: 'none' + }) + }else if(app.equipments.length == 0) { + uni.showToast({ + title: '你没有可更换的电池', + icon: 'none' + }) + }else { + this.$refs.equipmenPicker.show() + this.showEquipments = true + } + }, + confirmReplace(e) { + const app = this + uni.showModal({ + title: '提示', + content: `确认更换此电池?`, + success: (res) => { + if(res.confirm) { + app.doEquipment() + } + } + }) + console.log(e); + }, + doEquipment(canReset = false) { + const app = this + const { + equipmentId, + equipmentCode, + } = app.record + EquipmentApi.changeEquipment({ + equipmentCode, + equipmentId, + orderId: app.orderId + }).then(result => { + app.$success(result.message) + app.getEquipment() + app.getMyEquipments() + }).catch(err => { + app.$error(err.message) + }) + }, + } } diff --git a/pages/index/index.vue b/pages/index/index.vue index 50d4cd9..eff0ccf 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -94,13 +94,24 @@ // my.alert({ title: res.code }); // } // }) - my.scan({ - scanType: ['barCode'], + my.ap.openAlipayApp({ + appCode: 'alipayScan', success: res => { - console.log("res: ",res); - my.alert({ title: res.code }); + console.log('openAlipayApp success', res); }, + fail: err => { + console.log('openAlipayApp fail', err); + } }); + + // my.scan({ + // scanType: ['qrCode'], + // autoDecodeCharset: true, + // success: res => { + // console.log("res: ",res); + // my.ap.openAlipayApp() + // }, + // }); } } } @@ -138,7 +149,12 @@ } .bottom-bar{ position: fixed; + /* #ifdef H5 */ + bottom: 100rpx; + /* #endif */ + /* #ifndef H5 */ bottom: 10rpx; + /* #endif */ left: 25rpx; z-index: 1000; line-height: 70rpx; diff --git a/pages/order/delivery.vue b/pages/order/delivery.vue index 81d88ef..d7e5520 100755 --- a/pages/order/delivery.vue +++ b/pages/order/delivery.vue @@ -54,7 +54,7 @@ \ No newline at end of file diff --git a/pages/user/equipment/index.vue b/pages/user/equipment/index.vue index 73665c8..7f8bcb1 100644 --- a/pages/user/equipment/index.vue +++ b/pages/user/equipment/index.vue @@ -1,38 +1,41 @@ + } + \ No newline at end of file diff --git a/pages/user/user.vue b/pages/user/user.vue index 5b85c99..dcffa22 100644 --- a/pages/user/user.vue +++ b/pages/user/user.vue @@ -53,9 +53,9 @@ 查看明细 --> - + @@ -125,11 +125,11 @@ - + @@ -181,7 +181,7 @@ {id: 'get_order',name: '订单管理',icon: 'qpdingdan',type: 'link',url: 'pages/order/index'}, {id: 'equipment',name: '设备管理',icon: 'shouhuodizhi',type: 'link',url: 'pages/user/equipment/index'}, {id: 'saleman',name: '收益明细',icon: 'shouhuodizhi',type: 'link',url: 'pages/saleman/profir-log/profir-log'}, - {id: 'withdraw_kog',name: '提现记录',icon: 'shouhuodizhi',type: 'link',url: 'package/dealer/withdraw/apply'}, + // {id: 'withdraw_kog',name: '提现记录',icon: 'shouhuodizhi',type: 'link',url: 'package/dealer/withdraw/apply'}, {id: 'help',name: '使用帮助',icon: 'bangzhu',type: 'link',url: 'pages/help/index'}, {id: 'administration',name: '关于我们',icon: 'sy-yh',type: 'link',url: 'pages/help/about'}, ]