index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class="main">
  3. <navbar :config="config" backColor="#666"></navbar>
  4. <image class="cover" src="/static/publicDonation/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>
  12. <view class="common-form">
  13. <view class="form-title">联系人</view>
  14. <view class="form-item">
  15. <input v-model="form.contact_person" placeholder="请输入联系人" :maxlength="10" />
  16. </view>
  17. <view class="form-title">联系电话</view>
  18. <view class="form-item">
  19. <input v-model="form.contact_phone" type="number" placeholder="请输入联系电话" :maxlength="11" />
  20. </view>
  21. <view class="form-title">公司名称</view>
  22. <view class="form-item">
  23. <input v-model="form.company_name" placeholder="请输入公司名称,非必填" :maxlength="20" />
  24. </view>
  25. <view class="form-title">捐赠意向</view>
  26. <view class="form-item">
  27. <u-checkbox-group>
  28. <u-checkbox v-model="form.is_donation" name="捐款">捐款</u-checkbox>
  29. <u-checkbox v-model="form.is_offering" name="捐物">捐物</u-checkbox>
  30. </u-checkbox-group>
  31. </view>
  32. <template v-if="form.is_donation">
  33. <view class="form-title">意向金额</view>
  34. <view class="form-item">
  35. <input @input="dealMoney" type="digit" maxlength="7" v-model="form.interest_amount" placeholder="请填写想要捐赠的金额" />
  36. </view>
  37. </template>
  38. <template v-if="form.is_offering">
  39. <view class="form-title">意向物品</view>
  40. <view class="form-item">
  41. <input v-model="form.item_name" placeholder="请填写想要捐赠的物品" />
  42. </view>
  43. </template>
  44. <view class="form-tip">
  45. 注意:您填写捐赠信息后,基金工作人员将会电话联系您、确 定捐赠具体事宜!
  46. </view>
  47. <button class="submit-btn" @click="submit()">立即提交</button>
  48. </view>
  49. <uni-popup class="submit-popup" ref="submitPopup" type="center" :mask-click="false">
  50. <view class="content-box">
  51. <view class="title">提交完成</view>
  52. <view class="content">
  53. <image class="success-icon" src="/static/common/success-icon.png"></image>
  54. <view class="tip" style="width: 416rpx;">
  55. 公益捐款信息已经提交,工作人员会 尽快与您取得联系对接捐款事宜。
  56. </view>
  57. <button class="btn" @click="closePopup()">知道了</button>
  58. </view>
  59. </view>
  60. </uni-popup>
  61. <u-modal v-model="tostShow" content="确认提交?" show-cancel-button @confirm="affirmSubmit"></u-modal>
  62. </view>
  63. </template>
  64. <script>
  65. export default {
  66. data() {
  67. return {
  68. config: {
  69. back: true,
  70. title: '公益捐赠',
  71. color: '#1a1a1a',
  72. backgroundColor: [1, '#fff'],
  73. statusBarFontColor: 'black'
  74. },
  75. imgFiles: [],
  76. form: {
  77. contact_person: '',
  78. contact_phone: '',
  79. company_name: '',
  80. is_donation: false,
  81. is_offering: false,
  82. interest_amount: '',
  83. item_name: ''
  84. },
  85. tostShow:false
  86. }
  87. },
  88. watch: {
  89. 'form.is_donation'(val, oldVal){
  90. if(!this.form.is_donation){
  91. this.form.interest_amount = '';
  92. }
  93. },
  94. 'form.is_offering'(val, oldVal){
  95. if(!this.form.is_offering){
  96. this.form.item_name = '';
  97. }
  98. }
  99. },
  100. methods: {
  101. goApplyPointsHistory() {
  102. uni.navigateTo({
  103. url: '/pages/applyPoints/history'
  104. })
  105. },
  106. submit() {
  107. let regExp = new RegExp("^1\\d{10}$");
  108. if (!this.form.contact_person) {
  109. uni.showToast({
  110. icon: "none",
  111. title: '请输入联系人',
  112. duration: 1500
  113. });
  114. return
  115. } else if (!this.form.contact_phone) {
  116. uni.showToast({
  117. icon: "none",
  118. title: '请输入联系电话',
  119. duration: 1500
  120. });
  121. return
  122. } else if (!regExp.test(this.form.contact_phone)) {
  123. uni.showToast({
  124. icon: "none",
  125. title: '请输入正确的联系电话',
  126. duration: 1500
  127. });
  128. return
  129. } else if (!this.form.is_donation && !this.form.is_offering) {
  130. uni.showToast({
  131. icon: "none",
  132. title: '请选择捐赠意向',
  133. duration: 1500
  134. });
  135. return
  136. } else if (!this.form.item_name && this.form.is_offering) {
  137. uni.showToast({
  138. icon: "none",
  139. title: '请输入意向物品',
  140. duration: 1500
  141. });
  142. return
  143. } else if (!this.form.interest_amount && this.form.is_donation) {
  144. uni.showToast({
  145. icon: "none",
  146. title: '请输入意向金额',
  147. duration: 1500
  148. });
  149. return
  150. }
  151. this.form.is_donation = this.form.is_donation || false;
  152. this.form.is_offering = this.form.is_offering || false;
  153. this.tostShow=true;
  154. },
  155. dealMoney(e) {
  156. e.target.value = (e.target.value.match(/^\d*(\.?\d{0,2})/g)[0]) || null
  157. //重新赋值给input
  158. this.$nextTick(() => {
  159. this.form.interest_amount = e.target.value ?e.target.value:''
  160. })
  161. },
  162. affirmSubmit(){
  163. uni.showLoading({
  164. title: '加载中'
  165. });
  166. this.$http.post('/donation/apply', this.form).then(res => {
  167. uni.hideLoading();
  168. if (res && res.code == 200) {
  169. this.$refs.submitPopup.open();
  170. }
  171. })
  172. },
  173. closePopup() {
  174. this.$refs.submitPopup.close();
  175. uni.navigateBack()
  176. },
  177. }
  178. };
  179. </script>
  180. <style lang="scss" scoped>
  181. .main {
  182. box-sizing: border-box;
  183. .cover {
  184. width: 100%;
  185. height: 340rpx;
  186. background-color: #f2f2f2;
  187. }
  188. .content {
  189. box-sizing: border-box;
  190. padding: 40rpx 0 18rpx 0;
  191. }
  192. .mr20 {
  193. margin-right: 20rpx;
  194. }
  195. }
  196. </style>