Browse Source

抖音挑战赛

yuwenjun1997 2 years ago
parent
commit
a96d69cdb6

+ 9 - 0
src/api/activity.js

@@ -88,3 +88,12 @@ export function downloadVideo(params) {
     params
   })
 }
+
+// 获取抖音视频详情
+export function getShareVideo(params) {
+  return request({
+    url: '/auth/get/info/by/id',
+    method: 'get',
+    params
+  })
+}

+ 1 - 1
src/permission.js

@@ -11,7 +11,7 @@ if (userInfo) {
 
 // 路由白名单
 const whiteList = ['/login']
-const shareList = ['Share', 'SharePayVip', 'SharePaySuccess', 'SharePayFaild', 'DouyinResult']
+const shareList = ['Share', 'SharePayVip', 'SharePaySuccess', 'SharePayFaild', 'DouyinResult', 'DouyinShareSchema']
 
 // 路由拦截器
 router.beforeEach(async(to, from, next) => {

+ 6 - 0
src/router/module/base.js

@@ -13,6 +13,12 @@ export default [
     component: () => import(/* webpackChunkName: "common-page" */ '@/views/common/redirect/douyin'),
     hidden: true
   },
+  {
+    name: 'DouyinShareSchema',
+    path: '/douyin/schema',
+    component: () => import(/* webpackChunkName: "common-page" */ '@/views/common/redirect/schema'),
+    hidden: true
+  },
   {
     path: '/login',
     component: () => import(/* webpackChunkName: "common-page" */ '@/views/common/login'),

+ 1 - 1
src/views/admin/logistics-licensed/components/club-list.vue

@@ -40,7 +40,7 @@
 
       <el-table-column label="机构名称" align="center" prop="authParty" />
 
-      <el-table-column label="认证编号" align="center" width="240" />
+      <el-table-column label="认证编号" align="center" width="240" prop="authCode" />
 
       <el-table-column label="创建时间" class-name="status-col" width="160px">
         <template slot-scope="{ row }">

+ 100 - 0
src/views/common/redirect/schema.vue

@@ -0,0 +1,100 @@
+<template>
+  <div v-loading="isRequest" class="page">
+    <template v-if="!isRequest">
+      <!-- <img src="~@/assets/404_images/404.png" alt=""> -->
+      <span v-if="errorText">{{ errorText }}</span>
+    </template>
+    <a ref="schema" :href="schema" />
+    <!-- <div>{{ isIOS }}</div> -->
+  </div>
+</template>
+
+<script>
+import { getDouyinShareH5, getShareVideo } from '@/api/activity'
+export default {
+  data() {
+    return {
+      isRequest: true,
+      schema: '',
+      errorText: '',
+      userAgent: null,
+      isIOS: false
+    }
+  },
+  created() {
+    this.isRequest = true
+    this.initUserAgent()
+  },
+  methods: {
+    // 初始化userAgent
+    initUserAgent() {
+      const u = navigator.userAgent
+      // const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1 // 判断是否是 android终端
+      this.isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) // 判断是否是 iOS终端
+      this.getShareVideo()
+    },
+    // 获取要分享的视频信息
+    async getShareVideo() {
+      try {
+        const id = this.$route.query.id
+        const res = await getShareVideo({ videoId: id })
+        this.getDouyinSchema(res.data)
+        if (res.data.status === 1) {
+          return (this.errorText = '该视频已发布过')
+        }
+      } catch (error) {
+        this.isRequest = false
+        this.errorText = error.msg
+      }
+    },
+    // 获取抖音schema
+    async getDouyinSchema(row) {
+      try {
+        const res = await getDouyinShareH5({
+          title: row.title,
+          videoPath: row.ossUrl,
+          authId: row.authId
+        })
+        // 对 ios 和 Android 进行区分
+        this.schema = this.isIOS
+          ? res.data.replace('snssdk1128://openplatform', 'snssdk1128://deeplink/openplatform')
+          : res.data
+        // 触发链接
+        this.$nextTick(() => {
+          this.$refs.schema.click()
+          setTimeout(() => {
+            window.location.href = 'https://www.caimei365.com'
+          }, 3000)
+        })
+      } catch (error) {
+        this.errorText = error.msg
+      } finally {
+        this.isRequest = false
+      }
+    }
+  }
+}
+</script>
+
+<style scoped lang="scss">
+.page {
+  width: 100vw;
+  height: 100vh;
+  overflow: hidden;
+  display: flex;
+  align-items: center;
+  flex-direction: column;
+  box-sizing: border-box;
+  padding-top: 120px;
+  img {
+    width: 30%;
+  }
+
+  span {
+    font-size: 1.2em;
+    margin-top: 30px;
+    color: #51a3ef;
+    font-weight: bold;
+  }
+}
+</style>

+ 47 - 15
src/views/normal/activity/video/index.vue

@@ -58,7 +58,7 @@
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="序号" :index="indexMethod" align="center" width="80" type="index" />
       <el-table-column label="视频" align="center" width="100">
-        <template slot-scope="{ row }"><el-image :src="row.cover" style="wdith: 80px" /></template>
+        <template slot-scope="{ row }"><el-image class="cover" :src="row.cover" /></template>
       </el-table-column>
       <el-table-column label="登录账号" align="center" prop="userName" width="240" />
       <el-table-column label="机构名称" align="center" prop="authParty" />
@@ -71,9 +71,19 @@
           <span v-if="row.status === 0" class="status danger">未上传</span>
         </template>
       </el-table-column>
+      <el-table-column label="上传时间" align="center" width="160">
+        <template slot-scope="{ row }">
+          <span>{{ row.releaseTime | formatDate }}</span>
+        </template>
+      </el-table-column>
       <el-table-column label="操作" align="center" width="440">
         <template slot-scope="{ row }">
-          <permission-button size="mini" type="primary" @click="onSyancDouyin(row)">上传至抖音</permission-button>
+          <permission-button
+            v-if="row.status !== 1"
+            size="mini"
+            type="primary"
+            @click="onSyancDouyin(row)"
+          >上传至抖音</permission-button>
           <permission-button size="mini" type="primary" @click="onSaveCommand(row)">抖音口令</permission-button>
           <permission-button size="mini" type="primary" @click="onPlayVideo(row)">播放视频</permission-button>
           <permission-button size="mini" type="primary" @click="onDownload('single', row)">下载</permission-button>
@@ -129,7 +139,6 @@ import {
   fetchDouyinActivityStatus,
   fetchDouyinVideoList,
   getDouyinAccessToken,
-  getDouyinShareH5,
   onSendDouyinCommand,
   removeVideo,
   updateDouyinActivityStatus
@@ -239,17 +248,23 @@ export default {
         this.$confirm(dialog[flag], '提示', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
-          type: 'warning'
+          type: 'warning',
+          closeOnClickModal: false,
+          showClose: false
         })
           .then(() => {
             this.activityFormData.status = 0
           })
-          .catch(() => {})
+          .catch(() => {
+            this.activityFormData.status = 0
+          })
         return
       }
 
       this.updateActivityStatus()
     },
+
+    // 更新活动状态
     async updateActivityStatus() {
       try {
         const {
@@ -266,23 +281,26 @@ export default {
         console.log(error)
       }
     },
-    // 获取列表
+
+    // 获取视频列表
     getList() {
       this.list = []
       this.listQuery.pageNum = 1
       this.fetchDouyinVideoList()
     },
+
     // 获取视频列表
     async fetchDouyinVideoList() {
       try {
         this.listLoading = true
         const res = await fetchDouyinVideoList(this.listQuery)
         this.list = res.data.list.map((item, index) => {
-          item.rankNum = index + 1
+          if (item.rankingStatus === 1) {
+            item.rankNum = index + 1
+          }
           return item
         })
         this.listLoading = false
-        this.listQuery.pageNum++
       } catch (error) {
         console.log(error)
       }
@@ -292,10 +310,13 @@ export default {
     onSelectionChange(data) {
       this.selectionList = data
     },
+
     // 表格索引
     indexMethod(index) {
       return index + this.listQuery.pageSize * (this.listQuery.pageNum - 1) + 1
     },
+
+    // 获取已发布视频机构列表
     async getClubList(list) {
       try {
         const res = await fetchClubList()
@@ -304,6 +325,7 @@ export default {
         console.log(error)
       }
     },
+
     // 上传抖音
     async onSyancDouyin(row) {
       // 代理模式下不允许操作
@@ -322,18 +344,15 @@ export default {
           this.douyinLogin(row)
           return
         }
-        const res = await getDouyinShareH5({
-          title: row.title,
-          videoPath: row.ossUrl,
-          authId: row.authId
-        })
-        await this.generateQrcode(res.data)
+        const url = process.env.VUE_APP_LOCAL + `/#/douyin/schema?id=${row.id}`
+        await this.generateQrcode(url)
         // 获取分享码
       } catch (error) {
         console.log(error)
       }
     },
 
+    // 登录抖音
     async douyinLogin(row) {
       const code = getStorage('zp_douyin_code')
       if (!code) {
@@ -372,6 +391,7 @@ export default {
         console.log(error)
       }
     },
+
     // 提交抖音口令
     async onCommandSubmit() {
       try {
@@ -384,22 +404,26 @@ export default {
         console.log(error)
       }
     },
+
     // 保存抖音口令
     async onSaveCommand(row) {
       this.commandDialog = true
       this.commandFormData.authId = row.authId
       this.commandFormData.content = row.dyCommand
     },
-    // 清楚表单
+
+    // 清楚表单信息
     onCommandClose() {
       this.commandFormData.authId = ''
       this.$refs.commandForm.resetFields()
     },
+
     // 播放视频
     onPlayVideo(row) {
       this.videoDialog = true
       this.videoUrl = row.ossUrl
     },
+
     // 下载视频
     onDownload(type, row) {
       if (type === 'single') {
@@ -410,6 +434,7 @@ export default {
         this.downloadVideo(ids)
       }
     },
+
     // 下载视频
     async downloadVideo(fileIdList) {
       try {
@@ -449,6 +474,7 @@ export default {
         console.log(error)
       }
     },
+
     // 删除视频
     async onRemove(row) {
       try {
@@ -463,6 +489,7 @@ export default {
         this.$message.info('已取消操作')
       }
     },
+
     // 删除视频
     async removeVideo(row) {
       try {
@@ -484,6 +511,11 @@ export default {
   }
 }
 
+.cover {
+  width: 80px;
+  display: block;
+}
+
 .el-divider {
   margin: 12px 0;
 }