1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
// 圈子创建第一步
require_once ("../user_include.inc");
ErrorLogger::doOutput("Compass...ajax_circle_edit.php....Start.", 0);
//获取参数
$unionId = ParamUtil::getRequestString("unionId");
$circleId = ParamUtil::getRequestNumber("circleId", 0);
$title = ParamUtil::getRequestString("title");//圈子名称
$needCheck = ParamUtil::getRequestBoolean("needCheck", false);//圈子名称
$longitude = ParamUtil::getRequestString("longitude");//用户位置的经度
$latitude = ParamUtil::getRequestString("latitude");//用户位置的纬度
$comment = ParamUtil::getRequestString("comment");//圈子简介
$province = ParamUtil::getRequestString("province");
$city = ParamUtil::getRequestString("city");
$district = ParamUtil::getRequestString("district");
$result = array();
//参数检查
if(empty($unionId) || empty($circleId)) {
$result["message"] = "参数错误!";
responseNG($result);
}
//判断用户是否存在
$param = array();
$param['unionid'] = $unionId;
$param['delete_flg'] = false;
$userList = UserMst::getList($param,'id','desc', 0, 1);
if(empty($userList)) {
$result["message"] = "用户不存在!";
responseNG($result);
}
$userMst = $userList[0];
//圈子是否存在
$param = array();
$param['id'] = $circleId;
$param['owner_id'] = $userMst->id;
$param['delete_flg'] = false;
$circleDatList = CircleDat::getList($param,'id','desc', 0, 1);
if(empty($circleDatList)) {
$result["message"] = "圈子不存在!";
responseOK($result);
}
$circleDat = $circleDatList[0];
//编辑圈子
if(!empty($title)) {
$circleDat->title = $title;
$circleDat->need_check = $needCheck;
$circleDat->longitude = $longitude;
$circleDat->latitude = $latitude;
$circleDat->province = $province;
$circleDat->city = $city;
$circleDat->district = $district;
$circleDat->owner_id = $userMst->id;
$circleDat->comment = $comment;
$circleDat->save();
} else {
//上传图片处理
ErrorLogger::doOutput("Compass...ajax_circle_edit.php....here!!", 0);
if(!empty($_FILES['frontImage']['tmp_name'])){
$aliHandler = new AliUploadHandler();
$upload_file = FileUploadUtil::getScalarFile(@$_FILES['frontImage']);
$tmp_file_name = date("Ymd") . "_" . trim(basename($upload_file->name));//保存的名字自定义,这里如果图片的名字原来的是aa.jp,保存成20200220_aa.jpg
$url = $aliHandler->uploadImg($tmp_file_name, $upload_file->tmp_name);
ErrorLogger::doOutput("Compass...ajax_circle_edit.php....url1=" . $url, 0);
//这里的url就是http://compass-dev.oss-cn-beijing.aliyuncs.com/20200220_aa.jpg
$circleDat->front_image = $url;
$circleDat->save();
//返回数据
$result["message"] = "编辑成功!";
$result["circleDat"] = $circleDat;
responseOK($result);
}
}
//返回数据
$result["message"] = "编辑成功!";
$result["circleDat"] = $circleDat;
responseOK($result);
responseNG($result);
ErrorLogger::doOutput("Compass...ajax_circle_edit.php....End.", 0);
//返回结果
responseOK($result);
function responseNG($result) {
$result = array("status"=>"NG", "result"=>$result);
print json_encode($result);
exit;
}
function responseOK($result) {
$result = array("status"=>"OK", "result"=>$result);
print json_encode($result);
exit;
}
?>