fix:修复下单页面获取code

This commit is contained in:
hanlin 2024-12-11 10:52:40 +08:00
parent 409d5f0ab8
commit d329ab031f
3 changed files with 33 additions and 30 deletions

View File

@ -751,16 +751,6 @@ export default {
fileListLen++ fileListLen++
} }
}, },
async getOpenId() {
uni.login({
provider: 'weixin',
success: async ({ code }) => {
const res = await this.$api.login.getOpenId({ code })
this.status = res.data.status
if (res.data.status !== 0) this.$common.msgToast(res.msg)
}
})
},
async signContract() { async signContract() {
this.loading = true this.loading = true
const data1 = { const data1 = {
@ -770,25 +760,38 @@ export default {
'/api/v2/warehouse/create', '/api/v2/warehouse/create',
data1 data1
) )
await this.getOpenId() if (res1.code === 200) {
if (res1.code === 200 && this.status === 0) { uni.login({
const res2 = await postDataByParams('/api/v2/warehouse/paid', { provider: 'weixin',
ID: res1.data.ID success: async ({ code }) => {
}) console.log('code', code)
if (res2.code === 200) { const res3 = await this.$api.login.getOpenId({ code })
uni.requestPayment({ if (res3.status === 0) {
...res2.data, const res2 = await postDataByParams(
fail: (res) => { '/api/v2/warehouse/paid',
this.loading = false {
}, ID: res1.data.ID
success: () => { }
this.loading = false )
uni.navigateTo({ if (res2.code === 200) {
url: `/pages/paySuccess/paySuccess?ID=${res1.data.ID}` uni.requestPayment({
}) ...res2.data,
fail: (res) => {
this.loading = false
},
success: () => {
this.loading = false
uni.navigateTo({
url: `/pages/paySuccess/paySuccess?ID=${res1.data.ID}`
})
}
})
}
} else {
this.$common.msgToast(res3.msg)
} }
}) }
} })
} }
}, },
async obtainAmount() { async obtainAmount() {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long