<template>
|
<view class="container">
|
<view class="sendtip">
|
<uv-notice-bar :text="text" color='#fff' bgColor='#F56C6C'></uv-notice-bar>
|
</view>
|
<view style="padding: 0.8rem;">
|
<view class="input-box" style="width: 100%;">
|
<input v-model="mobile" type="number" placeholder="请输入要发送的手机号"
|
placeholder-class="text-color-assist font-size-base" />
|
</view>
|
</view>
|
<view style="padding: 0.8rem;">
|
<view class="input-box" style="width: 100%; position: relative;">
|
<view style="position: absolute; top: 0.4rem;">
|
{{smsSign}}
|
</view>
|
<textarea maxlength="500" v-model="smscontent" @input="CountSms" class="smstxt" placeholder="请输入发信内容"
|
placeholder-class="text-color-assist font-size-base"></textarea>
|
<view class="smsbottom">
|
<view v-if="tdTxt!=''" style="color: #000;">
|
{{tdTxt}}
|
</view>
|
<span @click="choosetemplate()" class="chooseTemplateTxt">
|
内置模板
|
</span>
|
<span>按照70个字/条计算,当前 <span class="smsword">{{wordcount}}</span>字,<span
|
class="smsword">{{smscount}}</span>条短信</span>
|
|
</view>
|
</view>
|
</view>
|
<view style="padding: 0.8rem;">
|
<view class="input-box" style="width: 100%; position: relative;">
|
<hTimePicker interval="1" timeNum="0" @changeTime="changeTime">
|
<view v-if="sendtime!=''" style="width: 100%;" slot="pCon"
|
class="changeTime input-box text-color-assist font-size-base">
|
{{sendtime}}
|
</view>
|
<view v-else style="width: 100%;" slot="pCon"
|
class="changeTime input-box text-color-assist font-size-base">
|
选择发送时间(不选择,默认立即发送)
|
</view>
|
</hTimePicker>
|
<image v-if="sendtime!=''" @click="cleartime"
|
style="position: absolute; width: 2.6rem;height: 2.6rem; right: 0px;"
|
src="/static/images/menu/close.png"></image>
|
</view>
|
</view>
|
<view style="padding: 0.8rem;">
|
<view class="d-flex align-items-center justify-content-start font-size-sm text-color-warning"
|
style="padding: 20rpx 0; color: #f11212e0;">
|
<view class="iconfont iconhelp line-height-100"></view>
|
<view>违规信息概不退款!预约信息不支持取消、修改和退款</view>
|
</view>
|
</view>
|
<view
|
class="w-100 pay-box position-fixed fixed-bottom d-flex align-items-center justify-content-between bg-white">
|
<view class="font-size-sm" style="margin-left: 20rpx;">合计:</view>
|
<view class="font-size-lg flex-fill">{{ smscount }}条短信</view>
|
<view class="bg-primary h-100 d-flex align-items-center just-content-center text-color-white font-size-base"
|
style="padding: 0 60rpx;" @tap="submit">
|
发送
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import hTimePicker from "@/components/h-timePicker/h-timePicker.vue";
|
export default {
|
components: {
|
hTimePicker
|
},
|
data() {
|
return {
|
sendtime: '',
|
smscontent: '',
|
mobile: '',
|
wordcount: 0,
|
smscount: 0,
|
smsSign: '',
|
tdTxt: '',
|
text: '请勿发送欺诈/辱骂等违规内容,发现一律报警处理'
|
}
|
},
|
onLoad(option) {
|
if (option.mobile) {
|
this.mobile = option.mobile;
|
}
|
if (option.templateTxt) {
|
this.smscontent = option.templateTxt;
|
}
|
this.getSmsSet();
|
|
let memberinfo = uni.getStorageSync('smsmemberinfo');
|
if (memberinfo == null || memberinfo.smscount == 0) { //未注册或没有短信余额
|
uni.showModal({
|
title: '提示',
|
content: '当前短信余额为0,请充值后发送!',
|
showCancel: false,
|
success: function(bac) {
|
uni.switchTab({
|
url: '/pages/mine/mine'
|
})
|
}
|
})
|
}
|
},
|
methods: {
|
getSmsSet() {
|
this.$http.post('/smsapi/SmsBusiness/GetSmsSet', {}).then(e => {
|
this.smsSign = "【" + e.result.smsname + "】";
|
this.tdTxt = e.result.suffix;
|
this.CountSms();
|
}).catch(function(err) {
|
console.log(err);
|
})
|
},
|
submit() { //提交短信任务
|
var re = /^1[3,4,5,6,7,8,9][0-9]{9}$/;
|
if (this.mobile == '' || !re.test(this.mobile)) {
|
uni.showModal({
|
title: '提示',
|
content: '请输入正确的手机号',
|
showCancel: false
|
})
|
return;
|
}
|
if (this.smscontent == '') {
|
uni.showModal({
|
title: '提示',
|
content: '请输入短信内容',
|
showCancel: false
|
})
|
return;
|
}
|
//先判断短信余额
|
this.openId = uni.getStorageSync('smsopenid');
|
var that = this;
|
uni.showLoading({
|
title: '提交中'
|
})
|
let data = {
|
OpenId: this.openId
|
}
|
this.$http.post('/smsapi/SmsBusiness/GetMemberInfo', data).then(e => {
|
if (e.result != null) {
|
if (e.result.smscount >= that.smscount) {
|
//提交短信任务
|
let Wantsendtype = that.sendtime == "" ? 1 : 2;
|
var sendTime = that.sendtime == "" ? new Date().toLocaleString() : that.sendtime;
|
let sendData = {
|
Mobile: that.mobile,
|
Smscontent: that.smscontent,
|
Memberid: e.result.id,
|
Wantsendtype: Wantsendtype,
|
Wantsendtime: sendTime
|
}
|
that.$http.post('/smsapi/SmsBusiness/AddSmsSend', sendData).then(e => {
|
if (e.result == true) { //提交成功
|
uni.showModal({
|
title: '提示',
|
content: '任务提交成功!',
|
showCancel: false,
|
success: function(bac) {
|
uni.switchTab({
|
url: '/pages/charthistory/index'
|
})
|
}
|
})
|
} else {
|
uni.showToast({
|
title: '任务提交失败,请联系客服!',
|
icon: 'none'
|
});
|
}
|
}).catch(function(err) {
|
console.log(err);
|
})
|
} else {
|
uni.showModal({
|
title: '提示',
|
content: '当前短信余额为0,请充值后发送!',
|
showCancel: false,
|
success: function(bac) {
|
uni.switchTab({
|
url: '/pages/mine/mine'
|
})
|
}
|
})
|
}
|
}
|
uni.hideLoading()
|
})
|
.catch(function(err) {
|
uni.hideLoading()
|
console.log(err);
|
})
|
},
|
changeTime(timestr, timespan) {
|
this.sendtime = timestr;
|
},
|
cleartime() {
|
this.sendtime = '';
|
},
|
// 计算字数和短信条数
|
CountSms() {
|
var count = this.smsSign.length + this.tdTxt.length;
|
if (!this.checkIsNull(this.smscontent)) {
|
count += this.smscontent.length
|
}
|
this.wordcount = count
|
var smsCount = Math.ceil(count / 70)
|
this.smscount = smsCount
|
},
|
choosetemplate() {
|
uni.navigateTo({
|
url: '/pages/smstemplate/index'
|
})
|
},
|
checkIsNull(value) {
|
if (value == undefined || value == '') {
|
return true
|
}
|
return false
|
},
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
/* #ifdef H5 */
|
page {
|
height: 100%;
|
}
|
|
/* #endif */
|
.chooseTemplateTxt {
|
float: left;
|
margin-left: 1rem;
|
color: rgb(245, 108, 108);
|
font-size: 15px;
|
font-weight: 600;
|
}
|
|
.changeTime {
|
width: 100%;
|
flex: 1;
|
height: 40px;
|
border: 0.5px solid #eee;
|
border-right: 0;
|
border-radius: 4px 0 0 4px;
|
padding: 10px;
|
font-size: 14px;
|
color: #5A5B5C;
|
color: #919293;
|
}
|
|
.pay-box {
|
box-shadow: 0 0 20rpx rgba(0, 0, 0, .1);
|
height: 100rpx;
|
}
|
|
.smsword {
|
color: #FF928F;
|
font-size: 14px;
|
font-weight: 700;
|
}
|
|
.sendtip {
|
margin: 0.5rem 0 0 0;
|
padding: 0.8rem;
|
font-size: 14px;
|
font-weight: 600;
|
text-align: center;
|
color: red;
|
}
|
|
.smsbottom {
|
position: absolute;
|
bottom: 1px;
|
width: 100%;
|
/* border: 1px solid red; */
|
right: 3px;
|
text-align: right;
|
font-size: 14px;
|
color: #919293;
|
}
|
|
.smstxt {
|
width: 100%;
|
height: 15rem;
|
padding: 10px;
|
padding-bottom: 2.5rem;
|
text-indent: 120rpx;
|
}
|
|
.sendset {
|
width: 100%;
|
padding: 16px 15px 5px;
|
box-shadow: 0 10px 10px -10px rgba(51, 51, 51, 0.1);
|
background: #FFFFFF;
|
}
|
|
.input-box {
|
background-color: #ffffff;
|
display: flex;
|
align-items: stretch;
|
width: 70%;
|
flex-shrink: 0;
|
|
input {
|
flex: 1;
|
height: 80rpx;
|
border: 1rpx solid #eee;
|
border-right: 0;
|
border-radius: 8rpx 0 0 8rpx;
|
padding: 20rpx;
|
font-size: $font-size-base;
|
color: $text-color-base;
|
}
|
|
button {
|
border-radius: 0 8rpx 8rpx 0;
|
display: flex;
|
align-items: center;
|
}
|
}
|
</style>
|