@uxda/appkit 4.2.46 → 4.2.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  import { PaymentParams } from '../types'
2
2
  import { DollarApp } from '../../Appkit'
3
3
  import { useHttp, endpoints } from '../../payment/api'
4
- import { requestPayment as weappRequestPayment } from '../../shared'
5
- import Taro from '@tarojs/taro'
4
+ import { requestWxH5Pay, requestPayment as weappRequestPayment } from '../../shared'
5
+ import Taro, { showToast } from '@tarojs/taro'
6
6
 
7
7
  const requestPayment = (params: PaymentParams) => {
8
8
  return new Promise<boolean>((resolve, reject) => {
@@ -39,7 +39,7 @@ const requestPaymentByBean = (params: PaymentParams, Appcode = '') => {
39
39
  })
40
40
  .then((response: any) => {
41
41
  if (!response.json) {
42
- Taro.showToast({
42
+ showToast({
43
43
  title: response.message,
44
44
  icon: 'none',
45
45
  })
@@ -57,10 +57,40 @@ const requestPaymentByBean = (params: PaymentParams, Appcode = '') => {
57
57
  })
58
58
  }
59
59
 
60
+ const requestBrandWCPay = (params: PaymentParams, Appcode = '') => {
61
+ return new Promise<boolean>((resolve, reject) => {
62
+ const $http = useHttp({
63
+ Appcode: Appcode,
64
+ Tenant: params.tenant,
65
+ })
66
+ $http
67
+ .post(endpoints.获取微信支付参数包, {
68
+ ...params,
69
+ })
70
+ .then((response: any) => {
71
+ if (!response.json) {
72
+ showToast({
73
+ title: response.message,
74
+ icon: 'none',
75
+ })
76
+ resolve(false)
77
+ } else {
78
+ requestWxH5Pay(response.json).then((result) => {
79
+ if (result) {
80
+ resolve(true)
81
+ } else {
82
+ resolve(false)
83
+ }
84
+ })
85
+ }
86
+ })
87
+ })
88
+ }
89
+
60
90
  export default {
61
91
  install($app: DollarApp) {
62
92
  $app.requestPayment = requestPayment
63
93
  },
64
94
  }
65
95
 
66
- export { requestPayment, requestPaymentByBean }
96
+ export { requestPayment, requestPaymentByBean, requestBrandWCPay }
@@ -2,11 +2,11 @@ export type PaymentParams = {
2
2
  /**
3
3
  * 支付金额
4
4
  */
5
- amount?: number,
5
+ amount?: number
6
6
  /**
7
7
  * 应用
8
8
  */
9
- app: string,
9
+ app: string
10
10
  /**
11
11
  * 支付场景
12
12
  */
@@ -14,16 +14,17 @@ export type PaymentParams = {
14
14
  /**
15
15
  * 租户
16
16
  */
17
- tenant: string,
17
+ tenant: string
18
18
  /**
19
19
  * 支付用户(微信登录的凭证 code)
20
20
  */
21
- user: string,
22
- caseConfigId?: string,
21
+ user?: string
23
22
  /**
24
23
  * 权益ID
25
24
  */
26
-
25
+ caseConfigId?: string
26
+ accountAuthFlag?: boolean
27
+ channelCode?: string
27
28
  }
28
29
 
29
- export type RechargeParams = Pick<PaymentParams, 'app' | 'tenant'>
30
+ export type RechargeParams = Pick<PaymentParams, 'app' | 'tenant'>
@@ -3,7 +3,7 @@ import { reactive } from 'vue'
3
3
  import OcrIcon from '../../shared/components/OcrIcon.vue'
4
4
  import DdArea from './../../components/dd-area/index.vue'
5
5
  import DdSelector from './../../components/dd-selector/index.vue'
6
- import Taro from '@tarojs/taro'
6
+ import Taro, { showToast } from '@tarojs/taro'
7
7
 
8
8
  const props = withDefaults(
9
9
  defineProps<{
@@ -53,7 +53,7 @@ function onOCRInfo(payload: any) {
53
53
 
54
54
  function showVerifyToast(tip: string, duration = 1500) {
55
55
  if (!tip) return
56
- Taro.showToast({
56
+ showToast({
57
57
  title: tip,
58
58
  icon: 'none',
59
59
  duration,
@@ -1,19 +1,16 @@
1
1
  <template>
2
- <nut-popup
3
- :pop-class="`app-drawer ${modelValue ? 'open' : ''}`"
4
- position="right"
5
- :visible="modelValue"
2
+ <nut-popup :pop-class="`app-drawer ${modelValue ? 'open' : ''}`" position="right" :visible="modelValue"
6
3
  @update:visible="onVisibleChange">
7
- <page-header
8
- :title="title"
9
- @close="onPageHeaderClose" />
10
- <div class="drawer-body">
11
- <slot></slot>
12
- </div>
4
+ <page-header :title="title" :style="Taro.getEnv() !== 'WEB' ? '' : '--height: 40px'" @close="onPageHeaderClose" />
5
+ <div class="drawer-body">
6
+ <slot></slot>
7
+ </div>
13
8
  </nut-popup>
14
9
  </template>
15
10
 
16
11
  <script lang="ts" setup>
12
+ import Taro from '@tarojs/taro'
13
+
17
14
  // 右侧页面
18
15
  // 模仿页面打开
19
16
  // 假的标题栏和返回按钮
@@ -44,9 +41,11 @@ const onPageHeaderClose = () => {
44
41
  position: absolute;
45
42
  display: flex;
46
43
  flex-direction: column;
44
+
47
45
  &.open {
48
46
  height: 100vh;
49
47
  }
48
+
50
49
  .drawer-body {
51
50
  flex-grow: 1;
52
51
  overflow: scroll;
@@ -5,7 +5,7 @@
5
5
  </template>
6
6
 
7
7
  <script lang="ts" setup>
8
- import Taro from '@tarojs/taro';
8
+ import Taro, { showToast, showLoading, hideLoading } from '@tarojs/taro';
9
9
  import { NsIcon } from '@uxda/nutshell/taro';
10
10
  import { useAppKitOptions } from '../../Appkit';
11
11
 
@@ -67,7 +67,7 @@ async function onIconClick() {
67
67
  const compressImg: any =
68
68
  (await taroImgCompress(path, getCompressQuality(size))) || {};
69
69
  const filePath = compressImg.tempFilePath || path;
70
- Taro.showLoading({ title: '营业执照识别中..' });
70
+ showLoading({ title: '营业执照识别中..' });
71
71
  const session = appKitOptions.token();
72
72
  const baseUrl = appKitOptions.baseUrl();
73
73
  const upRes: any = await Taro.uploadFile({
@@ -81,7 +81,7 @@ async function onIconClick() {
81
81
  token: session || '',
82
82
  },
83
83
  });
84
- Taro.hideLoading();
84
+ hideLoading();
85
85
  const res = JSON.parse(upRes.data);
86
86
  if (res.code === '200') {
87
87
  const faceInfo = res.result || {};
@@ -95,16 +95,16 @@ async function onIconClick() {
95
95
  };
96
96
  console.log('===识别', result);
97
97
  if (!result.companyName && !result.idCardNo) {
98
- Taro.showToast({ title: '识别失败,请重试', icon: 'none' });
98
+ showToast({ title: '识别失败,请重试', icon: 'none' });
99
99
  }
100
100
  } else {
101
- Taro.showToast({
101
+ showToast({
102
102
  title: res.msg,
103
103
  icon: 'error',
104
104
  });
105
105
  }
106
106
  } catch (err) {
107
- Taro.hideLoading();
107
+ hideLoading();
108
108
  console.log(err);
109
109
  }
110
110
  emits('complete', result);
@@ -10,7 +10,7 @@
10
10
  </template>
11
11
 
12
12
  <script lang="ts" setup>
13
- import Taro from '@tarojs/taro'
13
+ import Taro, { showToast, showLoading, hideLoading } from '@tarojs/taro'
14
14
  import { NsIcon } from '@uxda/nutshell/taro'
15
15
  import { useAppKitOptions } from '../../Appkit'
16
16
  import { ref } from 'vue';
@@ -83,7 +83,7 @@ async function onUploadFile(csRes: any) {
83
83
  let { path, size, tempFilePath } = csRes.tempFiles[0]
84
84
  const compressImg: any = (await taroImgCompress(path || tempFilePath, getCompressQuality(size))) || {}
85
85
  const filePath = compressImg.tempFilePath || path
86
- Taro.showLoading({ title: '身份证识别中..' })
86
+ showLoading({ title: '身份证识别中..' })
87
87
 
88
88
  const session = appKitOptions.token()
89
89
  const baseUrl = appKitOptions.baseUrl()
@@ -99,7 +99,7 @@ async function onUploadFile(csRes: any) {
99
99
  token: session || '',
100
100
  },
101
101
  })
102
- Taro.hideLoading()
102
+ hideLoading()
103
103
 
104
104
  const res = JSON.parse(upRes.data)
105
105
  if (res.code === '200') {
@@ -119,19 +119,19 @@ async function onUploadFile(csRes: any) {
119
119
  }
120
120
  console.log('===识别', result)
121
121
  if (props.side === 'face' && !result.faceInfo.name && !result.faceInfo.certNo) {
122
- Taro.showToast({ title: '识别失败,请重试', icon: 'none' })
122
+ showToast({ title: '识别失败,请重试', icon: 'none' })
123
123
  }
124
124
  if (props.side === 'back' && !result.backInfo?.startDate && !result.backInfo?.endDate) {
125
- Taro.showToast({ title: '识别失败,请重试', icon: 'none' })
125
+ showToast({ title: '识别失败,请重试', icon: 'none' })
126
126
  }
127
127
  } else {
128
- Taro.showToast({
128
+ showToast({
129
129
  title: res.msg,
130
130
  icon: 'error',
131
131
  })
132
132
  }
133
133
  } catch (err) {
134
- Taro.hideLoading()
134
+ hideLoading()
135
135
  console.log(err)
136
136
  }
137
137
  emits('complete', result)
@@ -1,4 +1,8 @@
1
1
  export * from './weixin'
2
2
  export * from './components'
3
3
  export * from './composables'
4
- export * from './http'
4
+ export * from './http'
5
+
6
+ import services from './weixin'
7
+
8
+ export { services }
@@ -1 +1,9 @@
1
- export * from './payment'
1
+ import { Service } from '../../payment/services'
2
+ import getSdkConfig from './jssdk'
3
+
4
+ const services: Service[] = [getSdkConfig]
5
+
6
+ export default services
7
+
8
+ export * from './payment'
9
+ export * from './jssdk'
@@ -0,0 +1,91 @@
1
+ import { DollarApp } from '../../Appkit'
2
+ import { useHttp } from '../../payment/api'
3
+
4
+ interface JssdkConfig {
5
+ appId: string
6
+ nonceStr: string
7
+ signature: string
8
+ timeTicket: string
9
+ timestamp: string
10
+ }
11
+
12
+ interface PrePayOptions {
13
+ appId: string
14
+ nonceStr: string
15
+ package: string
16
+ paySign: string
17
+ signType: string
18
+ timeStamp: string
19
+ }
20
+
21
+ /**
22
+ * jssdk 初始化配置
23
+ * @param appCode
24
+ */
25
+ const getSdkConfig = (appCode?: string): Promise<JssdkConfig> => {
26
+ return new Promise<JssdkConfig>((resolve, reject) => {
27
+ const $http = useHttp()
28
+
29
+ $http
30
+ .get('/wecom/config/getConfig', {
31
+ appCode: appCode || 'loankitMp',
32
+ callbackUrl: location.href,
33
+ })
34
+ .then((response: JssdkConfig) => {
35
+ resolve(response)
36
+ })
37
+ })
38
+ }
39
+
40
+ /**
41
+ * 唤起微信支付
42
+ * @param options
43
+ */
44
+ function requestWxH5Pay(options: PrePayOptions) {
45
+ return new Promise<boolean>((resolve, reject) => {
46
+ function onBridgeReady() {
47
+ // @ts-ignore
48
+ WeixinJSBridge.invoke(
49
+ 'getBrandWCPayRequest',
50
+ {
51
+ appId: options.appId,
52
+ nonceStr: options.nonceStr,
53
+ package: options.package,
54
+ paySign: options.paySign,
55
+ signType: options.signType,
56
+ timeStamp: options.timeStamp,
57
+ },
58
+ function (res) {
59
+ console.log(res, 'res')
60
+ if (res.err_msg == 'get_brand_wcpay_request:ok') {
61
+ resolve(res)
62
+ //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠,商户需进一步调用后端查单确认支付结果。
63
+ }
64
+ }
65
+ )
66
+ }
67
+ // @ts-ignore
68
+ if (typeof WeixinJSBridge == 'undefined') {
69
+ if (document.addEventListener) {
70
+ // @ts-ignore
71
+ document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
72
+ // @ts-ignore
73
+ } else if (document.attachEvent) {
74
+ // @ts-ignore
75
+ document.attachEvent('WeixinJSBridgeReady', onBridgeReady)
76
+ // @ts-ignore
77
+ document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
78
+ }
79
+ } else {
80
+ onBridgeReady()
81
+ }
82
+ })
83
+ }
84
+
85
+ export default {
86
+ install($app: DollarApp) {
87
+ $app.getSdkConfig = getSdkConfig
88
+ },
89
+ }
90
+
91
+ export { getSdkConfig, requestWxH5Pay }
@@ -1,4 +1,4 @@
1
- import Taro, { request as TaroRequest } from '@tarojs/taro'
1
+ import Taro, { request as TaroRequest, showToast } from '@tarojs/taro'
2
2
  import { HttpRequestConfig, PagingData, PagingParams, ResponseRaw, createHttp } from '../../shared'
3
3
  import { translates, transforms } from './endpoints'
4
4
  import { useAppKitOptions } from '../../Appkit'
@@ -32,7 +32,7 @@ const vendor = {
32
32
  data: data.result as T,
33
33
  })
34
34
  } else if (data.code !== '401') {
35
- Taro.showToast({
35
+ showToast({
36
36
  title: data.msg,
37
37
  icon: 'none',
38
38
  })
@@ -80,7 +80,7 @@ function useHttp() {
80
80
  },
81
81
  (raw) => {
82
82
  if (raw.status > 500 && raw.status != 51015 && raw.status != 51014) {
83
- Taro.showToast({
83
+ showToast({
84
84
  title: raw.message,
85
85
  icon: 'none',
86
86
  })
@@ -3,76 +3,39 @@
3
3
  <ns-page-content>
4
4
  <ns-card fill="#fff">
5
5
  <ns-form ref="formRef" v-model="formData">
6
- <ns-input
7
- label="你的姓名"
8
- name="姓名"
9
- v-model="formData.姓名"
10
- placeholder="请输入或拍照识别"
11
- :maxlength="30"
12
- :disabled="已认证"
13
- :rules="['required']"
14
- >
6
+ <ns-input label="你的姓名" name="姓名" v-model="formData.姓名" placeholder="请输入或拍照识别" :maxlength="30" :disabled="已认证"
7
+ :rules="['required']">
15
8
  <template #append>
16
9
  <ocr-icon v-if="!已认证" @complete="onOcrComplete" />
17
10
  </template>
18
11
  </ns-input>
19
- <ns-input
20
- label="身份证号码"
21
- name="身份证号码"
22
- placeholder="请输入身份证号码"
23
- :maxlength="30"
24
- v-model="formData.身份证号码"
25
- :disabled="已认证"
26
- :rules="[
27
- 'required',
28
- {
29
- name: 'function',
30
- message: '请输入正确格式的证件号码',
31
- method: (value: string) => isIdentityCard(value, 'zh-CN')
32
- }
33
- ]"
34
- />
35
- <ns-input
36
- label="电话号码"
37
- name="电话号码"
38
- placeholder="请输入电话号码"
39
- :maxlength="11"
40
- v-model="formData.电话号码"
41
- :disabled="true"
42
- :rules="[
43
- {
44
- name: 'function',
45
- message: '请输入正确格式的电话号码',
46
- method: (value: string) => isMobilePhone(value, 'zh-CN')
47
- }
48
- ]"
49
- />
12
+ <ns-input label="身份证号码" name="身份证号码" placeholder="请输入身份证号码" :maxlength="30" v-model="formData.身份证号码"
13
+ :disabled="已认证" :rules="[
14
+ 'required',
15
+ {
16
+ name: 'function',
17
+ message: '请输入正确格式的证件号码',
18
+ method: (value: string) => isIdentityCard(value, 'zh-CN')
19
+ }
20
+ ]" />
21
+ <ns-input label="电话号码" name="电话号码" placeholder="请输入电话号码" :maxlength="11" v-model="formData.电话号码"
22
+ :disabled="true" :rules="[
23
+ {
24
+ name: 'function',
25
+ message: '请输入正确格式的电话号码',
26
+ method: (value: string) => isMobilePhone(value, 'zh-CN')
27
+ }
28
+ ]" />
50
29
  </ns-form>
51
30
  </ns-card>
52
31
 
53
32
  <div class="user-auth-footer">
54
33
  <div v-if="!已认证" class="checkbox-row">
55
- <ns-checkbox style="font-size: 11px" v-model="formData.同意"
56
- >我已阅读并同意</ns-checkbox
57
- >
34
+ <ns-checkbox style="font-size: 11px" v-model="formData.同意">我已阅读并同意</ns-checkbox>
58
35
  <span @click="showAgreement" class="book">《个人信息授权协议》</span>
59
36
  </div>
60
- <ns-button
61
- v-if="!已认证"
62
- class="btn"
63
- color="#163391"
64
- type="primary"
65
- @click="toSubmit"
66
- >立即认证</ns-button
67
- >
68
- <ns-button
69
- v-else
70
- class="btn"
71
- color="#163391"
72
- type="primary"
73
- @click="toBack"
74
- >返回</ns-button
75
- >
37
+ <ns-button v-if="!已认证" class="btn" color="#163391" type="primary" @click="toSubmit">立即认证</ns-button>
38
+ <ns-button v-else class="btn" color="#163391" type="primary" @click="toBack">返回</ns-button>
76
39
  </div>
77
40
  </ns-page-content>
78
41
  </ns-page>
@@ -90,7 +53,7 @@ import {
90
53
  NsCheckbox,
91
54
  } from "@uxda/nutshell/taro";
92
55
  import { OcrIcon } from "../../shared/components";
93
- import Taro from "@tarojs/taro";
56
+ import Taro, { showToast } from "@tarojs/taro";
94
57
  import { useNutshell } from "@uxda/nutshell/taro";
95
58
  import isMobilePhone from "validator/es/lib/isMobilePhone";
96
59
  import isIdentityCard from "validator/es/lib/isIdentityCard";
@@ -158,17 +121,17 @@ async function toSubmit() {
158
121
  })
159
122
  .then((res: any) => {
160
123
  if (res?.status) {
161
- Taro.showToast({ title: "已提交认证信息", icon: "none" });
124
+ showToast({ title: "已提交认证信息", icon: "none" });
162
125
  // 提交认证信息,成功后返回
163
126
  setTimeout(() => {
164
127
  toBack();
165
128
  }, 500);
166
129
  } else {
167
- Taro.showToast({ title: "认证失败", icon: "none" });
130
+ showToast({ title: "认证失败", icon: "none" });
168
131
  }
169
132
  })
170
133
  .catch((err) => {
171
- Taro.showToast({ title: err?.errMsg || "认证失败", icon: "none" });
134
+ showToast({ title: err?.errMsg || "认证失败", icon: "none" });
172
135
  });
173
136
  }
174
137
  watch(