|
|
@@ -5,6 +5,20 @@ Vue.prototype.$store = store
|
|
|
|
|
|
import common from 'static/js/common.js';
|
|
|
Vue.prototype.$dialog = common;
|
|
|
+
|
|
|
+// 全局挂载getPhoneNumber方法,供生服插件调用
|
|
|
+Vue.prototype.getPhoneNumber = function({ params, success, fail }) {
|
|
|
+ console.log("获取手机号码",params,success,fail)
|
|
|
+ // 获取生服插件传递的加密参数
|
|
|
+ const { iv, encryptedData } = params
|
|
|
+ // 调用您的服务端接口,按照抖音官方解密规则解密encryptedData得到用户手机号
|
|
|
+ // 解密规则参考:https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/guide/open-capabilities/acquire-phone-number-acquire/
|
|
|
+ const result = {
|
|
|
+ phoneNumber: '13xxxxxxxxx'
|
|
|
+ }
|
|
|
+ // 回调通知生服插件获取手机号成功
|
|
|
+ success(result)
|
|
|
+}
|
|
|
|
|
|
// #ifndef VUE3
|
|
|
import Vue from 'vue'
|
|
|
@@ -21,7 +35,14 @@ app.$mount()
|
|
|
// #ifdef VUE3
|
|
|
import { createSSRApp } from 'vue'
|
|
|
export function createApp() {
|
|
|
- const app = createSSRApp(App)
|
|
|
+ const app = createSSRApp(App)
|
|
|
+ app.config.globalProperties.getPhoneNumber = ({ params, success, fail }) => {
|
|
|
+ console.log("获取手机号码",params,success,fail)
|
|
|
+ const { iv, encryptedData } = params
|
|
|
+ // 调用您的服务端接口解密encryptedData获取手机号
|
|
|
+ // 参考官方解密规则完成处理
|
|
|
+ success({ phoneNumber: '13xxxxxxxxx' })
|
|
|
+ }
|
|
|
return {
|
|
|
app
|
|
|
}
|