index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view class="main">
  3. <navbar :config="config" backColor="#666"></navbar>
  4. <image class="cover" src="/static/applyPoints/cover.png"></image>
  5. <view class="content">
  6. <view class="detail-top-title">
  7. <image class="line" src="/static/common/line1.png"></image>
  8. <text class="title">申领公益积分</text>
  9. <image class="line" src="/static/common/line1.png"></image>
  10. </view>
  11. <view class="common-form">
  12. <view class="form-title required">捐赠金额</view>
  13. <view class="form-item">
  14. <input v-model="form.donation_amount" type="digit" @input="changeDonation" placeholder="请输入捐赠金额" />
  15. </view>
  16. <view class="form-title required">
  17. 捐赠凭证<text class="tip">(如证书截图、付款记录、捐款记录等)</text>
  18. </view>
  19. <view class="form-item">
  20. <view class="upload-box">
  21. <view @click.stop.self="upload()">
  22. <u-upload max-count="1" action="" :file-list="imgFiles" :show-progress="false" upload-text="" height="154rpx" width="154rpx" custom-btn @on-remove="delImg">
  23. <view slot="addBtn" class="card" @click.stop="upload()">
  24. <text class="iconfont2">&#xe641;</text>
  25. </view>
  26. </u-upload>
  27. </view>
  28. <view class="upload-tip">注意:您填写申领信息后,基金工作人员将会在后台审核处 理,预计1-3天内处理!</view>
  29. <unloadimg ref="unloadimg" imgCount="1" type="other" url="" @result="unloadRes" style="display: none;"></unloadimg>
  30. </view>
  31. </view>
  32. <button class="submit-btn" @click="submit">立即提交</button>
  33. <view @click="goApplyPointsHistory" class="history">申领记录>></view>
  34. </view>
  35. </view>
  36. <uni-popup class="submit-popup" ref="submitPopup" type="center" :mask-click="false">
  37. <view class="content-box">
  38. <view class="title">提交完成</view>
  39. <view class="content">
  40. <image class="success-icon" src="/static/common/success-icon.png"></image>
  41. <view class="tip">
  42. 公益捐款信息已经提交,工作人员会 尽快与您取得联系对接捐款事宜。
  43. </view>
  44. <view class="btn-box">
  45. <button @click="closePopup();goHistory();">确认</button>
  46. </view>
  47. </view>
  48. </view>
  49. </uni-popup>
  50. </view>
  51. </template>
  52. <script>
  53. import unloadimg from "@/components/uploadImg/imgUpload.vue";
  54. export default {
  55. components: {
  56. unloadimg
  57. },
  58. data() {
  59. return {
  60. config: {
  61. back: true,
  62. title: '申领公益积分',
  63. color: '#1a1a1a',
  64. backgroundColor: [1, '#fff'],
  65. statusBarFontColor: 'black'
  66. },
  67. form: {
  68. donation_amount: ''
  69. },
  70. imgFiles: []
  71. }
  72. },
  73. methods: {
  74. // 限制只能输入2位小数
  75. changeDonation(e) {
  76. //正则表达试
  77. e.target.value = (e.target.value.match(/^\d*(\.?\d{0,2})/g)[0]) || null;
  78. //重新赋值给input
  79. this.$nextTick(() => {
  80. this.form.donation_amount = e.target.value
  81. })
  82. },
  83. goHistory(){
  84. uni.navigateTo({
  85. url: '/pages/applyPoints/history'
  86. })
  87. },
  88. goApplyPointsHistory(){
  89. uni.navigateTo({
  90. url: '/pages/applyPoints/history'
  91. })
  92. },
  93. upload(index){
  94. this.$refs.unloadimg.upPhoto();
  95. },
  96. unloadRes(e){
  97. this.imgFiles = e.map(url=>{
  98. return {
  99. url
  100. }
  101. });
  102. },
  103. closePopup(){
  104. this.$refs.submitPopup.close();
  105. },
  106. delImg(index){
  107. this.$refs.unloadimg.imgArray.splice(index, 1);
  108. this.imgFiles.splice(index,1);
  109. },
  110. valForm(){
  111. let error = '';
  112. if((this.form.donation_amount??'') == ''){
  113. error = '请输入捐赠金额';
  114. return error;
  115. }
  116. if(this.imgFiles.length <= 0){
  117. error = '请上传捐赠凭证';
  118. return error;
  119. }
  120. return error;
  121. },
  122. submit(){
  123. let that = this;
  124. let error = that.valForm()
  125. if(error==''){
  126. uni.showModal({
  127. title: '提示',
  128. content: '您确认要提交吗',
  129. success: function (res) {
  130. if (res.confirm) {
  131. uni.showLoading({
  132. title: '正在提交中...',
  133. mask: true
  134. });
  135. let isAdd = !that.form.id;
  136. that.$http.post('/official/donation/apply',{
  137. ...that.form,
  138. donation_voucher: that.imgFiles[0].url
  139. })
  140. .then(res => {
  141. if(res.code==200){
  142. that.$refs.submitPopup.open();
  143. }
  144. })
  145. .finally(()=>{
  146. uni.hideLoading();
  147. })
  148. }
  149. }
  150. });
  151. }else{
  152. uni.showToast({
  153. icon: 'none',
  154. title: error
  155. })
  156. }
  157. },
  158. }
  159. };
  160. </script>
  161. <style lang="scss" scoped>
  162. .main{
  163. box-sizing: border-box;
  164. .cover{
  165. width: 100%;
  166. height: 340rpx;
  167. background-color: #f2f2f2;
  168. }
  169. .content{
  170. box-sizing: border-box;
  171. padding: 40rpx 0 18rpx 0;
  172. }
  173. .upload-box{
  174. .card{
  175. height: 154rpx;
  176. width: 154rpx;
  177. background-color: #F5F5F5;
  178. display: flex;
  179. align-items: center;
  180. justify-content: center;
  181. .iconfont2{
  182. font-size: 60rpx;
  183. color: #999999;
  184. }
  185. }
  186. }
  187. .history{
  188. font-size: 30rpx;
  189. font-family: PingFang SC, PingFang SC-Regular;
  190. font-weight: 400;
  191. text-align: left;
  192. color: #0b844a;
  193. line-height: 38rpx;
  194. text-align: center;
  195. }
  196. }
  197. </style>