@@ -16,7 +16,7 @@ import { SERVICE_MAP } from '@/api/config'
|
|||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
*/
|
*/
|
||||||
export async function getUserInfo() {
|
export async function getUserInfo() {
|
||||||
const res = await mainClient.request<IApiResponse<{ user : IUserInfo }>>({
|
const res = await mainClient.request<IApiResponse<{ user: IUserInfo }>>({
|
||||||
url: 'common/user/getUserInfo',
|
url: 'common/user/getUserInfo',
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
})
|
})
|
||||||
@@ -27,7 +27,7 @@ export async function getUserInfo() {
|
|||||||
* 获取VIP信息
|
* 获取VIP信息
|
||||||
*/
|
*/
|
||||||
export async function getVipInfo() {
|
export async function getVipInfo() {
|
||||||
const res = await mainClient.request<IApiResponse<{ vipInfo : IVipInfo }>>({
|
const res = await mainClient.request<IApiResponse<{ vipInfo: IVipInfo }>>({
|
||||||
url: 'bookAbroad/home/getVipInfo',
|
url: 'bookAbroad/home/getVipInfo',
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
})
|
})
|
||||||
@@ -39,8 +39,8 @@ export async function getVipInfo() {
|
|||||||
* @param current 当前页码
|
* @param current 当前页码
|
||||||
* @param limit 每页数量
|
* @param limit 每页数量
|
||||||
*/
|
*/
|
||||||
export async function getOrderList(page : number, limit : number, orderStatus : string) {
|
export async function getOrderList(page: number, limit: number, orderStatus: string) {
|
||||||
const res = await mainClient.request<IApiResponse<{ orders : IPageData<IOrder> }>>({
|
const res = await mainClient.request<IApiResponse<{ orders: IPageData<IOrder> }>>({
|
||||||
url: 'common/buyOrder/commonBuyOrderList',
|
url: 'common/buyOrder/commonBuyOrderList',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { page, limit, orderStatus, come: '10', userId: uni.getStorageSync('userInfo').id }
|
data: { page, limit, orderStatus, come: '10', userId: uni.getStorageSync('userInfo').id }
|
||||||
@@ -52,7 +52,7 @@ export async function getOrderList(page : number, limit : number, orderStatus :
|
|||||||
* 获取VIP套餐列表
|
* 获取VIP套餐列表
|
||||||
*/
|
*/
|
||||||
export async function getVipPackages() {
|
export async function getVipPackages() {
|
||||||
const res = await mainClient.request<IApiResponse<{ sysDictDatas : IVipPackage[] }>>({
|
const res = await mainClient.request<IApiResponse<{ sysDictDatas: IVipPackage[] }>>({
|
||||||
url: 'book/sysdictdata/getData',
|
url: 'book/sysdictdata/getData',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { dictLabel: 'googleVip' }
|
data: { dictLabel: 'googleVip' }
|
||||||
@@ -64,8 +64,8 @@ export async function getVipPackages() {
|
|||||||
* 创建订单
|
* 创建订单
|
||||||
* @param data 订单数据
|
* @param data 订单数据
|
||||||
*/
|
*/
|
||||||
export async function createOrder(data : any) {
|
export async function createOrder(data: any) {
|
||||||
const res = await mainClient.request<IApiResponse<{ orderSn : string }>>({
|
const res = await mainClient.request<IApiResponse<{ orderSn: string }>>({
|
||||||
url: 'bookAbroad/order/placeOrder',
|
url: 'bookAbroad/order/placeOrder',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data
|
data
|
||||||
@@ -77,8 +77,8 @@ export async function createOrder(data : any) {
|
|||||||
* 获取交易记录列表
|
* 获取交易记录列表
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
*/
|
*/
|
||||||
export async function getTransactionList(userId : number) {
|
export async function getTransactionList(userId: number) {
|
||||||
const res = await mainClient.request<IApiResponse<{ transactionDetailsList : ITransaction[] }>>({
|
const res = await mainClient.request<IApiResponse<{ transactionDetailsList: ITransaction[] }>>({
|
||||||
url: 'common/transactionDetails/getTransactionDetailsList',
|
url: 'common/transactionDetails/getTransactionDetailsList',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { userId }
|
data: { userId }
|
||||||
@@ -90,7 +90,7 @@ export async function getTransactionList(userId : number) {
|
|||||||
* 更新用户基本信息
|
* 更新用户基本信息
|
||||||
* @param data 用户信息
|
* @param data 用户信息
|
||||||
*/
|
*/
|
||||||
export async function updateUserInfo(data : Partial<IUserInfo>) {
|
export async function updateUserInfo(data: Partial<IUserInfo>) {
|
||||||
const res = await mainClient.request<IApiResponse>({
|
const res = await mainClient.request<IApiResponse>({
|
||||||
url: 'book/user/update',
|
url: 'book/user/update',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -105,7 +105,7 @@ export async function updateUserInfo(data : Partial<IUserInfo>) {
|
|||||||
* @param email 邮箱地址
|
* @param email 邮箱地址
|
||||||
* @param code 验证码
|
* @param code 验证码
|
||||||
*/
|
*/
|
||||||
export async function updateEmail(id : number, email : string, code : string) {
|
export async function updateEmail(id: number, email: string, code: string) {
|
||||||
const res = await mainClient.request<IApiResponse>({
|
const res = await mainClient.request<IApiResponse>({
|
||||||
url: 'common/user/updateUserEmail',
|
url: 'common/user/updateUserEmail',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -119,7 +119,7 @@ export async function updateEmail(id : number, email : string, code : string) {
|
|||||||
* @param id 用户ID
|
* @param id 用户ID
|
||||||
* @param password 新密码
|
* @param password 新密码
|
||||||
*/
|
*/
|
||||||
export async function updatePassword(id : number, password : string) {
|
export async function updatePassword(id: number, password: string) {
|
||||||
const res = await mainClient.request<IApiResponse>({
|
const res = await mainClient.request<IApiResponse>({
|
||||||
url: 'common/user/setPasswordById',
|
url: 'common/user/setPasswordById',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -135,7 +135,7 @@ export async function updatePassword(id : number, password : string) {
|
|||||||
* 发送邮箱验证码
|
* 发送邮箱验证码
|
||||||
* @param email 邮箱地址
|
* @param email 邮箱地址
|
||||||
*/
|
*/
|
||||||
export async function sendEmailCode(email : string) {
|
export async function sendEmailCode(email: string) {
|
||||||
const res = await mainClient.request<IApiResponse>({
|
const res = await mainClient.request<IApiResponse>({
|
||||||
url: 'common/user/getMailCaptcha',
|
url: 'common/user/getMailCaptcha',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -152,7 +152,7 @@ export async function sendEmailCode(email : string) {
|
|||||||
* @param filePath 本地文件路径
|
* @param filePath 本地文件路径
|
||||||
* @returns 图片URL
|
* @returns 图片URL
|
||||||
*/
|
*/
|
||||||
export function uploadImage(filePath : string) : Promise<string> {
|
export function uploadImage(filePath: string): Promise<string> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: `${SERVICE_MAP.MAIN}oss/fileoss`,
|
url: `${SERVICE_MAP.MAIN}oss/fileoss`,
|
||||||
@@ -179,7 +179,7 @@ export function uploadImage(filePath : string) : Promise<string> {
|
|||||||
* 提交问题反馈
|
* 提交问题反馈
|
||||||
* @param data 反馈表单数据
|
* @param data 反馈表单数据
|
||||||
*/
|
*/
|
||||||
export async function submitFeedback(data : IFeedbackForm) {
|
export async function submitFeedback(data: IFeedbackForm) {
|
||||||
const res = await mainClient.request<IApiResponse>({
|
const res = await mainClient.request<IApiResponse>({
|
||||||
url: 'common/sysFeedback/addSysFeedback',
|
url: 'common/sysFeedback/addSysFeedback',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -194,12 +194,11 @@ export async function submitFeedback(data : IFeedbackForm) {
|
|||||||
* @param orderSn 订单号
|
* @param orderSn 订单号
|
||||||
* @param productId 产品ID
|
* @param productId 产品ID
|
||||||
*/
|
*/
|
||||||
export async function verifyGooglePay(productId : number, purchaseToken : string, orderSn : string) {
|
export async function verifyGooglePay(purchaseToken: string, orderSn: string, productId: string) {
|
||||||
console.log(productId, purchaseToken, orderSn);
|
|
||||||
const res = await mainClient.request<IApiResponse>({
|
const res = await mainClient.request<IApiResponse>({
|
||||||
url: 'pay/googlepay/googleVerify',
|
url: 'pay/googlepay/googleVerify',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { productId, purchaseToken, orderSn }
|
data: { purchaseToken, orderSn, productId }
|
||||||
})
|
})
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
@@ -208,7 +207,7 @@ export async function verifyGooglePay(productId : number, purchaseToken : string
|
|||||||
* 验证IAP支付
|
* 验证IAP支付
|
||||||
* @param data 支付数据
|
* @param data 支付数据
|
||||||
*/
|
*/
|
||||||
export async function verifyIAP(data : any) {
|
export async function verifyIAP(data: any) {
|
||||||
const res = await mainClient.request<IApiResponse>({
|
const res = await mainClient.request<IApiResponse>({
|
||||||
url: 'Ipa/veri',
|
url: 'Ipa/veri',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -222,11 +221,11 @@ export async function verifyIAP(data : any) {
|
|||||||
* @param type 固定值 point
|
* @param type 固定值 point
|
||||||
* @param qudao 支付类型
|
* @param qudao 支付类型
|
||||||
*/
|
*/
|
||||||
export async function getBookBuyConfigList(type : string, qudao : string) {
|
export async function getBookBuyConfigList(type: string, qudao: string) {
|
||||||
const res = await mainClient.request<IApiResponse>({
|
const res = await mainClient.request<IApiResponse>({
|
||||||
url: 'common/bookBuyConfig/getBookBuyConfigList',
|
url: 'common/bookBuyConfig/getBookBuyConfigList',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { type, qudao }
|
data: {type, qudao}
|
||||||
})
|
})
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
@@ -235,12 +234,12 @@ export async function getBookBuyConfigList(type : string, qudao : string) {
|
|||||||
* 获取隐私协议
|
* 获取隐私协议
|
||||||
* @param id 101众妙之门隐私政策
|
* @param id 101众妙之门隐私政策
|
||||||
*/
|
*/
|
||||||
export async function getAgreement(id : string) {
|
export async function getAgreement(id: string) {
|
||||||
console.log(id, 'id');
|
console.log(id, 'id');
|
||||||
const res = await mainClient.request<IApiResponse>({
|
const res = await mainClient.request<IApiResponse>({
|
||||||
url: '/sys/agreement/getAgreement',
|
url: '/sys/agreement/getAgreement',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { id }
|
data: {id}
|
||||||
})
|
})
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
@@ -257,13 +256,9 @@ export async function getActivityDescription() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 充值记录列表
|
* 获取充值列表
|
||||||
* @param current 当前页码
|
|
||||||
* @param limit 每页数量
|
|
||||||
* @param userId 用户id
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
export async function getTransactionDetailsList(current : number, limit : number, userId : string) {
|
export async function getTransactionDetailsList(current: number, limit: number, userId: string,) {
|
||||||
const res = await mainClient.request<IApiResponse>({
|
const res = await mainClient.request<IApiResponse>({
|
||||||
url: 'common/transactionDetails/getTransactionDetailsList',
|
url: 'common/transactionDetails/getTransactionDetailsList',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -271,31 +266,3 @@ export async function getTransactionDetailsList(current : number, limit : number
|
|||||||
})
|
})
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取订单编号
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
export async function getPlaceOrder(data: object) {
|
|
||||||
|
|
||||||
const res = await mainClient.request<IApiResponse>({
|
|
||||||
url: '/book/buyOrder/placeOrder',
|
|
||||||
method: 'POST',
|
|
||||||
data: data
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取积分数据
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
export async function getPointsData(current : number, limit : number, userId : string,) {
|
|
||||||
|
|
||||||
const res = await mainClient.request<IApiResponse>({
|
|
||||||
url: 'common/jfTransactionDetails/getJfTransactionDetailsList',
|
|
||||||
method: 'POST',
|
|
||||||
data: { current, limit, userId, }
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
@@ -79,13 +79,7 @@
|
|||||||
"navigationBarTitleText": "%user.virtual%",
|
"navigationBarTitleText": "%user.virtual%",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},{
|
}, {
|
||||||
"path": "pages/user/points/index",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "%user.points%",
|
|
||||||
"navigationStyle": "custom"
|
|
||||||
}
|
|
||||||
},{
|
|
||||||
"path": "pages/user/myBook/index",
|
"path": "pages/user/myBook/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
|
|||||||
@@ -47,14 +47,14 @@
|
|||||||
<view class="assets_row">天医币</view>
|
<view class="assets_row">天医币</view>
|
||||||
<view>{{userInfo.peanutCoin ?? 1}}</view>
|
<view>{{userInfo.peanutCoin ?? 1}}</view>
|
||||||
</view>
|
</view>
|
||||||
<view @click="goPointsList">
|
<view>
|
||||||
<view class="assets_row">积分</view>
|
<view class="assets_row">积分</view>
|
||||||
<view>{{userInfo.jf ?? 1}}</view>
|
<view>{{userInfo.jf ?? 1}}</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view>
|
<view>
|
||||||
<view class="assets_row">优惠卷</view>
|
<view class="assets_row">优惠卷</view>
|
||||||
<view>0</view>
|
<view>0</view>
|
||||||
</view> -->
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="chong_btn" @click="goRecharge">充 值</view>
|
<view class="chong_btn" @click="goRecharge">充 值</view>
|
||||||
<!-- <text class="wallet_title">{{$t('my.coin')}}<uni-icons type="help" size="19" color="#666"></uni-icons></text>
|
<!-- <text class="wallet_title">{{$t('my.coin')}}<uni-icons type="help" size="19" color="#666"></uni-icons></text>
|
||||||
@@ -81,7 +81,6 @@
|
|||||||
import type { IVipInfo } from '@/types/user'
|
import type { IVipInfo } from '@/types/user'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { getNotchHeight } from '@/utils/system'
|
import { getNotchHeight } from '@/utils/system'
|
||||||
import { onShow } from '@dcloudio/uni-app'
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
@@ -148,13 +147,12 @@
|
|||||||
* 获取数据
|
* 获取数据
|
||||||
*/
|
*/
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
console.log(userInfo.value);
|
|
||||||
try {
|
try {
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
const userRes = await getUserInfo()
|
const userRes = await getUserInfo()
|
||||||
console.log(userRes, '-----userRes');
|
console.log(userRes);
|
||||||
if (userRes.result) {
|
if (userRes.user) {
|
||||||
userStore.setUserInfo(userRes.result)
|
userStore.setUserInfo(userRes.user)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取VIP信息
|
// 获取VIP信息
|
||||||
@@ -230,21 +228,11 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 跳转积分列表
|
|
||||||
*/
|
|
||||||
const goPointsList = () => {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages/user/points/index'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
onShow(() => {
|
|
||||||
getData()
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getPlatform()
|
getPlatform()
|
||||||
|
getData()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -387,7 +375,7 @@
|
|||||||
border-radius: 50rpx;
|
border-radius: 50rpx;
|
||||||
color: #fffbf6;
|
color: #fffbf6;
|
||||||
padding: 10rpx 32rpx;
|
padding: 10rpx 32rpx;
|
||||||
background-color: #007bff;
|
background-image: linear-gradient(90deg, #3ab3ae 0%, #d5ecdd 200%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.assets {
|
.assets {
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
<view class="recharge_block" @click="chosPric(item)"
|
<view class="recharge_block" @click="chosPric(item)"
|
||||||
:class="aloneItem.priceTypeId === item.priceTypeId ? 'selected' : ''"
|
:class="aloneItem.priceTypeId === item.priceTypeId ? 'selected' : ''"
|
||||||
v-for="item in rechargeList.bookBuyConfigList" :key="item.priceTypeId">
|
v-for="item in rechargeList.bookBuyConfigList" :key="item.priceTypeId">
|
||||||
<view class="recharge_money">¥{{item.realMoney}}</view>
|
<view class="recharge_money">¥{{item.money}}</view>
|
||||||
<view>{{item.money}}{{$t('order.virtualCoin')}}</view>
|
<view>{{item.realMoney}}{{$t('order.virtualCoin')}}</view>
|
||||||
<!-- 红框位置的618活动标签 -->
|
<!-- 红框位置的618活动标签 -->
|
||||||
<!-- <view class="activity-tag">618活动</view> -->
|
<!-- <view class="activity-tag">618活动</view> -->
|
||||||
<span class="activity-label" v-if="item.givejf >0">618充值活动</span>
|
<span class="activity-label" v-if="item.givejf >0">618充值活动</span>
|
||||||
@@ -23,26 +23,25 @@
|
|||||||
<view class="cha_fangsh">
|
<view class="cha_fangsh">
|
||||||
<view class="cf_title PM_font">{{$t('user.paymentMethod')}}</view>
|
<view class="cf_title PM_font">{{$t('user.paymentMethod')}}</view>
|
||||||
<view class="cf_radio">
|
<view class="cf_radio">
|
||||||
<radio-group v-for="item in iosPaylist">
|
<radio-group v-for="item in iosPaylist" @click="choseType(item.id)">
|
||||||
<view style="width: 100%">
|
<view style="width: 100%">
|
||||||
<view :class="payType == item.id ? 'Tab_xf cf_xuanx' : 'cf_xuanx'">
|
<view :class="payType == item.id ? 'Tab_xf cf_xuanx' : 'cf_xuanx'">
|
||||||
<!-- <image class="pay_item_img" :src="item.imgUrl" mode="aspectFil">
|
<!-- <image class="pay_item_img" :src="item.imgUrl" mode="aspectFil">
|
||||||
</image> -->
|
</image> -->
|
||||||
<text>{{ item.title }}</text>
|
<text>{{ item.title }}</text>
|
||||||
<radio :checked="payType === item.id" @click="choseType(item.id)"></radio>
|
<radio :checked="payType === item.id"></radio>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</radio-group>
|
</radio-group>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="agree_wo flexbox">
|
<view class="agree_wo flexbox">
|
||||||
<radio-group class="agree" v-for="(item, index) in argee" :key="index">
|
<radio-group class="agree" v-for="(item, index) in argee" :key="index" @click="radioCheck">
|
||||||
<view>
|
<view>
|
||||||
<radio class="agreeRadio" :value="item.id" :checked="state" @click="radioCheck" color="#007bff"></radio>
|
<radio class="agreeRadio" :value="item.id" :checked="state" color="#007bff"></radio>
|
||||||
</view>
|
</view>
|
||||||
</radio-group>
|
</radio-group>
|
||||||
<view>{{$t('order.readAgree')}}<span class="highlight"
|
<view>{{$t('order.readAgree')}}<span class="highlight" @click="showAgreement">《{{$t('order.valueAddedServices')}}》</span></view>
|
||||||
@click="showAgreement">《{{$t('order.valueAddedServices')}}》</span></view>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="bottom-button-container">
|
<view class="bottom-button-container">
|
||||||
<button class="recharge-button" @click="handleRecharge">{{$t('order.recharge')}}</button>
|
<button class="recharge-button" @click="handleRecharge">{{$t('order.recharge')}}</button>
|
||||||
@@ -64,13 +63,10 @@
|
|||||||
import { ref, computed, onMounted, toRefs, reactive } from 'vue'
|
import { ref, computed, onMounted, toRefs, reactive } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useMessage } from '@/uni_modules/wot-design-uni'
|
import { useMessage } from '@/uni_modules/wot-design-uni'
|
||||||
import { getBookBuyConfigList, getAgreement, getActivityDescription, verifyGooglePay, getPlaceOrder } from '@/api/modules/user'
|
import { getBookBuyConfigList, getAgreement, getActivityDescription } from '@/api/modules/user'
|
||||||
import { onLogin } from '../../../../项目/nuttyreading-hw/config/login';
|
// const googlePay = uni.requireNativePlugin("sn-googlepay5");
|
||||||
import { useUserStore } from '@/stores/user'
|
|
||||||
const googlePay = uni.requireNativePlugin("sn-googlepay5");
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const userStore = useUserStore()
|
|
||||||
const payType = ref('1')
|
const payType = ref('1')
|
||||||
const iosPaylist = ref([
|
const iosPaylist = ref([
|
||||||
{
|
{
|
||||||
@@ -111,9 +107,6 @@
|
|||||||
|
|
||||||
const remark = ref({})
|
const remark = ref({})
|
||||||
const isConnected = ref(false)
|
const isConnected = ref(false)
|
||||||
const purchaseToken = ref()
|
|
||||||
// 订单编号
|
|
||||||
const orderSn = ref('')
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,34 +125,9 @@
|
|||||||
getData()
|
getData()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取订单编号
|
|
||||||
*/
|
|
||||||
const getPlaceOrderObj = async () => {
|
|
||||||
const {priceTypeId, realMoney, money} = toRefs(aloneItem.value)
|
|
||||||
const data = {
|
|
||||||
userId: userStore.userInfo.id, // 用户di
|
|
||||||
paymentMethod: '5', //支付方式4point 5google
|
|
||||||
orderMoney: money.value, //订单金额
|
|
||||||
realMoney: realMoney.value, //实际金额
|
|
||||||
come: '10', //订单来源 2医学吴门医述 10海外读书
|
|
||||||
orderType: 'point', //订单类型, point充值、order课程、书、vip 课vip、abroadVip 书vip、relearn 复读、trainingClass 培训班
|
|
||||||
productId: priceTypeId.value // 商品id
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const res = await getPlaceOrder(data)
|
|
||||||
orderSn.value = res.orderSn
|
|
||||||
console.log(orderSn.value, '获取订单号');
|
|
||||||
getGooglePay()
|
|
||||||
} catch (error) {
|
|
||||||
console.error('获取订单号失败', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 点击金额
|
// 点击金额
|
||||||
const chosPric = (item : any) => {
|
const chosPric = (item : any) => {
|
||||||
console.log(item, '金额每项');
|
console.log(item,'金额每项');
|
||||||
aloneItem.value = item;
|
aloneItem.value = item;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -168,6 +136,7 @@
|
|||||||
*/
|
*/
|
||||||
const radioCheck = () => {
|
const radioCheck = () => {
|
||||||
state.value = !state.value
|
state.value = !state.value
|
||||||
|
console.log('点击了', state.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -185,7 +154,6 @@
|
|||||||
console.log(rechargeList.value.bookBuyConfigList, '充值列表');
|
console.log(rechargeList.value.bookBuyConfigList, '充值列表');
|
||||||
// 默认选择第一个金额
|
// 默认选择第一个金额
|
||||||
aloneItem.value = rechargeList.value.bookBuyConfigList[0]
|
aloneItem.value = rechargeList.value.bookBuyConfigList[0]
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取订单列表失败:', error)
|
console.error('获取订单列表失败:', error)
|
||||||
}
|
}
|
||||||
@@ -227,17 +195,17 @@
|
|||||||
// payType.value = val;
|
// payType.value = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleRecharge = async () => {
|
const handleRecharge = () => {
|
||||||
getPlaceOrderObj()
|
if(!state.value){
|
||||||
if (!state.value) {
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: t('order.readAgreeServices'),
|
title: t('order.readAgreeServices'),
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uni.showLoading({ title: '生成订单中...' })
|
uni.showLoading({ title: '加载中...' })
|
||||||
|
console.log('立即充值');
|
||||||
|
getGooglePay()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -245,11 +213,12 @@
|
|||||||
*/
|
*/
|
||||||
const getGooglePay = () => {
|
const getGooglePay = () => {
|
||||||
googlePay.init({
|
googlePay.init({
|
||||||
}, (e : any) => {
|
}, (e:any) => {
|
||||||
console.log('init', e);
|
console.log('init', e);
|
||||||
if (e.code == 0) {
|
if (e.code == 0) {
|
||||||
isConnected.value = true;
|
isConnected.value = true;
|
||||||
getQuerySku()
|
getQuerySku()
|
||||||
|
// 初始化成功
|
||||||
} else {
|
} else {
|
||||||
// 初始化失败
|
// 初始化失败
|
||||||
isConnected.value = false;
|
isConnected.value = false;
|
||||||
@@ -260,87 +229,43 @@
|
|||||||
/**
|
/**
|
||||||
* 查询sku
|
* 查询sku
|
||||||
*/
|
*/
|
||||||
const getQuerySku = () => {
|
const getQuerySku = () =>{
|
||||||
const id = aloneItem.value.priceTypeId
|
const id = aloneItem.value.priceTypeId
|
||||||
console.log(id, '获取每项');
|
console.log(id, '获取每项');
|
||||||
googlePay.querySku(
|
googlePay.querySku(
|
||||||
{
|
{
|
||||||
inapp: [id], // 与subs二选一, 参数为商品ID(字符串)数组
|
inapp: [id], // 与subs二选一, 参数为商品ID(字符串)数组
|
||||||
},
|
},
|
||||||
(e : any) => {
|
(e:any) => {
|
||||||
if (e.code == 0) {
|
if (e.code == 0) {
|
||||||
// 查询成功.
|
// 查询成功.
|
||||||
console.log('querySku查询成功', e);
|
console.log('查询成功',e);
|
||||||
uni.hideLoading()
|
// e.list; // 查询结果, array
|
||||||
getPayAll()
|
|
||||||
} else {
|
} else {
|
||||||
console.log('查询失败', e);
|
console.log('查询失败');
|
||||||
// 查询失败
|
// 查询失败
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
const getPayAll = () =>{
|
||||||
* 发起支付
|
|
||||||
*/
|
|
||||||
const getPayAll = () => {
|
|
||||||
console.log(aloneItem.value.priceTypeId, orderSn.value, '发起支付传入产品id,订单id');
|
|
||||||
googlePay.payAll(
|
googlePay.payAll(
|
||||||
{
|
{
|
||||||
productId: aloneItem.value.priceTypeId, // 产品id
|
productId: "", // 产品id
|
||||||
accountId: orderSn.value // 订单编号
|
|
||||||
},
|
},
|
||||||
(e : any) => {
|
(e) => {
|
||||||
if (e.code == 0) {
|
if (e.code == 0) {
|
||||||
purchaseToken.value = e.data[0].original.purchaseToken
|
|
||||||
// 支付成功
|
// 支付成功
|
||||||
console.log(e, 'payAll方法成功返参');
|
e.data; //支付结果, array [ {original:{ }, signature: ''} ]
|
||||||
getConsume()
|
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({ title: '支付失败', icon: 'success' })
|
|
||||||
console.log(e, 'e');
|
|
||||||
// 支付失败
|
// 支付失败
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 消耗品 确认交易
|
|
||||||
*/
|
|
||||||
const getConsume = () => {
|
|
||||||
googlePay.consume(
|
|
||||||
{
|
|
||||||
purchaseToken: purchaseToken.value, // 来自支付结果的original.purchaseToken (或 original.token)
|
|
||||||
},
|
|
||||||
(e : any) => {
|
|
||||||
if (e.code == 0) {
|
|
||||||
console.log(e, '确认交易成功');
|
|
||||||
// 确认成功
|
|
||||||
googleVerify()
|
|
||||||
} else {
|
|
||||||
console.log(e, '确认交易失败');
|
|
||||||
// 确认失败
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验订单
|
|
||||||
*/
|
|
||||||
const googleVerify = async () => {
|
|
||||||
try {
|
|
||||||
const obj = await verifyGooglePay(aloneItem.value.priceTypeId, purchaseToken.value, orderSn.value)
|
|
||||||
uni.switchTab({
|
|
||||||
url: '/pages/user/index'
|
|
||||||
})
|
|
||||||
console.log(obj, '校验订单');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('校验订单失败:', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getDevName();
|
getDevName();
|
||||||
@@ -462,7 +387,7 @@
|
|||||||
border-bottom: 1px solid #ededed;
|
border-bottom: 1px solid #ededed;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items:center;
|
||||||
|
|
||||||
image {
|
image {
|
||||||
width: 40rpx;
|
width: 40rpx;
|
||||||
|
|||||||
Reference in New Issue
Block a user