Liuyi
2024-10-21 15a55f79a84e5dab670d54a9dc0c6b9133a18441
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
<template>
    <view class="container">
        <navbar title = '会员卡共享'></navbar>
        <view class="content">
            <block v-for="(item,index) in shareList" :key="index">
                <view class="item-box">
                    <view class="item-img">
                        <image src="../../../../static/images/index/head.png"></image>
                    </view>
                    <view class="item-info">
                        <text>{{item.shareUserName}}</text>
                        <text>{{item.sharePhone}}</text>
                    </view>
                    <view class="item-handel">
                        <view class="btn">
                            <view class="btn1" v-if="item.shareType == 1" @click="shareConfirm(2,item.id)">确认共享</view>
                            <view class="btn2" v-if="item.shareType == 1 || item.shareType == 2  " @click="shareConfirm(3,item.id)">取消共享</view>
                        </view>
                        <view v-if="item.shareType == 1" class="status">待确认</view>
                        <view v-if="item.shareType == 2" class="status">共享中</view>
                    </view>
                </view>
            </block>
        </view>
    </view>
</template>
 
<script setup>
    import { onMounted, ref } from 'vue'
    import { askShareListApi ,editShareTypeApi} from '../../../../api/index.js'
    const shareList = ref([
        // {shareUserName:'',sharePhone:'',id:'',pictureUrl:'',shareType:1},
    ])
    const userId = JSON.parse(uni.getStorageSync('userInfo')).id
    //获取共享列表
    async function getAskShareList(){
        await askShareListApi(userId).then((res) =>{
            console.log('res',res)
            shareList.value = res.data
        })
    }
    //共享确认
    function shareConfirm(val,rowId){
        let postData = {
            shareType:val,//1:待确认,2:确认,3:已取消
            id:rowId
        }
        if(val == 2){
            uni.showModal({
                title: '会员卡共享',
                content: '确认共享您的会员卡?',
                success: async function(res) {
                    if(res.confirm){
                        await editShareTypeApi(postData).then(async res1 =>{
                            if(res1.code == 200){
                                uni.showToast({
                                    title:'共享成功!',
                                })
                                await getAskShareList()
                            }else{
                                uni.showToast({
                                    title:'共享失败!',
                                    icon:'none'
                                })
                            }
                        })
                    }
                }
            });
        }else if(val == 3){
            uni.showModal({
                title: '会员卡共享',
                content: '确认取消共享?',
                success: async function(res) {
                    if(res.confirm) {
                        await editShareTypeApi(postData).then(async(res2) =>{
                            if(res2.code == 200){
                                uni.showToast({
                                    title:'取消共享成功!'
                                })
                                await getAskShareList()
                            }else{
                                uni.showToast({
                                    title:'取消失败!',
                                    icon:'none'
                                })
                            }
                        })
                    }
                }
            });
        }
    }
    onMounted(async() =>{
        await getAskShareList()
    })
</script>
 
<style lang="scss">
    
.container{
    width: 100%;
    height: 100vh;
    .content{
        width: 100%;
        height:calc(100vh - 176rpx);
        background:linear-gradient(to top,#FFFFFF,#E8EFFF);  
        box-sizing: border-box; 
        padding:60rpx 32rpx 0;
        display: flex;
        flex-direction: column;
        align-items: center; 
        overflow:scroll;
        .item-box{
            position: relative;
            width:100%;
            height:160rpx;
            background: #FFF;
            border-radius:24rpx;
            padding:10rpx 16rpx;
            box-sizing: border-box;
            margin-bottom:24rpx;
            display: flex;
            align-items: center;
            box-shadow: 0 4rpx 6rpx 1rpx rgba(155, 180, 250, 0.3);
            .item-img{
                image{
                    width:90rpx;
                    height: 90rpx;
                }
            }
            .item-info{
                height:100%;
                display: flex;
                flex-direction: column;
                justify-content: center;
                margin-left: 16rpx;
            }
            .item-handel{
                position: absolute;
                right:20rpx;
                display: flex;
                flex-direction:column;
                align-items: flex-end;
                height:85%;
                justify-content:flex-end;
                .btn{
                    display: flex;
                    margin-bottom:5rpx;
                    .btn1{
                        margin-right:10rpx;
                        width:130rpx;
                        height:60rpx;
                        line-height: 60rpx;
                        border-radius:30rpx;
                        text-align: center;
                        font-size: 24rpx;
                        font-weight:600;
                            color: #4b73e3;
                            background: linear-gradient(to right,rgba(210, 222, 249, 0.8),#FFF);
                    }
                    .btn2{
                            width:130rpx;
                            height:60rpx;
                            line-height: 60rpx;
                            border-radius:30rpx;
                            text-align: center;
                            font-size: 24rpx;
                            font-weight:600;
                            color: #4b73e3;
                            // border:1rpx solid #869cd8;
                            box-shadow: 0 0 1rpx 1rpx rgba(166, 195, 249, 0.7);
                    }
                }
                .status{
                    color: #e3b745;
                    font-size:22rpx;
                    margin-right: 10rpx;
                }
            }
        }
   }
}
</style>