前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >15.普通用户、网格长、网格员,操作数据(2)newapp/pages/center/center.vue

15.普通用户、网格长、网格员,操作数据(2)newapp/pages/center/center.vue

作者头像
玩蛇的胖纸
发布2020-07-03 10:42:26
3740
发布2020-07-03 10:42:26
举报

1.newapp/pages/center/center.vue

1.在newapp/components新建三个组件:putong.vue,wgy.vue,wgz.vue

2.在newapp/pages/center/center.vue中:

代码语言:javascript
复制
<template>
    <view class="content">
        <!-- 普通用户 -->
        <view class="putong" v-if="flag1">
            <putong :data1='data1'></putong>
        </view>
        <view class="wgy" v-if=flag2>
            <wgy :data2="data2" :wgy_can_edit="wgy_can_edit"></wgy>
        </view>
        <view class="wgz" v-if="flag3">
            <wgz :my_wgylist_and_loulist="my_wgylist_and_loulist" :data3="data3" :wgz_can_edit="wgz_can_edit"></wgz>
        </view>

        <!-- 版权信息 -->
        <view class="solid-bottom padding text-center margin-top">
            ©由赤峰市落忆网络科技有限公司提供技术支持
        </view>
        
    </view>
</template>

<script>
import {host,get,post} from '@/commons/post_and_get.js'
import putong from "@/components/putong.vue"
import wgz from "@/components/wgz.vue"
import wgy from "@/components/wgy.vue"
    export default {
        data() {
            return {
                //非网格员也非网格长
                flag1:false,
                data1:{},
                // 网格员
                flag2:false,
                data2:{},
                //网格长
                flag3:false,
                data3:{},
                    //网格长组件展示数据
                my_wgylist_and_loulist:[],
                wgz_can_edit:false,
                wgy_can_edit:false
            }
        },
        methods: {
            async isLogin(){
                let token=uni.getStorageSync('token');
                if(token){
                    //更新个人数据信息开始
                    let re=await get('/user_operations/upuserinfo/',{'token':token})
                    // console.log(111,re)
                    if(re.status==200){
                        uni.setStorageSync('token' , re.data.token);
                        uni.setStorageSync('info' , re.data.info);
                    }else{
                        uni.removeStorageSync('token');
                        uni.navigateTo({url:'/pages/login/login'})
                    }
                    //更新个人数据信息结束
                    
                    let f=uni.getStorageSync('info')
                    // console.log(f)
                    if(f.power==1||f.power==2||f.power==3){
                        this.flag1=true
                        this.flag2=false
                        this.flag3=false
                    }
                    if(f.power==4){
                        this.flag1=false
                        this.flag2=true
                        this.flag3=false
                    }
                    if(f.power==5){
                        this.flag1=false
                        this.flag2=false
                        this.flag3=true
                    }
                    this.GetCaoZuoData()
                }else{
                    uni.navigateTo({url:'/pages/login/login'})
                }
                
            },
            
            async GetCaoZuoData(){
                let re=await get('/user_operations/getcaozuo/',{'token':uni.getStorageSync('token')})
                // console.log(re)
                if(this.flag1){
                    re.data.wgy.img=host+re.data.wgy.img
                    re.data.wgz.img=host+re.data.wgz.img
                    this.data1=re
                }
                if(this.flag3){
                    this.data3=re.data
                    // console.log(this.data3.all_wgy_list,this.data3.lou_list)
                    //展示数据
                    this.my_wgylist_and_loulist=[]
                    for(var i=0;i<this.data3.all_wgy_list.length;i++){
                        let item={'wgy':{},'lou_list':[]}
                        for(var j=0;j<this.data3.lou_list.length;j++){
                            if(this.data3.lou_list[j].wgy==this.data3.all_wgy_list[i].id){
                                item.wgy=this.data3.all_wgy_list[i]
                                item.lou_list.push(this.data3.lou_list[j])
                            }
                        }
                        if(item.lou_list.length){
                            this.my_wgylist_and_loulist.push(item)
                        }
                    }
                    // console.log(this.my_wgylist_and_loulist)
                }
                if(this.flag2){
                    this.data2=re.data
                    // console.log(this.data2)
                }
            },
                
            //获取查看网格员和网格长有没有编辑的权利
            async getOnorOff(){
                let re=await get('/user_operations/editpower/')
                // console.log(re)
                this.wgz_can_edit=re.wgz
                this.wgy_can_edit=re.wgy
            },
        },
        components:{
            putong,
            wgz,
            wgy
        },
        onShow() {
            this.isLogin()
            this.getOnorOff()
        }
        
    }
</script>

<style>
.pic{
    width: 150upx;
    height: 200upx;
}
.pic image{
    width: 100%;
    height: 100%;
}
.pin{
    width: 400upx;
    font-size: 40upx;
}
.l{
    text-align: left;
}
.lz{
    font-size: 35upx;
}
.btn{
    margin-left:200upx ;
}
.v-header{
    display: flex;
    width: 100%;
    justify-content:space-around;
}

</style>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-07-03 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1.newapp/pages/center/center.vue
    • 1.在newapp/components新建三个组件:putong.vue,wgy.vue,wgz.vue
      • 2.在newapp/pages/center/center.vue中:
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档