Przeglądaj źródła

视频社区增加权限校验

jwyu 2 lat temu
rodzic
commit
1f57723e88
3 zmienionych plików z 113 dodań i 4 usunięć
  1. 1 1
      api/user.js
  2. 98 0
      pages/video/components/noAuth.vue
  3. 14 3
      pages/video/videoList.vue

+ 1 - 1
api/user.js

@@ -48,7 +48,7 @@ export const apiUserLogin=params=>{
  * @param company_name 公司名
  * @param permission 选择的权限
  * @param real_name 姓名
- * @param source 来源:我的1、活动2、图库3、研报4、问答社区5、价格驱动6、沙盘推演7、语音播报8
+ * @param source 来源:我的1、活动2、图库3、研报4、问答社区5、价格驱动6、沙盘推演7、语音播报8、视频社区9
  * @param source_agent 来源平台:1:小程序、2:小程序(pc)、3:公众号、4:官网web(pc)
  * @param from_page 来源页面: '活动列表'、'活动详情'等
  */

+ 98 - 0
pages/video/components/noAuth.vue

@@ -0,0 +1,98 @@
+<template>
+  <view class="voice-no-auth">
+        <image class="img" :src="globalImgUrls.activityNoAuth" mode="widthFix"></image>
+		<view style="margin-bottom:15px">您暂无权限查看视频社区</view>
+		<view v-if="info.type==='contact'" style="margin-bottom:15px">若想查看可以联系对口销售</view>
+		<view v-else style="margin-bottom:15px">若想查看可以申请开通</view>
+		<view v-if="info.type==='contact'">
+			{{info.name||''}}:<text @click="handleCall" style="color:#E3B377">{{info.mobile||''}}</text>
+		</view>
+		<view class="global-btn-yellow-change btn" @click="handleApply" v-else style="margin-top:30px">立即申请</view>
+  </view>
+</template>
+
+<script>
+import {apiApplyPermission} from '@/api/user'
+export default {    
+    props: {
+        info:null
+    },
+    watch:{
+        info(){
+            this.handleAutoApply()
+        }
+    },
+    
+    methods: {
+        handleCall(){
+
+            uni.makePhoneCall({
+                phoneNumber: this.info.mobile,
+                success: (result) => {},
+                fail: (error) => {}
+            })
+        },
+
+        handleAutoApply(){
+            if(this.info.type=='contact'&&!this.info.customer_info.has_apply){
+                if(this.info.customer_info.status=='冻结'||(this.info.customer_info.status=='试用'&&this.info.customer_info.is_suspend==1)){
+                    apiApplyPermission({
+                        company_name:this.info.customer_info.company_name,
+                        real_name:this.info.customer_info.name,
+                        source:9,
+                        from_page:'视频社区'
+                    }).then(res=>{
+                        if(res.code===200){
+                            console.log('主动申请成功');
+                        }
+                    }) 
+                }
+            }
+        },
+
+        handleApply(){
+            const {customer_info}=this.info
+            if(customer_info.has_apply){
+                uni.showToast({
+                  title:'您已提交过申请,请耐心等待',
+                  icon:'none'
+                })
+            }else{
+                if (!customer_info.status || customer_info.status != '流失') {
+                    uni.navigateTo({
+                        url: "/pages-applyPermission/applyPermission?source=9&from_page=视频社区"
+                    })
+                }else{
+                    apiApplyPermission({
+                        company_name:customer_info.company_name,
+                        real_name:customer_info.name,
+                        source:9,
+                        from_page:'视频社区'
+                    }).then(res=>{
+                        uni.navigateTo({url:'/pages-applyPermission/applyResult'})
+                    })
+                }
+            }
+        }
+    }
+}
+</script>
+
+<style lang="scss" scoped>
+.voice-no-auth{
+    padding: 34rpx;
+    text-align: center;
+    font-size: $global-font-size-lg;
+    .img{
+        width: 100%;
+        margin-bottom: 50rpx;
+    }
+    .btn{
+        width: 380rpx;
+        line-height: 70rpx;
+        margin-left: auto;
+        margin-right: auto;
+        margin-top: 40rpx;
+    }
+}
+</style>

+ 14 - 3
pages/video/videoList.vue

@@ -1,5 +1,5 @@
 <template>
-    <view class="video-list-page">
+    <view class="video-list-page" v-if="isAuth">
         <van-sticky style="background: #fff">
             <view class="flex search-wrap">
                 <view @click="goSearchPage" style="flex:1;margin-right:30rpx" >
@@ -90,13 +90,17 @@
             </view>
         </van-popup>
     </view>
-    
+    <noAuth :info="noAuthData" v-else/>
 </template>
 <script>
 import {apiVideoList,apiVideoPlayLog} from '@/api/video'
 import {apiOptionList} from '@/api/question'
 import {apiGetSceneToParams,apiGetTagTree} from '@/api/common'
+import noAuth from './components/noAuth.vue'
 export default {
+    components:{
+        noAuth
+    },
     data() {
         return {
             showFilter:false,
@@ -111,7 +115,10 @@ export default {
             list:[],
 
             curVideoId:0,
-            curVideoIns:null
+            curVideoIns:null,
+
+            isAuth:true,
+            noAuthData:null,
         }
     },
     onLoad(options){
@@ -208,6 +215,10 @@ export default {
                 if(arr.length===0){
                     this.finished=true
                 }
+            }else if(res.code===403){
+                //无权限用户
+                this.isAuth=false
+                this.noAuthData=res.data
             }
         },