zhaojs
2023-05-16 9707c4410a67d6a6d63b634f53565711d2d337da
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<template>
    <view class="wxlogin-wrapper wrapperLayer">
        <titleBar titleText='' :pageForm='"login"' @backIndex="backHome"></titleBar>
        <view class="pageContent borderBox colCen">
            <image class="applogo" :src="appInfo.logo" mode="aspectFill"></image>
 
            <view class="wxlogoBtn rowCenCen" @tap="wxlogin()" v-if="haswxlogin">
                <image class="logoIcon" src="../../static/images/mine/wxwhite.png" mode=""></image>
                <view>微信一键登录</view>
            </view>
            <view class="goaccount rowCenCen" @tap="goaccount()">
                <view>手机号登录/注册</view>
            </view>
        </view>
 
        <view class="bottom-fixed colCen">
            <view class="explain-text rowCen">
                <switch type="checkbox" @change="changeread" :checked='isread' style="transform:scale(0.6)" />
                登陆代表已详细阅读并同意<text @click="goPage('agreement')">《用户协议》</text>和<text
                    @click="goPage('policy')">《隐私政策》</text>
            </view>
        </view>
    </view>
</template>
 
<script>
    import {
        mapMutations
    } from 'vuex';
    import titleBar from '../../components/backTitlebar.vue'
    export default {
        components: {
            titleBar
        },
        data() {
            return {
                appInfo: '',
                ifPasslogin: false,
                isread: false,
                haswxlogin: false
            }
        },
        onLoad() {
            this.appInfo = uni.getStorageSync('appInfo')
            console.log(this.appInfo.iosExamine)
            console.log(getApp().globalData.ifwt)
            //this.haswxlogin = this.appInfo.iosExamine ? false : (getApp().globalData.ifwt == 1 ? true : false)
            this.haswxlogin = getApp().globalData.ifwt == 1 ? true :false;
        },
        methods: {
            ...mapMutations(['login']),
            backHome() {
                var pages = getCurrentPages();
                console.log(pages.length);
                if (pages.length == 1) {
                    uni.switchTab({
                        url: '../index/index'
                    })
                } else {
                    uni.navigateBack({
                        delta: 1
                    })
                }
            },
            wxlogin() {
                var that = this;
                if (this.isread) {
                    uni.getProvider({
                        service: 'oauth',
                        success: othres => {
                            console.log(othres.provider)
                            if (~othres.provider.indexOf('weixin')) {
                                uni.login({
                                    provider: 'weixin',
                                    success: (loginRes) => {
                                        that.$u.api.wxapplogin({
                                            openid: loginRes.authResult.openid,
                                            access_token: loginRes.authResult.access_token
                                        }).then(e => {
                                            if (e.code != 0) return that.$alert(e.msg)
                                            var res = e.data;
                                            if(res.type == 'goUser'){
                                                that.login(e.data.userinfo);
                                                that.$alert('登录成功')
                                                setTimeout(function() {
                                                    if (res.userinfo.isPwd ==
                                                        'N') {
                                                        uni.redirectTo({
                                                            url: './setPass'
                                                        })
                                                    } else {
                                                        uni.switchTab({
                                                            url: '../index/index'
                                                        })
                                                    }
                                                }, 1000)
                                            }else if(res.type == 'bindMobile'){
                                                uni.navigateTo({
                                                    url: "./bindingPhone?wx="+encodeURIComponent(JSON.stringify(res.info))
                                                })
                                            }
                                            
                                            
                                        }).catch(function(err) {
                                            console.log(err)
                                        })
                                    },
                                    fail: err => {
                                        console.log('111');
                                        console.log(err);
                                        uni.showToast({
                                            title: '微信授权登录失败!',
                                            icon: 'none'
                                        })
                                    }
                                })
                            }
                        }
                    })
                } else {
                    uni.showToast({
                        title: '请先阅读并同意《用户协议》和《隐私协议》',
                        icon: "none",
                    })
                }
            },
 
            changeread(e) {
                console.log(e);
                this.isread = e.target.value
            },
 
            goPage(type) {
                uni.navigateTo({
                    url: './policyAgreement?type=' + type
                })
            },
 
            goaccount() {
                uni.navigateTo({
                    url: './login'
                })
            }
        }
    }
</script>
 
<style lang="scss">
    .wxlogin-wrapper {
        width: 100%;
        min-height: 100vh;
        background-color: #FFFFFF;
 
        .pageContent {
            width: 100%;
            padding: 0 32rpx;
 
            .applogo {
                width: 168rpx;
                height: 168rpx;
                margin-top: 80rpx;
            }
 
            .wxlogoBtn {
                width: 100%;
                height: 100rpx;
                background: #32BD00;
                border-radius: 50rpx;
                font-size: 30rpx;
                font-weight: 500;
                color: #FFFFFF;
                margin-top: 140rpx;
 
                .logoIcon {
                    width: 47rpx;
                    height: 39rpx;
                    margin-right: 20rpx;
                }
            }
 
            .goaccount {
                width: 100%;
                height: 100rpx;
                background: #FFFFFF;
                border: 1rpx solid #999999;
                border-radius: 50rpx;
                font-size: 30rpx;
                font-weight: 500;
                color: #333333;
                margin-top: 30rpx;
            }
        }
 
        .bottom-fixed {
            width: 100%;
            position: fixed;
            bottom: 100rpx;
            bottom: calc(100rpx + constant(safe-area-inset-bottom));
            bottom: env(100rpx + constant(safe-area-inset-bottom));
            left: 0;
            z-index: 1;
 
            .verification-Code {
                white-space: nowrap;
                font-size: 28rpx;
                font-weight: 500;
                color: #333333;
            }
 
            .explain-text {
                font-size: 22rpx;
                font-weight: 500;
                color: #999999;
                margin-top: 30rpx;
                white-space: nowrap;
            }
        }
    }
</style>