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
This diff is collapsed.
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
// 获取规格Id // 获取规格Id
this.standardId = app.globalData.photo.currentItem._id this.standardId = app.globalData.photo.currentItem._id
} }
getApp().trackPage('照片预览页') getApp().trackPage('照片预览页')
const globalTempPath = getApp().globalData.photo.tempPath const globalTempPath = getApp().globalData.photo.tempPath
if(globalTempPath && globalTempPath.mixWater){ if(globalTempPath && globalTempPath.mixWater){
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
if(e.standardId) { if(e.standardId) {
this.standardId = e.standardId this.standardId = e.standardId
} }
this.token = getApp().globalData.token this.token = getApp().globalData.token
}, },
methods: { methods: {
...@@ -135,11 +135,12 @@ ...@@ -135,11 +135,12 @@
uni.showLoading({ uni.showLoading({
title:'图片保存中…' title:'图片保存中…'
}) })
self.saveTempToLocal()
self.confirmUpload(true) self.confirmUpload(true)
}, },
submitFile() { submitFile() {
let self = this let self = this
if(self.keys.length) { if(self.keys.length) {
for (let s of self.keys) { for (let s of self.keys) {
self.$u.cloudApi.saveImage({ self.$u.cloudApi.saveImage({
...@@ -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
}) })
} }
}) })
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
.pic { .pic {
flex:1; flex:1;
width: 100%; width: 100%;
/* height:auto */ /* height:auto */
/* height: 760rpx; */ /* height: 760rpx; */
} }
......
This diff is collapsed.
// 本文件中的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