Commit d1535e5e by biao

111

parent f21dbba2
...@@ -33,17 +33,18 @@ if(empty($familyEventDat)) { ...@@ -33,17 +33,18 @@ if(empty($familyEventDat)) {
$result["message"] = "参数错误!"; $result["message"] = "参数错误!";
responseNG($result); responseNG($result);
} }
$familyEventDat->publish_time = substr($familyEventDat->publish_time,0,10);
//todo 改为从家园系统数据库获取数据,格式一致!! //todo 改为从家园系统数据库获取数据,格式一致!!
//todo 获取已完成和未完成人员名单 //todo 获取已完成和未完成人员名单
$finishUserList = array(); $finishUserList = array();
$finishUserList[] = "家校用户1"; $finishUserList[] = array("name"=>"家园用户1", "head_img"=>"http://zgzyz.cyol.com/tplimg/25049.files/zt_ewm2.gif");
$finishUserList[] = "家校用户2"; $finishUserList[] = array("name"=>"家园用户2", "head_img"=>"http://zgzyz.cyol.com/tplimg/25049.files/zt_ewm2.gif");
$unfinishUserList = array(); $unfinishUserList = array();
$unfinishUserList[] = "家校用户3"; $unfinishUserList[] = array("name"=>"家园用户3", "head_img"=>"http://zgzyz.cyol.com/tplimg/25049.files/zt_ewm2.gif");
$unfinishUserList[] = "家校用户4"; $unfinishUserList[] = array("name"=>"家园用户4", "head_img"=>"http://zgzyz.cyol.com/tplimg/25049.files/zt_ewm2.gif");
//组装返回数据 //组装返回数据
......
...@@ -33,6 +33,7 @@ if(empty($sociaEventDat)) { ...@@ -33,6 +33,7 @@ if(empty($sociaEventDat)) {
$result["message"] = "参数错误!"; $result["message"] = "参数错误!";
responseNG($result); responseNG($result);
} }
$sociaEventDat->publish_time = substr($sociaEventDat->publish_time,0,10);
//todo 改为从家校系统数据库获取数据,格式一致!! //todo 改为从家校系统数据库获取数据,格式一致!!
......
...@@ -13,7 +13,7 @@ $comment = ParamUtil::getRequestString("comment");//说明 ...@@ -13,7 +13,7 @@ $comment = ParamUtil::getRequestString("comment");//说明
$result = array(); $result = array();
//参数检查 //参数检查
if(empty($unionId || empty($eventId) || empty($comment))) { if(empty($unionId || empty($eventId))) {
$result["message"] = "参数错误!"; $result["message"] = "参数错误!";
responseNG($result); responseNG($result);
} }
...@@ -28,9 +28,9 @@ if(empty($userList)) { ...@@ -28,9 +28,9 @@ if(empty($userList)) {
responseNG($result); responseNG($result);
} }
//查询社会实践活动 //查询亲子活动活动
//todo 以后改为家校系统查询 //todo 以后改为家校系统查询
$familyEventDat = VolunteerEventDat::getById($eventId); $familyEventDat = FamilyEventDat::getById($eventId);
if(empty($familyEventDat)) { if(empty($familyEventDat)) {
$result["message"] = "参数错误!"; $result["message"] = "参数错误!";
responseNG($result); responseNG($result);
...@@ -39,23 +39,48 @@ if(empty($familyEventDat)) { ...@@ -39,23 +39,48 @@ if(empty($familyEventDat)) {
$userMst = $userList[0]; $userMst = $userList[0];
//添加用户完成情况 //添加用户完成情况
$familyEventMemberDat = new FamilyEventMemberDat[0]; if(!empty($comment)) {
$familyEventMemberDat->family_event_id = $familyEventDat->id; //没有图片,只有感想的情况
$familyEventMemberDat->user_id = $userMst->id; $familyEventMemberDat = new FamilyEventMemberDat();
$familyEventMemberDat->comment = $comment; $familyEventMemberDat->family_event_id = $familyEventDat->id;
$familyEventMemberDat->save(); $familyEventMemberDat->user_id = $userMst->id;
$familyEventMemberDat->comment = $comment;
//处理上传图片 $familyEventMemberDat->point = ABILITY_POINT;
$aliHandler = new AliUploadHandler(); $familyEventMemberDat->save();
if(!empty($_FILES['photo']['tmp_name'])){
//给用户添加能力分(todo)
$userMst->ability_point += ABILITY_POINT;
$userMst->save();
} else {
//批量接受上传图
$param = array();
$param['social_event_id'] = $familyEventDat->id;
$param['user_id'] = $userMst->id;
$param['delete_flg'] = false;
$tmpList = FamilyEventMemberDat::getList($param,'id','desc', 0, 1);
if(!empty($tmpList)) {
$familyEventMemberDat = $tmpList[0];
//接受图片并更新
//处理上传图片
$aliHandler = new AliUploadHandler();
if(!empty($_FILES['photo']['tmp_name'])){
$upload_file = FileUploadUtil::getScalarFile(@$_FILES['photo']); $upload_file = FileUploadUtil::getScalarFile(@$_FILES['photo']);
$tmp_file_name = date("Ymd") . "_" . trim(basename($upload_file->name));//保存的名字自定义,这里如果图片的名字原来的是aa.jp,保存成20200220_aa.jpg $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); $url = $aliHandler->uploadImg($tmp_file_name, $upload_file->tmp_name);
//这里的url就是http://compass-dev.oss-cn-beijing.aliyuncs.com/20200220_aa.jpg //这里的url就是http://compass-dev.oss-cn-beijing.aliyuncs.com/20200220_aa.jpg
ErrorLogger::doOutput("Compass...ajax_set_social_event_result.php....images=" . $familyEventMemberDat->images, 0);
if(empty($familyEventMemberDat->images)) {
$familyEventMemberDat->images = $url; $familyEventMemberDat->images = $url;
} else {
$familyEventMemberDat->images = $familyEventMemberDat->images . "|" . $url;
}
$familyEventMemberDat->save();
}
}
} }
$familyEventMemberDat->save();
//todo 改为通知家校系统用户 //todo 改为通知家校系统用户
......
src/wx/img/1.jpg

50 KB | W: | H:

src/wx/img/1.jpg

93.7 KB | W: | H:

src/wx/img/1.jpg
src/wx/img/1.jpg
src/wx/img/1.jpg
src/wx/img/1.jpg
  • 2-up
  • Swipe
  • Onion skin
...@@ -38,7 +38,7 @@ Page({ ...@@ -38,7 +38,7 @@ Page({
success: function (res) { success: function (res) {
if (res.statusCode == 200) { if (res.statusCode == 200) {
that.setData({ that.setData({
eventDat: res.data.result.sociaEventDat, eventDat: res.data.result.familyEventDat,
finishUserList: res.data.result.finishUserList, finishUserList: res.data.result.finishUserList,
unfinishUserList: res.data.result.unfinishUserList unfinishUserList: res.data.result.unfinishUserList
}) })
......
// pages/uploadDocuments/uploadDocuments.js // pages/uploadDocuments/uploadDocuments.js
import Notify from '../../dist/notify/notify';
var app = getApp()
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
value:'', eventId: '',
fileList: [], eventTitle: '',
comment: '',
fileList1: [],
fileList2: [],
fileList3: [],
imgPaths: [],
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
//获取参数
this.setData({
eventId: options.eventId,
eventTitle: options.eventTitle
})
}, },
/** /**
...@@ -64,23 +76,78 @@ Page({ ...@@ -64,23 +76,78 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
}, },
onChange(event) { //第1张图片
// event.detail 为当前输入的值 delete1(event) {
console.log(event.detail); const { index, name } = event.detail;
const fileList = this.data[`fileList1`];
fileList.splice(index, 1);
this.setData({ [`fileList1`]: fileList });
},
afterRead1(event) {
const { file, name } = event.detail;
const fileList = this.data[`fileList1`];
const images = this.data.imgPaths;
this.setData({
[`fileList1`]: fileList.concat(file),
imgPaths: images.concat(file[0].path)
});
},
beforeRead1(event) {
const { file, callback } = event.detail;
if (file[0].path.indexOf('jpg') < 0) {
wx.showToast({ title: '请选择jpg图片上传', icon: 'none' });
callback(false);
return;
}
callback(true);
},
//第2张图片
delete2(event) {
const { index, name } = event.detail;
const fileList = this.data[`fileList2`];
fileList.splice(index, 1);
this.setData({ [`fileList2`]: fileList });
},
afterRead2(event) {
const { file, name } = event.detail;
const fileList = this.data[`fileList2`];
const images = this.data.imgPaths;
this.setData({
[`fileList2`]: fileList.concat(file),
imgPaths: images.concat(file[0].path)
});
},
beforeRead2(event) {
const { file, callback } = event.detail;
if (file[0].path.indexOf('jpg') < 0) {
wx.showToast({ title: '请选择jpg图片上传', icon: 'none' });
callback(false);
return;
}
callback(true);
}, },
delete(event) {
//第3张图片
delete3(event) {
const { index, name } = event.detail; const { index, name } = event.detail;
const fileList = this.data[`fileList`]; const fileList = this.data[`fileList3`];
fileList.splice(index, 1); fileList.splice(index, 1);
this.setData({ [`fileList`]: fileList }); this.setData({ [`fileList3`]: fileList });
}, },
afterRead(event) { afterRead3(event) {
const { file, name } = event.detail; const { file, name } = event.detail;
const fileList = this.data[`fileList`]; const fileList = this.data[`fileList3`];
const images = this.data.imgPaths;
this.setData({ [`fileList`]: fileList.concat(file) }); this.setData({
[`fileList3`]: fileList.concat(file),
imgPaths: images.concat(file[0].path)
});
}, },
beforeRead(event) { beforeRead3(event) {
const { file, callback } = event.detail; const { file, callback } = event.detail;
if (file[0].path.indexOf('jpg') < 0) { if (file[0].path.indexOf('jpg') < 0) {
wx.showToast({ title: '请选择jpg图片上传', icon: 'none' }); wx.showToast({ title: '请选择jpg图片上传', icon: 'none' });
...@@ -89,7 +156,78 @@ Page({ ...@@ -89,7 +156,78 @@ Page({
} }
callback(true); callback(true);
}, },
shangchuan(){ //上传素材
upload() {
var that = this;
//感想必须输入
if (that.data.comment == null || that.data.comment.trim() == "") {
Notify('请输入感想')
return
}
var config = wx.getStorageSync('config');
wx.request({
url: app.url + 'ajax_set_family_event_result.php',
data: {
unionId: config.unionId,
eventId: that.data.eventId,
comment: that.data.comment,
},
header: { 'content-type': 'application/json' },
method: 'GET',
dataType: 'json',
success: function (res) {
//循环上传图片
var completeCount = 0;
for (var i = 0; i < that.data.imgPaths.length; i++) {
//停顿1秒
var imgPath = that.data.imgPaths[i];
setTimeout(function () {
wx.uploadFile({
url: app.url + 'ajax_set_family_event_result.php?unionId=' + config.unionId + "&eventId=" + that.data.eventId,
filePath: imgPath,
name: 'photo',
header: { 'content-type': 'multipart/form-data' },
success: function (res) {
},
fail: function (res) {
console.log(res, '上传失败')
},
complete: function (res) {
completeCount++;
},
})
}, 1000) //延迟时间 这里是1秒
}
//循环执行等待全部结束
var a = setInterval(function () {
//循环执行代码
if (that.data.imgPaths.length == completeCount) {
//跳转到首页
wx.showToast({
title: '上传成功!',
icon: 'success',
duration: 2000
});
clearInterval(a)
//跳转到社会实践页面
wx.redirectTo({
url: '../familyEvent/familyEvent',
});
}
}, 1000) //循环时间 这里是1秒
},
fail: function (res) { },
complete: function (res) { },
})
},
//获取输入的感想
inputComment(event) {
this.setData({
comment: event.detail.value
})
} }
}) })
\ No newline at end of file
{ {
"usingComponents": {} "usingComponents": {},
"navigationBarTitleText": "亲子活动"
} }
\ No newline at end of file
<!--pages/uploadDocuments/uploadDocuments.wxml--> <!--pages/joinSocialEvent/joinSocialEvent.wxml-->
<view class='uploadDocuments'> <view class='uploadDocuments'>
<view class='uploadDocuments_title'>活动名称:马群xxxxxxxx</view> <view class='uploadDocuments_title'>活动名称:{{eventTitle}}</view>
<view class='uploadDocuments_ganwu'> <view class='uploadDocuments_ganwu'>
活动感悟:<textarea class='inpGanwu'></textarea> 活动感悟:<textarea class='inpGanwu' bindinput="inputComment" value='{{comment}}'></textarea>
</view> </view>
<view style="width:100%;margin-top:10px;">活动图片(3张即可):</view>
<view class='uploadDocuments_img'> <view class='uploadDocuments_img'>
活动图片:
<view> <view>
<van-uploader file-list="{{ fileList }}" <van-uploader file-list="{{ fileList1 }}"
max-count="3" max-count="1"
multiple multiple
bind:after-read="afterRead" bind:after-read="afterRead1"
bind:before-read="beforeRead" bind:before-read="beforeRead1"
use-before-read="{{ true }}" use-before-read="{{ true }}"
bind:delete="delete"/> bind:delete="delete1"/>
<text style='font-size:12px;color:#666'>仅支持jpg格式</text> <text style='font-size:12px;color:#666'>仅支持jpg格式</text>
</view> </view>
<text style='font-size:14px;color:#666'>(3张即可)</text> <view>
<van-uploader file-list="{{ fileList2 }}"
max-count="1"
multiple
bind:after-read="afterRead2"
bind:before-read="beforeRead2"
use-before-read="{{ true }}"
bind:delete="delete2"/>
<text style='font-size:12px;color:#666'>仅支持jpg格式</text>
</view>
<view>
<van-uploader file-list="{{ fileList3 }}"
max-count="1"
multiple
bind:after-read="afterRead3"
bind:before-read="beforeRead3"
use-before-read="{{ true }}"
bind:delete="delete3"/>
<text style='font-size:12px;color:#666'>仅支持jpg格式</text>
</view>
<text style='font-size:14px;color:#666'></text>
</view> </view>
<view style='width:100%;display:flex;justify-content: center;'> <view style='width:100%;display:flex;justify-content: center;'>
<van-button type="default" bind:click="shangchuan">确认上传</van-button> <view class="actionBtn" bindtap="upload">确认上传</view>
</view> </view>
<van-notify id="van-notify" />
</view> </view>
...@@ -22,10 +22,23 @@ ...@@ -22,10 +22,23 @@
} }
.uploadDocuments_img{ .uploadDocuments_img{
display: flex; display: flex;
height: 320px; height: 240px;
margin-top: 20px; margin-top: 10px;
} }
.uploadDocuments_img>view{ .uploadDocuments_img>view{
width: 100px; width: 100px;
height: 100px; height: 100px;
} }
.actionBtn{
width: 75%;
height: 40px;
line-height: 40px;
text-align: center;
font-size: 14px;
margin: 10px auto;
background: #0D76ED;
margin-bottom: 10px;
color: #fff;
border-radius: 15px;
}
\ No newline at end of file
...@@ -77,10 +77,7 @@ Page({ ...@@ -77,10 +77,7 @@ Page({
onShareAppMessage: function () { onShareAppMessage: function () {
}, },
onChange(event) {
// event.detail 为当前输入的值
console.log(event.detail);
},
//第1张图片 //第1张图片
delete1(event) { delete1(event) {
const { index, name } = event.detail; const { index, name } = event.detail;
...@@ -218,7 +215,7 @@ Page({ ...@@ -218,7 +215,7 @@ Page({
clearInterval(a) clearInterval(a)
//跳转到社会实践页面 //跳转到社会实践页面
wx.navigateTo({ wx.redirectTo({
url: '../socialEvent/socialEvent', url: '../socialEvent/socialEvent',
}); });
} }
......
<!--pages/uploadDocuments/uploadDocuments.wxml--> <!--pages/joinSocialEvent/joinSocialEvent.wxml-->
<view class='uploadDocuments'> <view class='uploadDocuments'>
<view class='uploadDocuments_title'>活动名称:{{eventTitle}}</view> <view class='uploadDocuments_title'>活动名称:{{eventTitle}}</view>
<view class='uploadDocuments_ganwu'> <view class='uploadDocuments_ganwu'>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment