index.vue
2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<template>
<view class="container">
<!-- 切换环境 -->
<view v-if="!hasInit" style="display: flex; flex-direction: row; align-items: center;justify-content: center;">
<view>{{isDebug ? '测试环境' : '正式环境'}}</view>
<switch :checked="isDebug" @change="onChangeVersion" />
</view>
<!-- 初始化 -->
<button v-if="!hasInit" type="default" style="margin-top: 40rpx; width: 500rpx;" @click="doInit">初始化</button>
<view v-else>
<input
v-if="!hasLogin"
v-model="userToken"
class="input-title f30 main-black-color"
style="width: 200upx; background-color: #00000000;"
adjust-position="false"
placeholder="请输入UserToken"
type="text"
/>
<button v-if="!hasLogin" type="default" style="margin-top: 40rpx;" @click="doLogin">登录</button>
<button v-if="hasLogin" type="default" style="margin-top: 40rpx;" @click="goHome">跳转首页</button>
<button v-if="hasLogin" type="default" style="margin-top: 40rpx;" @click="doCall">呼叫</button>
<button v-if="hasLogin" type="default" style="margin-top: 40rpx;" @click="logout">登出</button>
</view>
</view>
</template>
<script>
var plugins = require('../../common/plugins.js')
export default {
data() {
return {
hasInit:false,
hasLogin:false,
userToken:'',
isDebug:true,
}
},
methods: {
doInit(){
plugins.PluginTestFunction("doInit",this.isDebug);
this.hasInit = true
},
onChangeVersion(e) {
this.isDebug = e.target.value
},
doLogin() {
if(this.userToken.length == 0) {
uni.showToast({
title:'请输入userToken'
})
return
}
plugins.PluginTestFunction("doLogin",this.userToken);
setTimeout(()=>{
this.hasLogin = true
}, 200);
},
goHome(){
plugins.PluginTestFunction("goHome",this.userToken);
},
doCall(){
plugins.PluginTestFunction("doCall",this.userToken);
},
logout(){
plugins.PluginTestFunction("logout",this.userToken);
this.hasLogin = false
}
}
}
</script>
<style>
.container {
padding: 20px;
font-size: 14px;
line-height: 24px;
}
</style>