陶杰
2024-12-04 0dabf05bfe9df453ffd394e2f280f878c848942a
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<template>
    <view class="main-container user-container">
    
        <view class="user-utils m-20">
            <view class="user-util m-t-12 flex" v-if="selftype==='customer'||!selftype"
                @click="goto('/sub_pages/customer/customer-info/customer-info',true)">
                <view class="title">个人资料</view>
                <view class="right-icon">
                    <uni-icons type="right"></uni-icons>
                </view>
            </view>
            <view class="user-util m-t-12 flex" v-if="selftype==='customer'||!selftype"
                @click="goto('/sub_pages/customer/setup/account-self',true)">
                <view class="title">账户安全</view>
                <view class="right-icon">
                    <uni-icons type="right"></uni-icons>
                </view>
            </view>
            <view class="user-util m-t-12 flex" v-if="selftype==='customer'"
                @click="goto('/pages/help/content?id=隐私政策',false)" >
                <view class="title">隐私政策</view>
                <view class="right-icon">
                    <uni-icons type="right"></uni-icons>
                </view>
            </view>
            <view class="user-util m-t-12 flex" v-if="selftype==='customer'"
                @click="goto('/pages/help/content?id=用户协议',false)" >
                <view class="title">用户协议</view>
                <view class="right-icon">
                    <uni-icons type="right"></uni-icons>
                </view>
            </view>
            <view class="user-util m-t-12 flex" v-if="selftype==='customer'"
                @click="goto('/pages/help/content?id=关于花满芫',false)" >
                <view class="title">关于花满芫</view>
                <view class="right-icon">
                    <uni-icons type="right"></uni-icons>
                </view>
            </view>
 
            <view class="user-util m-t-12 flex logout" @click="clearlogout">
                <view class="title2">退出登录</view>
                <!-- <view class="right-icon">
                    <uni-icons type="right"></uni-icons>
                </view> -->
            </view>
 
 
 
        </view>
 
    </view>
</template>
 
