Browse Source

前置表单

duanshenglang 3 weeks ago
parent
commit
fdc0699afb
5 changed files with 776 additions and 52 deletions
  1. 11 9
      lottery/clientSop.html
  2. 1 1
      lottery/clientSopTip.html
  3. 646 0
      lottery/groupSop.html
  4. 4 5
      lottery/groupSopTip.html
  5. 114 37
      lottery/index.html

+ 11 - 9
lottery/clientSop.html

@@ -5,7 +5,7 @@
   <meta charset="UTF-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
-  <title>数据查看</title>
+  <title>客户SOP</title>
   <!--引入 element-ui 的样式,-->
   <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
   <!-- 必须先引入vue,  后使用element-ui -->
@@ -15,9 +15,9 @@
   <script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
   <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
   <script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script>
-  <script>
-		  var vConsole = new window.VConsole();
-		</script>
+  <!-- <script>
+    var vConsole = new window.VConsole();
+  </script> -->
 </head>
 <style>
   body {
@@ -105,7 +105,7 @@
   }
   .sop_foot {
     display: flex;
-    justify-content: space-between;
+    justify-content: flex-end;
     align-items: center;
     margin: 10px 0;
   }
@@ -146,7 +146,7 @@
               {{timeFormat(item.executeTime, 'yyyy-MM-dd')}}
             </div>
             <div class="sop_item">
-              <div><span style="color: #1890ff;">{{timeFormat(item.executeTime, 'hh:mm:ss')}}</span>发送</div>
+              <div><span style="color: #1890ff;">{{timeFormat(item.executeTime, 'hh:mm:ss')}}</span>发送<span style="color: #999;">{{item.isSend ? '(已发送)' : ''}}</span></div>
               <div class="sop_body" v-if="item.ctOthers.length > 0">
                 <div v-for="(c, cIndex) in item.ctOthers" :key="cIndex">
                   <div class="sop_c" v-if="c.matterType === 0">
@@ -165,7 +165,6 @@
                     <span>{{ c.fileName }}</span>
                   </div>
                   <div class="sop_foot">
-                    <span style="color: #999;">{{item.isSend ? '已发送' : ''}}</span>
                     <div class="sop_btn" @click="handleSend(item.id, c)">发送</div>
                   </div>
                 </div>
@@ -193,7 +192,7 @@
               {{timeFormat(item.executeTime, 'yyyy-MM-dd')}}
             </div>
             <div class="sop_item">
-              <div><span style="color: #1890ff;">{{timeFormat(item.executeTime, 'hh:mm:ss')}}</span>发送</div>
+              <div><span style="color: #1890ff;">{{timeFormat(item.executeTime, 'hh:mm:ss')}}</span>发送(<span style="color: #999;">{{item.isSend ? '已发送' : ''}}</span>)</div>
               <div class="sop_body" v-if="item.ctOthers.length > 0">
                 <div v-for="(c, cIndex) in item.ctOthers" :key="cIndex">
                   <div class="sop_c" v-if="c.matterType === 0">
@@ -212,7 +211,6 @@
                     <span>{{ c.fileName }}</span>
                   </div>
                   <div class="sop_foot">
-                    <span style="color: #999;">{{item.isSend ? '已发送' : ''}}</span>
                     <div class="sop_btn" @click="handleSend(item.id, c)">发送</div>
                   </div>
                 </div>
@@ -338,6 +336,10 @@
         })
       },
       handleClickTab(tab) {
+        this.executeData = []
+        this.sopItem = {}
+        this.sopPlans = []
+        this.historyId = null
         if (tab.name === 'playing') {
           this.executeSopList(0)
         } else {

+ 1 - 1
lottery/clientSopTip.html

@@ -5,7 +5,7 @@
   <meta charset="UTF-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
-  <title>数据查看</title>
+  <title>客户SOP</title>
   <!--引入 element-ui 的样式,-->
   <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
   <!-- 必须先引入vue,  后使用element-ui -->

+ 646 - 0
lottery/groupSop.html

@@ -0,0 +1,646 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta charset="UTF-8">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>客户群SOP</title>
+  <!--引入 element-ui 的样式,-->
+  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
+  <!-- 必须先引入vue,  后使用element-ui -->
+  <script src="./js/vue.js"></script>
+  <!-- 引入element 的组件库-->
+  <script src="https://unpkg.com/element-ui/lib/index.js"></script>
+  <script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
+  <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
+  <script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script>
+  <!-- <script>
+    var vConsole = new window.VConsole();
+  </script> -->
+</head>
+<style>
+  body {
+    margin: 0;
+    padding: 0;
+  }
+
+  .box {
+    width: 100vw;
+    height: 100vh;
+    box-sizing: border-box;
+    background: #FAFAFA;
+  }
+
+  .page4 {
+    width: 100vw;
+    height: 100vh;
+    box-sizing: border-box;
+  }
+
+  .top_tip {
+    background: #afdefd;
+    display: flex;
+    justify-content: center;
+    color: #FFF;
+    font-size: 14px;
+    padding: 6px 0;
+  }
+
+  .logo {
+    width: 20px;
+    height: 20px;
+    margin-right: 10px;
+  }
+
+  .tag_list {
+    display: flex;
+    align-items: center;
+    padding: 10px 20px;
+    overflow-x: auto;
+  }
+
+  .content {
+    padding: 20px;
+    margin-bottom: 10px;
+    background: #FFF;
+  }
+
+  .icon_logo {
+    width: 20px;
+    vertical-align: bottom;
+  }
+
+  .sop_content {
+    background: #f1f9ff;
+    padding: 10px 20px;
+    border-radius: 10px;
+    font-size: 14px;
+  }
+
+  .font {
+    color: #1890ff;
+  }
+
+  .sop_list {
+    padding: 10px 20px;
+  }
+
+  .sop_time {
+    font-weight: 600;
+  }
+
+  .dot {
+    width: 10px;
+    height: 10px;
+    color: #1890ff;
+  }
+
+  .sop_item {
+    background: #FFF;
+    padding: 20px;
+    margin: 10px 0;
+    font-size: 14px;
+  }
+
+  .sop_body {
+    margin: 10px 0;
+  }
+
+  .sop_c {
+    background: #FAFAFA;
+    padding: 10px;
+  }
+
+  .sop_foot {
+    display: flex;
+    justify-content: flex-end;
+    align-items: center;
+    margin: 10px 0;
+  }
+
+  .sop_btn {
+    background: #1890ff;
+    color: #FFFFFF;
+    padding: 5px 20px;
+    border-radius: 4px;
+    font-size: 12px;
+  }
+</style>
+
+<body>
+  <div id="box" class="box">
+    <!-- 数据查看 -->
+    <div class="page4">
+      <div class="top_tip">
+        <img class="logo" src="./img/wefan.png"></img>
+        微分机器人提供技术支持
+      </div>
+      <el-tabs v-model="activeName" stretch @tab-click="handleClickTab">
+        <el-tab-pane label="执行中" name="playing">
+          <div class="tag_list">
+            <el-tag style="margin-right: 10px;" :type="item.type" effect="plain" v-for="(item, index) in executeData"
+              :key="index" @click="getSop(item)">{{item.sopName}}</el-tag>
+          </div>
+          <div class="content">
+            <div class="sop_content">
+              <img class="icon_logo" :src="sopItem.clientAvatar || './img/avatar.png'"></img>
+              <span>「{{sopItem.clientName}}」在「{{timeFormat(sopItem.triggerTime, 'yyyy-MM-dd hh:mm:ss')}}」</span>
+              <span class="font" v-if="sopItem.triggerType">添加好友后触发客户SOP任务,</span>
+              <span class="font" v-else>打上标签后触发客户SOP任务,</span>
+              <span>快去跟进吧</span>
+            </div>
+          </div>
+          <div class="sop_list" v-for="(item, index) in sopPlans" :key="index">
+            <div class="sop_time">
+              <span class="dot">·</span>
+              {{timeFormat(item.executeTime, 'yyyy-MM-dd')}}
+            </div>
+            <div class="sop_item">
+              <div><span style="color: #1890ff;">{{timeFormat(item.executeTime, 'hh:mm:ss')}}</span>发送<span style="color: #999;">{{item.isSend ? '(已发送)' : ''}}</span></div>
+              <div class="sop_body" v-if="item.ctOthers.length > 0">
+                <div v-for="(c, cIndex) in item.ctOthers" :key="cIndex">
+                  <div class="sop_c" v-if="c.matterType === 0">
+                    <span>{{ c.matterText }}</span>
+                  </div>
+                  <div class="sop_c" v-if="c.matterType === 1">
+                    <img style="width: 100px;" :src="c.imgUrl" />
+                  </div>
+                  <div class="sop_c" v-if="c.matterType === 5">
+                    <span>{{ c.linkTitle }}</span>
+                  </div>
+                  <div class="sop_c" v-if="c.matterType === 2">
+                    <span>自定义视频</span>
+                  </div>
+                  <div class="sop_c" v-if="c.matterType === 4">
+                    <span>{{ c.fileName }}</span>
+                  </div>
+                  <div class="sop_foot">
+                    <div class="sop_btn" @click="handleSend(item.id, c)">发送</div>
+                  </div>
+                </div>
+              </div>
+            </div>
+          </div>
+        </el-tab-pane>
+        <el-tab-pane label="已完成" name="ending">
+          <div class="tag_list">
+            <el-tag style="margin-right: 10px;" :type="item.type" effect="plain" v-for="(item, index) in executeData"
+              :key="index" @click="getSop(item)">{{item.sopName}}</el-tag>
+          </div>
+          <div class="content">
+            <div class="sop_content">
+              <img class="icon_logo" :src="sopItem.clientAvatar || './img/avatar.png'"></img>
+              <span>「{{sopItem.clientName}}」在「{{timeFormat(sopItem.triggerTime, 'yyyy-MM-dd hh:mm:ss')}}」</span>
+              <span class="font" v-if="sopItem.triggerType">添加好友后触发客户SOP任务,</span>
+              <span class="font" v-else>打上标签后触发客户SOP任务,</span>
+              <span>快去跟进吧</span>
+            </div>
+          </div>
+          <div class="sop_list" v-for="(item, index) in sopPlans" :key="index">
+            <div class="sop_time">
+              <span class="dot">·</span>
+              {{timeFormat(item.executeTime, 'yyyy-MM-dd')}}
+            </div>
+            <div class="sop_item">
+              <div><span style="color: #1890ff;">{{timeFormat(item.executeTime, 'hh:mm:ss')}}</span>发送<span style="color: #999;">{{item.isSend ? '(已发送)' : ''}}</span></div>
+              <div class="sop_body" v-if="item.ctOthers.length > 0">
+                <div v-for="(c, cIndex) in item.ctOthers" :key="cIndex">
+                  <div class="sop_c" v-if="c.matterType === 0">
+                    <span>{{ c.matterText }}</span>
+                  </div>
+                  <div class="sop_c" v-if="c.matterType === 1">
+                    <img style="width: 100px;" :src="c.imgUrl" />
+                  </div>
+                  <div class="sop_c" v-if="c.matterType === 5">
+                    <span>{{ c.linkTitle }}</span>
+                  </div>
+                  <div class="sop_c" v-if="c.matterType === 2">
+                    <span>自定义视频</span>
+                  </div>
+                  <div class="sop_c" v-if="c.matterType === 4">
+                    <span>{{ c.fileName }}</span>
+                  </div>
+                  <div class="sop_foot">
+                    <div class="sop_btn" @click="handleSend(item.id, c)">发送</div>
+                  </div>
+                </div>
+              </div>
+            </div>
+          </div>
+        </el-tab-pane>
+      </el-tabs>
+    </div>
+  </div>
+</body>
+<script>
+  new Vue({
+    el: '#box',
+    data() {
+      return {
+        httpUrl: '',
+        bId: null,
+        env: '',
+        memberId: null,
+        activeName: 'playing',
+        executeData: [],
+        sopItem: {},
+        sopPlans: [],
+        historyId: null,
+        externalUserId: null,
+      }
+    },
+    created() {
+      this.bId = this.getQueryParam('bId')
+      this.env = this.getQueryParam('env')
+
+      if (!this.env || this.env === 'prod') {
+        this.httpUrl = 'https://wlapi.wefanbot.com'
+      } else {
+        this.httpUrl = 'http://test.wefanbot.com:18993'
+      }
+      if (this.getQueryParam('memberId')) {
+        // 已授权
+        this.memberId = this.getQueryParam('memberId')
+        this.getQyWxSign()
+      } else {
+        // 授权
+        this.getAuth()
+      }
+      // this.memberId = "woU17nDAAAnoSca19vZVKiNEKdc9tyYQ"
+      // this.externalUserId = "wmU17nDAAAGT2PF6G8PUHdSx2DY1ljpg"
+      // this.executeSopList()
+    },
+    methods: {
+      getAuth() {
+        fetch(this.httpUrl + `/p/insuite/p/getRedirectUri?env=${this.env}&bId=${this.bId}`)
+          .then(res => {
+            return res.json()
+          }).then(result => {
+            let { data, code, msg } = result
+            if (code === 1) {
+              window.location.replace(data)
+            } else {
+              this.$message({
+                message: msg,
+                type: 'warning'
+              })
+            }
+          })
+      },
+      getQyWxSign() {
+        fetch(this.httpUrl + '/scrm/v1/wxcp-corp/p/getAgentConfig', {
+          method: 'post',
+          body: JSON.stringify({
+            bId: this.bId,
+            url: window.location.href,
+          }),
+          headers: {
+            'Content-Type': 'application/json'
+          }
+        }).then(res => {
+          return res.json()
+        }).then(result => {
+          let { data, code, msg } = result
+          if (code === 1) {
+            let that = this
+            wx.agentConfig({
+              corpid: data.corpid,
+              agentid: data.agentId,
+              timestamp: data.timestamp, // 必填,生成签名的时间戳
+              nonceStr: data.nonceStr, // 必填,生成签名的随机串
+              signature: data.agentSignature, // 必填,签名,见附录1
+              jsApiList: ['getCurExternalChat'], // 必填,需要使用的JS接口列表
+              success: function (res) {
+                // 回调
+                // 此处直接在注入回调中调用了获取当前外部联系人userId的接口,注意此接口是从聊天框的工具栏进入才能获取
+                wx.invoke('getCurExternalChat', {
+                }, function (res) {
+                  if (res.err_msg == "getCurExternalChat:ok") {
+                    that.externalUserId = res.chatId
+                    that.executeSopList()
+                  } else {
+                    //错误处理
+                    console.log('invoke失败:', res)
+                  }
+                });
+
+              },
+              fail: function (res) {
+                if (res.errMsg.indexOf('function not exist') > -1) {
+                  alert('版本过低请升级');
+                }
+              },
+              complete: function (res) {
+                // 回调
+                console.log('complete1', res);
+              }
+            });
+
+          } else {
+            this.$message({
+              message: msg,
+              type: 'warning'
+            })
+          }
+        })
+      },
+      handleClickTab(tab) {
+        this.executeData = []
+        this.sopItem = {}
+        this.sopPlans = []
+        this.historyId = null
+        if (tab.name === 'playing') {
+          this.executeSopList(0)
+        } else {
+          this.executeSopList(1)
+        }
+      },
+      //获取执行中的sop计划
+      executeSopList(status) {
+        fetch(this.httpUrl + `/scrm/v1/wxcp-group-sop/p/executeSopList?chatId=${this.externalUserId}&memberId=${this.memberId}&bId=${this.bId}&status=${status || 0}`)
+          .then(res => {
+            return res.json()
+          }).then(result => {
+            let { data, code, msg } = result
+            if (code === 1) {
+              this.executeData = data
+              if (data.length > 0) {
+                this.executeData.forEach(i => {
+                  i.type = ''
+                })
+                this.getSop(data[0], status)
+              }
+            } else {
+              this.$message({
+                message: msg,
+                type: 'warning'
+              })
+            }
+          })
+      },
+      getSop(item, status) {
+        this.sopItem = item
+        this.executeData.forEach(i => {
+          if (i.sopId !== item.sopId) {
+            i.type = ''
+          } else {
+            i.type = 'success'
+          }
+        })
+        this.getSopHistoryList(item, status)
+      },
+      // 获取sop内容
+      getSopHistoryList(item, status) {
+        fetch(this.httpUrl + `/scrm/v1/wxcp-group-sop/p/executeSopHistoryList?groupId=${item.groupId}&memberId=${this.memberId}&sopId=${item.sopId}&status=${status || 0}`)
+          .then(res => {
+            return res.json()
+          }).then(result => {
+            let { data, code, msg } = result
+            if (code === 1) {
+              this.sopPlans = data
+            } else {
+              this.$message({
+                message: msg,
+                type: 'warning'
+              })
+            }
+          })
+      },
+      handleSend(historyId, c) {
+        this.historyId = historyId
+        if (c.matterType === 1 || c.matterType === 2 || c.matterType === 4) {
+          fetch(this.httpUrl + `/scrm/v1/wxcp-group-sop/p/getMedia?planContentId=${c.id}`)
+            .then(res => {
+              return res.json()
+            }).then(result => {
+              let { data, code, msg } = result
+              if (code === 1) {
+                this.sendData(c, data.mediaId)
+              } else {
+                this.$message({
+                  message: msg,
+                  type: 'warning'
+                })
+              }
+            })
+        } else {
+          this.sendData(c)
+        }
+      },
+      sendData(c, mediaId) {
+        fetch(this.httpUrl + '/scrm/v1/wxcp-corp/p/getAgentConfig', {
+          method: 'post',
+          body: JSON.stringify({
+            bId: this.bId,
+            url: window.location.href,
+          }),
+          headers: {
+            'Content-Type': 'application/json'
+          }
+        }).then(res => {
+          return res.json()
+        }).then(result => {
+          let { data, code, msg } = result
+          if (code === 1) {
+            let that = this
+            wx.agentConfig({
+              corpid: data.corpid,
+              agentid: data.agentId,
+              timestamp: data.timestamp, // 必填,生成签名的时间戳
+              nonceStr: data.nonceStr, // 必填,生成签名的随机串
+              signature: data.agentSignature, // 必填,签名,见附录1
+              jsApiList: ['sendChatMessage'], // 必填,需要使用的JS接口列表
+              success: function (res) {
+                // 回调
+                if (c.matterType === 0) {
+                  wx.invoke('sendChatMessage', {
+                    msgtype: "text", //消息类型,必填
+                    enterChat: false, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
+                    text: {
+                      content: c.matterText, //文本内容
+                    },
+                  }, function (res) {
+                    if (res.err_msg == 'sendChatMessage:ok') {
+                      that.updateSop()
+                      //发送成功
+                      that.$message({
+                        message: '发送成功',
+                        type: 'success'
+                      })
+                    }
+                  })
+                } else if (c.matterType === 1) {
+                  wx.invoke('sendChatMessage', {
+                    msgtype: "image", //消息类型,必填
+                    enterChat: false, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
+                    image:
+                    {
+                      mediaid: mediaId, //图片的素材id
+                    },
+                  }, function (res) {
+                    if (res.err_msg == 'sendChatMessage:ok') {
+                      that.updateSop()
+                      //发送成功
+                      that.$message({
+                        message: '发送成功',
+                        type: 'success'
+                      })
+                    }
+                  })
+                } else if (c.matterType === 2) {
+                  wx.invoke('sendChatMessage', {
+                    msgtype: "video", //消息类型,必填
+                    enterChat: false, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
+                    video:
+                    {
+                      mediaid: mediaId, //视频的素材id
+                    },
+                  }, function (res) {
+                    if (res.err_msg == 'sendChatMessage:ok') {
+                      that.updateSop()
+                      //发送成功
+                      that.$message({
+                        message: '发送成功',
+                        type: 'success'
+                      })
+                    }
+                  })
+                } else if (c.matterType === 4) {
+                  wx.invoke('sendChatMessage', {
+                    msgtype: "file", //消息类型,必填
+                    enterChat: false, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
+                    file:
+                    {
+                      mediaid: mediaId, //文件的素材id
+                    },
+                  }, function (res) {
+                    if (res.err_msg == 'sendChatMessage:ok') {
+                      that.updateSop()
+                      //发送成功
+                      that.$message({
+                        message: '发送成功',
+                        type: 'success'
+                      })
+                    }
+                  })
+                } else if (c.matterType === 5) {
+                  wx.invoke('sendChatMessage', {
+                    msgtype: "news", //消息类型,必填
+                    enterChat: false, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
+                    news:
+                    {
+                      link: c.linkUrl, //H5消息页面url 必填
+                      title: c.linkTitle, //H5消息标题
+                      desc: c.linkDescription, //H5消息摘要
+                      imgUrl: c.linkThumbUrl, //H5消息封面图片URL 
+                    }
+                  }, function (res) {
+                    if (res.err_msg == 'sendChatMessage:ok') {
+                      that.updateSop()
+                      //发送成功
+                      that.$message({
+                        message: '发送成功',
+                        type: 'success'
+                      })
+                    }
+                  })
+                }
+              },
+              fail: function (res) {
+                if (res.errMsg.indexOf('function not exist') > -1) {
+                  alert('版本过低请升级');
+                }
+              },
+              complete: function (res) {
+                // 回调
+                console.log('complete', res);
+              }
+            });
+          } else {
+            this.$message({
+              message: msg,
+              type: 'warning'
+            })
+          }
+        })
+      },
+      // 发送成功后刷新数据
+      updateSop() {
+        fetch(this.httpUrl + `/scrm/v1/wxcp-group-sop/p/updateHistorySendStatus?historyId=${this.historyId}`)
+          .then(res => {
+            return res.json()
+          }).then(result => {
+            let { data, code, msg } = result
+            if (code === 1) {
+              this.getSopHistoryList(this.sopItem)
+            } else {
+              this.$message({
+                message: msg,
+                type: 'warning'
+              })
+            }
+          }).finally(() => {
+            this.historyId = null
+          })
+      },
+      // 截取url中的数据
+      getQueryParam(paramName) {
+        // 获取当前URL的查询字符串部分  
+        const queryString = window.location.search;
+        // 创建一个URLSearchParams对象  
+        const urlParams = new URLSearchParams(queryString);
+        // 返回指定参数的值,如果不存在则返回null  
+        return urlParams.get(paramName);
+      },
+      timeFormat(time, format = 'yyyy-MM-dd hh:mm:ss') {
+        if (time === undefined || time === '' || time === null) {
+          return '/';
+        }
+
+        const date = new Date(time);
+        const o = {
+          'M+': date.getMonth() + 1, // 月份
+          'd+': date.getDate(),      // 日
+          'h+': date.getHours(),     // 小时
+          'm+': date.getMinutes(),   // 分钟
+          's+': date.getSeconds(),   // 秒
+          'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
+          'S': date.getMilliseconds() // 毫秒
+        };
+
+        // 处理年份
+        if (/(y+)/.test(format)) {
+          format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
+        }
+
+        // 处理日期和时间部分
+        for (let k in o) {
+          if (new RegExp('(' + k + ')').test(format)) {
+            let value = o[k];
+            let padding = RegExp.$1.length === 1 ? '' : '00'; // 根据格式字符串中的长度决定是否补零
+            format = format.replace(RegExp.$1, ('' + value).padStart(padding.length + value.toString().length - value.toString().length, '0'));
+          }
+        }
+
+        // 如果格式只包含时间部分,移除日期部分可能的占位符
+        if (!/(M+|d+)/.test(format)) {
+          // 移除任何可能存在的日期占位符(如:'yyyy-MM-dd ')
+          format = format.replace(/(\s*-\s*){2}/g, ''); // 移除两个'-'之间的任何内容
+          format = format.replace(/^\s*yyyy-\s*/, ''); // 移除开头的'yyyy-'
+        }
+
+        // 如果格式只包含日期部分,移除时间部分可能的占位符
+        if (!/(h+|m+|s+)/.test(format)) {
+          // 移除任何可能存在的时间占位符(如:' hh:mm:ss')
+          format = format.replace(/(\s*:\s*){2}/g, ''); // 移除两个':'之间的任何内容
+          format = format.replace(/\s*hh:\s*$/, ''); // 移除结尾的' hh:'
+        }
+
+        return format;
+      }
+    }
+  })   
+</script>
+
+</html>

+ 4 - 5
lottery/groupSopTip.html

@@ -5,7 +5,7 @@
   <meta charset="UTF-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
-  <title>数据查看</title>
+  <title>客户群SOP</title>
   <!--引入 element-ui 的样式,-->
   <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
   <!-- 必须先引入vue,  后使用element-ui -->
@@ -182,7 +182,7 @@
           triggerTime: '',
           triggerType: '',
           ctOthers: [],
-          externalUserid: '',
+          chatId: '',
           clientAvatar: '',
         },
       }
