小程序
小游戏
企业微信
微信支付
扫描小程序码分享
在本地调试时一切正常的,云端测试就报错,这是什么原因啊,大神们帮忙看看呀,谢谢啦
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
为什么总是不走本地调试啊,好奇怪。
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
为什么总是不走本地调试啊,好奇怪。
const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV,
traceUser: true
})
const db = cloud.database()
const qC = db.collection("jobinfo")
// 云函数入口函数
exports.main = async (event, context) => {
const value = {
SysID: "0000000003",
CSysID: "0000000003",
Status: 5
}
const sendvalue = Buffer.from(JSON.stringify(value)).toString('base64')
const soap = require('soap');
const url = 'http://sup.wcube.foxconn.com/OAPlatform/ComService.asmx?wsdl';
const args = {
sendvalue: sendvalue,
taskstatus: 2
};
//拿到所有的close狀態的任務
const returnResult = await new Promise((resolve, reject) => {
soap.createClient(url, function (err, client) {
if (err) {
console.log(err);
}
//返回一个客户端,并且传参调用Java的接口,接收返回的数据
client.GetTaskList(args, function (error, result) {
//打印接收到的数据
resolve(JSON.parse(result.GetTaskListResult))
console.log(JSON.parse(result.GetTaskListResult))
const resultList = JSON.parse(result.GetTaskListResult).Resultvalue
console.log("1", JSON.parse(result.GetTaskListResult).Resultvalue)
console.log("2", JSON.parse(result.GetTaskListResult).Resultvalue.length)
for (let index = 0; index < JSON.parse(result.GetTaskListResult).Resultvalue.length; index++) {
const re = JSON.parse(Buffer.from(resultList[index].Value, 'base64').toString('utf-8'))
console.log("3", re)
// console.log("4", Buffer.from(re.title, 'base64').toString('utf-8'))
console.log("5", Buffer.from(re.operationtyoe, 'base64').toString('utf-8'))
// return
// 2. 先把图片上传到云存储 -> fileID
if (Buffer.from(re.operationtyoe, 'base64').toString('utf-8') == 2) {
qC.doc(re._id).update({
data: {
updateTime: db.serverDate(),
// updatePerson: Buffer.from(re.updatePerson, 'base64').toString('utf-8'),
status: '1'
}
})
} else {
let urlName = 'jobImages/' + re._id + Date.now() + index + '.png'
console.log("6", Buffer.from(re.fileIDs[0], 'base64'))
cloud.uploadFile({
cloudPath: urlName,
fileContent: Buffer.from(re.fileIDs[0], 'base64')
}).then(e => {
console.log("7", e.fileID)
var fileIDs = []
fileIDs.push(e.fileID)
if (Buffer.from(re.operationtyoe, 'base64').toString('utf-8') == 0) {
qC.add({
data: {
title: Buffer.from(re.title, 'base64').toString('utf-8'),
factoryname: Buffer.from(re.factoryname, 'base64').toString('utf-8'),
totalnum: Buffer.from(re.totalnum, 'base64').toString('utf-8'),
bonus: Buffer.from(re.bonus, 'base64').toString('utf-8'),
address: Buffer.from(re.address, 'base64').toString('utf-8'),
specification: Buffer.from(re.specification, 'base64').toString('utf-8'),
salary: Buffer.from(re.salary, 'base64').toString('utf-8'),
founder: Buffer.from(re.founder, 'base64').toString('utf-8'),
position: Buffer.from(re.position, 'base64').toString('utf-8'),
createTime: db.serverDate(),
fileIDs: fileIDs,
signupNum: Buffer.from(re.signupNum, 'base64').toString('utf-8'),
status: '0',
mobile: Buffer.from(re.mobile, 'base64').toString('utf-8'),
jobcontent: Buffer.from(re.jobcontent, 'base64').toString('utf-8'),
others: Buffer.from(re.others, 'base64').toString('utf-8'),
route: Buffer.from(re.route, 'base64').toString('utf-8'),
updateTime: db.serverDate(),
updatePerson: '',
_id: re._id
}
}).then(res => {
console.log("8", res)
}).catch(e => {
console.log("9", e)
})
} else if (Buffer.from(re.operationtyoe, 'base64').toString('utf-8') == 1) {
try {
qC.doc(re._id).update({
data: {
title: Buffer.from(re.title, 'base64').toString('utf-8'),
factoryname: Buffer.from(re.factoryname, 'base64').toString('utf-8'),
totalnum: Buffer.from(re.totalnum, 'base64').toString('utf-8'),
bonus: Buffer.from(re.bonus, 'base64').toString('utf-8'),
address: Buffer.from(re.address, 'base64').toString('utf-8'),
specification: Buffer.from(re.specification, 'base64').toString('utf-8'),
salary: Buffer.from(re.salary, 'base64').toString('utf-8'),
founder: Buffer.from(re.founder, 'base64').toString('utf-8'),
position: Buffer.from(re.position, 'base64').toString('utf-8'),
createTime: db.serverDate(),
fileIDs: fileIDs,
signupNum: Buffer.from(re.signupNum, 'base64').toString('utf-8'),
status: '0',
mobile: Buffer.from(re.mobile, 'base64').toString('utf-8'),
jobcontent: Buffer.from(re.jobcontent, 'base64').toString('utf-8'),
others: Buffer.from(re.others, 'base64').toString('utf-8'),
route: Buffer.from(re.route, 'base64').toString('utf-8'),
updateTime: db.serverDate(),
updatePerson: ''
}
}).then(res => {
console.log("10", res)
}).catch(e => {
console.log("11", e)
})
} catch (e) {
console.log(e)
}
}
})
}
// return
const sendvalue = {
Rid: JSON.parse(result.GetTaskListResult).Resultvalue[index].Rid,
Status: 3
}
const sendvalueStr = JSON.stringify(sendvalue)
const sendvalue64 = Buffer.from(sendvalueStr).toString('base64')
const args1 = {
sendvalue: sendvalue64,
};
new Promise((resolve, reject) => {
soap.createClient(url, function (err, client) {
if (err) {
console.log(err);
}
//返回一个客户端,并且传参调用Java的接口,接收返回的数据
client.Delete(args1, function (error, result) {
//打印接收到的数据
resolve(result)
});
});
})
}
});
});
})
}