liuyg
2022-03-09 f7167fe6e19783eeef8386b5f74dbc7bdfdab327
pages/myself/myself.vue
@@ -16,7 +16,7 @@
               <view class="dept-name">所属部门:&nbsp;{{deptName}}</view>
            </view>
         </view>
      </view>
      </view>
      <view class="bomBut">
         <!-- <view class="attendance-btn">
            <view class="attendance-info"  @click="goToAttendance()">
@@ -105,10 +105,10 @@
               },
            ],
            tabbar:this.$store.state.tabbar,
            name:'',
            id:'',
            deptName:''
            tabbar: this.$store.state.tabbar,
            name: '',
            id: '',
            deptName: ''
         }
      },
      components: {
@@ -123,42 +123,42 @@
         }
      },
      onLoad() {
         if(this.$store.state.puserID){
         if (this.$store.state.puserID) {
            //获取个人信息
            this.getOneselfInFo();
         }
         if(this.$store.state.avatar!=null && this.$store.state.avatar!=''){
         if (this.$store.state.avatar != null && this.$store.state.avatar != '') {
            this.useimg = this.$store.state.avatar;
         }
      },
      //子页面返回时执行
      onShow() {
      },
      methods: {
         goToAttendance(){
            if(this.$store.state.UserData.stype != "1"){
         goToAttendance() {
            if (this.$store.state.UserData.stype != "1") {
               this.$refs.uToast.show({
                  title: '功能暂未开放',
                  type: 'warning',
               });
               return;
            }
            uni.navigateTo({
               url:'../clockSignIn/clockSignIn'
               url: '../clockSignIn/clockSignIn'
            })
         },
         openThere(fn) {
            this[fn]();
         },
         collect(){
         collect() {
            uni.navigateTo({
               url: './childen/collect',
            })
         },
         chenzs(){
         chenzs() {
            uni.navigateTo({
               url: '../shengzs/index',
            })
@@ -205,17 +205,17 @@
            });
         },
         //登录成功后,获取个人信息
         getOneselfInFo(){
         getOneselfInFo() {
            var that = this;
            //保安信息查询
            uni.request({
               url:that.$store.state.piAPI + '/blade-user/details?id='+this.$store.state.puserID,
               method:'POST',
               url: that.$store.state.piAPI + '/blade-user/details?id=' + this.$store.state.puserID,
               method: 'POST',
               success(resdata) {
                  that.name = resdata.data.data.realName;
                  that.id = resdata.data.data.id;
                  var dept = resdata.data.data.deptName;
                  if(dept !=null && dept !=""){
                  if (dept != null && dept != "") {
                     var name = dept.split(",");
                     that.deptName = name[name.length - 1];
                  }
@@ -240,21 +240,21 @@
            var that = this;
            uni.showActionSheet({
               // itemList按钮的文字接受的是数组
               itemList: ["查看头像","拍摄","从相册选择"],
               success(e){
               itemList: ["查看头像", "拍摄", "从相册选择"],
               success(e) {
                  var index = e.tapIndex;
                  if(index == 0){
                  if (index == 0) {
                     // 用户点击了预览当前图片
                     // 可以自己实现当前头像链接的读取
                      let url  = that.useimg;
                      let arr=[]
                      arr.push(url)
                      uni.previewImage({
                     let url = that.useimg;
                     let arr = []
                     arr.push(url)
                     uni.previewImage({
                        // 预览功能图片也必须是数组的
                        urls: arr
                      })
                     })
                  }
                   if(index == 1 || index==2 ){
                  if (index == 1 || index == 2) {
                     //拍照或从图库上传
                     that.uploadPictrue(index);
                  }
@@ -262,50 +262,51 @@
            });
         },
         //图片上传
         uploadPictrue(e){
         uploadPictrue(e) {
            var that = this;
            var sourceTypeArr = [];
            e==1 ? sourceTypeArr.push("camera") : sourceTypeArr.push("album")
            e == 1 ? sourceTypeArr.push("camera") : sourceTypeArr.push("album")
            uni.chooseImage({
               count: 1, //可选择数量,默认9
               sizeType: ['compressed','original'], //上传压缩图,原图
               sizeType: ['compressed', 'original'], //上传压缩图,原图
               sourceType: sourceTypeArr, //从相册选择
               success: async (res) => {
                  if(res.tempFiles[0].size > 10 * 1024 * 1000){  //上传图片大小限制
                  if (res.tempFiles[0].size > 10 * 1024 * 1000) { //上传图片大小限制
                     uni.showToast({
                        title: "照片大小不能10MB",
                        title: "照片大小不能10MB",
                        icon: "none"
                     })
                     return
                  }
                  var tempFilePath = res.tempFilePaths;
                  try{
                  try {
                     uni.showLoading({
                        title:"上传中...",
                        mask:true
                        title: "上传中...",
                        mask: true
                     })
                     // 文件上传
                     uni.uploadFile({
                        // url: 'https://web.byisf.com/api/depl/put-depl', //仅为示例,非真实的接口地址
                        url: that.$store.state.piAPI+'/depl/put-depl',
                        url: that.$store.state.piAPI + '/depl/put-depl',
                        filePath: tempFilePath[0],
                        name: 'file',
                        formData: {
                           'user': 'test'  // 上传附带参数
                           'user': 'test' // 上传附带参数
                        },
                        success: (data) => {
                           that.useimg = JSON.parse(data.data).data;
                           that.$store.state.avatar = that.useimg;
                           //修改用户头像信息
                           uni.request({
                              url:that.$store.state.piAPI + "/blade-user/updateUserInfo",
                              method:"POST",
                              data:{
                              url: that.$store.state.piAPI +
                                 "/blade-user/updateUserInfo",
                              method: "POST",
                              data: {
                                 id: that.$store.state.puserID,
                                 avatar:that.useimg
                                 avatar: that.useimg
                              },
                              success:(res)=> {
                                 if(res.data.code==200){
                              success: (res) => {
                                 if (res.data.code == 200) {
                                    uni.showToast({
                                       title: '上传成功!',
                                       duration: 2000
@@ -315,9 +316,9 @@
                           })
                        }
                     });
                  }catch(e){
                  } catch (e) {
                     console.log(e);
                  }finally{
                  } finally {
                     uni.hideLoading();
                  }
               }
@@ -327,7 +328,7 @@
   }
</script>
<style>
   page{
   page {
      width: 100%;
      height: 100%;
      background-color: #F7F7F7;
@@ -335,10 +336,10 @@
</style>
<style lang="scss" scoped>
   $imgSize: 1.2rem;
   .m-top,
   .my-user-info,
   .user-name-id{
   .user-name-id {
      display: flex;
   }
@@ -360,18 +361,18 @@
            height: 6rem;
            align-items: center;
            // border: 1px solid #007AFF;
            .user-name-id{
            .user-name-id {
               flex-direction: column;
               justify-content: center;
               .user-name{
               .user-name {
                  font-size: 1.5rem;
                  letter-spacing: 1rpx;
               }
               .user-id{
               .user-id {
                  font-size: 0.6rem;
                  color: #fff;
                  margin-top: 0.3rem;
@@ -396,17 +397,17 @@
            margin: 0 auto;
            height: 2.4rem;
            background-image: linear-gradient(to bottom, #103289, #174cd1);
            box-shadow:0 0 0.1px 0.1px #0BB9C8;
            box-shadow: 0 0 0.1px 0.1px #0BB9C8;
            // border: 1px solid #00ff00;
            .dept-info{
            .dept-info {
               width: 92%;
               height: 1.8rem;
               line-height: 1.8rem;
               margin-left: 0.6rem;
               margin-top: 0.3rem;
               background-image: linear-gradient(to bottom, #103289, #174cd1);
               .dept-name {
                  margin-left: 0.3rem;
               }
@@ -422,13 +423,13 @@
         border-radius: 2px;
         margin-top: -2.5rem;
         background-color: #fff;
         .attendance-btn{
         .attendance-btn {
            width: 100%;
            height: 6.1rem;
            border-bottom: 2px solid rgba($color: #F7F7F7, $alpha:0.8);
            .attendance-info{
            .attendance-info {
               width: 7rem;
               height: 100%;
               // background-color: #007AFF;
@@ -436,13 +437,13 @@
               align-items: center;
               justify-content: center;
               flex-direction: column;
               image{
               image {
                  width: 3.5rem;
                  height: 3.2rem;
               }
               .attendance-title{
               .attendance-title {
                  margin-top: 0.3rem;
                  font-weight: 550;
               }
@@ -475,8 +476,8 @@
                  font-size: 0.9rem;
               }
            }
            image{
            image {
               margin-right: 1rem;
            }
         }