@@ -201,7 +201,7 @@
     },
     methods: {
       executeDetail() {
-        fetch(this.httpUrl + `/scrm/v1/wxcp-sop/p/executeDetail?id=${this.bId}`)
+        fetch(this.httpUrl + `/scrm/v1/wxcp-group-sop/p/executeDetail?id=${this.bId}`)
           .then(res => {
             return res.json()
           }).then(result => {
@@ -273,9 +273,8 @@
       },
       toFollow() {
         wx.openEnterpriseChat({
-          externalUserIds: this.executeData.externalUserid, // 参与会话的外部联系人列表,格式为userId1;userId2;…,用分号隔开。
           groupName: "",  // 会话名称。单聊时该参数传入空字符串""即可。
-          chatId: "",
+          chatId: this.executeData.chatId,
           success: function (res) {
             var chatId = res.chatId; //返回当前群聊ID,仅当使用agentConfig注入该接口权限时才返回chatId
             // 回调

+ 114 - 37
lottery/index.html

@@ -491,23 +491,44 @@
 			</div>
 		</el-dialog>
 		<el-dialog title="请问您是否已购五菱/宝骏车型?" :visible.sync="showTipDialog" :show-close="false" :close-on-click-modal="false">
-			<el-form :model="form" class="prize_form"label-position="top">
-				<el-form-item label="姓名:">
-					<el-radio-group v-model="radioYesNo">
-						<el-radio :label="1">是</el-radio>
-						<el-radio :label="0">否</el-radio>
-					</el-radio-group>
-				</el-form-item>
-				<el-form-item label="已购车型:" v-if="radioYesNo === 1">
-					<el-select v-model="carData" placeholder="请选择">
-						<el-option
-							v-for="item in allCarList"
-							:key="item"
-							:label="item"
-							:value="item">
-						</el-option>
-					</el-select>
-				</el-form-item>
+			<el-form :model="getInfoForm" class="prize_form"label-position="top">
+				<div v-if="preFormType">
+					<el-form-item label="手机号:">
+						<el-input type="number" v-model="getInfoForm.phone" autocomplete="off"
+						maxlength="11"
+						oninput="value=value.replace(/[^\d]/g,'')" 
+						@blur="$event => {getInfoForm.phone = Number($event.target.value) || '';}"
+						></el-input>
+					</el-form-item>
+					<el-form-item label="地址:">
+						<el-cascader v-model="cityData" :options="transformedData" @change="handleInfoCity">
+						</el-cascader>
+					</el-form-item>
+					<el-form-item label="意向车型:">
+						<el-select v-model="getInfoForm.intenModel" placeholder="请选择">
+							<el-option
+								v-for="item in allCarList"
+								:key="item"
+								:label="item"
+								:value="item">
+							</el-option>
+						</el-select>
+					</el-form-item>
+				</div>
+				<div v-else>
+					<el-form-item label="确认:">
+						<el-radio-group v-model="getInfoForm.buyCar">
+							<el-radio :label="1">是</el-radio>
+							<el-radio :label="0">否</el-radio>
+						</el-radio-group>
+					</el-form-item>
+					<el-form-item label="已购车型:" v-if="getInfoForm.buyCar">
+						<el-select v-model="getInfoForm.car" placeholder="请选择">
+							<el-option v-for="item in allCarList" :key="item" :label="item" :value="item">
+							</el-option>
+						</el-select>
+					</el-form-item>
+				</div>
 			</el-form>
 			<div slot="footer" class="dialog-footer">
 				<el-button type="primary" @click="handleSaveCar">确 定</el-button>
@@ -519,7 +540,8 @@
         el: '#box',
         data() {
           return {
-						httpUrl: true,
+          	env: '',
+						httpUrl: '',
 						h5Type: null,
 						qrCodeData: {
 							qrCode: '',
@@ -550,8 +572,14 @@
 						cityData: '',
 						showTipDialog: false,
 						allCarList: [],
-						radioYesNo: 1,
-						carData: '',
+						getInfoForm: {
+							buyCar: 1,
+							phone: '',
+							province: '',
+							city: '',	
+							intenModel: '',
+							car: '',
+						},
 						prizeData: {
 							acceptType: null,
 							name: '',
@@ -564,17 +592,19 @@
 						currentIndex: 0, // 当前活动的格子索引
 						isSpinning: false,
 						intervalId: null,
-						showRuleDialog: false
+						showRuleDialog: false,
+						preFormType: null,
           }
         },
         created() {
-					if (this.httpUrl) {
+					this.bId = this.getQueryParam('bId')
+					this.env = this.getQueryParam('env')
+					this.h5Type = this.getQueryParam('h5Type')
+					if (!this.env || this.env === 'prod') {
 						this.httpUrl = 'https://wlapi.wefanbot.com'
 					} else {
 						this.httpUrl = 'http://test.wefanbot.com:18993'
 					}
-					this.bId = this.getQueryParam('bId')
-					this.h5Type = this.getQueryParam('h5Type')
 					if (this.h5Type == 19) {
 						if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
 							if (!this.getQueryParam('externalUserid')) {
@@ -622,6 +652,10 @@
 						// 群SOP提醒
 						var currentQueryParams = window.location.search;
 						window.location.replace('groupSopTip.html' + currentQueryParams)
+					} else if (this.h5Type == 27) {
+						// 群SOP内容
+						var currentQueryParams = window.location.search;
+						window.location.replace('groupSop.html' + currentQueryParams)
 					} else if (!this.h5Type) {
 						this.getAuth()
 					}
@@ -731,7 +765,7 @@
 					},
 					// 获取抽奖信息
 					raffleInfo () {
-            fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/raffleInfoByOpenId?openId=${this.getQueryParam('openId') || localStorage.getItem('openId')}&raffleId=${this.bId}`)
+            fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/raffleInfoByOpenId?openId=${this.getQueryParam('openId') || localStorage.getItem('openId')}&bId=${this.bId}`)
               .then(res => {
 								return res.json()
               }).then(result => {
@@ -745,7 +779,8 @@
 									this.shareTitle = data.name
 									this.shareDes = data.description
 									this.shareCover = data.cover
-									if (data.preForm) {
+									this.preFormType = data.preFormType
+									if (data.preForm && !data.isSubmit) {
 										this.showTipDialog = true
 									}
 								}
@@ -757,7 +792,7 @@
               method: 'post',
               body: JSON.stringify({
                 openId: this.getQueryParam('openId') || localStorage.getItem('openId'),
-								raffleId: this.bId,
+								bid: this.bId,
 								page: 1,
 								pageCount: 1000,
               }),
@@ -823,19 +858,57 @@
 						})
 					},
 					handleSaveCar () {
-						if (this.radioYesNo && !this.carData) {
-							this.$message({
-								message: '请选择已购车型',
-								type: 'warning'
-							})
-							return
+						if (this.preFormType) {
+							if (!this.getInfoForm.phone) {
+								this.$message({
+									message: '请输入手机号',
+									type: 'warning'
+								})
+								return
+							}
+							if (!this.getInfoForm.city) {
+								this.$message({
+									message: '请选择城市',
+									type: 'warning'
+								})
+								return
+							}
+							if (!this.getInfoForm.intenModel) {
+								this.$message({
+									message: '请选择意向车型',
+									type: 'warning'
+								})
+								return
+							}
+							this.getInfoForm.buyCar = null
+							this.getInfoForm.car = ''
+						} else {
+							if (this.getInfoForm.buyCar) {
+								if (!this.getInfoForm.car) {
+									this.$message({
+										message: '请选择已购车型',
+										type: 'warning'
+									})
+									return	
+								}
+							} else {
+								this.getInfoForm.car = ''
+							}
+							this.getInfoForm.phone = ''
+							this.getInfoForm.province = ''
+							this.getInfoForm.city = ''
+							this.getInfoForm.intenModel = ''
 						}
 						fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/submitPreForm', {
               method: 'post',
               body: JSON.stringify({
 								bid: this.bId,
-								buyCar: this.radioYesNo,
-								car: this.radioYesNo ? this.carData : '',
+								buyCar: this.getInfoForm.buyCar,
+								car: this.getInfoForm.car,
+								phone: this.getInfoForm.phone,
+								province: this.getInfoForm.province,
+								city: this.getInfoForm.city,
+								intenModel: this.getInfoForm.intenModel,
 								mpOpenId: this.getQueryParam('openId') || this.localStorage.getItem('openId'),
 							}),
               headers: {
@@ -865,7 +938,7 @@
 					},
 					// 获取全部车型
 					getAllCar () {
-						fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/getCarList`)
+						fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/getCarList?bId=${this.bId}`)
               .then(res => {
 								return res.json()
               }).then(result => {
@@ -879,6 +952,10 @@
 						this.form.province = value[0]
 						this.form.city = value[1]
 					},
+					handleInfoCity (value) {
+						this.getInfoForm.province = value[0]
+						this.getInfoForm.city = value[1]	
+					},
 					// 点击抽奖
 					handleLottery () {
 						if (!this.remainNum) {
@@ -906,7 +983,7 @@
 							let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
 							const headers = new Headers();
 							headers.append('police', 110);
-							fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/lottery?externalUserid=${externalUserid}&openId=${openId}&raffleId=${this.bId}`, {
+							fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/lottery?externalUserid=${externalUserid}&openId=${openId}&bId=${this.bId}`, {
 								method: 'GET',
 								headers: headers
 							})