<script>
    export default {
        computed: {
        },
        data() {
            return {
                CustomBar: uni.getStorageSync('CustomBar'),
                StatusBar: uni.getStorageSync('StatusBar'),
                tcode: '',
                inviterName: '',
                // StatusBar:0,
                tel: '19288780072',
                tj: {},
                tj_order: {},
                cacheUserId: '',
                signToday: false
                // order_pendding_num: 0,
 
            };
        },
        // #ifndef PUB_CUSTOMER
        onShareAppMessage() {
            let that = this;
            var name = that.currentInfo.customerDTO && currentInfo.customerDTO.name || that.currentInfo.supplierDTO &&
                currentInfo.supplierDTO.name || that.currentInfo.partnerDTO && currentInfo.partnerDTO.name || ''
            var url =
                `/pages/login/supplier-login?shareId=${this.currentInfo&&this.currentInfo.id||''}&shareName=${name||''}`; //你的转发页面路径拼接参数
            return {
                title: "花满芫",
                path: url,
            }
        },
        onShareTimeline() {
            let that = this;
            var name = that.currentInfo.customerDTO && that.currentInfo.customerDTO.name || that.currentInfo.supplierDTO &&
                that.currentInfo.supplierDTO.name || that.currentInfo.partnerDTO && that.currentInfo.partnerDTO.name || ''
            var url =
                `/pages/login/supplier-login?shareId=${this.currentInfo&&this.currentInfo.id||''}&shareName=${name||''}`; //你的转发页面路径拼接参数
            return {
                title: "花满芫",
                path: url,
            }
        },
        // #endif
        // #ifdef PUB_CUSTOMER
        onShareAppMessage() {
            let that = this;
            var name = that.currentInfo.customerDTO && that.currentInfo.customerDTO.name || that.currentInfo.supplierDTO &&
                that.currentInfo.supplierDTO.name || that.currentInfo.partnerDTO && that.currentInfo.partnerDTO.name || ''
            var url =
                `/pages/home/home?shareId=${this.currentInfo&&this.currentInfo.id||''}&shareName=${name||''}`; //你的转发页面路径拼接参数
            return {
                title: "花满芫",
                path: url,
            }
        },
        onShareTimeline() {
            let that = this;
            var name = that.currentInfo.customerDTO && that.currentInfo.customerDTO.name || that.currentInfo.supplierDTO &&
                that.currentInfo.supplierDTO.name || that.currentInfo.partnerDTO && that.currentInfo.partnerDTO.name || ''
            var url =
                `/pages/home/home?shareId=${this.currentInfo&&this.currentInfo.id||''}&shareName=${name||''}`; //你的转发页面路径拼接参数
            return {
                title: "花满芫",
                path: url,
            }
        },
        // #endif
        onShow() {
            this.cacheUserId = ''
            this.getTj()
 
 
        },
        onLoad(options) {
            // const url = options.q ? decodeURIComponent(options.q) : '';
            // const urlcode = options.url && decodeURIComponent(options.url) || ''
            // #ifdef PUB_CUSTOMER
            if (options.partnerUserId) {
                this.bindPartnerUser(options.partnerUserId, options.partnerUserName)
            }
            // #endif
 
 
        },
        created() {
 
        },
 
        async onPullDownRefresh() {
            await this.$store.dispatch('getCurrentInfo')
            uni.stopPullDownRefresh()
        },
        methods: {
            async bindPartnerUser(userId, name) {
                // await this.$message.confirm(`确定要绑定${name}合伙人吗?`)
                //调用接口绑定
                this.$message.showLoading()
                const {
                    code,
                    data
                } = await this.$http.request('post', '/api/customer/bind/partner', {
                    data: {
                        partnerUserId: userId
                    }
                })
                this.$message.hideLoading()
                if (code == 0) {
                    this.$message.showToast(`绑定合伙人${name}成功`)
                    await this.$store.dispatch('getCurrentInfo')
                }
            },
            async scanPartnerCode() {
                //扫二维码确认
                let that = this
                uni.scanCode({
                    success: async function(res) {
                        console.log('条码内容:' + res.result);
                        if (!res.result) {
                            that.$message.showToast('未识别出合伙人信息,请用微信扫码打开')
                            return
                        }
                        var dto = undefined
                        try {
                            if (res.result && (res.result.startsWith('https://') || res.result.startsWith(
                                    'http://')) && res.result.indexOf(
                                    'partnerUserId') >= 0) {
                                var arr = res.result.split("?")[1].split("&")
                                dto = {}
                                for (var item of arr) {
                                    var tarr = item.split("=")
                                    // console.log('tarr',tarr)
                                    if (tarr[1]) {
                                        dto[tarr[0]] = tarr[1]
                                    }
                                }
                                dto['name'] = dto['partnerUserName'] || ''
                                dto['userId'] = dto['partnerUserId'] || ''
                                // console.log('tmp arr',arr,dto)
 
                            } else {
                                dto = JSON.parse(res.result)
 
                            }
                            if (!!dto['userId']) {
                                var partnerName = dto['name'] || ''
                                var partnerId = dto['userId'] || ''
                                that.bindPartnerUser(partnerId, partnerName)
 
                            } else {
                                that.$message.showToast('二维码格式不正确扫码失败')
                            }
                        } catch (e) {
                            console.log('e', e)
                            that.$message.showToast('二维码扫码错误')
                        }
                    },
                    fail() {
                        that.$message.showToast('扫码失败')
 
                    }
                });
            },
 
 
            toInfo() {
                var url = ''
                if (this.currentInfo.id) {
                    // #ifdef PUB_CUSTOMER
                    url = '/sub_pages/customer/customer-info/customer-info'
                    // #endif
                    // #ifdef PUB_PARTNER
                    url = '/sub_pages/partner/partner-info/partner-info'
                    // #endif
                    // #ifdef PUB_SUPPLIER
                    url = '/sub_pages/supplier/supplier-info/supplier-info'
                    // #endif
                    if (url) {
                        uni.navigateTo({
                            url: url
                        })
                    }
                }
            },
            getTj() {
                // /api/supplier/delivery    
 
                if (this.currentInfo.id && this.currentInfo.id !== this.cacheUserId) {
                    this.cacheUserId = this.currentInfo.id
                    let that = this
                    setTimeout(() => {
 
 
 
                        // #ifdef PUB_CUSTOMER
                        this.$http.request('get', '/api/customer/center/tj', {}).then(res => {
                            if (res.code === 0) {
                                that.tj = res.data || {}
                            }
                        })
                        //获取待支付数目
 
                        this.$http.request('get', '/api/customer/order/statistics/count', {
                            params: {}
                        }).then(res => {
                            if (res.code === 0) {
                                // that.order_pendding_num = res.data || 0
                                that.tj_order = res.data || {}
                                // this.$forceUpdate()
                                console.log('tj_order', that.tj_order)
                            }
                        })
                        //判断有没有签到
                        let that = this
                        this.$http.request('get', '/api/customer/point/sign/sign/today', {}).then(res => {
                            if (res.data) {
                                that.signToday = true
                            }
                        })
 
                        // #endif
                    }, 200)
                }
 
            },
 
            async clearlogout() {
                await this.$message.confirm('是否退出登录?')
                this.$store.commit('updateLogin', false)
 
                uni.reLaunch({
                    url: '/pages/login/supplier-login'
                })
            },
            async callTel() {
                await this.$message.confirm('是否拨打客服电话')
                uni.makePhoneCall({
                    phoneNumber: this.tel //仅为示例
                });
            },
            toCustomerLogin() {
                uni.navigateTo({
                    url: '/pages/login/supplier-login'
                })
            },
        }
    }
</script>
 
<style lang="scss" scoped>
    @import "@/pages/user/user.scss";
</style>
<!-- #ifdef PUB_CUSTOMER -->
<style lang="scss" scoped>
    @import "@/pages/user/user-customer.scss";
</style>