Commit 5c4be0b7 authored by 李超鹏's avatar 李超鹏

Merge branch 'dev-photo-v2'

# Conflicts:
#	take-order/pages/photo/list.vue
#	take-order/pages/photo/preview.vue
#	take-order/pages/photo/setting.vue
parents 2ebfe4e1 7766596c
...@@ -83,8 +83,12 @@ ...@@ -83,8 +83,12 @@
}).then(res => { }).then(res => {
this.loading = false this.loading = false
if (res && res.result) { if (res && res.result) {
if(res.result.error_code){
uni.showToast({title: res.result.error_msg})
}else{
that.handleData(res.result) that.handleData(res.result)
} }
}
}) })
}, },
......
...@@ -135,6 +135,7 @@ ...@@ -135,6 +135,7 @@
uni.showLoading({ uni.showLoading({
title:'图片保存中…' title:'图片保存中…'
}) })
self.saveTempToLocal()
self.confirmUpload(true) self.confirmUpload(true)
}, },
submitFile() { submitFile() {
...@@ -148,9 +149,8 @@ ...@@ -148,9 +149,8 @@
"url": s, "url": s,
}).then(async res =>{ }).then(async res =>{
console.log(res, "云服务保存图片"); console.log(res, "云服务保存图片");
if(res.result) { if(res.result.code) {
// TODO 参数是否要来回传递 // TODO 参数是否要来回传递
await self.saveTempToLocal()
const photo = getApp().globalData.photo const photo = getApp().globalData.photo
photo.currentItemLength = photo.currentItemLength + 1 photo.currentItemLength = photo.currentItemLength + 1
uni.hideLoading() uni.hideLoading()
...@@ -178,7 +178,7 @@ ...@@ -178,7 +178,7 @@
// },2000) // },2000)
} else { } else {
uni.showToast({ uni.showToast({
title:'图片上传失败' title:'图片上传失败 '+ res.result.msg
}) })
} }
}) })
......
...@@ -133,10 +133,15 @@ ...@@ -133,10 +133,15 @@
'token': getApp().globalData.token, 'token': getApp().globalData.token,
'system_id': this.systemId 'system_id': this.systemId
}).then(res => { }).then(res => {
if (res && res.result) { if (res && res.result) {
if(res.result.error_code){
uni.showToast({title: res.result.error_msg})
}else{
this.result = res.result this.result = res.result
} }
}else{
uni.showToast({title: '网络异常'})
}
this.loading = false this.loading = false
}) })
}, },
...@@ -146,9 +151,11 @@ ...@@ -146,9 +151,11 @@
'token': getApp().globalData.token, 'token': getApp().globalData.token,
'watermark': this.result 'watermark': this.result
}).then(res => { }).then(res => {
if (res.result == true) { if (res.result.code == true) {
const photo = getApp().globalData.photo const photo = getApp().globalData.photo
photo.waterSetting = this.result photo.waterSetting = this.result
}else{
uni.showToast({title: res.result.msg})
} }
this.loading = false this.loading = false
......
// 本文件中的json内容将在云函数【运行】时作为参数传给云函数。
// 配置教程参考:https://uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
{"token":""
}
\ No newline at end of file
'use strict';
const {
getUserId
} = require('user-common')
exports.main = async (event, context) => {
let userId = getUserId(event.token)
let result = {code: false, msg: "用户没有权限"}
if (userId) {
let res = await uniCloud.database().collection("user_upload_file").where({
'user_id': userId
}).remove()
result = {code: true, msg: ""}
}
//返回数据给客户端
return result
};
async function getUserId(token) { async function getUserId(token) {
const res = await uniCloud.httpclient.request("https://system.dev.banshouhui.com/wxh-worker-rest/rest/" + const res = await uniCloud.httpclient.request("https://system.banshouhui.com/wxh-worker-rest/rest/" +
token + token +
"/myinfo/id", { "/myinfo/id", {
method: 'GET', method: 'GET',
dataType: 'text' dataType: 'text'
}) })
return res && res.status === 200 ? res.data : token return res && res.status === 200 ? res.data : ""
} }
module.exports = { module.exports = {
......
...@@ -7,6 +7,10 @@ exports.main = async (event, context) => { ...@@ -7,6 +7,10 @@ exports.main = async (event, context) => {
const _ = db.command const _ = db.command
const $ = db.command.aggregate const $ = db.command.aggregate
const user_id = await getUserId(event.token) const user_id = await getUserId(event.token)
if(!user_id){
return {error_code:'user_auth',error_msg:"用户没有权限"}
}
let res = await db.collection("standardV2").aggregate().lookup({ let res = await db.collection("standardV2").aggregate().lookup({
from: 'user_upload_file', from: 'user_upload_file',
let: { let: {
......
...@@ -5,6 +5,9 @@ const { ...@@ -5,6 +5,9 @@ const {
exports.main = async (event, context) => { exports.main = async (event, context) => {
//event为客户端上传的参数 //event为客户端上传的参数
const user_id = await getUserId(event.token) const user_id = await getUserId(event.token)
if(!user_id){
return {error_code:'user_auth',error_msg:"用户没有权限"}
}
const collection = uniCloud.database().collection("user_watermark").field({ const collection = uniCloud.database().collection("user_watermark").field({
'_id': false '_id': false
}) })
......
...@@ -12,8 +12,8 @@ exports.main = async (event, context) => { ...@@ -12,8 +12,8 @@ exports.main = async (event, context) => {
url: "https://img2.banshouhui.com/" + event.url, url: "https://img2.banshouhui.com/" + event.url,
create_date: new Date() create_date: new Date()
}) })
return true return {code:true}
}else{
return {code:false,msg:"用户没有权限"}
} }
return false
}; };
...@@ -5,7 +5,6 @@ const { ...@@ -5,7 +5,6 @@ const {
exports.main = async (event, context) => { exports.main = async (event, context) => {
let user_id = await getUserId(event.token) let user_id = await getUserId(event.token)
console.log(user_id);
const watermark = event.watermark const watermark = event.watermark
if (user_id) { if (user_id) {
watermark.user_id = user_id watermark.user_id = user_id
...@@ -19,7 +18,8 @@ exports.main = async (event, context) => { ...@@ -19,7 +18,8 @@ exports.main = async (event, context) => {
} else { } else {
await collection.add(watermark) await collection.add(watermark)
} }
return {code:true}
}else{
return {code:false,msg:"用户没有权限"}
} }
//返回数据给客户端
return 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