zhaojs
2023-09-27 74098f1401afe40f961d1d167bb18dd0a71c4d59
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
<template>
    <view class="container" style="height: auto;">
        <v-tabs v-model="currentTab" :tabs="tabList" :pills="true" line-height="0" activeColor="#fff"
            @change="changeTab" pillsColor="#FF928F" :fixed="true" ></v-tabs>
        <cc-pullScroolView class="pullScrollView" ref="pullScroll" :enablePullDown="false" :back-top="false">
            <view>
                <uni-list>
                    <uni-list-item direction="column" v-for="item in smsList">
                        <template v-slot:body>
                            <text style="white-space:break-spaces;">{{item.templetecontent}}</text>
                        </template>
                        <template v-slot:footer>
                            <view @click="toSend(item)" class="uni-footer">
                                <text class="uni-footer-text">使用</text>
                            </view>
                        </template>
                    </uni-list-item>
                </uni-list>
            </view>
        </cc-pullScroolView>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                currentTab: 0,
                tabList: [],
                smsTypeList: [],
                smsList: [],
                curPageNum: 1,
                pageCount: 10,
                totalNum: 0,
                checkType: ''
            }
        },
        onLoad(option) {
            if (option.templateType && option.templateType > 0) {
                console.log(option.templateType);
                this.checkType = option.templateType;
            }
            this.getTemplateType();
 
        },
        // 上拉加载
        onReachBottom() {
            if (this.curPageNum * this.pageCount < this.totalNum) {
                // 数据为加载完
                this.$refs.pullScroll.showUpLoading();
                this.curPageNum++;
                this.getTemplateData();
            }
        },
        methods: {
            //获取模板分类
            getTemplateType() {
                this.$http.post('/smsapi/SmsBusiness/GetTempleteType', {}).then(e => {
                    this.smsTypeList = e.result;
                    let list = [];
                    list.push("全部");
                    e.result.forEach((item, index) => {
                        list.push(item.typename);
                    })
                    this.tabList = list;
                    if (this.checkType != '') {
                        let check = e.result.filter(t => t.id == this.checkType);
                        if (check && check.length > 0) {
                            this.currentTab = e.result.indexOf(check[0]) + 1;
                        }
                    }
                    this.getTemplateData();
                }).catch(function(err) {
                    console.log(err);
                })
            },
            changeTab(index) {
                this.currentTab = index;
                this.smsList = [];
                this.curPageNum = 1;
                this.totalNum = 0;
                this.getTemplateData();
            },
            //发短信
            toSend(record) {
                uni.navigateTo({
                    url: '/pages/sendsms/index?templateTxt=' + record.templetecontent
                })
            },
            getTemplateData() {
                let templateId = "";
                if (this.currentTab != 0) {
                    templateId = this.smsTypeList[this.currentTab - 1].id;
                }
                let param = {
                    TempleteId: templateId,
                    PageNo: this.curPageNum,
                    PageSize: this.pageCount
                }
                uni.showLoading({
                    title: '加载中'
                })
                this.$http.post('/smsapi/SmsBusiness/GetTempleteForTempleteId', param).then(e => {
                    this.totalNum = e.result.totalCount;
                    this.smsList = this.smsList.concat(e.result.data);
                    if (this.curPageNum * this.pageCount >= this.totalNum) {
                        // 如果是最后一页
                        this.$refs.pullScroll.finish();
                    } else {
                        // 不是最后一页
                        this.$refs.pullScroll.success();
                    }
                    uni.hideLoading()
                }).catch(function(err) {
                    uni.hideLoading()
                    console.log(err);
                })
 
 
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    page {
        background-color: #fff;
        height: 100%;
    }
 
    .container {
        display: flex;
        flex-direction: column;
        padding: 0.4rem;
    }
 
    .uni-flex {
        display: flex;
    }
 
    .uni-flex-row {
        @extend .uni-flex;
        flex-direction: row;
        box-sizing: border-box;
    }
 
    /* 列表footer */
    .uni-footer {
        @extend .uni-flex-row;
        justify-content: right;
        margin-top: $uni-spacing-col-lg;
    }
 
    .uni-footer-text {
        font-size: 14px;
        color: $uni-text-color-grey;
        margin-left: 5px;
        color: #FF928F;
        font-weight: 700;
    }
</style>