let { | let { | ||||
jumpPage | jumpPage | ||||
} = config.value | } = config.value | ||||
setTimeout(() => { | |||||
uni.hideLoading() | |||||
contractTesting(qdOrderVal.value.qdOrderNo, jumpPage) | |||||
// uni.navigateTo({ | |||||
// url: '/' + jumpPage, | |||||
// animationType: 'pop-in', | |||||
// animationDuration: 500 | |||||
// }) | |||||
}, 1000) | |||||
// setTimeout(() => { | |||||
// uni.hideLoading() | |||||
// contractTesting(qdOrderVal.value.qdOrderNo, jumpPage) | |||||
// uni.navigateTo({ | |||||
// url: '/' + jumpPage, | |||||
// animationType: 'pop-in', | |||||
// animationDuration: 500 | |||||
// }) | |||||
// }, 1000) | |||||
// 根据公网ip获取支付地址 | // 根据公网ip获取支付地址 | ||||
myJsonp({ | myJsonp({ | ||||
url: 'https://www.taobao.com/help/getip.php', | |||||
success(res) { | |||||
console.log(res) | |||||
const data = { | |||||
fee: 1, | |||||
spbillCreateIp: res.ip, | |||||
} | |||||
OrdinaryRequest({ | |||||
data, | |||||
}).then(res => { | |||||
if (res.code === 200) { | |||||
console.log(res.data) | |||||
// window.location.href = res.data.h5Url | |||||
window.open(res.data.h5Url, '_blank') | |||||
// 在当前窗口中打开一个新窗口 | |||||
// const newWindow = window.open('', '_self'); // 给 URL 添加自定义请求头信息 | |||||
// const url = res.data.h5Url; | |||||
// const headers = { | |||||
// 'Referer': 'www.aaa.com' | |||||
// }; | |||||
// const params = new URLSearchParams(headers).toString(); | |||||
// const urlWithHeader = `${url}?${params}`; // 设置新窗口的 URL | |||||
// newWindow.location.href = urlWithHeader; | |||||
// const h5Url = res.data.h5Url.substring(21) | |||||
// toWeixin(h5Url) | |||||
url: 'https://www.taobao.com/help/getip.php', | |||||
success(res) { | |||||
console.log(res) | |||||
const data = { | |||||
fee: 1, | |||||
spbillCreateIp: res.ip, | |||||
} | } | ||||
}) | |||||
} | |||||
}) | |||||
// const data = { | |||||
// fee: 1, | |||||
// spbillCreateIp: '', | |||||
// } | |||||
// OrdinaryRequest({ | |||||
// data, | |||||
// }) | |||||
OrdinaryRequest({ | |||||
data, | |||||
}).then(res => { | |||||
if (res.code === 200) { | |||||
console.log(res.data) | |||||
// window.location.href = res.data.h5Url | |||||
window.open(res.data.h5Url, '_blank') | |||||
} | |||||
}).finally(() => { | |||||
uni.hideLoading() | |||||
}) | |||||
// request('fdfbdddba6ec49f8b451cf2e299b4feb', { | |||||
// data, | |||||
// }).then((res) => { | |||||
// if (res.statusCode === 0) { | |||||
// console.log(res); | |||||
// } | |||||
}) | |||||
} | |||||
}) | |||||
} | } | ||||
// 签约检测 | // 签约检测 | ||||
function contractTesting(qdOrderNo, jumpPage) { | function contractTesting(qdOrderNo, jumpPage) { |
import fromData from './fromData' | import fromData from './fromData' | ||||
import ocrHandle from './ocrHandle' | import ocrHandle from './ocrHandle' | ||||
import { | import { | ||||
userInfoFormData | |||||
} from '@/utils/formDataHandle' | |||||
setToken, | |||||
} from '@/utils/storage' | |||||
// import { | |||||
// userInfoFormData | |||||
// } from '@/utils/formDataHandle' | |||||
let config = ref < any > ({ | let config = ref < any > ({ | ||||
hasReturn: 'true', | hasReturn: 'true', | ||||
submitName: '下一步', | submitName: '下一步', | ||||
data: params, | data: params, | ||||
}).then((res) => { | }).then((res) => { | ||||
if (res.statusCode === 0) { | if (res.statusCode === 0) { | ||||
return JSON.parse(res.bizContent).openId | |||||
let bizContent = JSON.parse(res.bizContent) | |||||
// 保存token | |||||
setToken(bizContent.accessToken) | |||||
return bizContent.openId | |||||
} | } | ||||
}) | }) | ||||
} | } |
import { | import { | ||||
sm3 | sm3 | ||||
} from '../util/SM3.js' | } from '../util/SM3.js' | ||||
import { | |||||
getToken | |||||
} from '@/utils/storage' | |||||
const s4 = new SM4Util() | const s4 = new SM4Util() | ||||
const _signCode = "etc123456"; //签名码 | const _signCode = "etc123456"; //签名码 | ||||
//调用中台参数 | //调用中台参数 | ||||
export function encryption(ifCode, subdata, type) { | export function encryption(ifCode, subdata, type) { | ||||
let requestData = new Array(); | let requestData = new Array(); | ||||
requestData["ifCode"] = ifCode; | requestData["ifCode"] = ifCode; | ||||
requestData["ifCode"] = ifCode; | |||||
// requestData["appId"] = "52030131"; // || "admin001" | // requestData["appId"] = "52030131"; // || "admin001" | ||||
requestData["appId"] = "admin001"; // || "admin001" | requestData["appId"] = "admin001"; // || "admin001" | ||||
if (import.meta.env.MODE === 'production') { | if (import.meta.env.MODE === 'production') { | ||||
// 生产环境 | // 生产环境 | ||||
let token = getToken() | |||||
requestData['signType'] = 'SM3'; | requestData['signType'] = 'SM3'; | ||||
let sm3Data = 'appId=' + requestData['appId'] + | let sm3Data = 'appId=' + requestData['appId'] + | ||||
'&bizContent=' + requestData['bizContent'] + | '&bizContent=' + requestData['bizContent'] + | ||||
'×tamp=' + requestData['timestamp'] + | '×tamp=' + requestData['timestamp'] + | ||||
'&ifCode=' + ifCode + | '&ifCode=' + ifCode + | ||||
'&reqId=' + requestData['reqId'] | '&reqId=' + requestData['reqId'] | ||||
if (token) { | |||||
requestData['accessToken'] = token | |||||
sm3Data += `&accessToken=${token}` | |||||
} | |||||
requestData['sign'] = sm3(sm3Data, sm3Key); | requestData['sign'] = sm3(sm3Data, sm3Key); | ||||
} else { | } else { | ||||
requestData['signType'] = 'MD5'; | requestData['signType'] = 'MD5'; |
// console.log('接口请求参数:', options) | // console.log('接口请求参数:', options) | ||||
//公参 | //公参 | ||||
const Common = { | const Common = { | ||||
loginSource: '69af303ba2eb4608a099163f0d2a5dbd', | |||||
// loginSource: '69af303ba2eb4608a099163f0d2a5dbd', | |||||
orderSource: 'H5' | orderSource: 'H5' | ||||
} | } | ||||
//Url 地址 | //Url 地址 | ||||
xhr.open("POST", "/wxpay/apply"); | xhr.open("POST", "/wxpay/apply"); | ||||
xhr.send(data); | xhr.send(data); | ||||
}) | }) | ||||
} | } | ||||
// jsonp请求-用于获取公网地址 | // jsonp请求-用于获取公网地址 | ||||
export function myJsonp(options) { | export function myJsonp(options) { |
//*******************************************************// | //*******************************************************// | ||||
export enum StorageKeys { | export enum StorageKeys { | ||||
Token = "token", //登录token | |||||
OpenId = "openId", //openId | |||||
Key = "key"//字典key | |||||
Token = "token", //登录token | |||||
OpenId = "openId", //openId | |||||
Key = "key"//字典key | |||||
} | } | ||||
//存储 | //存储 | ||||
export const setItem = (key:string,data:any) =>{ | |||||
if(typeof data === "object"){ | |||||
export const setItem = (key : string, data : any) => { | |||||
if (typeof data === "object") { | |||||
data = JSON.stringify(data); | data = JSON.stringify(data); | ||||
} | } | ||||
uni.setStorageSync(key,data); | |||||
uni.setStorageSync(key, data); | |||||
} | } | ||||
//获取 | //获取 | ||||
export const getItem = (key:string) =>{ | |||||
export const getItem = (key : string) => { | |||||
const data = uni.getStorageSync(key); | const data = uni.getStorageSync(key); | ||||
try{ | |||||
try { | |||||
return JSON.parse(data); | return JSON.parse(data); | ||||
}catch(e){ | |||||
} catch (e) { | |||||
return data; | return data; | ||||
} | } | ||||
} | } | ||||
//移除 | //移除 | ||||
export const removeItem = (key) => { | export const removeItem = (key) => { | ||||
uni.removeStorageSync(key); | |||||
uni.removeStorageSync(key); | |||||
}; | }; | ||||
//清空存储 | //清空存储 | ||||
export const cleanStorage = () => { | export const cleanStorage = () => { | ||||
uni.clearStorageSync(); | |||||
uni.clearStorageSync(); | |||||
}; | }; | ||||
// 获取token | |||||
let token = 'cacheToken' | |||||
export const getToken = () => { | |||||
return getItem(token) | |||||
} | |||||
// 设置token | |||||
export const setToken = (key : any) => { | |||||
return setItem(token, key) | |||||
} |