minix-template
Version:
minix template
197 lines (195 loc) • 4.28 kB
JavaScript
/*
* @Description:
* @Autor: tangsj
* @Date: 2022-05-12 17:26:59
* @LastEditTime: 2022-05-23 16:25:56
*/
import router from '@system.router'
import prompt from '@system.prompt'
export default {
data: {
integrageList:[
{
name:'burialPoint',
// url:'pages/base/canlUse/index',
describe:'埋点:自定义上报事件'
},
{
name:'getPayAuthorize',
// url:'pages/base/log/index',
describe:'获取支付权限(目前只支持支付宝权限获取,后续可扩展)'
},
{
name:'pay',
// url:'pages/base/canlUse/index',
describe:'支付'
},
{
name:'reportError',
// url:'pages/base/log/index',
describe:'上报bugly报告错误信息'
},
{
name:'trackEvent',
// url:'pages/base/log/index',
describe:'埋点:跟踪事件'
}
]
},
goRouter(url){
router.push({
uri: url,
})
},
/**
* @description: 埋点:自定义上报事件
* @param {*}
* @return {*}
*/
burialPoint(){
const params={
uploadType: 1,
pluginType: 2,
widget_name: 'widget_name',
widget_version: 'v6.7',
page_name: 'page1',
action_type: 'sence',
sub_action: 'click',
action_result: 'xxx',
}
this.$app.$def.bridge.burialPoint(params).then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
/**
* @description: 获取支付权限
* @param {*}
* @return {*}
*/
getPayAuthorize(){
const params = {
type: 'alipay',
data: '参考支付宝文档请求字符串',
}
this.$app.$def.bridge.getPayAuthorize(params).then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
/**
* @description: 支付
* @param {*}
* @return {*}
*/
pay(){
const params={
type: 'wxpay',
data: JSON.stringify({
timestamp: new Date().valueOf,
partnerid: 'partnerId',
prepayid: 'prepayId',
noncestr: 'nonce',
}),
}
this.$app.$def.bridge.pay(params).then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
/**
* @description: 从麦克风采集语音识别转文字
* @param {*}
* @return {*}
*/
reportError(){
const params={
errorMsg: 'app selft test error message',
errorType: 'app selft test error',
stack: ['page1 line1', 'page2 line2', 'page3 line3', 'page4 line4'],
extraInfo: {
key1: 'value1',
key2: 'value2',
channel: 'weex', //建议增加渠道 区分h5和weex
},
}
this.$app.$def.bridge.reportError(params).then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
/**
* @description: 从麦克风采集语音识别转文字
* @param {*}
* @return {*}
*/
trackEvent(){
const params={
event: 'error1',
eventParams: {
param_1: 'xxxxx',
param_2: 123456,
},
}
this.$app.$def.bridge.trackEvent(params).then((res)=>{
prompt.showToast({
message: res,
duration: 200,
})
}).catch((err)=>{
prompt.showToast({
message: '接口调用失败',
duration: 200,
})
})
},
testBridge(name){
switch(name){
case 'burialPoint':
this.burialPoint()
break;
case 'getPayAuthorize':
this.getPayAuthorize()
break;
case 'pay':
this.pay()
break;
case 'reportError':
this.reportError()
break;
case 'trackEvent':
this.trackEvent()
break;
default:
break;
}
}
}