tyb 2 mesi fa
parent
commit
5ee29e1fd6
2 ha cambiato i file con 49 aggiunte e 4 eliminazioni
  1. 8 0
      src/api/couponpackage.js
  2. 41 4
      src/views/promotion/couponPackageDetail.vue

+ 8 - 0
src/api/couponpackage.js

@@ -122,3 +122,11 @@ export function sendSmsInPhone(data, config) {
     data
   })
 }
+
+export function getSmsTemplateByType(query) {
+  return request({
+    url: '/couponPackageDetail/getSmsTemplateByType',
+    method: 'get',
+    params: query
+  })
+}

+ 41 - 4
src/views/promotion/couponPackageDetail.vue

@@ -325,9 +325,16 @@
           <input type="file" @change="getImportPhoneFile($event)" ref="fileupload" />
           <span style="color: black">导入成功手机号<span style="color: red">{{importPhoneCount}}</span>个</span>
         </el-form-item>
-        <span style="color: #0b0b0b">领取短链:{{couponPackage.shortChain}}</span>
+        <el-form-item label="领取短链">
+          <span style="color: #0b0b0b">{{couponPackage.shortChain}}</span>
+        </el-form-item>
+         <el-form-item label="短信模板" prop="rid">
+          <el-select @change="selectTemplage" v-model="dataImportPhoneForm.smsTemplateId" style="width: 100%" class="filter-item" placeholder="请选择短信模板" filterable="">
+            <el-option v-for="item in smsTemplateList" :key="item.id" :label="item.templateName" :value="item.id" />
+          </el-select>
+        </el-form-item>
         <el-form-item label="短信内容">
-          <el-input  type="textarea"
+          <el-input  type="textarea" disabled
                  :rows="5"  v-model="dataImportPhoneForm.content" />
         </el-form-item>
      </el-form>
@@ -348,7 +355,7 @@ import {
   packageDetailSend,
   listPackageDetailExport,
   packageImport,
-  packageDetailDelete, importPhone, sendSmsInPhone,
+  packageDetailDelete, importPhone, sendSmsInPhone, getSmsTemplateByType,
 } from "@/api/couponpackage";
 import Pagination from "@/components/Pagination"; // Secondary package based on el-pagination
 import {
@@ -467,9 +474,12 @@ export default {
       dialogImportPhoneVisible: false,
       dataImportPhoneForm: {
         file: undefined,
+        smsTemplateId:'',
+        content:''
       },
       importPhoneCount:0,
       importMarkers:'',
+      smsTemplateList:[]
 
     };
   },
@@ -746,7 +756,7 @@ export default {
       this.dialogImportPhoneVisible=true
       this.importPhoneCount=0;
       this.importMarkers='';
-      this.dataImportPhoneForm.content="恭喜您获得鲸致生活的一张卡卷包,请及时点击以下链接领取,"+this.couponPackage.shortChain
+      this.getSmsTemplate();
     },
     importPhoneConfirm() {
       if (this.dataImportPhoneForm.file == "" || this.dataImportPhoneForm.file == undefined) {
@@ -798,6 +808,11 @@ export default {
     sendPhoneMsg(){
       if(this.importPhoneCount==0){
         this.$message.error("请先导入手机号!");
+        return;
+      }
+      if(this.dataImportPhoneForm.smsTemplateId==''){
+        this.$message.error("请先选择短信模板!");
+        return;
       }
       const loading = this.$loading({
         lock: true,
@@ -825,6 +840,28 @@ export default {
           this.$message.warning(err.data.errmsg);
         });
 
+    },
+    getSmsTemplate(){
+      getSmsTemplateByType({type:1})
+        .then((res) => {
+          if (res.data.errno == 0) {
+            console.log(res.data.data)
+            this.smsTemplateList=res.data.data;
+          } else {
+            this.$message.warning(res.data.errmsg);
+          }
+        })
+        .catch((err) => {
+          this.$message.warning(err.data.errmsg);
+        });
+    },
+    selectTemplage(){
+      let smsTemplateId=this.dataImportPhoneForm.smsTemplateId
+      let smsTemplate=this.smsTemplateList.find(item=>item.id==smsTemplateId);
+
+      this.dataImportPhoneForm.content=smsTemplate.content.replace("#changeable",this.couponPackage.shortChain);
+      console.log(smsTemplate)
+
     }
   },
 };