jhzh
2025-04-03 db12897dc68c68d40c557aa59ad78022e2b30ac2
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
<template>
    <view>
        <v-header class="nav_bar m-y-xs" :left-text="$t('base.a1')" :title="$t('otc.k4')"
            :left-arrow="true">
            <template #right>
                <v-link to="/pages/otc/order" class="d-flex align-center">
                    {{$t('otc.k2')}}
                </v-link>
            </template>
        </v-header>
        <!-- <view class="cu-bar"></view> -->
        <scroll-view :scroll-y="modalName==null" class="page" :class="modalName!=null?'show':''">
        <view class="cu-bar bg-white solid-bottom margin-top">
<!--                 <view class="action">
                    <text class="cuIcon-title text-orange "></text>
                </view> -->
            </view>
            
            <view class="cu-list menu-avatar" v-for="item in List_Info" :key="item.id" >
                <view class="cu-item"  @click="chat_detail(item.last_message.toid)">
                    <view class="cu-avatar radius lg"
                        :style="{ 'background-image':'url('+ item.head_url +')'  }">
                    </view>
                    <view class="content">
                        <!-- <view class="text-grey">{{item.username}}</view> -->
                        <view class="text-gray text-sm flex" >
                            <view class="text-cut">{{item.username}}</view>
                            <view class="cu-tag round bg-orange sm">买家</view>
                        </view>
                        <view class="text-gray text-sm flex">
                            <view class="text-cut">{{item.last_message.content}}</view>
                        </view>
                    </view>
                    <view class="action">
                        <view class="text-grey text-xs">{{new Date(parseInt(item.last_message.time)).toTimeString().substr(0, 8)}}</view>
                        <view class="cu-tag round bg-green sm">{{item.last_message.isread}}</view>
                    </view>
                </view>
            </view>
 
        </scroll-view>
    </view>
 
</template>
 
<script>
    import Profile from "@/api/profile";
    export default {
        data() {
            return {
                connected: false,
                connecting: false,
                socketTask: false,
                msg: false,
                API_URL: "https://socket.kocoinlab.com/index.php/api/chat2/",
                from_id: 0,
                List_Info:{},
                modalName:null,
 
            };
        },
        computed: {
            
            
        },
        // onLoad() {
        //     this.getUserInfo()
        //     this.get_list();    
        // },
        onLoad() {
            this.getUserInfo();
        },
        methods: {
            chat_detail(toid){
                console.log(toid);
                this.$router.push({ path: "/pages/otc/chat", query: { id:toid} });
            },
            
            //获取聊天列表
            get_list() {
                //console.log(this.fromid);
                //console.log(this.List_info);
                uni.request({
                    method:'POST',
                    url:this.API_URL+"get_list",
                    data:{"id":this.from_id},
                    success: (res) => {
                        //console.log(res);
                        var data = res.data
                        if (data.code == 0) {
                            console.log(data.data)
                            this.List_Info = data.data      
                            this.$forceUpdate()
                        } else{
                            console.log("false")
                        }
                        
                    }
                })
            },
            getUserInfo() {
                Profile.getUserInfo().then((res) => {
                    console.log(res.data)
                    this.from_id = res.data.user_id
                    console.log(this.from_id)
                    this.get_list();
                });
            },
        }
 
    }
</script>
 
<style>
    .page {
        height: 100Vh;
        width: 100vw;
    }
 
    .page.show {
        overflow: hidden;
    }
 
    .switch-sex::after {
        content: "\e716";
    }
 
    .switch-sex::before {
        content: "\e7a9";
    }
 
    .switch-music::after {
        content: "\e66a";
    }
 
    .switch-music::before {
        content: "\e6db";
    }
</style>