jwyu 3 years ago
parent
commit
67974f1d3a

+ 10 - 0
api/chart.js

@@ -31,4 +31,14 @@ export const apiChartClassifyList=params=>{
  */
 export const apiChartMove=params=>{
     return httpPost('/my_chart/moveMyChart',params)
+}
+
+/**
+ * 分类移动排序
+ * @param MyChartClassifyId
+ * @param PrevClassifyId
+ * @param NextClassifyId
+ */
+export const apiClassifyMove=params=>{
+    return httpPost('/my_chart/moveMyChartClassify',params)
 }

+ 4 - 1
pages-chart/chartDetail.vue

@@ -7,8 +7,11 @@ import {h5BaseUrl} from '../utils/config'
 export default {
     data () {
         return {
-            url:h5BaseUrl+'/hzyb/chart/detail'
+            url:''
         }
+    },
+    onLoad(options) {
+        this.url=`${h5BaseUrl}/hzyb/chart/detail?ChartInfoId=${options.chartInfoId}&token=${this.$store.state.user.token}`
     }
 }
 </script>

+ 41 - 8
pages/chart/chart.vue

@@ -1,6 +1,6 @@
 <template>
     <page-meta :page-style="showFilter? 'overflow: hidden;' : ''" :scroll-top="pageMetaScrollTop" />
-    <view class="chart-page" v-if="true">
+    <view class="chart-page" v-if="hasAuth">
       <van-sticky style="background: #fff">
         <view class="flex search-wrap" id="search-wrap">
             <van-search
@@ -45,7 +45,7 @@
     </view>
 
     <!-- 无权限 -->
-    <noAuth v-else></noAuth>
+    <noAuth :info="noAuthData" v-else></noAuth>
     
     <!-- 筛选弹窗 -->
       <van-popup 
@@ -78,6 +78,7 @@
               :rowHeight="rowHeight"
               :listHeight="classifyListHeight+20"
               @onclick="myClassifyClick"
+              @confirm="myClassifyMoveEnd"
             ></dragSorts>
             </block>
           </view>
@@ -89,7 +90,7 @@
 import chartItem from './component/chartItem.vue'
 import dragSorts from '../../components/chartClassifyItem/HM-dragSorts.vue'
 import noAuth from './component/noAuth.vue'
-import {apiChartList,apiChartClassifyList,apiChartMove} from '@/api/chart'
+import {apiChartList,apiChartClassifyList,apiChartMove,apiClassifyMove} from '@/api/chart'
 export default {
     components: {
       'chart-item':chartItem,
@@ -114,6 +115,9 @@ export default {
           rowHeight:44,
 
           searchVal:'',//图库搜素关键词
+
+          hasAuth:true,//是否有权限
+          noAuthData:null,//没有权限时传给无权限组件的值
         }
     },
     onLoad() {
@@ -155,6 +159,7 @@ export default {
         })
         // console.log(res);
         if(res.code===200){
+          this.hasAuth=true
           if(res.data){
             // 公共图库分类下数据不允许拖动
             let arr=res.data.map(item=>{
@@ -168,10 +173,13 @@ export default {
           }else{
             this.finished=true
           }
+        }else if(res.code===403){//无权限
+          this.hasAuth=false
+          this.noAuthData=res.data
         }
       },
 
-      //移动排序结束
+      //图表移动排序结束
       async chartSortend(e){
         // curIndex 为排序前元素所在位置  listData为排序后的数组
         let {curIndex,listData}=e.detail
@@ -203,15 +211,15 @@ export default {
         }
       },
 
-      // 点击某项
+      // 图表点击某项
       chartClick(e){
         console.log(e.detail.data);
         uni.navigateTo({
-          url:'/pages-chart/chartDetail'
+          url:'/pages-chart/chartDetail?chartInfoId='+e.detail.data.ChartInfoId
         })
       },
 
-      // 移动时滚动
+      // 图表移动时滚动
       chartScroll(e){
         uni.stopPullDownRefresh()
         this.pageMetaScrollTop=e.detail.scrollTop
@@ -258,12 +266,37 @@ export default {
         this.showFilter=false
       },
 
+      // 分类移动
+      async myClassifyMoveEnd(e){
+        const moveTarget=e.moveRow
+        const index=e.moveTo// 拖动后的序号
+        const list=e.list//拖动后的列表
+        // console.log(moveTarget.myChartClassifyId);
+        // console.log(index);
+        // console.log(list);
+        const PrevClassifyId=list[index-1]&&list[index-1].myChartClassifyId||0
+        const NextClassifyId=list[index+1]&&list[index+1].myChartClassifyId||0
+        const res=await apiClassifyMove({
+          MyChartClassifyId:moveTarget.myChartClassifyId,
+          PrevClassifyId:PrevClassifyId,
+          NextClassifyId:NextClassifyId
+        })
+        if(res.code===200){
+          this.myClassifyList=list
+        }else{
+          uni.showToast({
+            title: '移动失败',
+            icon: 'none'
+          })
+        }
+      },
+
       // 搜索关键词变化
       searchValChange(e){
         this.searchVal=e.detail
       },
 
-      // 确认搜索
+      // 确认搜索 搜索图表下的都不允许拖动排序
       onSearch(){
         this.initPage()
         this.isPublic=true

+ 7 - 2
pages/chart/component/chartItem.vue

@@ -2,7 +2,7 @@
   <view class="chart-item" :data-id="itemData.dragId" @click.stop="itemClick">
       <rich-text 
         class="van-multi-ellipsis--l2 title" 
-        :nodes="itemData.ChartName"
+        :nodes="formatTitle(itemData.ChartName)"
         @longpress.stop="chartTitle(itemData,$event)"
       ></rich-text>
       <view class="pop-title" v-if="showPopTitle">{{itemData.ChartName}}</view>
@@ -33,6 +33,11 @@ export default {
         this.showPopTitle=false
       },
 
+      formatTitle(e){
+        const reg=new RegExp(this.searchVal,'gi')
+        return e.replace(reg,`<span style="color:#FF0000">${this.searchVal}</span>`)
+      },
+
       // 长按标题
       chartTitle(data,e){
         this.showPopTitle=true
@@ -60,7 +65,7 @@ export default {
     position: relative;
     .title{
       font-size: 26rpx;
-      min-height: 60rpx;
+      min-height: 68rpx;
     }
     .pop-title{
       position: absolute;

+ 39 - 4
pages/chart/component/noAuth.vue

@@ -2,15 +2,50 @@
   <view class="chart-no-auth">
         <image class="img" :src="globalImgUrls.activityNoAuth" mode="widthFix"></image>
         
-        <view style="margin-bottom:15px">您暂无权限查看图库</view>
-        <view>若想查看请联系对口销售</view>
-        <view class="global-btn-yellow-change btn" style="margin-top:30px">立即申请</view>
+        <block v-if="authType==1">
+            <view style="margin-bottom:15px">您暂无权限查看图库</view>
+            <view>若想查看请联系对口销售</view>
+            <!-- <view>{{info.name}}:{{info.mobile}}</view> -->
+            <view class="global-btn-yellow-change btn" style="margin-top:30px" @click="handleCall">联系销售</view>
+        </block>
+        
   </view>
 </template>
 
 <script>
-export default {
+export default {    
+    props: {
+        info:null
+    },
+    computed: {
+        authType(){
+            if(!this.info) return
+            let type
+            let status=this.info.customer_info.status //客户状态
+            // 该客户为冻结、试用暂停状态;该客户为正式、试用、永续状态,但联系人图表权限未开启或禁用
+            if(
+                status=='冻结'||
+                (status=='试用'&&this.info.customer_info.is_suspend)||
+                (['正式','试用','永续'].includes(status))
+            ){
+                type=1
+            }
+
+            // 该客户为正式、试用、永续状态,联系人图表权限已到期
+            // if()
 
+            return type
+        }
+    },
+    methods: {
+        handleCall(){
+            uni.makePhoneCall({
+                phoneNumber: this.info.mobile,
+                success: (result) => {},
+                fail: (error) => {}
+            })
+        }
+    }
 }
 </script>
 

+ 6 - 3
utils/request.js

@@ -103,9 +103,12 @@ const http=(url,params,method)=>{
 					},0)
 					return
 				}
-				console.log(ENV);
-				let res=JSON.parse(CryptoJS.Des3Decrypt(e.data));//解密
-				// let res=e.data
+				let res
+				if(ENV.envVersion==='release'){
+					res=JSON.parse(CryptoJS.Des3Decrypt(e.data));//解密
+				}else{
+					res=e.data
+				}
 				if(res.code!==200&&res.code!==403&&res.code!==4001&&res.code!==401){
 					showError(res)
 				}