源文件
This commit is contained in:
27
jeepay-ui-uapp-cashier/pages/hub/default.vue
Normal file
27
jeepay-ui-uapp-cashier/pages/hub/default.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<view></view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import navigateUtil from '@/util/navigateUtil.js'
|
||||
|
||||
onLoad( (toPageParams) => {
|
||||
|
||||
// #ifdef H5
|
||||
navigateUtil.to('/pages/hub/h5', toPageParams)
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-WEIXIN || MP-ALIPAY
|
||||
navigateUtil.to('/pages/hub/lite', toPageParams)
|
||||
// #endif
|
||||
|
||||
} )
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
42
jeepay-ui-uapp-cashier/pages/hub/h5.vue
Normal file
42
jeepay-ui-uapp-cashier/pages/hub/h5.vue
Normal file
@@ -0,0 +1,42 @@
|
||||
<template>
|
||||
<view></view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import { setToken } from '@/util/jeepayTokenUtil.js'
|
||||
import { $getRedirectUrl } from '@/http/apiManager.js'
|
||||
import navigateUtil from '@/util/navigateUtil.js'
|
||||
import storageManage from '@/util/storageManage.js'
|
||||
import { onMounted } from 'vue'
|
||||
import { navigateTo } from "@/util/member.js"
|
||||
|
||||
// uniapp 的钩子事件(同步), 一般用作获取到页面传参
|
||||
// 通用放置token & 如果获取异常 将跳转到错误页面;
|
||||
onLoad( (toPageParams) => setToken(toPageParams) )
|
||||
|
||||
// vue的挂载钩子
|
||||
onMounted( (opt) => {
|
||||
$getRedirectUrl().then( ({bizData}) => {
|
||||
// 如果缓存包含该渠道用户ID, 那么直接跳转。
|
||||
if(bizData.channelUserIdCacheKey && storageManage.channelUserId(bizData.channelUserIdCacheKey)){
|
||||
navigateTo(storageManage.channelUserId(bizData.channelUserIdCacheKey))
|
||||
return false
|
||||
}
|
||||
// 需要重定向
|
||||
if(bizData.redirectFlag){
|
||||
location.href = bizData.redirectUrl
|
||||
return false;
|
||||
}else{ // 无需获取
|
||||
navigateUtil.redirectTo('/pages/payway/index') // 跳转到输入金额 页面;
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
124
jeepay-ui-uapp-cashier/pages/hub/lite.vue
Normal file
124
jeepay-ui-uapp-cashier/pages/hub/lite.vue
Normal file
@@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import { setToken, setPageType, setLiteToken } from '@/util/jeepayTokenUtil.js'
|
||||
import { reactive } from 'vue'
|
||||
import { $getChannelUserId } from '@/http/apiManager.js'
|
||||
import { toErrPageFunc } from '@/util/toErrorPageUtil.js'
|
||||
import storageManage from '@/util/storageManage.js'
|
||||
// import { Base64 } from 'js-base64'
|
||||
import { navigateTo } from "@/util/member.js"
|
||||
onLoad((options) => {
|
||||
|
||||
setPageType()
|
||||
|
||||
if (appConfig.currentPageType == appConfig.PAGE_TYPE_ENUM.WECHAT_LITE) {
|
||||
getWxParams(options)
|
||||
} else if (appConfig.currentPageType == appConfig.PAGE_TYPE_ENUM.ALIPAY_LITE) {
|
||||
getAliParams(options)
|
||||
}
|
||||
})
|
||||
|
||||
// 微信登录
|
||||
function getWxParams(options) {
|
||||
|
||||
let query = options.q || ''
|
||||
setLiteToken(decodeURIComponent(query))
|
||||
|
||||
uni.showLoading({title: '加载中...'})
|
||||
|
||||
// 获取openId
|
||||
wx.login({
|
||||
success(res) {
|
||||
commonGetChannelUserIdFunc(appConfig.PAGE_TYPE_ENUM.WECHAT_LITE, res.code, { 'code': res.code })
|
||||
},
|
||||
fail() {
|
||||
uni.hideLoading()
|
||||
toErrPageFunc('登录失败')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 支付宝登录
|
||||
function getAliParams(options) {
|
||||
|
||||
// 首页扫码进入
|
||||
if (options && options.isNeedParseQrc) {
|
||||
let query = options.q || ''
|
||||
setLiteToken(decodeURIComponent(query))
|
||||
}
|
||||
|
||||
uni.showLoading({title: '加载中...'})
|
||||
|
||||
my.getAuthCode({
|
||||
success: (res) => {
|
||||
commonGetChannelUserIdFunc(appConfig.PAGE_TYPE_ENUM.ALIPAY_LITE, res.authCode, { 'auth_code': res.authCode })
|
||||
},
|
||||
fail: (res) => {
|
||||
uni.hideLoading()
|
||||
toErrPageFunc('登录失败')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function commonGetChannelUserIdFunc(pageType, authCode, reqParams){
|
||||
|
||||
if (authCode) {
|
||||
|
||||
// 缓存KEY: jeepayChannelUserId_pageType
|
||||
// 此处不再查询后端的缓存KEY, 不同小程序之间做了隔离, 与浏览器有区别。 所以此处不需要根据appID做区分。
|
||||
// 此小程序内, 获取到的只能是此服务商该小程序APPID的openID
|
||||
let channelUserIdCacheKey = 'jeepayChannelUserId_' + pageType;
|
||||
// let jeepayChannelUniIdKey = 'jeepayChannelUniId_' + pageType;
|
||||
// 存在缓存
|
||||
if(storageManage.channelUserId(channelUserIdCacheKey)){
|
||||
navigateTo(storageManage.channelUserId(channelUserIdCacheKey))
|
||||
uni.hideLoading()
|
||||
return
|
||||
}
|
||||
// 传输是否为特约商户的小程序账号
|
||||
if(reqParams){
|
||||
reqParams.isUseSubmchAccount = appConfig.isUseSubmchAccount
|
||||
}
|
||||
// 以下为不存在缓存数据
|
||||
$getChannelUserId(reqParams).then(({ bizData }) => {
|
||||
console.log('channelUserId',bizData);
|
||||
// 放置 userID缓存。
|
||||
if(bizData){
|
||||
storageManage.channelUserId(channelUserIdCacheKey, bizData)
|
||||
}
|
||||
navigateTo(bizData)
|
||||
uni.hideLoading()
|
||||
|
||||
}).catch(err => {
|
||||
uni.hideLoading()
|
||||
console.log(err);
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
return toErrPageFunc('登录失败')
|
||||
}
|
||||
}
|
||||
// 跳转至收银台
|
||||
function setChannelUserIdAndToPaywayPage() {
|
||||
uni.redirectTo({
|
||||
url: '/pages/payway/index',
|
||||
success() {
|
||||
uni.hideLoading()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user