lefengyang
2026-08-27 6ff51a2017246dd3a77e4005f77352e7a803e0de
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="page_bg">
        <uv-navbar title="模版" :placeholder="true" leftIcon="" bgColor="rgba(0,0,0,0)" titleStyle="color:#fff"></uv-navbar>
        
        <view class="temp_add" @click="gotoTemp">
            <uv-icon name="plus" color="#3086F3" size="30rpx"></uv-icon>
            <view class="name">
                新增动画
            </view>
        </view>
        
        <view class="temp_list" v-if="listData.length > 0">
            <view class="item" v-for="(item,index) in listData" :key="index">
                <view class="pic" >
                    <uv-image :src="baseURL+item.pic" width="200rpx" height="150rpx" :radius="5"></uv-image>
                </view>
                <view class="info">
                    <view class="name">
                        {{item.name}}
                    </view>
                    <view class="text">
                        {{item.screen}}
                    </view>
                </view>
                <view class="btn">
                    <uv-button type="primary" :plain="true" shape="circle" text="编辑" size="small" @click="clickTempleteEdit(item.id)"></uv-button>
                    <uv-button type="primary" :plain="true" shape="circle" text="删除" size="small" custom-style="marginTop:20rpx" @click="clickTempleteDel(item.id)"></uv-button>
                </view>
                <!-- <view class="btn">
                    <uv-button type="primary" shape="circle" text="编辑" size="small" @click="gotoTemp"></uv-button>
                </view> -->
            </view>
        </view>
        <uv-empty v-if="listData.length == 0" mode="list" marginTop="300rpx" iconColor="#eee" textColor="#ddd"></uv-empty>
 
        <view style="height: 100rpx;"></view>
        
    </view>
</template>
 
<script>
    import { templeteList,templeteDel } from '@/api/api.js'
    export default {
        data() {
            return {
                userId: '',
                listData: [],
                baseURL: '',
            }
        },
        onLoad() {
            this.baseURL = uni.$uv.http.config.baseURL
        },
        onShow() {
            this.userId = uni.getStorageSync('userId');
            this.getTempleteList()
        },
        methods: {
            // 编辑
            clickTempleteEdit(id){
                uni.navigateTo({
                    url: '/pages/addTemplate/addTemplate?id='+id
                });
            },
            // 删除
            clickTempleteDel(id){
                uni.showModal({
                    title: '提示',
                    content: '删除后无法恢复,确定删除吗?',
                    success: (resa) => {
                        if (resa.confirm) {
                            console.log('用户点击确定');
                            templeteDel(id).then(res=>{
                                console.log(res)
                                uni.showToast({
                                    title: res.msg,
                                    duration: 2000,
                                    icon: 'none'
                                });
                                if(res.code == 200){
                                    this.getTempleteList()
                                }
                            })
                        } else if (resa.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                });
                
            },
            getTempleteList(){
                templeteList({
                    userId: this.userId,
                    pageNum: 1,
                    pageSize: 99
                }).then(res=>{
                    console.log('模版list-----------',res)
                    if(res.code == 200){
                        this.listData = res.rows
                    }
                    else{
                        uni.showToast({
                            title: res.msg,
                            duration: 2000,
                            icon: 'none'
                        });
                    }
                })
            },
            gotoTemp(){
                uni.navigateTo({
                    url: '/pages/addTemplate/addTemplate'
                });
            }
        }
    }
</script>
 
<style lang="scss" scoped>
.temp_list{
    padding:0 30rpx;
    .item{
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 160rpx;
        background: linear-gradient( 180deg, #FFFFFF 0%, rgba(255,255,255,0.5) 100%);
        box-shadow: 8rpx 8rpx 23rpx 0rpx rgba(67,147,248,0.1), -8rpx -8rpx 23rpx 0rpx rgba(255,255,255,0.4);
        border-radius: 20rpx;
        border: 2rpx solid #FFFFFF;
        margin-bottom: 20rpx;
        box-sizing: border-box;
        padding:15px 30rpx;
        .pic{
            width: 200rpx;
            flex-shrink: 0;
            margin-right: 25rpx;
        }
        .info{
            width: 100%;
            .name{
                font-weight: 500;
                font-size: 28rpx;
                color: rgba(0,0,0,0.9);
                line-height: 40rpx;
            }
            .text{
                font-weight: 600;
                font-size: 27rpx;
                color: rgba(0,0,0,0.7);
                line-height: 40rpx;
                margin-top: 10rpx;
            }
        }
        .btn{
            flex-shrink: 0;
            margin-left: 20rpx;
        }
    }
}
.temp_add{
    display: flex;
    align-items: center;
    justify-content: center;
    margin:10rpx 30rpx 20rpx;
    height: 90rpx;
    background: #FFFFFF;
    box-shadow: 0rpx 12rpx 27rpx 0rpx rgba(56,151,243,0.38);
    border-radius: 20rpx;
    border: 2rpx solid #3086F3;
    .name{
        font-size: 28rpx;
        color: #3086F3;
        line-height: 42rpx;
        margin-left: 6rpx;
    }
}
.page_bg{
    width: 100%;
    height: calc(100vh - var(--window-bottom));
    background:url('/static/img/bg_2.jpg') no-repeat center top;
    background-size: 100% auto;
}
</style>