Explorar o código

app的名称使用拼音首字母库

onecold hai 1 ano
pai
achega
aa5ffc6e5b

+ 1 - 1
entry/src/main/ets/common/constants/CommonConstants.ets

@@ -108,7 +108,7 @@ export class CommonConstants {
   static readonly WX_PAY_APPID: string = "wx263d1c80d204c3c0"
 
 
-  static readonly OUT_TRADE_NO_PRE: string = "TTJT"
+  // static readonly OUT_TRADE_NO_PRE: string = "TTJT"
 
   //微信支付的证书序列号id,在账户中心,API安全
   static readonly WX_PAY_SERIALNO: string = "60A30CD8E9591C492497DF601456767AE4E09065"

+ 1 - 1
entry/src/main/ets/pages/NewIndex.ets

@@ -706,7 +706,7 @@ struct NewIndex{
       .fontSize(16)
       .fontColor('#222')
       .width('100%')
-      .textAlign(TextAlign.Center)
+      .textAlign(TextAlign.Start)
       .padding(16)
   }
 }

+ 6 - 1
entry/src/main/ets/pages/UserCenter.ets

@@ -20,6 +20,7 @@ import { cryptoFramework } from '@kit.CryptoArchitectureKit';
 import json from '@ohos.util.json';
 import UserUtil, { VipFeature, VipPlanApi, VipPlanListApiResponse, WeChatPrepayId } from '../common/util/UserUtil';
 import { Utility } from '../common/util/Utility';
+import { pinyin4js } from '@ohos/pinyin4js';
 
 
 // 微信支付相关工具方法
@@ -144,6 +145,7 @@ export struct UserCenter {
   @StorageProp('themeColor') themeColor: string = CommonConstants.DEFAULT_THEME_COLOR;
   @State isDarkMode: boolean = false
   @State webUrl: string = CommonConstants.NEW_MEMBER_AGREEMENTS
+  @State appName:string = ''
   @StorageProp('topRectHeight') topRectHeight: number = px2vp(AppUtil.getStatusBarHeight());
   @StorageProp('currentColorMode') @Watch('onColorModeChange') currentMode: number =
     ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT;
@@ -243,6 +245,9 @@ export struct UserCenter {
       .padding(16)
   }
   aboutToAppear(): void {
+    Utility.getAppName(getContext(this)).then((appName:string)=>{
+      this.appName = appName
+    })
     this.topRectHeight = px2vp(AppUtil.getStatusBarHeight());
     let themeColor = PreferencesUtil.getStringSync('THEME_COLOR', CommonConstants.DEFAULT_THEME_COLOR);
     this.isDarkMode = this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK
@@ -1003,7 +1008,7 @@ export struct UserCenter {
     const appName = PreferencesUtil.getStringSync('appName', 'TTMusic');
     hilog.info(0x0000, 'UserCenter', `doWxPay: current this.userId is ${this.userId}`);
     const prepayId = await createWeChatOrder(CommonConstants.WX_PAY_APPID, CommonConstants.WX_PAY_MCHID,
-      appName, Number(plan.price) * 100, CommonConstants.OUT_TRADE_NO_PRE, this.userId, plan.id);
+      appName, Number(plan.price) * 100, pinyin4js.getShortPinyin(this.appName), this.userId, plan.id);
     if (prepayId) {
       await this.wechatPay(prepayId);
     } else {

+ 2 - 1
entry/src/main/ets/pages/VipPage.ets

@@ -32,6 +32,7 @@ import { cryptoFramework } from '@kit.CryptoArchitectureKit';
 import { JSON } from '@kit.ArkTS';
 import { BreakpointTypeEnum } from '../common/util/BreakpointSystem';
 import { resourceManager } from '@kit.LocalizationKit';
+import { pinyin4js } from '@ohos/pinyin4js';
 
 const context = getContext(this) as common.UIAbilityContext;
 @Preview
@@ -574,7 +575,7 @@ export  struct  VipPage{
 
       //需要德本的服务端支持,德本的接口返回prepayId
       createWeChatOrder(CommonConstants.WX_PAY_APPID, CommonConstants.WX_PAY_MCHID,
-        this.appName, this.payPrice*100,CommonConstants.OUT_TRADE_NO_PRE)
+        this.appName, this.payPrice*100,pinyin4js.getShortPinyin(this.appName))
         .then((prepayId: string) => {
           this.wechatPay(prepayId)
           // console.log('onecold Prepay ID:', prepayId);