fillNonprofitArchives.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="common_page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title="填写公益档案" bgColor="transparent"></cus-header>
  4. <image src="https://oss.familydaf.cn/sxsnfile/20251218/ff31a76e0e1148378a318382b998a51f.png" class="top_bg_img" mode="widthFix"></image>
  5. <view class="box" v-if="activity">
  6. <view class="box-title">活动信息</view>
  7. <view class="box-pre adf">
  8. <view class="box-pre-left">活动名称</view>
  9. <view class="box-pre-right">{{activity?.activityName||''}}</view>
  10. </view>
  11. <view class="box-pre adf">
  12. <view class="box-pre-left">人员姓名</view>
  13. <view class="box-pre-right">{{activity?.memberName||''}}</view>
  14. </view>
  15. <view class="box-pre adf">
  16. <view class="box-pre-left">参与时间</view>
  17. <view class="box-pre-right">{{activity?.signinTime||''}}</view>
  18. </view>
  19. <view class="box-pre adf">
  20. <view class="box-pre-left">公益支持</view>
  21. <view class="box-pre-right">{{activity?.channelName||''}}</view>
  22. </view>
  23. </view>
  24. <view class="box">
  25. <view class="box-title">活动心得</view>
  26. <up-textarea v-model="experience" placeholder="请分享参加公益活动心得,至少输入10个字~" count border="none" style="height: 250rpx;margin-top: 28rpx;padding: 0;font-size: 26rpx;color: #252525;"></up-textarea>
  27. </view>
  28. <view class="box">
  29. <view class="box-title">活动照片<text>(分享活动照片)</text></view>
  30. <view class="box-img">
  31. <up-upload
  32. :fileList="fileList"
  33. @afterRead="afterRead"
  34. @delete="deletePic"
  35. multiple
  36. :maxCount="3"
  37. width="160rpx"
  38. height="160rpx"
  39. >
  40. <image src="https://oss.familydaf.cn/sxsnfile/20251218/2131899f0e684fa1a451ea8aa3ebc237.png"
  41. mode="widthFix" style="width: 160rpx;height: 160rpx;"></image>
  42. </up-upload>
  43. </view>
  44. </view>
  45. <view class="btn" @click="handleSubmit">提交</view>
  46. </view>
  47. </template>
  48. <script setup name="">
  49. import CusHeader from '@/components/CusHeader/index.vue'
  50. import { BaseApi2 } from '../common/api/baseApi';
  51. import { onLoad } from '@dcloudio/uni-app'
  52. import { ref, getCurrentInstance } from 'vue'
  53. const { proxy } = getCurrentInstance()
  54. const activity = ref(null)
  55. const experience = ref('')
  56. const fileList = ref([])
  57. const deletePic = (event) => {
  58. const index = typeof event === 'object' ? event.index : event
  59. fileList.value.splice(index, 1);
  60. };
  61. // 新增图片
  62. const afterRead = async (event) => {
  63. let lists = [].concat(event.file);
  64. let fileListLen = fileList.value.length;
  65. lists.map((item) => {
  66. fileList.value.push({
  67. ...item,
  68. status: 'uploading',
  69. message: '上传中',
  70. });
  71. });
  72. for (let i = 0; i < lists.length; i++) {
  73. const result = await uploadFilePromise(lists[i].url);
  74. let item = fileList.value[fileListLen];
  75. fileList.value.splice(fileListLen, 1, {
  76. ...item,
  77. status: 'success',
  78. message: '',
  79. url: result,
  80. });
  81. fileListLen++;
  82. }
  83. };
  84. const uploadFilePromise = (url) => {
  85. return new Promise((resolve, reject) => {
  86. let a = uni.uploadFile({
  87. url: BaseApi2+'/sys/oss/upload',
  88. filePath: url,
  89. name: 'file',
  90. success: (res) => {
  91. setTimeout(() => {
  92. let data = JSON.parse(res.data)
  93. if(data&&data.code===0){
  94. resolve(data.data);
  95. }else proxy.$showToast(data?.msg)
  96. }, 1000);
  97. },
  98. fail: err =>{
  99. resolve('');
  100. }
  101. });
  102. });
  103. };
  104. const handleSubmit = () => {
  105. if(!experience.value) return proxy.$showToast('请输入活动心得')
  106. if(fileList.value.length===0) return proxy.$showToast('请上传活动照片')
  107. let activityFile = fileList.value.map(f=>f.url).join(';')
  108. proxy.$api.post('/core/activity/signup/addArchive',{
  109. activityFile,
  110. activityId:activity.value?.activityId,
  111. experience:experience.value,
  112. memberId:activity.value?.memberId
  113. }).then(({data:res})=>{
  114. if(res.code!==0) return proxy.$showToast(res.msg)
  115. uni.navigateTo({
  116. url:'/pagesHome/fillNonprofitResult'
  117. })
  118. })
  119. }
  120. onLoad((options)=>{
  121. if(options.activity){
  122. activity.value = JSON.parse(decodeURIComponent(options.activity));
  123. if(activity.value.signinTime) activity.value.signinTime = new Date(activity.value.signinTime).Format('yyyy.MM.dd hh:mm:ss')
  124. }
  125. })
  126. </script>
  127. <style scoped lang="scss">
  128. .common_page{
  129. padding-bottom: 64rpx;
  130. .box{
  131. background: #FFFFFF;
  132. border-radius: 24rpx;
  133. margin-top: 20rpx;
  134. padding: 36rpx 24rpx;
  135. position: relative;
  136. &-title{
  137. font-family: PingFang-SC, PingFang-SC;
  138. font-weight: bold;
  139. font-size: 36rpx;
  140. color: #151B29;
  141. line-height: 48rpx;
  142. text{
  143. font-weight: 400;
  144. font-size: 26rpx;
  145. color: #B2B2B2;
  146. line-height: 37rpx;
  147. margin-left: 16rpx;
  148. }
  149. }
  150. &-pre{
  151. margin-top: 35rpx;
  152. &-left{
  153. width: 160rpx;
  154. font-family: PingFangSC, PingFang SC;
  155. font-weight: 400;
  156. font-size: 28rpx;
  157. color: #676775;
  158. line-height: 30rpx;
  159. text-align: left;
  160. }
  161. &-right{
  162. width: calc(100% - 160rpx);
  163. font-family: PingFangSC, PingFang SC;
  164. font-weight: 400;
  165. font-size: 30rpx;
  166. color: #252525;
  167. line-height: 30rpx;
  168. }
  169. }
  170. &-img{
  171. margin-top: 47rpx;
  172. }
  173. }
  174. .btn{
  175. width: calc(100% - 32rpx);
  176. height: 90rpx;
  177. background: #B7F358;
  178. border-radius: 45rpx;
  179. font-family: PingFang-SC, PingFang-SC;
  180. font-weight: bold;
  181. font-size: 32rpx;
  182. color: #151B29;
  183. line-height: 90rpx;
  184. text-align: center;
  185. letter-spacing: 2rpx;
  186. margin: 40rpx auto 0;
  187. }
  188. }
  189. </style>