Liuyi
2024-11-26 53dc2bac460d2ff210aa9523717753ae1fd2c159
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
<script setup>
    import { onMounted, ref } from 'vue';
    import { pointsExchangeApi } from '../../../api/index.js'
    const userInfo = JSON.parse(uni.getStorageSync('userInfo'))
    
    const pointExchangeList = ref([
        // {goodsName:'纸巾',integralAmount:1232,receiveStatusName:'已领取',exchangeDate:'2024-11-13 14:46:40',receiveDate:'2024-11-13 14:46:40'},
    ])
    async function searchPoints(){
        await pointsExchangeApi({limit:10000,page:1,userId:userInfo.id}).then((res) =>{
            pointExchangeList.value = res.data.list
        })
    }
    //兑换码相关
    const popupCode = ref()
    const codeValue = ref('')
    const codeGoodsName = ref('')
    //点击兑换
    function showConvertCode(redeemCode,goodsName){
        codeValue.value = redeemCode
        popupCode.value.open()
        codeGoodsName.value = goodsName
    }
    //弹窗改变事件
    let codeInterVal
    async function popupChange(e){
        console.log('tanchuan',e)
        if(e.show == true){
            console.log('打开弹窗')
            codeInterVal = setInterval(async() =>{
                await searchPoints()
                pointExchangeList.value.forEach((item) =>{
                    if(item.redeemCode == codeValue.value){
                        if(item.receiveStatus == 1){
                            clearInterval(codeInterVal)
                            popupCode.value.close()
                            uni.showToast({
                                title:'领取成功!'
                            })
                        }
                    }
                })
            },2000)
        }else if(e.show == false){
            console.log('关闭弹窗')
            clearInterval(codeInterVal)
            await searchPoints()
        }
    }
    onMounted(async() =>{
        await searchPoints()
    })
    
</script>
<template>
    <view class="container">
        <point-navbar title='兑换订单'></point-navbar>
        <view class="content">
            <view class="main" v-if="pointExchangeList.length > 0">
                <block v-for="(item,index) in pointExchangeList">
                    <view class="item">
                        <view class="item-box">
                            <view class="item-row1">
                                <text>兑换商品:</text>
                                <text class="goods-name">{{item.goodsName}}</text>
                            </view>
                            <view class="item-row2">
                                <view class="status">
                                    <text>领取状态:</text>
                                    <text class="status-value">{{item.receiveStatusView}}</text>
                                </view>
                                <view class="advert-code" v-if="item.receiveStatus == 0" @click="showConvertCode(item.redeemCode,item.goodsName)">
                                    <text>出示兑换码</text>
                                </view>
                            </view>
                            <view class="item-row3">
                                <view>积分消耗:</view>
                                <view class="points">
                                    <text class="points-value">-{{item.integralAmount}}</text>
                                    <image class="points-img" src="../../../static/images/pointMall/advert/money1.svg"></image>
                                </view>
                            </view>
                            <view class="item-row4">
                                <view class="time">
                                    <text class="time-value">兑换时间:{{item.exchangeDate}}</text>
                                    <text v-if="item.receiveStatus == 1" class="time-value">领取时间:{{item.receiveDate}}</text>
                                </view>
                            </view>
                        </view>
                    </view>
                </block>
            </view>
            <view v-else class="nodata">
                <image src="../../../static/images/pointMall/noRecord.svg" alt=""></image>
                <text>暂无记录</text>
            </view>
        </view>
        <uni-popup ref="popupCode" @change="popupChange" type="center" background-color="#fff" border-radius="10px">
            <view class="convert-code"> 
                <text class="code-title">兑换码</text>
                <view class="code-value">
                    <!-- <l-qrcode :value="codeValue" size="260rpx" color="rgb(12, 15, 36)"></l-qrcode> -->
                    <text>{{codeValue}}</text>
                </view>
                <text>商品名称:{{codeGoodsName}}</text>
            </view>
        </uni-popup>
    </view>
</template>
 
<style lang="scss" scoped>
    
    .container{
       width:100%;
       height:100vh;
       .content{
           width:100%;
           height:calc(100vh - 176rpx);
           background:linear-gradient(to bottom,#fef7da,#FFF);
           padding:50rpx 32rpx 100rpx;
           box-sizing: border-box;
           .main{
                  width:99%;
                  height:calc(100% - 50rpx);
                  background: rgba(255,255,255,0.8);
                  box-shadow: 0 0 6rpx 2rpx #fbd1a2;
                  border-radius:20rpx;
                  margin: 0 auto;
                  padding:28rpx 48rpx;
                  box-sizing: border-box;
                  overflow: scroll;
                  .item{
                      width:100%;
                      height:260rpx;
                      border-bottom:1rpx solid #D8D8D8;
                      box-sizing:border-box;
                      padding:20rpx 0 10rpx;
                      margin-bottom:10rpx;
                      .item-box{
                          width:100%;
                          height:100%;
                          display: flex;
                          flex-direction: column;
                          justify-content:space-around;
                           font-weight:500;
                           font-size: 32rpx;
                           color: #5f5b57;
                          .item-row1{
                             width:100%;
                             .goods-name{
                                 color: #4b4845;
                             }
                          }
                          .item-row2{
                            width:100%;
                              display: flex;
                            justify-content: space-between;
                            align-items: center;
                            .status-value{
                                color: #e2ac21;
                            }
                            .advert-code{
                                width: 200rpx;
                                height:55rpx;
                                background: linear-gradient(to right,#efa339,#fbc671);
                                border-radius:30rpx;
                                display: flex;
                                justify-content: center;
                                align-items: center;
                                color: #FFF;
                                letter-spacing:1rpx;
                                font-size: 30rpx;
                            }
                          }
                          .item-row3{
                             display: flex;
                              .points{
                                  display: flex;
                                  align-items: center;
                                  .points-img{
                                      width:40rpx;
                                      height:40rpx;
                                      margin-left:5rpx;
                                  }
                                  .points-value{
                                     color: #efab22; 
                                  }
                              }
                          }
                          .item-row4{
                               width:100%;;
                               .time{
                                     font-weight: 300;
                                     font-size:26rpx;
                                     color: #909090;
                                     display: flex;
                                     flex-direction: column;
                               }
                          }
                      }
                  }
       }
       .nodata{
            width:100%;
            height:1200rpx;
            display: flex;
            justify-content: center;
            align-items: center;
            padding-bottom:400rpx;
            box-sizing: border-box;
            flex-direction: column;
            image{
              width:300rpx;
              height:300rpx;
            }
            text{
              color:#fbd1a2;
            }
       }
    }
    .convert-code{
        width: 550rpx;
        height: 550rpx;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content:space-evenly;
        padding:10rpx 0;
        box-sizing: border-box;
        .code-title{
            font-weight:600;
        }
        .code-value{
            padding: 30rpx;
            border:1rpx solid #e2e2e2;
            box-sizing: border-box;
            border-radius:10rpx;
            font-weight:600;
            letter-spacing:1rpx;
        }
    }
}
</style>