| | |
| | | import { VueQueryPlugin, VueQueryPluginOptions } from '@tanstack/vue-query'; |
| | | import { myClient } from '@/constants/query'; |
| | | import { VueLifeRechargePlugin } from '@life-payment/core-vue'; |
| | | import { blLifeRecharge } from '@/utils/blLifeRecharge'; |
| | | import { blLifeRecharge, LifeRechargeOptions } from '@/utils/blLifeRecharge'; |
| | | import { isWeChat } from '@/utils/env'; |
| | | |
| | | window.uni = Taro; |
| | |
| | | |
| | | App.use(VueLifeRechargePlugin, { |
| | | blLifeRecharge, |
| | | // options: LifeRechargeOptions, |
| | | }); |
| | | |
| | | export default App; |
| | |
| | | } |
| | | |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | const { virtualUserInfo } = useVirtualUserInfo(); |
| | | // const { virtualUserInfo } = useVirtualUserInfo(); |
| | | |
| | | const isChannelAccount = computed(() => virtualUserInfo.value.isBackClientUser); |
| | | const isChannelAccount = computed(() => blLifeRecharge.accountModel.isBackClientUser); |
| | | |
| | | return { |
| | | user: userInfo, |
| | |
| | | wxCode, |
| | | wxOpenId, |
| | | isChannelAccount, |
| | | virtualUserInfo, |
| | | // virtualUserInfo, |
| | | }; |
| | | } |
| | | |
| | |
| | | |
| | | <script setup lang="ts"> |
| | | import { ShareQrcodeView } from '@life-payment/components'; |
| | | import { useLifeRechargeContext } from '@life-payment/core-vue'; |
| | | import { useUser } from '@/hooks'; |
| | | |
| | | defineOptions({ |
| | | name: 'InnerPage', |
| | | }); |
| | | |
| | | const { virtualUserInfo } = useUser(); |
| | | // const { virtualUserInfo } = useUser(); |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | |
| | | const userChannles = computed(() => virtualUserInfo.value.channlesNum ?? []); |
| | | const userChannles = computed(() => blLifeRecharge.accountModel.userChannles ?? []); |
| | | |
| | | const channlesType = ref(userChannles.value[0]?.channlesNum ?? ''); |
| | | |
| | |
| | | phoneNumber: getStorageVirtualUserId()?.virtualPhoneNumber ?? '', |
| | | channlesNum: '818', |
| | | }); |
| | | |
| | | export const LifeRechargeOptions = { |
| | | axiosConfig: config, |
| | | userId: getStorageVirtualUserId()?.virtualUserId ?? '', |
| | | phoneNumber: getStorageVirtualUserId()?.virtualPhoneNumber ?? '', |
| | | channlesNum: '818', |
| | | }; |
| | |
| | | export const VueLifeRechargePlugin = { |
| | | install: (app: any, { blLifeRecharge }: VueLifeRechargePluginOptions) => { |
| | | const _blLifeRecharge = reactive(blLifeRecharge); |
| | | _blLifeRecharge.init(); |
| | | |
| | | // blLifeRecharge.listener.addListener({ |
| | | // update: (state) => { |
| | |
| | | static constants = LifeRechargeConstants; |
| | | constants = LifeRechargeConstants; |
| | | |
| | | /**用户所有的渠道 */ |
| | | userChannles = [] as ChannelOutput[]; |
| | | isBackClientUser: boolean; |
| | | |
| | | constructor(options: BlLifeRechargeOptions<TResponse, TRequestOptions>) { |
| | | this.listener = new LifeRechargeListener(); |
| | | this.services = new BlLifeRechargeServices(this, options); |
| | |
| | | }); |
| | | } |
| | | |
| | | init() { |
| | | if (this.accountModel.userId) { |
| | | this.accountModel.getUserInfo(); |
| | | } |
| | | } |
| | | |
| | | async login(body: PhoneMesssageCodeLoginInput, options?: RequestConfig) { |
| | | try { |
| | | let res = await this.services.lifePayPhoneMesssageCodeLogin(body, options); |
| | | this.accountModel.setUserId(res.userId); |
| | | this.accountModel.getUserInfo(); |
| | | this.accountModel.setPhoneNumber(body.phoneNumber); |
| | | return res; |
| | | } catch (error) { |
| | |
| | | phoneNumber = ''; |
| | | channlesNum = ''; |
| | | |
| | | /**用户所有的渠道 */ |
| | | userChannles = [] as ChannelOutput[]; |
| | | isBackClientUser: boolean; |
| | | |
| | | constructor( |
| | | ctx: BlLifeRecharge<TResponse, TRequestOptions>, |
| | | options: BlLifeRechargeAccountModelOptions = {} |
| | |
| | | setUserId(userId: string) { |
| | | this.userId = userId; |
| | | this.ctx.listener.fireEvent('update', this.ctx); |
| | | if (userId) { |
| | | this.getUserInfo(userId); |
| | | } |
| | | // if (userId) { |
| | | // this.getUserInfo(userId); |
| | | // } |
| | | } |
| | | |
| | | async getUserInfo(userId: string) { |
| | | async getUserInfo(userId?: string) { |
| | | try { |
| | | let res = await this.ctx.services.lifePayUserMesssageByIduser( |
| | | { |
| | | id: userId, |
| | | id: userId || this.userId, |
| | | }, |
| | | { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | this.ctx.isBackClientUser = res.isBackClientUser; |
| | | this.isBackClientUser = res.isBackClientUser; |
| | | if (res && res.isBackClientUser) { |
| | | this.setUserChannles(res.channlesNum ?? []); |
| | | } |
| | |
| | | this.ctx.listener.fireEvent('update', this.ctx); |
| | | } |
| | | setUserChannles(userChannles: ChannelOutput[]) { |
| | | this.ctx.userChannles = userChannles; |
| | | this.userChannles = userChannles; |
| | | this.ctx.listener.fireEvent('update', this.ctx); |
| | | } |
| | | } |