Ejemplo n.º 1
0
 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)
     })
Ejemplo n.º 2
0
 def Edit(self):
     # 验证
     token = self.Post('token')
     msg = AdminToken.Verify(token, request.path)
     if msg != '': return self.GetJSON({'code': 4001, 'msg': msg})
     tData = AdminToken.Token(token)
     # 参数
     data = self.Post('data')
     if not data: return self.GetJSON({'code': 4000, 'msg': '参数错误!'})
     param = Util.JsonDecode(data)
     # 数据
     model = UserInfoM()
     info = {
         'nickname': Util.Trim(param['nickname']),
         'name': Util.Trim(param['name']),
         'gender': Util.Trim(param['gender']),
         'birthday': Util.Strtotime(Util.Trim(param['birthday']),
                                    '%Y-%m-%d'),
         'position': Util.Trim(param['position']),
     }
     model.Set(info)
     model.Where('uid=%s', tData['uid'])
     model.Update()
     # 返回
     info['uname'] = tData['uname']
     info['img'] = param['img']
     info['birthday'] = Util.Date('%Y-%m-%d', info['birthday'])
     return self.GetJSON({'code': 0, 'msg': '成功', 'uinfo': info})