zhaojs
2023-06-04 1d7b09da53a6ec55b108d0bb23b3af1ec85897a3
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
<template>
    <view class="empower-container colCen">
        <view class="applogo-title rowCenCen">
            <image class="applogo" :src="applogo" mode="aspectFill"></image>
            <image class="jiantou" src="../static/images/app/jiantou.png" mode="aspectFill"></image>
            <image class="applogo" src="../static/images/app/tb.png" mode="aspectFill"></image>
        </view>
        <view class="txt-tit">
            申请淘宝授权
        </view>
        <view class="txt-desc">
            应淘宝要求,获得返现前请先进行官方授权备案(淘宝账号一经绑定无法修改,请谨慎操作!如需更改,请联系客服!)
        </view>
 
        <view class="btn-container rowCenBet">
            <view class="close-btn rowCenCen" @click="close()">
                <view>关闭</view>
            </view>
            <view class="confirm-btn rowCenCen" @tap="confirm()">
                <view>前往淘宝授权</view>
            </view>
        </view>
    </view>
</template>
 
<script>
    import util from '../utils/utils.js'
    const plug = uni.requireNativePlugin('xiguazhu-baichuan')
    export default {
        data() {
            return {
                applogo: ''
            }
        },
        created() {
            this.applogo = getApp().globalData.appinfo.logo
            /* console.log(uni.getSystemInfoSync().platform);
            if (uni.getSystemInfoSync().platform == 'ios') {
                                    plug.init({}, result => {
                                        console.log(result)
                                    });
                            } */
        },
        methods: {
            confirm() {
                
                console.log(getApp().globalData.appinfo);
                console.log(plug);
                plug.login({}, result => {
                    console.log(result);
                    var nick = result.userinfo.nick
                    if (result.code == 0) {
                        plug.taobaoOauth({
                            "url": getApp().globalData.appinfo.tbEmpower
                        }, ret => {
                            console.log(ret);
                            if(ret.code==1){
                                plug.logout({}, result => {
                                    console.log(result);
                                    this.$emit('closemodel')
                                });
                            }else{
                                var that = this;
                                this.$u.api.getPublisher({
                                    tb_account:nick,
                                    access_token:ret.info.access_token
                                }).then(e => {
                                    console.log(e)
                                    if(e.code != 0) return that.$alert(e.msg)
                                    that.$emit('@updataInfo')
                                    that.$emit('closemodel')
                                    uni.navigateTo({
                                        url:'/pages/mine/setting/accountAuthorization?status=1'
                                    })
                                }).catch(function (err) {
                                    console.log(err)
                                        plug.logout({}, result => {
                                        });
                                        this.$emit('closemodel')
                                        uni.navigateTo({
                                            url:'/pages/mine/setting/accountAuthorization?status=0&res='+err
                                        })
                                })
                            }
                        });
                    }else{
                        plug.logout({}, result => {
                            console.log(result);
                        });
                    }
                });
            },
            close() {
                this.$emit('closemodel')
                plug.logout({}, result => {
                    console.log(result);
                });
            }
        }
    }
</script>
 
<style lang="scss">
    .empower-container {
        width: 564rpx;
        height: 540rpx;
        background: #FFFFFF;
        border-radius: 24rpx;
        padding: 0 20rpx;
 
        .applogo-title {
            margin-top: 60rpx;
 
            .applogo {
                width: 92rpx;
                height: 92rpx;
                border-radius: 50%;
            }
            .jiantou{
                width: 56rpx;
                height: 30rpx;
                margin: 0 30rpx;
            }
        }
 
        .txt-tit {
            margin-top: 30rpx;
            font-size: 34rpx;
            font-weight: bold;
            color: #333333;
        }
 
        .txt-desc {
            margin-top: 30rpx;
            width: 100%;
            padding: 0 45rpx;
            font-size: 24rpx;
            font-weight: 500;
            line-height: 46rpx;
            color: #666666;
        }
 
        .btn-container {
            width: 100%;
            margin-top: 30rpx;
            font-size: 30rpx;
            font-weight: 500;
            color: #FFFFFF;
 
            .close-btn {
                width: 158rpx;
                height: 76rpx;
                background: #E5E5E5;
                box-shadow: 0px 5rpx 9rpx 0px rgba(229, 229, 229, 0.33);
                opacity: 0.97;
                border-radius: 38rpx;
            }
 
            .confirm-btn {
                width: 240rpx;
                height: 76rpx;
                background: #FD002F;
                box-shadow: 0px 5rpx 9rpx 0px rgba(253, 0, 47, 0.33);
                opacity: 0.97;
                border-radius: 38rpx;
            }
        }
    }
</style>