zhao_js
2023-11-16 0c5dcd2d78119981b5935b0f7acfbef1ff9ce5e4
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<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="492" 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: '',
                maxlength:500,
                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>