Liuyi
2024-12-20 d470e67ac1997882502b75cbfdaf359626cfaaa8
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
<template>
    <view class="container">
        <navbar title = '会员卡共享'></navbar>
        <view class="content">
            <view class="img">
                <image src="../../../../static/images/index/card11.png"></image>
                <text>卡号:{{shareData.cardNumber}}</text>
            </view>
            <view @click="shareConfirm()" class="requset-btn">请求共享</view>
            <view class="tips">
                <text>1、提交请求共享,通知水卡实际拥有者进行确认。</text>
                <text>2、水卡实际拥有者确认后,您可使用此卡消费。</text>
            </view>
            <view>
                <uni-popup ref="messagePopup" type="center" backgroundColor="#d0dced" borderRadius="10rpx">
                    <view class="pop-text">
                        <text>提示</text>
                        <text>{{messageText}}</text>
                    </view>
                </uni-popup>
            </view>
        </view>
    </view>
</template>
 
<script setup>
    import { ref } from 'vue'
    import { onLoad } from "@dcloudio/uni-app"
    import { askShareApi } from '../../../../api/index.js'
    const messagePopup = ref()
    const messageText = ref()
    const shareData = ref({
        shareUserId:'',
        cardNumber:'',
    })
    //共享请求
    async function shareConfirm(){
            console.log('发起请求')
        shareData.value.shareUserId = JSON.parse(uni.getStorageSync('userInfo')).id    
        console.log('shareData.value',shareData.value)
        await askShareApi(shareData.value).then((res) =>{
            console.log('请求响应',res)
            if(res.code == 200){
                uni.showToast({
                    title:'已发起,待确认',
                    duration:1500,
                })
                setTimeout(() =>{
                    uni.navigateTo({
                        url:'/pages/index/index'
                    })
                },1500)
            }else if(res.code == 300){
                messageText.value = res.msg
                messagePopup.value.open('center')
            }else{
                uni.showToast({
                    title:'请求错误!',
                    icon:'none'
                })
            }
        })
    }
    onLoad(async(option)=>{
        shareData.value.cardNumber = option.codeParams
    })
</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; 
            .img{
                width: 100%;
                position: relative;
                margin-bottom:50rpx;
                image{
                    width:100%;
                    height:290rpx;
                }
                text{
                    position: absolute;
                    left:20rpx;
                    top: 20rpx;
                    color: #FFFFFF;
                }
            }
            .requset-btn{
                width:400rpx;
                height: 80rpx;
                background: #2b74e1;
                border-radius:40rpx;
                text-align: center;
                line-height: 80rpx;
                color: #FFFFFF;
                letter-spacing:5rpx;
                margin-bottom: 50rpx;
            }
            .tips{
                text{
                    display: block;
                    font-size:26rpx;
                    margin-bottom:10rpx;
                    color: #555555;
                    line-height:56rpx;
                }
            }
            .pop-text{
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: space-evenly;
                color: #648ecc;
                padding: 20rpx 30rpx;
                text{
                    text-align: center;
                    line-height: 50rpx;
                    margin-bottom:10rpx;
                    color: #5281c6;
                    letter-spacing:3rpx;
                }
            }
        }
    }
</style>