Commit 716488c3 authored by 李俊赕's avatar 李俊赕

add-router

parent 7856a621
This diff is collapsed.
import Vue from 'vue'
import App from './App'
import uView from "uview-ui";
import {router,RouterMount} from '@/router/index.js' //路径换成自己的
Vue.config.productionTip = false
Vue.use(uView);
App.mpType = 'app'
const app = new Vue({
...App
})
// http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
import httpInterceptor from '@src/common/http.interceptor.js'
import httpInterceptor from '@/common/http.interceptor.js'
Vue.use(httpInterceptor, app)
Vue.use(router)
// http接口API抽离,免于写url或者一些固定的参数
import httpApi from '@src/common/http.api.js'
import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app)
app.$mount()
//v1.3.5起 H5端 你应该去除原有的app.$mount();使用路由自带的渲染方式
// #ifdef H5
RouterMount(app,router,'#app')
// #endif
// #ifndef H5
app.$mount(); //为了兼容小程序及app端必须这样写才有效果
// #endif
\ No newline at end of file
{
"name": "",
"appid": "",
"description": "",
"versionName": "1.0.0",
"versionCode": "100",
"transformPx": false,
"app-plus": { /* 5+App特有相关 */
"usingComponents": true,
"splashscreen": {
"alwaysShowBeforeRender": true,
"waiting": true,
"autoclose": true,
"delay": 0
},
"modules": { /* 模块配置 */
},
"distribute": { /* 应用发布信息 */
"android": { /* android打包配置 */
"permissions": ["<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
"ios": { /* ios打包配置 */
},
"sdkConfigs": { /* SDK配置 */
}
}
},
"quickapp": { /* 快应用特有相关 */
},
"mp-weixin": { /* 微信小程序特有相关 */
"appid": "",
"setting": {
"urlCheck": false
},
"usingComponents": true
},
"mp-alipay" : {
"name" : "自营平台",
"appid" : "",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
"app-plus" : {
/* 5+App特有相关 */
"usingComponents" : true,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
"modules" : {},
/* 模块配置 */
"distribute" : {
/* 应用发布信息 */
"android" : {
/* android打包配置 */
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
"ios" : {},
/* ios打包配置 */
"sdkConfigs" : {}
}
},
/* SDK配置 */
"quickapp" : {},
/* 快应用特有相关 */
"mp-weixin" : {
/* 微信小程序特有相关 */
"appid" : "",
"setting" : {
"urlCheck" : false
},
"usingComponents" : true
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
......
// router.js
import {RouterMount,createRouter} from 'uni-simple-router';
const router = createRouter({
platform: process.env.VUE_APP_PLATFORM,
routes: [...ROUTES]
});
//全局路由前置守卫
router.beforeEach((to, from, next) => {
console.log('fff')
next();
// setTimeout(()=>{ // 保证onLaunch 和 index 页面下 onLoad 生命周期的执行顺序
// next();
// },3000)
});
// 全局路由后置守卫
router.afterEach((to, from) => {
console.log('跳转结束')
})
export {
router,
RouterMount
}
\ No newline at end of file
This diff is collapsed.
{
"passwordSecret": "passwordSecret-demo",
"tokenSecret": "tokenSecret-demo",
"tokenExpiresIn": 7200,
"tokenExpiresThreshold": 600,
"passwordErrorLimit": 6,
"bindTokenToDevice": true,
"passwordErrorRetryTime": 3600,
"autoSetInviteCode": false,
"forceInviteCode": false,
"app-plus": {
"tokenExpiresIn": 2592000,
"oauth" : {
"weixin" : {
"appid" : "weixin appid",
"appsecret" : "weixin appsecret"
}
}
},
"mp-weixin": {
"oauth" : {
"weixin" : {
"appid" : "weixin appid",
"appsecret" : "weixin appsecret"
}
}
},
"mp-alipay": {
"oauth" : {
"alipay" : {
"appid" : "alipay appid",
"privateKey" : "alipay privateKey"
}
}
},
"service": {
"sms": {
"name": "DCloud",
"codeExpiresIn": 300,
"smsKey": "your sms key",
"smsSecret": "your sms secret"
}
}
}
This diff is collapsed.
{
"name": "uni-id",
"version": "2.0.3",
"description": "uni-id for uniCloud",
"main": "index.js",
"homepage": "https://uniapp.dcloud.io/uniCloud/uni-id",
"repository": {
"type": "git",
"url": "git+https://gitee.com/dcloud/uni-id.git"
},
"author": "",
"license": "Apache-2.0"
}
\ No newline at end of file
async function getUserId(token) {
const res = await uniCloud.httpclient.request("https://system.dev.banshouhui.com/wxh-worker-rest/rest/" +
token +
"/myinfo/id", {
method: 'GET',
dataType: 'text'
})
return res && res.status === 200 ? res.data : token
}
module.exports = {
getUserId
}
{
"name": "user-common",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
'use strict';
exports.main = async (event, context) => {
const db = uniCloud.database();
let res = await db.collection("standard").where(event).get();
let data = res.data
const map = new Map()
for(let i = 0; i < data.length; i++){
let key = data[i].type
if(map.has(key)){
data[i].images = data[i].images.split(",")
map.get(key).list.push(data[i])
}else{
data[i].images = data[i].images.split(",")
map.set(key,{type:key, list:[data[i]]})
}
}
return [...map.values()]
};
// 本文件中的json内容将在云函数【运行】时作为参数传给云函数。
// 配置教程参考:https://uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
{
"token": "RTOKENeb70458c5502c48838d5e4cf84900767fa010f00",
"classify_id": "79550af260555cc20afb34146966a2c4",
"system_id": "79550af260555cc20afb34156c94b32c",
"brand_id": "28ee4e3e6063f2880d8956a013293a7f"
}
'use strict';
const {
getUserId
} = require('user-common')
exports.main = async (event, context) => {
const db = uniCloud.database();
const _ = db.command
const $ = db.command.aggregate
const user_id = await getUserId(event.token)
let res = await db.collection("standardV2").aggregate().lookup({
from: 'user_upload_file',
let: {
standard_id: '$_id'
},
pipeline: $.pipeline()
.match(_.expr($.and([
$.eq(['$standard_id', '$$standard_id']),
$.eq(['$user_id', user_id])
]))).sort({
create_date: -1
}).limit(10)
.project({
"_id": 0,
"url": 1,
})
.done(),
as: 'imageList'
}).match({"classify_id": event.classify_id, "system_id": event.system_id, "brand_id": event.brand_id}).limit(100).end()
const watermarkC = uniCloud.database().collection("user_watermark").field({'_id': false})
let userWatermark = await watermarkC.where({
user_id: user_id,
system_id: event.system_id
}).get()
if (!userWatermark.data || userWatermark.data.length <= 0) { // 用户没有 获取模板
userWatermark = await watermarkC.where({system_id: event.system_id}).get()
}
let userWatermarkData = userWatermark.data[0]
let data = res.data
const map = new Map()
for (let i = 0; i < data.length; i++) {
data[i].imageList = data[i].imageList.map(a => a.url)
let key = data[i].type
if (map.has(key)) {
data[i].images = data[i].images.split(",")
map.get(key).list.push(data[i])
} else {
data[i].images = data[i].images.split(",")
map.set(key, {
type: key,
userWatermark: userWatermarkData,
list: [data[i]]
})
}
}
return [...map.values()]
};
{
"name": "getGroupStandardV2",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"user-common": {
"version": "file:../common/user-common"
}
}
}
{
"name": "getGroupStandardV2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"user-common": "file:../common/user-common"
}
}
// 本文件中的json内容将在云函数【运行】时作为参数传给云函数。
// 配置教程参考:https://uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
{
"classify_id": "79550af260555cc20afb34146966a2c4",
"system_id": "79550af260555cc20afb34156c94b32c",
"field": "brand_id"
}
'use strict';
exports.main = async (event, context) => {
const param = {
"classify_id": event.classify_id,
"system_id": event.system_id,
"brand_id": event.brand_id
}
const db = uniCloud.database()
let res = await db.collection("standardV2").aggregate().match(param).group({
_id: "$" + event.field
}).end();
res = await db.collection('dictionary').field({
"_id": true,
"name": true
}).where({
_id: db.command.in(Array.from(res.data, item => item._id))
}).get()
return res.data
};
'use strict';
exports.main = async (event, context) => {
//event为客户端上传的参数
const db = uniCloud.database()
let res = await db.collection("standardV2").field({"classify_id": true, "system_id": true, "brand_id": true}).get();
let data = {}
let id = []
res.data.map(item => {
id.push(item.classify_id)
id.push(item.system_id)
id.push(item.brand_id)
if (data[item.classify_id]) {
if (data[item.classify_id][item.system_id]) {
if (data[item.classify_id][item.system_id].indexOf(item.brand_id) < 0)
data[item.classify_id][item.system_id].push(item.brand_id)
} else {
data[item.classify_id][item.system_id] = [item.brand_id]
}
} else {
let obj = {}
obj[item.system_id] = [item.brand_id]
data[item.classify_id] = obj
}
})
let dic = await db.collection("dictionary").where({
_id: db.command.in(id)
}).get()
let dic_data = {}
dic.data.map(item => {
dic_data[item._id] = item.name
})
let result = []
for (let first in data) {
let secondArr = []
for (let second in data[first]) {
let thirdArr = []
data[first][second].map(third => {
thirdArr.push({id: third, name: dic_data[third]})
})
secondArr.push({id: second, name: dic_data[second], child: thirdArr})
}
result.push({id: first, name: dic_data[first], child: secondArr})
}
return result;
};
// 本文件中的json内容将在云函数【运行】时作为参数传给云函数。
// 配置教程参考:https://uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
{
"token": "fdsadfsafsafsadfdsa",
"system_id": "79550af260555cc20afb34156c94b32c"
}
'use strict';
const {
getUserId
} = require('user-common')
exports.main = async (event, context) => {
//event为客户端上传的参数
const user_id = await getUserId(event.token)
const collection = uniCloud.database().collection("user_watermark").field({
'_id': false
})
let res = await collection.where({
user_id: user_id,
system_id: event.system_id
}).get()
if (!res.data || res.data.length <= 0) { // 用户没有 获取模板
res = await collection.where({
system_id: event.system_id
}).get()
}
return res.data[0]
};
{
"name": "getUserWatermark",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"user-common": {
"version": "file:../common/user-common"
}
}
}
{
"name": "getUserWatermark",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"user-common": "file:../common/user-common"
}
}
'use strict';
const {
getUserId
} = require('user-common')
exports.main = async (event, context) => {
//event为客户端上传的参数
let workerId = await getUserId(event.token)
if (workerId) {
await uniCloud.database().collection("user_upload_file").add({
"user_id": workerId,
"standard_id": event.standardId,
url: "https://img2.banshouhui.com/" + event.url,
create_date: new Date()
})
return true
}
return false
};
{
"name": "saveImage",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"user-common": {
"version": "file:../common/user-common"
}
}
}
{
"name": "saveImage",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"user-common": "file:../common/user-common"
}
}
'use strict';
const {
getUserId
} = require('user-common')
exports.main = async (event, context) => {
let user_id = await getUserId(event.token)
console.log(user_id);
const watermark = event.watermark
if (user_id) {
watermark.user_id = user_id
const collection = uniCloud.database().collection("user_watermark");
const res = await collection.where({
user_id: user_id,
system_id: watermark.system_id
}).get()
if (res.data && res.data.length > 0) {
await collection.doc(res.data[0]._id).update(watermark)
} else {
await collection.add(watermark)
}
}
//返回数据给客户端
return true
};
{
"name": "saveUserWatermark",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"user-common": {
"version": "file:../common/user-common"
}
}
}
{
"name": "saveUserWatermark",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"user-common": "file:../common/user-common"
}
}
{
"token": "fdsadfsafsafsadfdsa",
"watermark": {
"has_origin": true,
"lower_right": {
"body": [{
"enable": true,
"watemark_text": "时间",
"watemark_type": "时间",
"watemark_value": ""
}, {
"enable": true,
"watemark_text": "地址",
"watemark_type": "地址",
"watemark_value": ""
}, {
"enable": true,
"watemark_text": "经度",
"watemark_type": "经度",
"watemark_value": ""
}, {
"enable": true,
"watemark_text": "纬度",
"watemark_type": "纬度",
"watemark_value": ""
}, {
"enable": false,
"watemark_text": "",
"watemark_type": "备注",
"watemark_value": ""
}, {
"watemark_value": "蓝天工程队3",
"enable": true,
"watemark_text": "工程队名称3",
"watemark_type": "备注"
}, {
"enable": true,
"watemark_text": "10000",
"watemark_type": "备注",
"watemark_value": "111111"
}, {
"enable": false,
"watemark_text": "",
"watemark_type": "备注",
"watemark_value": ""
}, {
"enable": false,
"watemark_text": "",
"watemark_type": "备注",
"watemark_value": ""
}]
},
"mid_text": "现场拍照",
"system_id": "79550af260555cc20afb34156c94b32c",
"user_id": "fdsadfsafsafsadfdsa"
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
{
"passwordSecret": "passwordSecret-demo",
"tokenSecret": "tokenSecret-demo",
"tokenExpiresIn": 7200,
"tokenExpiresThreshold": 600,
"passwordErrorLimit": 6,
"bindTokenToDevice": true,
"passwordErrorRetryTime": 3600,
"autoSetInviteCode": false,
"forceInviteCode": false,
"app-plus": {
"tokenExpiresIn": 2592000,
"oauth" : {
"weixin" : {
"appid" : "weixin appid",
"appsecret" : "weixin appsecret"
}
}
},
"mp-weixin": {
"oauth" : {
"weixin" : {
"appid" : "weixin appid",
"appsecret" : "weixin appsecret"
}
}
},
"mp-alipay": {
"oauth" : {
"alipay" : {
"appid" : "alipay appid",
"privateKey" : "alipay privateKey"
}
}
},
"service": {
"sms": {
"name": "DCloud",
"codeExpiresIn": 300,
"smsKey": "your sms key",
"smsSecret": "your sms secret"
}
}
}
This diff is collapsed.
{
"name": "uni-id",
"version": "2.0.3",
"description": "uni-id for uniCloud",
"main": "index.js",
"homepage": "https://uniapp.dcloud.io/uniCloud/uni-id",
"repository": {
"type": "git",
"url": "git+https://gitee.com/dcloud/uni-id.git"
},
"author": "",
"license": "Apache-2.0"
}
\ No newline at end of file
async function getUserId(token) {
const res = await uniCloud.httpclient.request("https://system.dev.banshouhui.com/wxh-worker-rest/rest/" +
token +
"/myinfo/id", {
method: 'GET',
dataType: 'text'
})
return res && res.status === 200 ? res.data : token
}
module.exports = {
getUserId
}
{
"name": "user-common",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
'use strict';
exports.main = async (event, context) => {
const db = uniCloud.database();
let res = await db.collection("standard").where(event).get();
let data = res.data
const map = new Map()
for(let i = 0; i < data.length; i++){
let key = data[i].type
if(map.has(key)){
data[i].images = data[i].images.split(",")
map.get(key).list.push(data[i])
}else{
data[i].images = data[i].images.split(",")
map.set(key,{type:key, list:[data[i]]})
}
}
return [...map.values()]
};
// 本文件中的json内容将在云函数【运行】时作为参数传给云函数。
// 配置教程参考:https://uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
{
"token": "RTOKENeb70458c5502c48838d5e4cf84900767fa010f00",
"classify_id": "79550af260555cc20afb34146966a2c4",
"system_id": "79550af260555cc20afb34156c94b32c",
"brand_id": "28ee4e3e6063f2880d8956a013293a7f"
}
'use strict';
const {
getUserId
} = require('user-common')
exports.main = async (event, context) => {
const db = uniCloud.database();
const _ = db.command
const $ = db.command.aggregate
const user_id = await getUserId(event.token)
let res = await db.collection("standardV2").aggregate().lookup({
from: 'user_upload_file',
let: {
standard_id: '$_id'
},
pipeline: $.pipeline()
.match(_.expr($.and([
$.eq(['$standard_id', '$$standard_id']),
$.eq(['$user_id', user_id])
]))).sort({
create_date: -1
}).limit(10)
.project({
"_id": 0,
"url": 1,
})
.done(),
as: 'imageList'
}).match({"classify_id": event.classify_id, "system_id": event.system_id, "brand_id": event.brand_id}).limit(100).end()
const watermarkC = uniCloud.database().collection("user_watermark").field({'_id': false})
let userWatermark = await watermarkC.where({
user_id: user_id,
system_id: event.system_id
}).get()
if (!userWatermark.data || userWatermark.data.length <= 0) { // 用户没有 获取模板
userWatermark = await watermarkC.where({system_id: event.system_id}).get()
}
let userWatermarkData = userWatermark.data[0]
let data = res.data
const map = new Map()
for (let i = 0; i < data.length; i++) {
data[i].imageList = data[i].imageList.map(a => a.url)
let key = data[i].type
if (map.has(key)) {
data[i].images = data[i].images.split(",")
map.get(key).list.push(data[i])
} else {
data[i].images = data[i].images.split(",")
map.set(key, {
type: key,
userWatermark: userWatermarkData,
list: [data[i]]
})
}
}
return [...map.values()]
};
{
"name": "getGroupStandardV2",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"user-common": {
"version": "file:../common/user-common"
}
}
}
{
"name": "getGroupStandardV2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"user-common": "file:../common/user-common"
}
}
// 本文件中的json内容将在云函数【运行】时作为参数传给云函数。
// 配置教程参考:https://uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
{
"classify_id": "79550af260555cc20afb34146966a2c4",
"system_id": "79550af260555cc20afb34156c94b32c",
"field": "brand_id"
}
'use strict';
exports.main = async (event, context) => {
const param = {
"classify_id": event.classify_id,
"system_id": event.system_id,
"brand_id": event.brand_id
}
const db = uniCloud.database()
let res = await db.collection("standardV2").aggregate().match(param).group({
_id: "$" + event.field
}).end();
res = await db.collection('dictionary').field({
"_id": true,
"name": true
}).where({
_id: db.command.in(Array.from(res.data, item => item._id))
}).get()
return res.data
};
'use strict';
exports.main = async (event, context) => {
//event为客户端上传的参数
const db = uniCloud.database()
let res = await db.collection("standardV2").field({"classify_id": true, "system_id": true, "brand_id": true}).get();
let data = {}
let id = []
res.data.map(item => {
id.push(item.classify_id)
id.push(item.system_id)
id.push(item.brand_id)
if (data[item.classify_id]) {
if (data[item.classify_id][item.system_id]) {
if (data[item.classify_id][item.system_id].indexOf(item.brand_id) < 0)
data[item.classify_id][item.system_id].push(item.brand_id)
} else {
data[item.classify_id][item.system_id] = [item.brand_id]
}
} else {
let obj = {}
obj[item.system_id] = [item.brand_id]
data[item.classify_id] = obj
}
})
let dic = await db.collection("dictionary").where({
_id: db.command.in(id)
}).get()
let dic_data = {}
dic.data.map(item => {
dic_data[item._id] = item.name
})
let result = []
for (let first in data) {
let secondArr = []
for (let second in data[first]) {
let thirdArr = []
data[first][second].map(third => {
thirdArr.push({id: third, name: dic_data[third]})
})
secondArr.push({id: second, name: dic_data[second], child: thirdArr})
}
result.push({id: first, name: dic_data[first], child: secondArr})
}
return result;
};
// 本文件中的json内容将在云函数【运行】时作为参数传给云函数。
// 配置教程参考:https://uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
{
"token": "fdsadfsafsafsadfdsa",
"system_id": "79550af260555cc20afb34156c94b32c"
}
'use strict';
const {
getUserId
} = require('user-common')
exports.main = async (event, context) => {
//event为客户端上传的参数
const user_id = await getUserId(event.token)
const collection = uniCloud.database().collection("user_watermark").field({
'_id': false
})
let res = await collection.where({
user_id: user_id,
system_id: event.system_id
}).get()
if (!res.data || res.data.length <= 0) { // 用户没有 获取模板
res = await collection.where({
system_id: event.system_id
}).get()
}
return res.data[0]
};
{
"name": "getUserWatermark",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"user-common": {
"version": "file:../common/user-common"
}
}
}
{
"name": "getUserWatermark",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"user-common": "file:../common/user-common"
}
}
'use strict';
const {
getUserId
} = require('user-common')
exports.main = async (event, context) => {
//event为客户端上传的参数
let workerId = await getUserId(event.token)
if (workerId) {
await uniCloud.database().collection("user_upload_file").add({
"user_id": workerId,
"standard_id": event.standardId,
url: "https://img2.banshouhui.com/" + event.url,
create_date: new Date()
})
return true
}
return false
};
{
"name": "saveImage",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"user-common": {
"version": "file:../common/user-common"
}
}
}
{
"name": "saveImage",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"user-common": "file:../common/user-common"
}
}
'use strict';
const {
getUserId
} = require('user-common')
exports.main = async (event, context) => {
let user_id = await getUserId(event.token)
console.log(user_id);
const watermark = event.watermark
if (user_id) {
watermark.user_id = user_id
const collection = uniCloud.database().collection("user_watermark");
const res = await collection.where({
user_id: user_id,
system_id: watermark.system_id
}).get()
if (res.data && res.data.length > 0) {
await collection.doc(res.data[0]._id).update(watermark)
} else {
await collection.add(watermark)
}
}
//返回数据给客户端
return true
};
{
"name": "saveUserWatermark",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"user-common": {
"version": "file:../common/user-common"
}
}
}
{
"name": "saveUserWatermark",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"user-common": "file:../common/user-common"
}
}
{
"token": "fdsadfsafsafsadfdsa",
"watermark": {
"has_origin": true,
"lower_right": {
"body": [{
"enable": true,
"watemark_text": "时间",
"watemark_type": "时间",
"watemark_value": ""
}, {
"enable": true,
"watemark_text": "地址",
"watemark_type": "地址",
"watemark_value": ""
}, {
"enable": true,
"watemark_text": "经度",
"watemark_type": "经度",
"watemark_value": ""
}, {
"enable": true,
"watemark_text": "纬度",
"watemark_type": "纬度",
"watemark_value": ""
}, {
"enable": false,
"watemark_text": "",
"watemark_type": "备注",
"watemark_value": ""
}, {
"watemark_value": "蓝天工程队3",
"enable": true,
"watemark_text": "工程队名称3",
"watemark_type": "备注"
}, {
"enable": true,
"watemark_text": "10000",
"watemark_type": "备注",
"watemark_value": "111111"
}, {
"enable": false,
"watemark_text": "",
"watemark_type": "备注",
"watemark_value": ""
}, {
"enable": false,
"watemark_text": "",
"watemark_type": "备注",
"watemark_value": ""
}]
},
"mid_text": "现场拍照",
"system_id": "79550af260555cc20afb34156c94b32c",
"user_id": "fdsadfsafsafsadfdsa"
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -5,6 +5,8 @@ const path = require("path");
function resolve(dir) {
return path.join(__dirname, dir);
}
const TransformPages = require('uni-read-pages')
const {webpack} = new TransformPages()
const name = "自营平台";
......@@ -24,5 +26,15 @@ module.exports = {
"@v": resolve("src/pages"),
},
},
plugins: [
new webpack.DefinePlugin({
ROUTES: webpack.DefinePlugin.runtimeValue(() => {
const tfPages = new TransformPages({
includes: ['path', 'name', 'aliasPath']
});
return JSON.stringify(tfPages.routes)
}, true)
})
]
},
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment