<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>
|