Переглянути джерело

feat:移动端市场分析报告新增功能

yangfeng 1 рік тому
батько
коміт
a548bcb427

+ 1 - 1
src/jfw/modules/app/src/web/templates/big-member/page_report_analysis_history.html

@@ -31,7 +31,7 @@
             </van-tabs>
             <section v-show="tabActiveName === 'analysis'" class="j-main analysis-content"></section>
             <section v-show="tabActiveName === 'history'" class="j-main history-content">
-                <report-list-mobile-component ref="list" @go-report="goToAnalysis"></report-list-mobile-component>
+                <report-list-mobile-component ref="list" @go-report="goToAnalysis"  @go-delete="goDelete"></report-list-mobile-component>
             </section>
         </div>
     </div>

+ 1 - 1
src/web/staticres/common-module/collection/js/keyword-mobile.js

@@ -198,7 +198,7 @@ var keywordComponent = {
           if(_this.protype == 'bigmember') {
             if(res.error_code == 0) {
               let maxarr = []
-              if(res.data) {
+              if(res.data && res.data.member_jy) {
                 let data = res.data.member_jy.a_items
                 _this.keywordGroupList = data
                 data.forEach(function(item,index) {

+ 44 - 5
src/web/staticres/common-module/diy-report/css/report-list.css

@@ -12,7 +12,7 @@
     background: #FFFFFF;
     box-shadow: 0px 2px 8px 1px rgba(54, 147, 179, 0.05);
     border-radius: 8px;
-    padding: .32rem .24rem;
+    padding: 0 .32rem .32rem;
     box-sizing: border-box;
     font-size: .26rem;
     font-weight: 500;
@@ -20,10 +20,10 @@
     line-height: .4rem;
 }
 .info-card-item .text-title {
-    font-size: .3rem;
+    font-size: .26rem;
     font-weight: 700;
     color: #161826;
-    line-height: .44rem;
+    line-height: .4rem;
 }
 .info-flex-r-box {
     display: flex;
@@ -44,7 +44,7 @@
     align-items: flex-start;
     justify-content: flex-start;
 }
-.info-card-item button {
+/* .info-card-item button {
     display: flex;
     align-items: center;
     justify-content: center;
@@ -58,7 +58,7 @@
     font-weight: 400;
     color: #FFFFFF;
     border: none;
-}
+} */
 .info-card-item .toggle-row-box i {
     font-size: .32rem;
     margin-left: .04rem;
@@ -85,3 +85,42 @@
     font-size: .26rem;
     color: #161826;
 }
+.info-status-header{
+  display: flex;
+  justify-content: space-between;
+  padding: 0 0 .32rem 0;
+}
+.info-status-header .r-status{
+  flex-shrink: 0;
+  margin-left: -0.32rem;
+  padding: 0.04rem .24rem;
+  font-size: .26rem;
+  line-height: .4rem;
+  color: #fff;
+  border-radius: 0.16rem 0 .16rem 0;
+}
+.info-status-header .r-status.green{
+  background: #0BD991;
+}
+.info-status-header .r-status.yellow{
+  background: #FF9F40;
+}
+.info-status-header .r-status.red{
+  background: #FB483D;
+}
+.info-status-header .r-notes{
+  margin-left: .24rem;
+  padding-top: 0.12rem;
+  font-size: .26rem;
+  color: #5F5E64;
+  white-space: nowrap;
+  text-overflow: ellipsis;
+  overflow: hidden;
+}
+.j-button-group{
+  padding: .24rem 0 0;
+}
+.j-button-group button{
+  border-radius: 0.12rem;
+  height: .72rem;
+}

+ 52 - 2
src/web/staticres/common-module/diy-report/js/report-list.js

@@ -14,8 +14,18 @@ var reportListTemplate = `
             </div>
         </div>
         <div class="info-card-item" v-for="(item, i) in reportList" :key="item.id" :class="{ 'card-opened': item.open }">
+            <div class="info-status-header">
+              <div class="r-status" :class="getStatusBg(item.state)" v-if="item.state || item.state === 0">@@getStatusTitle(item.state)@@</div>
+              <div class="r-notes" v-if="item.state === 0">
+                <span v-if="item.msgOpen">请留意微信、APP报告生成成功消息提醒</span>
+                <div class="info-flex-r-box" @click.stop="goSetPush" v-else><span class="ellipsis">前往开启【消息-服务通知】提醒</span><van-icon name="arrow" style="margin-left:4px;"></van-icon></div>
+              </div>
+              <div class="r-notes" v-if="item.state >= 1 && item.updateTime">
+                于<span class="highlight-text">@@(item.updateTime * 1000)|formatTime('yyyy-MM-dd HH:mm:ss')@@</span><span v-if="item.state === 1">生成成功</span><span v-else>取消</span>
+              </div>
+            </div>
             <div class="info-flex-r-box">
-                <div class="text-title">报告&nbsp;@@(item.createTime * 1000)|formatTime('yyyy.MM.dd HH:mm:ss')@@</div>
+                <div class="text-title">发起时间:@@(item.createTime * 1000)|formatTime('yyyy-MM-dd HH:mm:ss')@@</div>
                     <div class="info-flex-r-box toggle-row-box" @click="item.open = !item.open">
                         <span>@@item.open ? '收起' : '展开'@@条件</span>
                         <transition name="van-fade">
@@ -63,7 +73,13 @@ var reportListTemplate = `
                         </div>
                     </div>
                 </div>
-                <button @click="goReport(item.id)">查看报告</button>
+                <div class="j-button-group" v-if="item.state === 1">
+                  <button class="j-button-cancel" @click="goDelete(item.id)">删除</button>
+                  <button class="j-button-confirm" @click="goReport(item.id)">查看</button>
+                </div>
+                <div class="j-button-group" v-else>
+                  <button class="j-button-confirm" @click="goDelete(item.id)">删除</button>
+                </div>
             </div>
         </div>
     </van-list>
@@ -149,6 +165,9 @@ var reportListMobileComponent = {
         goReport: function (id) {
             this.$emit('go-report', id)
         },
+        goDelete: function (id) {
+            this.$emit('go-delete', id)
+        },
         getList: function () {
             $.ajax({
                 url: '/bigmember/marketAnalysis/analysisHistory',
@@ -229,6 +248,37 @@ var reportListMobileComponent = {
                 }
             } catch (e) {}
             return tempStr
+        },
+        getStatusTitle: function (state) {
+          switch (state) {
+            case 0:
+              return '报告生成中'
+            case 1:
+              return '报告生成成功'
+            case 2:
+              return '报告已取消'
+          }
+        },
+        getStatusBg: function (state) {
+          switch (state) {
+            case 0:
+              return 'yellow'
+            case 1:
+              return 'green'
+            case 2:
+              return 'red'
+          }
+        },
+        goSetPush: function () {
+          location.href = '/jy_mobile/push/pushsetting'
+        },
+        onRefresh: function () {
+          this.listState.pageNum = 1
+          this.listState.loaded = false
+          this.listState.loading = true
+          this.listState.finished = false
+          this.reportList = []
+          this.getList()
         }
     }
 }

+ 9 - 2
src/web/staticres/common-module/report-analysis/css/report_analysis.css

@@ -42,8 +42,8 @@
   color: #5F5E64;
 }
 .van-dialog .van-button {
-  font-size: 18px;
-  line-height: 26px;
+  font-size: .36rem;
+  line-height:.52rem;
 }
 
 .van-dialog  .van-button--default {
@@ -67,12 +67,19 @@
 }
 .j-confirm-dialog.text-center .van-dialog__message {
   text-align: center;
+  color: #5F5E64;
 }
 .j-confirm-dialog .van-button {
   font-size: .36rem;
   color: #171826;
   line-height: .52rem;
 }
+.j-confirm-dialog.text-justify .van-dialog__message {
+  font-size: .3rem!important;
+  color: #5F5E64!important;
+  line-height: .44rem!important;
+  text-align: justify!important;
+}
 
 /* j-tag */
 .j-tag {

+ 82 - 8
src/web/staticres/common-module/report-analysis/js/report_analysis.js

@@ -857,25 +857,78 @@ var vm = new Vue({
 
       this.analysis.loaded = false
       this.analysis.loading = true
-      this.showLoading()
-
+      var loading = this.showLoading()
+      /* 
+        1.如该用户当前身份下存在“生成中”的报告 则弹框提示报告生成中等等。。。
+        2.该用户不存在“生成中”的报告,且该报告需要离线生成
+         2-1:【消息-服务通知】APP、微信提醒均未开启 则弹框提示去开启
+         2-2:【消息-服务通知】APP或微信提醒已开启 则弹框提示我知道了
+      */
       $.ajax({
         type: 'POST',
         url: '/bigmember/marketAnalysis/doAnalysis',
         data: query,
         success: function (res) {
+          loading.clear()
           if (res && res.error_code === 0 && res.data) {
-            this.rid = res.data
-            this.analysis.loaded = true
-            // location.replace('./report_analysis?id=' + res.data)
-            this.rid = res.data
-            history.replaceState({}, null, '?id=' + this.rid)
-            this.getReportResult()
+            // id:报告id
+            // msgOpen:微信或APP提醒是否打开(离线生成时会返回该字段)
+            // status:0-在线生成 走原逻辑 1-离线生成 (判断msgOpen出提示文案) 2-存在正在生成的报告(需要出弹出提示,由用户确认,id为需要取消的报告id,如果用户确认,则传该id调用取消接口后再次调用分析接口)
+            if (res.data.status === 0) {
+              this.rid = res.data.id
+              this.analysis.loaded = true
+              // location.replace('./report_analysis?id=' + res.data)
+              this.rid = res.data.id
+              history.replaceState({}, null, '?id=' + this.rid)
+              this.getReportResult()
+            } else if (res.data.status === 1) {
+              return this.showDialog({
+                allowHtml: true,
+                title: '报告生成中',
+                message: res.data.msgOpen ? '由于您的分析内容较多,报告正在努力生成中,生成成功后将会通过微信、APP给您发送1消息通知,届时您再前往查看此报告。' : '由于您的分析内容较多,报告正在努力生成中。建议您前往开启“<span class="highlight-text">消息-服务通知</span>”提醒,报告生成成功后可通过微信或APP给您发送1消息通知,届时您可前往查看此报告。',
+                className: 'j-confirm-dialog text-justify',
+                showCancelButton: !res.data.msgOpen,
+                confirmButtonText: res.data.msgOpen ? '我知道了' : '去开启',
+                cancelButtonText: res.data.msgOpen ? '' : '暂不开启',
+                beforeClose: (action, done) => {
+                  if (action === 'confirm') {
+                    if (!res.data.msgOpen) {
+                      // 去开启  进到推送设置页面
+                      location.href = '/jy_mobile/push/pushsetting'
+                    } else {
+                      // 我知道了 回到历史报告页面
+                      this.goToAnalysisHistory()
+                    }
+                  } else {
+                    // 暂不开启  回到历史报告页面
+                    this.goToAnalysisHistory()
+                  }
+                  done()
+                }
+              })
+            } else if (res.data.status === 2) {
+              return this.showDialog({
+                title: '报告生成确认',
+                message: '您有1份报告正在“生成中”,请确定是否按照此条件重新生成,注:如确定则原状态为“生成中”的报告将被自动取消。',
+                className: 'j-confirm-dialog text-justify',
+                beforeClose: (action, done) => {
+                  if (action === 'confirm') {
+                    this.reportCancel(res.data.id)
+                    done()
+                  } else {
+                    done()
+                  }
+                }
+              })
+            }
+            
           } else {
+            loading.clear()
             this.$toast(res.error_msg)
           }
         }.bind(this),
         complete: function () {
+          loading.clear()
           this.analysis.loading = false
         }.bind(this)
       })
@@ -2097,6 +2150,27 @@ var vm = new Vue({
           location.href = `./unit_portrayal?entName=${id}`
         }
       }
+    },
+    // 报告取消
+    reportCancel: function (id) {
+      var _this = this
+      $.ajax({
+        type: 'POST',
+        url: '/bigmember/marketAnalysis/cancel',
+        data: {
+          rid: id
+        },
+        success: function (res) {
+          if (res.data) {
+            _this.startAnalysis()
+          } else {
+            _this.showToast(res.error_msg)
+          }
+        },
+        error: function (error) {
+          console.error(error)
+        }
+      })
     }
   }
 })

+ 119 - 6
src/web/staticres/common-module/report-analysis/js/report_analysis_history.js

@@ -101,16 +101,107 @@ var vm = new Vue({
     beforeTabChange: function (name) {
       if (name !== this.tabActiveName) {
         this.saveState()
-        this.goToAnalysis()
+        // this.goToAnalysis()
+        var href = './report_analysis'
+        location.replace(href)
       }
       return false
     },
     goToAnalysis: function (id) {
-      var href = './report_analysis'
-      if (id) {
-        href += ('?id=' + id)
-      }
-      location.replace(href)
+      var loading = this.showLoading()
+      var _this = this
+      $.ajax({
+        type: 'POST',
+        url: '/bigmember/marketAnalysis/isOffline',
+        data: {
+          rid: id
+        },
+        success: function (res) {
+          loading.clear()
+          if (res.data) {
+            if (res.data.status === 0) {
+              // 原逻辑
+              var href = './report_analysis'
+              if (id) {
+                href += ('?id=' + id)
+              }
+              location.replace(href)
+            } else if (res.data.status === 1) {
+              // 离线生成 (判断msgOpen 出提示文案)
+              _this.showDialog({
+                allowHtml: true,
+                title: '报告生成中',
+                message: res.data.msgOpen ? '由于您的分析内容较多,报告正在努力生成中,生成成功后将会通过微信、APP给您发送1消息通知,届时您再前往查看此报告。' : '由于您的分析内容较多,报告正在努力生成中。建议您前往开启“<span class="highlight-text">消息-服务通知</span>”提醒,报告生成成功后可通过微信或APP给您发送1消息通知,届时您可前往查看此报告。',
+                className: 'j-confirm-dialog text-justify',
+                showCancelButton: !res.data.msgOpen,
+                confirmButtonText: res.data.msgOpen ? '我知道了' : '去开启',
+                cancelButtonText: res.data.msgOpen ? '' : '暂不开启'
+              }).then(function () {
+                  // 未开启-去开启
+                  if (!res.data.msgOpen) {
+                    location.href = '/jy_mobile/push/pushsetting'
+                  }
+              })
+              .catch(function(error) {
+                console.log(error)
+              })
+            } else if (res.data.status === 2) {
+              // 存在正在生成的报告 需要出弹出提示,由用户确认,id为需要取消的报告id,如果用户确认,则传该id调用取消接口后再次调用该接口)
+              _this.showDialog({
+                title: '报告生成确认',
+                message: '您有1份报告正在“生成中”,请确定是否按照此条件重新生成,注:如确定则原状态为“生成中”的报告将被自动取消。',
+                className: 'j-confirm-dialog text-justify',
+              }).then(function () {
+                // 调用取消
+                _this.reportCancel(res.data.id)
+              })
+              .catch(function() {
+                console.log('catch')
+              })
+            }
+          } else {
+            _this.showToast(res.data.error_msg)
+          }
+        },
+        error: function (error) {
+          loading.clear()
+          console.warn(error)
+        }
+      })
+      
+    },
+    goDelete: function (id) {
+      var _this = this
+      _this.showDialog({
+        title: '报告删除确认',
+        message: '确定删除此报告吗?',
+        className: 'j-confirm-dialog text-center',
+      }).then(function (res) {
+          var loading = _this.showLoading()
+          $.ajax({
+            type: 'POST',
+            url: '/bigmember/marketAnalysis/delete',
+            data: {
+              rid: id
+            },
+            success: function (res) {
+              loading.clear()
+              if (res.data) {
+                _this.showToast('删除成功')
+                _this.$refs.list.onRefresh()
+              } else {
+                _this.showToast(res.error_msg || '删除失败')
+              }
+            },
+            error: function (error) {
+              loading.clear()
+              console.warn(error)
+            }
+          })
+      })
+      .catch(function() {
+          console.log('取消删除报告')
+      })
     },
     // 重置列表数据
     resetHistoryState: function () {
@@ -217,6 +308,28 @@ var vm = new Vue({
       }
 
       return $data
+    },
+    // 报告取消
+    reportCancel: function (id) {
+      var _this = this
+      $.ajax({
+        type: 'POST',
+        url: '/bigmember/marketAnalysis/cancel',
+        data: {
+          rid: id
+        },
+        success: function (res) {
+          if (res.data) {
+            _this.$refs.list.onRefresh()
+            _this.goToAnalysis(id)
+          } else {
+            _this.showToast(res.error_msg)
+          }
+        },
+        error: function (error) {
+          console.error(error)
+        }
+      })
     }
   }
 })

+ 1 - 1
src/web/templates/big-member/wx/page_report_analysis_history.html

@@ -44,7 +44,7 @@
           </van-tabs>
           <section v-show="tabActiveName === 'analysis'" class="j-main analysis-content"></section>
           <section v-show="tabActiveName === 'history'" class="j-main history-content">
-              <report-list-mobile-component ref="list" @go-report="goToAnalysis"></report-list-mobile-component>
+              <report-list-mobile-component ref="list" @go-report="goToAnalysis" @go-delete="goDelete"></report-list-mobile-component>
           </section>
       </div>
   </div>