示例#1
0
文件: user_info.py 项目: webmiss/base
 def Upimg(self):
     # 验证
     token = self.Post('token')
     msg = AdminToken.Verify(token, request.path)
     if msg != '': return self.GetJSON({'code': 4001, 'msg': msg})
     tData = AdminToken.Token(token)
     # 参数
     base64 = self.Post('base64')
     if not base64: return self.GetJSON({'code': 4000, 'msg': '参数错误!'})
     # 上传
     img = Upload.Base64({'path': self.ImgDir, 'base64': base64})
     if not img: return self.GetJSON({'code': 5000, 'msg': '上传失败!'})
     # 数据
     model = UserInfoM()
     model.Columns('img')
     model.Where('uid=%s', tData['uid'])
     imgData = model.FindFirst()
     model.Set({'img': self.ImgDir + img})
     model.Where('uid=%s', tData['uid'])
     if not model.Update():
         return self.GetJSON({'code': 5000, 'msg': '上传失败!'})
     # 清理
     rmImg = imgData['img']
     FileEo.RemoveAll(rmImg)
     # 返回
     return self.GetJSON({
         'code': 0,
         'msg': '成功',
         'img': Data.Img(self.ImgDir + img)
     })
示例#2
0
 def Token(self):
   # 验证
   token = self.Post('token')
   msg = ApiToken.Verify(token, '')
   if msg != '' : return self.GetJSON({'code':4001, 'msg':msg})
   # 参数
   uinfo = self.Post('uinfo')
   tData = ApiToken.Token(token)
   if uinfo!='1' : return self.GetJSON({'code':0, 'msg':'成功', 'token_time':tData['time']})
   # 用户信息
   model = UserInfo()
   model.Columns('nickname','position','name','img')
   model.Where('uid=%s',tData['uid'])
   info = model.FindFirst()
   info['uname'] = tData['uname']
   info['img'] = Data.Img(info['img'])
   return self.GetJSON({'code':0, 'msg':'成功', 'token_time':tData['time'], 'uinfo':info})
示例#3
0
文件: user_info.py 项目: webmiss/base
 def List(self):
     # 验证
     token = self.Post('token')
     msg = AdminToken.Verify(token, request.path)
     if msg != '': return self.GetJSON({'code': 4001, 'msg': msg})
     tData = AdminToken.Token(token)
     # 查询
     model = UserInfoM()
     model.Columns('nickname', 'name', 'gender',
                   'FROM_UNIXTIME(birthday, %s) as birthday', 'position',
                   'img')
     model.Where('uid=%s', '%Y-%m-%d', str(tData['uid']))
     list = model.FindFirst()
     # 数据
     list['img'] = Data.Img(str(list['img']))
     # 返回
     return self.GetJSON({'code': 0, 'msg': '成功', 'list': list})