fix:live_image[]请求体改为重复key,签名用逗号拼接
This commit is contained in:
parent
5245d6a86d
commit
7082dfda6f
@ -2147,35 +2147,47 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = {
|
// 签名用参数:live_image[] 用逗号拼接
|
||||||
app_key: 'psi',
|
const signParams = {
|
||||||
client_id: 'psi',
|
app_key: 'psi', client_id: 'psi', fid: '0', type: '4',
|
||||||
fid: '0',
|
isbn: this.noIsbnIsbn || this.noIsbnUnifyIsbn || '', f_isbn: '0',
|
||||||
type: '4',
|
book_name: this.noIsbnBookName || '', f_book_name: '',
|
||||||
isbn: this.noIsbnIsbn || this.noIsbnUnifyIsbn || '',
|
author: this.noIsbnAuthor || '', publisher: this.noIsbnPublisher || '',
|
||||||
f_isbn: '0',
|
publication_time: pubTimestamp, binding_layout: '',
|
||||||
book_name: this.noIsbnBookName || '',
|
|
||||||
f_book_name: '',
|
|
||||||
author: this.noIsbnAuthor || '',
|
|
||||||
publisher: this.noIsbnPublisher || '',
|
|
||||||
publication_time: pubTimestamp,
|
|
||||||
binding_layout: '',
|
|
||||||
fix_price: this.noIsbnPrice ? String(Math.round(parseFloat(this.noIsbnPrice) * 100)) : '',
|
fix_price: this.noIsbnPrice ? String(Math.round(parseFloat(this.noIsbnPrice) * 100)) : '',
|
||||||
page_count: '0',
|
page_count: '0', word_count: this.noIsbnWordCount || '', book_format: '',
|
||||||
word_count: this.noIsbnWordCount || '',
|
|
||||||
book_format: '',
|
|
||||||
'live_image[]': imageUrls.join(','),
|
'live_image[]': imageUrls.join(','),
|
||||||
timestamp: timestamp,
|
timestamp: timestamp, sign_method: 'md5'
|
||||||
sign_method: 'md5'
|
|
||||||
}
|
}
|
||||||
|
var sign = calculateSign(signParams)
|
||||||
|
|
||||||
// 计算签名(与仓库列表一致的签名算法)
|
// 手动构建请求体:live_image[] 重复 key 出现,服务端收到后自动逗号拼接
|
||||||
var sign = calculateSign(params)
|
var b = []
|
||||||
params.sign = sign
|
b.push('app_key=psi&client_id=psi&fid=0&type=4')
|
||||||
|
b.push('isbn=' + encodeURIComponent(this.noIsbnIsbn || this.noIsbnUnifyIsbn || ''))
|
||||||
|
b.push('f_isbn=0')
|
||||||
|
b.push('book_name=' + encodeURIComponent(this.noIsbnBookName || ''))
|
||||||
|
b.push('f_book_name=')
|
||||||
|
b.push('author=' + encodeURIComponent(this.noIsbnAuthor || ''))
|
||||||
|
b.push('publisher=' + encodeURIComponent(this.noIsbnPublisher || ''))
|
||||||
|
b.push('publication_time=' + pubTimestamp)
|
||||||
|
b.push('binding_layout=')
|
||||||
|
b.push('fix_price=' + (this.noIsbnPrice ? String(Math.round(parseFloat(this.noIsbnPrice) * 100)) : '0'))
|
||||||
|
b.push('page_count=0')
|
||||||
|
b.push('word_count=' + (this.noIsbnWordCount || '0'))
|
||||||
|
b.push('book_format=0')
|
||||||
|
for (var ii = 0; ii < imageUrls.length; ii++) {
|
||||||
|
b.push('live_image[]=' + encodeURIComponent(imageUrls[ii]))
|
||||||
|
}
|
||||||
|
b.push('timestamp=' + timestamp)
|
||||||
|
b.push('sign_method=md5')
|
||||||
|
b.push('sign=' + sign)
|
||||||
|
var bodyStr = b.join('&')
|
||||||
|
|
||||||
const apiUrl = 'https://psi.api.buzhiyushu.cn/api/syncBook'
|
const apiUrl = 'https://psi.api.buzhiyushu.cn/api/syncBook'
|
||||||
console.log('【syncBook】请求地址:', apiUrl)
|
console.log('【syncBook】请求地址:', apiUrl)
|
||||||
console.log('【syncBook】请求参数:', params)
|
console.log('【syncBook】签名参数:', signParams)
|
||||||
|
console.log('【syncBook】请求body:', bodyStr)
|
||||||
|
|
||||||
const res = await new Promise(function (resolve, reject) {
|
const res = await new Promise(function (resolve, reject) {
|
||||||
uni.request({
|
uni.request({
|
||||||
@ -2185,7 +2197,7 @@ export default {
|
|||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
'Authorization': 'Bearer ' + token
|
'Authorization': 'Bearer ' + token
|
||||||
},
|
},
|
||||||
data: params,
|
data: bodyStr,
|
||||||
success: function (r) { resolve(r) },
|
success: function (r) { resolve(r) },
|
||||||
fail: function (e) { reject(e) }
|
fail: function (e) { reject(e) }
|
||||||
})
|
})
|
||||||
@ -2218,7 +2230,7 @@ export default {
|
|||||||
type: this.currentTab,
|
type: this.currentTab,
|
||||||
apiUrl: apiUrl,
|
apiUrl: apiUrl,
|
||||||
apiResponse: res.data,
|
apiResponse: res.data,
|
||||||
data: params
|
data: signParams
|
||||||
})
|
})
|
||||||
uni.setStorageSync('uploadHistory', uploadHistory.slice(0, 100))
|
uni.setStorageSync('uploadHistory', uploadHistory.slice(0, 100))
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user