@@ -20,4 +20,11 @@ export const activityGetApply = function (data) { | |||
method: 'GET', | |||
data | |||
}) | |||
} | |||
export const api_getApply = function (data) { | |||
return request({ | |||
url: '/westreamActivityApply/getApply', | |||
method: 'GET', | |||
data | |||
}) | |||
} |
@@ -9,8 +9,17 @@ Page({ | |||
* 页面的初始数据 | |||
*/ | |||
data: { | |||
ossForm: {}, | |||
imageList:[], | |||
imagePreviewList: [], | |||
formRules: { | |||
imageList: { | |||
validator: function (value) { | |||
return value.length!=0; | |||
}, | |||
warning: false | |||
} | |||
} | |||
}, | |||
/** | |||
@@ -176,68 +185,79 @@ validateForm() { | |||
}, | |||
/* 表单上传 */ | |||
submit(){ | |||
let ossForm = this.data.ossForm | |||
let temp = [] | |||
if (this.data.imageList.length > 0) { | |||
wx.showLoading({title:"上传中",mask:true}) | |||
temp = this.data.imageList.map(item => { | |||
console.log(item); | |||
// 设置文件上传路径 | |||
const randomString = Math.random().toString(36).slice(2) | |||
const timestamp = new Date().getTime() | |||
const key = `imagedir/${randomString}_${timestamp}.png` | |||
// 上传图片 | |||
return new Promise((resolve, reject)=> { | |||
wx.uploadFile({ | |||
url: 'https://ta-tech-image.oss-cn-shanghai.aliyuncs.com', | |||
filePath: item, | |||
name: 'file', | |||
formData: { | |||
key, | |||
OSSAccessKeyId: ossForm.OSSAccessKeyId, | |||
signature: ossForm.signature, | |||
policy: ossForm.policy, | |||
'x-oss-security-token': ossForm.SecurityToken | |||
}, | |||
success: (res)=> { | |||
if(res.statusCode === 204) { | |||
// 上传成功,将图片路径resolve出去 | |||
resolve(key) | |||
} else { | |||
wx.showToast({ | |||
title: '图片上传失败', | |||
}) | |||
this.validateForm().then(res => { | |||
let ossForm = this.data.ossForm | |||
let temp = [] | |||
if (this.data.imageList.length > 0) { | |||
wx.showLoading({title:"上传中",mask:true}) | |||
temp = this.data.imageList.map(item => { | |||
console.log(item); | |||
// 设置文件上传路径 | |||
const randomString = Math.random().toString(36).slice(2) | |||
const timestamp = new Date().getTime() | |||
const key = `imagedir/${randomString}_${timestamp}.png` | |||
// 上传图片 | |||
return new Promise((resolve, reject)=> { | |||
wx.uploadFile({ | |||
url: 'https://ta-tech-image.oss-cn-shanghai.aliyuncs.com', | |||
filePath: item, | |||
name: 'file', | |||
formData: { | |||
key, | |||
OSSAccessKeyId: ossForm.OSSAccessKeyId, | |||
signature: ossForm.signature, | |||
policy: ossForm.policy, | |||
'x-oss-security-token': ossForm.SecurityToken | |||
}, | |||
success: (res)=> { | |||
if(res.statusCode === 204) { | |||
// 上传成功,将图片路径resolve出去 | |||
resolve(key) | |||
wx.showToast({ | |||
title: '您的图片已提交', | |||
icon:'none' | |||
}) | |||
setTimeout(()=>{ | |||
wx.redirectTo({ | |||
url: '../../pages/AttentionMethod/index', | |||
}) | |||
},2000) | |||
} else { | |||
wx.showToast({ | |||
title: '图片上传失败', | |||
}) | |||
reject('图片上传失败') | |||
} | |||
}, | |||
fail: (e)=> { | |||
console.log(e); | |||
reject('图片上传失败') | |||
} | |||
}, | |||
fail: (e)=> { | |||
console.log(e); | |||
reject('图片上传失败') | |||
} | |||
}) | |||
}) | |||
}) | |||
}) | |||
Promise.all(temp).then((res)=> { | |||
let tenantObj = wx.getStorageSync('tenant') | |||
let openid = wx.getStorageSync('openid') | |||
let data = { | |||
openid:openid, | |||
imageUrl:res.join(','), | |||
tenantId:tenantObj.tenantId | |||
} | |||
api_TiktokAdd(data).then(res => { | |||
if (res.code === 0) { | |||
wx.reLaunch({ | |||
url: '/package_first/pages/successPage/index', | |||
}) | |||
Promise.all(temp).then((res)=> { | |||
let tenantObj = wx.getStorageSync('tenant') | |||
let openid = wx.getStorageSync('openid') | |||
let data = { | |||
openid:openid, | |||
imageUrl:res.join(','), | |||
tenantId:tenantObj.tenantId | |||
} | |||
}).finally(()=>{ | |||
wx.hideLoading(); | |||
api_TiktokAdd(data).then(res => { | |||
if (res.code === 0) { | |||
wx.reLaunch({ | |||
url: '/package_first/pages/successPage/index', | |||
}) | |||
} | |||
}).finally(()=>{ | |||
wx.hideLoading(); | |||
}) | |||
}).catch(()=> { | |||
wx.hideLoading() | |||
}) | |||
}).catch(()=> { | |||
wx.hideLoading() | |||
}) | |||
} | |||
} | |||
}) | |||
} | |||
}) |
@@ -2,16 +2,30 @@ | |||
<view> | |||
<view class="add_container"> | |||
<view class="title">上传图片</view> | |||
<view class="upload_image" bindtap="uploadImage"> | |||
<!-- <view class="upload_image" bindtap="uploadImage"> | |||
<view class="add_imageList" wx:for="{{imageList}}" wx:key="index"> | |||
<image style="width:100%;" mode="widthFix" src="{{item}}"></image> | |||
<div class="close" data-current="{{index}}" catchtap="deleteImage"></div> | |||
</view> | |||
<view wx:if="{{imageList.length<5}}" class="upload_part"> | |||
<image style="height: 70rpx;width:70rpx;" mode="widthFix" src="../../../assets/img/upload.png"></image> | |||
<image class="upload_img" style="height: 70rpx;width:70rpx;" mode="widthFix" src="../../../assets/img/upload.png"></image> | |||
<view class="upload_text">上传图片</view> | |||
</view> | |||
</view> --> | |||
<view class="upload_images {{formRules.imageList.warning? 'warning': ''}}"> | |||
<view class="image_list"> | |||
<view class="image_preview" wx:for="{{imagePreviewList}}" wx:key="index"> | |||
<image class="image_item" src="{{item}}" mode="aspectFill" data-item="{{item}}"> | |||
</image> | |||
<div class="close" data-current="{{index}}" catchtap="deleteImage"></div> | |||
</view> | |||
<view class="upload_image" bindtap="uploadImage" wx:if="{{imageList.length<5}}"> | |||
<image style="height: 56rpx;width: 56rpx; padding-top: 80rpx;" mode="widthFix" src="../../../assets/img/upload.png"></image> | |||
<view class="upload_text">上传图片</view> | |||
</view> | |||
</view> | |||
<text class="tips">请先上传图片</text> | |||
</view> | |||
<view class="button" bindtap="submit"> | |||
提交 | |||
</view> |
@@ -30,8 +30,8 @@ | |||
} | |||
.close{ | |||
position: absolute; | |||
top:180rpx; | |||
right:65rpx; | |||
top:0; | |||
right:0; | |||
transform: translate(40%,-40%); | |||
height:50rpx; | |||
width:50rpx; | |||
@@ -39,8 +39,36 @@ | |||
border-radius: 50%; | |||
z-index: 10; | |||
} | |||
.close::before{ | |||
content: ""; | |||
display: block; | |||
position: absolute; | |||
width: 60%; | |||
height: 6rpx; | |||
top:50%; | |||
left:50%; | |||
background:rgb(124, 124, 124); | |||
transform-origin: center; | |||
/* transform: ; */ | |||
transform: translate(-50%,-50%) rotate(45deg); | |||
} | |||
.close::after{ | |||
content: ""; | |||
display: block; | |||
position: absolute; | |||
width: 60%; | |||
height: 6rpx; | |||
top:50%; | |||
left:50%; | |||
background:rgb(124, 124, 124); | |||
transform-origin: center; | |||
/* transform: ; */ | |||
transform: translate(-50%,-50%) rotate(-45deg); | |||
} | |||
.upload_part { | |||
padding-top: 70rpx; | |||
width: 100%; | |||
height: 180rpx; | |||
} | |||
.upload_text{ | |||
@@ -63,4 +91,50 @@ | |||
.add_imageList { | |||
width: 100%; | |||
} | |||
.tips{ | |||
position: absolute; | |||
bottom: 150rpx; | |||
left: 0rpx; | |||
color: red; | |||
font-size: 24rpx; | |||
transform: translate(27rpx, -5rpx); | |||
display: none; | |||
} | |||
.form_item.warning .tips, .use_purpose.warning .tips, .upload_images.warning .tips{ | |||
display: block; | |||
} | |||
.image_item { | |||
height:100%; | |||
width: 100%; | |||
margin-right: 30rpx; | |||
margin-bottom: 20rpx; | |||
} | |||
.image_preview { | |||
height: 250rpx; | |||
width: 100%; | |||
margin-right: 30rpx; | |||
margin-bottom: 20rpx; | |||
position: relative; | |||
} | |||
.image_list { | |||
width: 100%; | |||
margin-top: 20rpx; | |||
padding: 20rpx 0; | |||
display: flex; | |||
flex-wrap: wrap; | |||
justify-content: flex-start; | |||
align-content: flex-start; | |||
} | |||
/* 上传图片 */ | |||
.upload_images { | |||
width: 100%; | |||
margin-bottom: 30rpx; | |||
padding: 0 30rpx; | |||
display: flex; | |||
justify-content: space-between; | |||
align-items: flex-start; | |||
font-size: 28rpx; | |||
color: #666666; | |||
position: relative; | |||
} |
@@ -132,14 +132,14 @@ Page({ | |||
// dialogShow, | |||
// }) | |||
wx.showToast({ | |||
title: '提交成功', | |||
title: '您的宝贵意见已提交', | |||
icon:'none' | |||
}) | |||
setTimeout(()=>{ | |||
wx.switchTab({ | |||
url: '/pages/FirstPage/index', | |||
}) | |||
},1000) | |||
},2000) | |||
}) | |||
} | |||
} |
@@ -10,7 +10,7 @@ | |||
<view class="bottom"> | |||
<view class="suggestion">护河建议</view> | |||
<view class="suggestion_text"> | |||
<textarea class="text_content" maxlength="150" bindinput="remarkInputAction" placeholder="请留下您的宝贵意见。" auto-focus="true" value="{{form.content}}" /> | |||
<textarea class="text_content" maxlength="200" bindinput="remarkInputAction" placeholder="请留下您的宝贵意见。" auto-focus="true" value="{{form.content}}" /> | |||
</view> | |||
<view class="button" bindtap="submit"> | |||
提交 |
@@ -1,5 +1,5 @@ | |||
// package_first/pages/volunteerActivity/index.js | |||
import {api_westreamActivity,activitySubmit,} from '../../../api/volunteer'; | |||
import {api_westreamActivity,activitySubmit,api_getApply} from '../../../api/volunteer'; | |||
Page({ | |||
/** | |||
@@ -7,7 +7,6 @@ Page({ | |||
*/ | |||
data: { | |||
list:[], | |||
activityId:'', | |||
nickname:'', | |||
activityTitle:'', | |||
applyName:'', | |||
@@ -23,7 +22,11 @@ Page({ | |||
* 生命周期函数--监听页面加载 | |||
*/ | |||
onLoad(options) { | |||
const activityId = options.id | |||
this.setData({ | |||
activityId | |||
}) | |||
console.log(options); | |||
}, | |||
/** | |||
@@ -110,7 +113,6 @@ Page({ | |||
list, | |||
}), | |||
console.log(res); | |||
}) | |||
}, | |||
@@ -1,5 +1,5 @@ | |||
// package_first/pages/VolunteerDetail/index.js | |||
import {api_westreamActivity,activitySubmit} from '../../../api/volunteer'; | |||
import {api_westreamActivity,activitySubmit,api_getApply} from '../../../api/volunteer'; | |||
Page({ | |||
@@ -27,6 +27,7 @@ Page({ | |||
this.setData({ | |||
activityInfo:data | |||
}) | |||
this.getApply() | |||
}, | |||
/** | |||
@@ -70,6 +71,21 @@ Page({ | |||
onReachBottom() { | |||
}, | |||
getApply(){ | |||
const openid = wx.getStorageSync('openid') | |||
const params = { | |||
openid, | |||
activityId: this.data.activityInfo.id, | |||
} | |||
api_getApply(params).then(res=>{ | |||
if(res.code==0){ | |||
let status = res.data==null?true:res.data.status==3?true:false | |||
this.setData({ | |||
status | |||
}) | |||
} | |||
}) | |||
}, | |||
activitySubmit(){ | |||
let tenantObj = wx.getStorageSync('tenant') | |||
@@ -98,29 +114,21 @@ Page({ | |||
return `${year}年${month}月${day}日`; | |||
}, | |||
goApply(e){ | |||
if(this.data.status){ | |||
wx.showToast({ | |||
title: '您已报名', | |||
icon:"none" | |||
}) | |||
return | |||
} | |||
// if(status == 2){ | |||
// console.log(this.data.status); | |||
// wx.navigateTo({ | |||
// url:"/package_first/pages/ActivityApply/index" | |||
// }) | |||
// }else{ | |||
// wx.showToast({ | |||
// title: '不在报名时间', | |||
// icon:'none' | |||
// }) | |||
// } | |||
wx.navigateTo({ | |||
url:"/package_first/pages/ActivityApply/index?id=" + this.data.activityInfo.id | |||
}) | |||
wx.navigateTo({ | |||
url:"/package_first/pages/ActivityApply/index?id=" + this.data.activityInfo.id | |||
}) | |||
}, | |||
/** | |||
* 用户点击右上角分享 | |||
*/ | |||
onShareAppMessage() { | |||
} | |||
}) |
@@ -16,7 +16,7 @@ | |||
<view class="time_act">{{activityInfo.activityBeginTime}}~{{activityInfo.activityEndTime}}</view> | |||
</view> | |||
</view> | |||
<view class="button" bindtap="goApply"> | |||
{{status==3?'已报名':'报名'}} | |||
<view wx:if="{{activityInfo.status==2}}" class="button" bindtap="goApply"> | |||
{{status?'已报名':'立即报名'}} | |||
</view> | |||
</view> |