{
  template: '${tmpl}',
    data: function() {
      return {
        /**图标信息 */
        showLogin: true,
        oauthUrl: null,
        userName: null,
        autofocus: null,
        phoneNum: null,
        url: '/web/orderCtl/getOrderTotal',/**订单数量url */
        newInfo: '/imgs/mobilehome/icon.png',
        nameDisabled: true,
        avatar: '/imgs/a1.jpg',
        idLists: [], /* 订单接口 需要的id */
        paymentStates: [], /*付款状态以及对应的id */
        /**我的 */
        selected: 0,
        obj: {},
        myTask: ['商标', '专利', '版权', '其他订单'],
        showLoading: false,
        d: {},
        fileName: '',
        ossAction: '',
        /* 全选和单选 */
        state: [
          {
            info: "待付款",
            num: '',
          },
          {
            info: "已付款",
            num: '',
          },
          {
            info: "已完成",
            num: '',
          }
        ],
        /**我的功能 link为路由*/
        userItems: [
          {
            title: '官文',
            holder: '官文查询/邮寄',
            img: '/imgs/mobilemy/guanwen.png',
            link: '/mobilemanagedocument',
            islink: true,
          },
          {
            title: '发票',
            holder: '发票申请/邮寄',
            img: '/imgs/mobilemy/fapiao.png',
            link: '/mobileinvoice',
            islink: true,

          },
          {
            title: '客服中心',
            holder: '',
            img: '/imgs/mobilemy/kefu.png',
            link: 'tel: 4006-789-999',
            islink: false,

          },
          {
            title: '关于我们',
            holder: '',
            img: '/imgs/mobilemy/about.png',
            link: '/mobileabout',
            islink: true,

          },
        ]
      }
    },
  mounted: function() {

    if (!localStorage.gsbWxUser || localStorage.gsbWxUser == "null") {
      this.$root.checkAndLogin().then((res) => {
        /* 1111*/
        if (localStorage.gsbUser && localStorage.gsbUser != "") {
          let gsbUser = JSON.parse(localStorage.gsbUser);
          this.userName = gsbUser.nickName;
          this.phoneNum = gsbUser.mobile;
          if (gsbUser.headUrl) {
            this.avatar = gsbUser.headUrl;
          }
        }

        /*拿id参数 */
        this.showLoading = true;
        this.$root.postReq("/web/producttypeCtl/getProductTypeList", {}).then((res) => {
          this.showLoading = false;
          console.log(res.data, "mmmmmmmmmmmmmmmmmmmmm");
          res.data.forEach((item, index) => {
            this.idLists.push(item.id);
          });
          let arr = this.idLists.slice(0, 1);
          this.obj.productonetypeid_list = arr;
          this.getOrderTotal(this.url, this.obj, arr);

        });
        /*获取oss参数 */
        this.$root.postReq("/web/uploadCtl/getOssConfig", "").then((d) => {
          this.d["key"] = "key";
          this.d["Bucket"] = d.Bucket;
          this.d["OSSAccessKeyId"] = d.OSSAccessKeyId;
          this.d["Signature"] = d.Signature;
          this.d["policy"] = d.policy;
          this.d["success_action_status"] = d.success_action_status;
          this.ossAction = d.url;
          console.log(this.d, this.ossAction);
        });
        /*结束 */
        console.log(res, 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzzz');
      });
      return
    } else {

      /*判断用户手机是否绑定 */
      console.log("判断用户手机是否绑定");
      if (!localStorage.gsbUser || localStorage.gsbUser == 'null') {
        this.$router.push({ path: "/mobilelog", query: {} });
        return
      }

      if (localStorage.gsbUser && localStorage.gsbUser != "") {
        let gsbUser = JSON.parse(localStorage.gsbUser);
        this.userName = gsbUser.nickName;
        this.phoneNum = gsbUser.mobile;
        if (gsbUser.headUrl) {
          this.avatar = gsbUser.headUrl;
        }
      }

      /*拿id参数 */
      this.showLoading = true;
      this.$root.postReq("/web/producttypeCtl/getProductTypeList", {}).then((res) => {
        this.showLoading = false;
        console.log(res.data, "mmmmmmmmmmmmmmmmmmmmm");
        res.data.forEach((item, index) => {
          this.idLists.push(item.id);
        });
        let arr = this.idLists.slice(0, 1);
        this.obj.productonetypeid_list = arr;
        this.getOrderTotal(this.url, this.obj, arr);
      });
      /*获取oss参数 */
      this.$root.postReq("/web/uploadCtl/getOssConfig", "").then((d) => {
        this.d["key"] = "key";
        this.d["Bucket"] = d.Bucket;
        this.d["OSSAccessKeyId"] = d.OSSAccessKeyId;
        this.d["Signature"] = d.Signature;
        this.d["policy"] = d.policy;
        this.d["success_action_status"] = d.success_action_status;
        this.ossAction = d.url;
        console.log(this.d, this.ossAction);
      });
      /*结束 */
    }




    this.$root.showmenu();
    console.log(localStorage);

  },
  created: function() {
    /**wx登录 */

  },
  /* 监听点击的是哪一个大类 */
  watch: {
    selected(n){
      switch (n) {
        case 0:

          this.obj.productonetypeid_list = this.idLists.slice(n, n + 1);
          this.getOrderTotal(this.url, this.obj);
          break;
        case 1:
          this.obj.productonetypeid_list = this.idLists.slice(n, n + 1);

          this.getOrderTotal(this.url, this.obj);
          break;
        case 2:
          this.obj.productonetypeid_list = this.idLists.slice(n, n + 1);
          this.getOrderTotal(this.url, this.obj);
          break;
        case 3:
          this.obj.productonetypeid_list = this.idLists.slice(n);
          this.getOrderTotal(this.url, this.obj);
          break;

      }
    }
  },
  methods: {
    setKey(name, flag){
      name = name.substring(name.length - 5);
      var myDate = new Date();
      var key = "zc_" + flag + Math.round(Math.random() * 10000) + myDate.getTime() + myDate.getFullYear() + myDate.getMonth() + myDate.getDate() + ".jpg";
      this.$refs['avatar'].d.key = key;
    },
    uploadsuccess(obj){
      let data = {};
      data.headUrl = obj.result;
      /* 
      传参：data {nickname:”昵称”, headUrl:”头像”, sex:”性别”, email:”邮箱”}
      */
      this.$root.postReq('/web/userCtl/editUserBaseInfo', data).then((res) => {
        this.showLoading = false;
        if (res.code == 1) {
          /**存缓存 */
          this.avatar = obj.result;
          let gsbUser = JSON.parse(localStorage.gsbUser);
          gsbUser.headUrl = this.avatar;
          localStorage.gsbUser = JSON.stringify(gsbUser);
          console.log(this.avatar);
        }

      });


    },
    getOrderTotal(url, obj, id){
      this.showLoading = true;
      this.$root.postReq(url, obj).then((res) => {
        this.showLoading = false;
        /**取出来对应的状态码 转称数组 */
        this.paymentStates = [];
        for (let i in res.data) {
          this.paymentStates.push(res.data[i]);
        };
        /*改变所有订单状态 */
        this.state.forEach((item, index) => {
          this.state[index].num = this.paymentStates[index].count;
        });
        console.log(res.data, "nnnnnnnnnnnnnnnnnn");
        console.log(this.paymentStates, '.....,.,.,,,,,,,,,,,,,,,,,,');
      });
    },
    goMyindent(index, index1){
      /*index一级标题控制导航高亮,index1付款状态控制 */
      let states = JSON.stringify(this.paymentStates);
      let idLists = JSON.stringify(this.idLists);
      console.log(index, index1, states, idLists, ".......................");
      this.$router.push({ path: "/mobilemyindent", query: { index, index1, states, idLists } });
    },




    /* 修改昵称 */
    subName(){
      this.nameDisabled = !this.nameDisabled;
      this.$root.postReq("/web/userCtl/putNickName", { "nick_name": this.userName }).then((res) => {
        console.log("修改昵称成功!", this.nameDisabled);
        this.$toast({
          message: '修改昵称成功',
          duration: 5000
        });
        if (localStorage.gsbUser && localStorage.gsbUser != "") {
          let gsbUser = JSON.parse(localStorage.gsbUser);
          console.log(gsbUser);
          gsbUser.nickName = this.userName;
          localStorage.gsbUser = JSON.stringify(gsbUser);
        }
      });
    },
    modifiyName(){
      this.nameDisabled = !this.nameDisabled;
      this.$nextTick(() => {
        this.$refs.userName.focus();
      });
      console.log(111111, this.nameDisabled);
      console.log(this.$refs.userName, "xxxxxxxxxxxxxxxxxxxxx");
    },
    /* 和监听的作用一样,通过index的值获取用户点击的大类类型,通过index1的值获取订单状态*/

  },
  vname: "gsb-mobilemy"
}
