Quellcode durchsuchen

feat: 支持代免费用户订阅

zhangyuhan vor 1 Woche
Ursprung
Commit
dbaf19b571

+ 10 - 0
apps/bigmember_pc/src/api/modules/public.js

@@ -16,6 +16,16 @@ export function getFreeUserPushInfo() {
   })
 }
 
+// 获取帮免费用户订阅信息列表
+export function getHelpFreeUserKeyList(data) {
+  data = qs.stringify(data)
+  return request({
+    url: '/publicapply/subscribe/freePositionList',
+    method: 'POST',
+    data
+  })
+}
+
 // 获取免费订阅信息接口
 export function getFreeUserSubscribeList() {
   return request({

+ 113 - 27
apps/bigmember_pc/src/views/subscribe/FreeConfig.vue

@@ -1,22 +1,35 @@
 <template>
   <div class="free-config-setting-container">
-    <div class="config-title">
-      订阅设置
-      <div class="subscribe-manage-tip">
-        注:修改完订阅条件后,预计30分钟左右生效。
+
+    <div class='config-title flex flex-(row items-center)'>
+      <h1>帮用户订阅(免费订阅)</h1>
+      <div class='flex flex-(row items-center)'>
+        <span>选择用户身份:</span>
+        <el-select v-model="checkUserKey" @change='doChangeUserKey' placeholder="请选择用户身份">
+          <el-option
+            v-for="item in userKeyList"
+            :key="item.value"
+            :label="item.label"
+            :value="item.value">
+          </el-option>
+        </el-select>
       </div>
     </div>
-    <!-- 订阅设置 -->
-    <free-sub-config :datas="setData" :setStatus="setStatus" @update="getUpdate"></free-sub-config>
-    <!-- 关键词设置 -->
-    <free-key-config id="setkey" :datas="setData" :setStatus="setStatus" @update="getUpdate"></free-key-config>
-    <!-- 关键词列表 -->
-    <key-list
-      v-if="setData.keyList.length > 0"
-      ref="keyConfigRef"
-      :datas="setData"
-      :setStatus="setStatus"
-    ></key-list>
+
+    <div v-loading='pageLoading'>
+      <!-- 订阅设置 -->
+      <free-sub-config :datas="setData" :setStatus="setStatus" @update="getUpdate"></free-sub-config>
+      <!-- 关键词设置 -->
+      <free-key-config id="setkey" :datas="setData" :setStatus="setStatus" @update="getUpdate"></free-key-config>
+      <!-- 关键词列表 -->
+      <key-list
+        v-if="setData.keyList.length > 0"
+        ref="keyConfigRef"
+        :datas="setData"
+        :setStatus="setStatus"
+      ></key-list>
+    </div>
+
     <el-dialog
       custom-class="small-dialog"
       title="关键词升级提示"
@@ -46,11 +59,11 @@
 </template>
 
 <script>
-import { Dialog, Button } from 'element-ui'
+import { Dialog, Button, Select, Option } from 'element-ui'
 import FreeSubConfig from './components/key/FreeSubConfig'
 import FreeKeyConfig from './components/key/FreeKeyConfig'
 import KeyList from './components/key/List'
-import { getFreeUserSubscribeList, setUserInfoVip, updateKey } from '@/api/modules'
+import { getFreeUserSubscribeList, setUserInfoVip, updateKey, getHelpFreeUserKeyList } from '@/api/modules'
 import $bus from '@/utils/bus'
 import { mixinNoOpenSetMessage } from '@/utils/mixins/subscribe-setting-prompt.js'
 import { getOneLevelNamesByValues } from '@/assets/js/selector'
@@ -60,12 +73,17 @@ export default {
   components: {
     [Dialog.name]: Dialog,
     [Button.name]: Button,
+    [Select.name]: Select,
+    [Option.name]: Option,
     KeyList,
     FreeSubConfig,
     FreeKeyConfig
   },
   data() {
     return {
+      pageLoading: true,
+      checkUserKey: '',
+      userKeyList: [],
       getBigInfoCount: 0,
       setData: {
         title: '关键词设置',
@@ -107,11 +125,19 @@ export default {
   },
   created() {
     if (!this.canSubmanager) {
-      history.back()
+      this.$alert('页面参数异常', '', {
+        confirmButtonText: '点击关闭页面',
+        confirmButtonColor: '#2ABDD1',
+        showClose: false,
+        center: true,
+        callback: action => {
+          history.back()
+        }
+      })
     }
-    this.getBigInfo()
   },
   mounted() {
+    this.getHelpUserList()
     $bus.$on('updateKey', (data) => {
       // this.updateKeyWordsApi(data)
       this.getBigInfo()
@@ -119,6 +145,51 @@ export default {
     setTimeout(this.scrollToId, 100)
   },
   methods: {
+    getHelpUserList () {
+      getHelpFreeUserKeyList({
+        phone: this.$route.query.phone,
+      }).then(res => {
+        if (res.data && Array.isArray(res.data) && res.data.length > 0) {
+          this.userKeyList = res.data.map(item => {
+            if (item.checked) {
+              this.checkUserKey = item.token
+            }
+            return {
+              label: item.name,
+              value: item.token
+            }
+          })
+          if (!this.checkUserKey) {
+            this.doChangeUserKey(this.userKeyList[0].value || '')
+          }
+        } else {
+          this.$alert(res.error_msg || '获取用户身份信息异常', '', {
+            confirmButtonText: '点击关闭页面',
+            confirmButtonColor: '#2ABDD1',
+            showClose: false,
+            center: true,
+            callback: action => {
+              history.back()
+            }
+          })
+        }
+      }).catch(e => {
+        this.$alert('获取用户身份信息异常', '', {
+          confirmButtonText: '点击关闭页面',
+          confirmButtonColor: '#2ABDD1',
+          showClose: false,
+          center: true,
+          callback: action => {
+            history.back()
+          }
+        })
+      })
+    },
+    doChangeUserKey (key = '') {
+      this.checkUserKey = key
+      this.$cookies.set('usrDewkYanV3', key)
+      this.getBigInfo()
+    },
     async setSwitchCallback() {
       // 调用api开启/关闭
       const { flag } = await setUserInfoVip({
@@ -164,10 +235,12 @@ export default {
       })
     },
     async getBigInfo() {
+      this.pageLoading = true
       this.getBigInfoCount += 1
       // const provinceArr = []
       // let areaArr = []
       const data = await getFreeUserSubscribeList()
+      this.pageLoading = false
       const res = data.data
       if (res) {
 
@@ -226,14 +299,14 @@ export default {
         this.setData.maxCount = 10
 
         if (!Array.isArray(res.keys) || res.keys.length === 0) {
-          setUserInfoVip({
-            pageType: 'keyWords',
-            actionType: 'SC',
-            classify_name: '未分类',
-            vSwitch: 'f'
-          }).then((res) => {
-            this.getBigInfo()
-          })
+          // setUserInfoVip({
+          //   pageType: 'keyWords',
+          //   actionType: 'SC',
+          //   classify_name: '未分类',
+          //   vSwitch: 'f'
+          // }).then((res) => {
+          //   this.getBigInfo()
+          // })
         }
 
       } else {
@@ -338,6 +411,19 @@ export default {
   background: #fff;
   border-radius: 5px;
   box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.08);
+  .config-title {
+    padding-bottom: 12px;
+    font-size: 18px;
+    color: #1d1d1d;
+    line-height: 28px;
+    border-bottom: 1px solid #ececec;
+
+    span {
+      margin-left: 16px;
+      font-size: 14px;
+    }
+  }
+
   &-title{
     display: flex;
     align-items: center;