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
| <template>
| <view class="main">
| <view class="list">
| <view class="list-call">
| <u--input v-model="username"
| clearable
| maxlength="32"
| type="text"
| placeholder="请输入手机号"
| prefixIcon="account"
| prefixIconStyle="font-size: 22px;color: #909399"></u--input>
| </view>
| <view class="list-call">
| <u--input v-model="password"
| clearable
| maxlength="32"
| type="password"
| placeholder="请输入密码"
| prefixIcon="lock"
| prefixIconStyle="font-size: 22px;color: #909399"></u--input>
| </view>
| </view>
| <view class="loginBtn"><u-button type="primary"
| text="确认"
| @click="submit()"></u-button></view>
| </view>
| </template>
|
| <script>
| import { BaseUrl } from '@/api/publicInterface.js'
| export default {
| data() {
| return {
| username: '',
| password: '',
| code: ''
| };
| },
| methods: {
| submit() {
| if (this.username.length === 0) {
| return this.$u.toast('请输入手机号')
| }
| if (this.password.length === 0) {
| return this.$u.toast('请输入密码')
| }
| this.setUpWxOpenid(this.username, this.password, uni.getStorageSync('bindCode'))
| },
| setUpWxOpenid(userName, passWord, code) {
| uni.request({
| url: `${BaseUrl}/admin/user/setUpWxOpenid`,
| data: {
| userName,
| passWord,
| code
| },
| method: 'POST',
| header: {
| 'content-type': 'application/x-www-form-urlencoded'
| },
| success: (res) => {
| console.log(res, '绑定结果');
| if (res.data.code === 1) {
| this.$u.toast(res.data.msg ? res.data.msg : '绑定失败')
| }
| }
| })
| },
| onShow() {
| uni.login({
| success(res) {
| if (res.code) {
| console.log(res.code, '获取code');
| this.code = res.code
| uni.setStorageSync('bindCode', this.code)
| } else {
| uni.showToast({
| title: '出现错误',
| duration: 2000
| });
| }
| }
| })
| },
| }
| }
| </script>
|
| <style lang="scss"
| scoped>
| @import 'index.scss';
|
| .main {
| width: 100%;
| height: 100%;
| margin: 0 auto;
| }
|
| .loginBtn {
| width: 80%;
| margin: 0 auto;
| }
| </style>
|
|