修改问题
This commit is contained in:
parent
1d51fe072a
commit
f655104cdd
|
|
@ -16,12 +16,29 @@ use app\common\model\UserCoupon;
|
||||||
use app\common\model\UserRecharge;
|
use app\common\model\UserRecharge;
|
||||||
use app\common\model\UserVip;
|
use app\common\model\UserVip;
|
||||||
use app\common\server\LiveMoney;
|
use app\common\server\LiveMoney;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Chart\Legend;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
use app\common\server\Qcode;
|
use app\common\server\Qcode;
|
||||||
|
|
||||||
|
use Qcloud\Cos\Client;
|
||||||
class User extends Base
|
class User extends Base
|
||||||
{
|
{
|
||||||
|
private $secretId; // 腾讯云 API 密钥 SecretId
|
||||||
|
private $secretKey; // 腾讯云 API 密钥 SecretKey
|
||||||
|
private $bucket; // 存储桶名称
|
||||||
|
private $region; // 存储桶所在地域
|
||||||
|
private $domain; // 存储桶所在地域
|
||||||
|
public function initialize()
|
||||||
|
{
|
||||||
|
$config = getConfig('uploads');
|
||||||
|
$this->secretId = $config['AccessKeyId'];
|
||||||
|
$this->secretKey = $config['AccessKeySecret'];
|
||||||
|
$this->bucket = $config['Bucket'];
|
||||||
|
$this->region = $config['Region'];
|
||||||
|
$this->domain = $config['Domain'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 我的
|
* 我的
|
||||||
|
|
@ -130,6 +147,8 @@ class User extends Base
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
$nickname = request()->param('nickname', '');
|
$nickname = request()->param('nickname', '');
|
||||||
$headimg = request()->param('headimg', '');
|
$headimg = request()->param('headimg', '');
|
||||||
|
$imagebase = request()->param('imagebase', '');
|
||||||
|
|
||||||
if (empty($nickname)) {
|
if (empty($nickname)) {
|
||||||
return $this->renderError("请输入姓名");
|
return $this->renderError("请输入姓名");
|
||||||
}
|
}
|
||||||
|
|
@ -137,15 +156,52 @@ class User extends Base
|
||||||
if ($nickname) {
|
if ($nickname) {
|
||||||
$save['nickname'] = $nickname;
|
$save['nickname'] = $nickname;
|
||||||
}
|
}
|
||||||
if ($headimg) {
|
if ($imagebase && $imagebase != "") {
|
||||||
|
$base64Image = str_replace('data:image/png;base64,', '', $imagebase);
|
||||||
|
// 解码 Base64 数据为二进制数据
|
||||||
|
$binaryData = base64_decode($base64Image);
|
||||||
|
// 初始化腾讯云 COS 客户端
|
||||||
|
$cosClient = new Client([
|
||||||
|
'region' => $this->region,
|
||||||
|
'schema' => 'https', // 协议
|
||||||
|
'credentials' => [
|
||||||
|
'secretId' => $this->secretId,
|
||||||
|
'secretKey' => $this->secretKey,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
// 生成唯一文件名
|
||||||
|
$userId = $user['id'];
|
||||||
|
$date = date('Ymd');
|
||||||
|
|
||||||
if (strpos($headimg, '/storage') !== false) {
|
$uniqueFileName = $userId . '_' . uniqid('') . '.png';
|
||||||
$str = explode('/storage',$headimg);
|
$cosKey = 'storage/users/icon/' . $uniqueFileName; // COS 中的文件路径
|
||||||
$save['headimg'] = '/storage'.$str[1];
|
|
||||||
} else {
|
try {
|
||||||
$save['headimg'] = $headimg;
|
// 上传文件到腾讯云 COS
|
||||||
|
$result = $cosClient->putObject([
|
||||||
|
'Bucket' => $this->bucket,
|
||||||
|
'Key' => $cosKey,
|
||||||
|
'Body' => $binaryData, // 文件内容
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 获取文件访问 URL
|
||||||
|
// $cosUrl = $result['Location'];
|
||||||
|
$imgurl = $this->domain . $cosKey;
|
||||||
|
$save['headimg'] = $imgurl;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->renderError('头像上传失败' . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// if ($headimg) {
|
||||||
|
|
||||||
|
// if (strpos($headimg, '/storage') !== false) {
|
||||||
|
// $str = explode('/storage', $headimg);
|
||||||
|
// $save['headimg'] = '/storage' . $str[1];
|
||||||
|
// } else {
|
||||||
|
// $save['headimg'] = $headimg;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
$res = Usermodel::field('nickname,headimg')->where('id', '=', $user['id'])->update($save);
|
$res = Usermodel::field('nickname,headimg')->where('id', '=', $user['id'])->update($save);
|
||||||
if ($res) {
|
if ($res) {
|
||||||
return $this->renderSuccess('修改成功');
|
return $this->renderSuccess('修改成功');
|
||||||
|
|
@ -402,7 +458,8 @@ class User extends Base
|
||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function coupon_detail(){
|
public function coupon_detail()
|
||||||
|
{
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
$user_id = $user['id'];
|
$user_id = $user['id'];
|
||||||
$coupon_id = request()->param("coupon_id/d", 0);
|
$coupon_id = request()->param("coupon_id/d", 0);
|
||||||
|
|
@ -606,7 +663,8 @@ writelog(11111111111,$user_id);
|
||||||
/**
|
/**
|
||||||
* 红包随机金额
|
* 红包随机金额
|
||||||
*/
|
*/
|
||||||
public function rand_money($total,$personal_num,$min_money=1){
|
public function rand_money($total, $personal_num, $min_money = 1)
|
||||||
|
{
|
||||||
// $money_total = $total; //总金额
|
// $money_total = $total; //总金额
|
||||||
// $personal_num = $personal_num; //总数量
|
// $personal_num = $personal_num; //总数量
|
||||||
// $min_money = $min_money; //最小金额
|
// $min_money = $min_money; //最小金额
|
||||||
|
|
@ -644,7 +702,8 @@ writelog(11111111111,$user_id);
|
||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function coupon_ji_suan(Request $request){
|
public function coupon_ji_suan(Request $request)
|
||||||
|
{
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
$user_id = $user['id'];
|
$user_id = $user['id'];
|
||||||
$coupon_ids = request()->param("coupon_ids", '');
|
$coupon_ids = request()->param("coupon_ids", '');
|
||||||
|
|
@ -703,7 +762,8 @@ writelog(11111111111,$user_id);
|
||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function coupon_synthesis(){
|
public function coupon_synthesis()
|
||||||
|
{
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
$user_id = $user['id'];
|
$user_id = $user['id'];
|
||||||
$coupon_ids = request()->param("coupon_ids", '');
|
$coupon_ids = request()->param("coupon_ids", '');
|
||||||
|
|
@ -882,7 +942,8 @@ writelog(11111111111,$user_id);
|
||||||
海报生成器
|
海报生成器
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public function product_img(){
|
public function product_img()
|
||||||
|
{
|
||||||
#海报名称
|
#海报名称
|
||||||
$user_info = $this->getUser();
|
$user_info = $this->getUser();
|
||||||
$user_id = $user_info['id'];
|
$user_id = $user_info['id'];
|
||||||
|
|
@ -999,7 +1060,8 @@ writelog(11111111111,$user_id);
|
||||||
* 重抽卡列表
|
* 重抽卡列表
|
||||||
* @return \think\response\Json
|
* @return \think\response\Json
|
||||||
*/
|
*/
|
||||||
public function item_card_list(){
|
public function item_card_list()
|
||||||
|
{
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
|
|
||||||
$list = Db::name('user_item_card')
|
$list = Db::name('user_item_card')
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ class Wx extends MyController
|
||||||
'access_token_time' => $access_token_time,
|
'access_token_time' => $access_token_time,
|
||||||
];
|
];
|
||||||
|
|
||||||
$redis->set($redis_key, json_encode($data), $expires_in);
|
$redis->set($redis_key, json_encode($data), $expires_in - 1800);
|
||||||
|
|
||||||
return $access_token;
|
return $access_token;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user