idonate.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. <template>
  2. <view class="idonate">
  3. <view class="one" v-show="limit === 1">
  4. <view class="item">
  5. <view class="item-tit">捐赠个体<text>*</text></view>
  6. <radio-group @change="typeChange" class="check-box">
  7. <label v-for="(item, index) in items" :key="item.value">
  8. <radio :value="item.iid" :checked="index === type" color="#f3392c" style="transform:scale(0.7)" />
  9. <text style="color: #000000;">{{ item.value }}</text>
  10. </label>
  11. </radio-group>
  12. </view>
  13. <template v-if="type === 1">
  14. <view class="item">
  15. <view class="item-tit">捐赠单位<text>*</text></view>
  16. <input type="text" v-model="unit" placeholder="请填写捐赠单位"/>
  17. </view>
  18. <view class="item">
  19. <view class="item-tit">单位联系人<text>*</text></view>
  20. <input type="text" v-model="contacts" placeholder="请填写捐赠方联系人"/>
  21. </view>
  22. <view class="item">
  23. <view class="item-tit">单位电话<text>*</text></view>
  24. <input type="text" v-model="tel" placeholder="请填写单位联系方式"/>
  25. </view>
  26. <view class="item">
  27. <view class="item-tit">企业信用代码</view>
  28. <input type="text" v-model="qyxydm" placeholder="请填写单位的企业信用代码"/>
  29. </view>
  30. </template>
  31. <template v-if="type === 0">
  32. <view class="item">
  33. <view class="item-tit">姓名<text>*</text></view>
  34. <input type="text" v-model="name" placeholder="请填写您的姓名"/>
  35. </view>
  36. <view class="item">
  37. <view class="item-tit">联系方式<text>*</text></view>
  38. <input type="text" v-model="phone" placeholder="请填写您的联系方式"/>
  39. </view>
  40. <view class="item">
  41. <view class="item-tit">身份证号</view>
  42. <input type="text" v-model="identityNumber" placeholder="请填写您的身份证号"/>
  43. </view>
  44. </template>
  45. <view class="item">
  46. <view class="item-tit">是否匿名</view>
  47. <radio-group @change="anonymousChange" class="check-box">
  48. <label>
  49. <radio value="1" :checked="IsAnonymous" color="#f3392c" style="transform:scale(0.7)" />
  50. <text style="color: #000000;">是</text>
  51. </label>
  52. <label>
  53. <radio value="0" :checked="!IsAnonymous" color="#f3392c" style="transform:scale(0.7)" />
  54. <text style="color: #000000;">否</text>
  55. </label>
  56. </radio-group>
  57. </view>
  58. <view class="item">
  59. <view class="item-tit">物流方式<text>*</text></view>
  60. <picker @change="bindLogChange" :range="logs" range-key="name">
  61. <view class="log select" :class="{'action': log }">{{ log || '请选择物流方式' }}</view>
  62. </picker>
  63. </view>
  64. <view class="item no-border-b">
  65. <view class="item-tit">开具发票<text>*</text></view>
  66. <radio-group @change="openChange" class="check-box">
  67. <label>
  68. <radio value="1" :checked="Isopen" color="#f3392c" style="transform:scale(0.7)" />
  69. <text style="color: #000000;">是</text>
  70. </label>
  71. <label>
  72. <radio value="0" :checked="!Isopen" color="#f3392c" style="transform:scale(0.7)" />
  73. <text style="color: #000000;">否</text>
  74. </label>
  75. </radio-group>
  76. </view>
  77. <view class="mask">
  78. <textarea :value="mask" placeholder="如果有备注请填写"/>
  79. </view>
  80. <view class="bbtm"></view>
  81. <view class="jzwz">
  82. <view class="item-tit">捐赠物资<text>*</text></view>
  83. <view class="choose-box">
  84. <view class="choose-item" v-for="(item,index) in wzList" :key="index" @click="dianji(index)">
  85. <picker @change="bindWzChange" :range="wzs" range-key="name">
  86. <view class="wz select" :class="{'action': item.project_donation_name }">{{ item.project_donation_name || '请选择物资分类' }}</view>
  87. </picker>
  88. <input type="number" v-model="item.project_donation_num" placeholder="填写数量"/>
  89. </view>
  90. <view class="more" @click="addMore">
  91. +添加更多
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. <view class="tow" v-show="limit === 2">
  97. <view class="t-item">
  98. <view class="t-tit">
  99. 实物照片(必填)<text>{{swimg | much}}/3</text>
  100. </view>
  101. <view class="img-list flex">
  102. <template v-for="(item,index) in swimg">
  103. <image src="../../static/images/upload.png" mode="" v-if="!item" @click.stop="imgsub(swimg,index)" :key="index"></image>
  104. <image :src="item" mode="" v-if="item" @click.stop="imgsub(item)" :key="index"></image>
  105. </template>
  106. </view>
  107. </view>
  108. <!-- <view class="t-item" v-if="type === 1">
  109. <view class="t-tit">
  110. 营业执照(必填)<text>{{yyimg | much}}/3</text>
  111. </view>
  112. <view class="img-list flex">
  113. <template v-for="(item,index) in yyimg">
  114. <image src="../../static/images/upload.png" mode="" v-if="!item" @click.stop="imgsub(yyimg,index)" :key="index"></image>
  115. <image :src="item" mode="" v-if="item" @click.stop="imgsub(yyimg,index)" :key="index"></image>
  116. </template>
  117. </view>
  118. </view> -->
  119. <view class="t-item">
  120. <view class="t-tit">
  121. 质量合格书(必填)<text>{{zlimg | much}}/3</text>
  122. </view>
  123. <view class="img-list flex">
  124. <template v-for="(item,index) in zlimg">
  125. <image src="../../static/images/upload.png" mode="" v-if="!item" @click.stop="imgsub(zlimg,index)" :key="index"></image>
  126. <image :src="item" mode="" v-if="item" @click.stop="imgsub(zlimg,index)" :key="index"></image>
  127. </template>
  128. </view>
  129. </view>
  130. <view class="t-item">
  131. <view class="t-tit">
  132. 价值凭证<text>{{jzimg | much}}/3</text>
  133. </view>
  134. <view class="img-list flex">
  135. <template v-for="(item,index) in jzimg">
  136. <image src="../../static/images/upload.png" mode="" v-if="!item" @click.stop="imgsub(jzimg,index)" :key="index"></image>
  137. <image :src="item" mode="" v-if="item" @click.stop="imgsub(jzimg,index)" :key="index"></image>
  138. </template>
  139. </view>
  140. </view>
  141. </view>
  142. <view class="jg">
  143. </view>
  144. <view class="btn">
  145. <view class="next" v-show="limit === 1" @click="nextLimit()">
  146. 下一页
  147. </view>
  148. <view class="prev" v-show="limit === 2" @click="prevLimit()">
  149. 上一步
  150. </view>
  151. <view class="sub" v-show="limit === 2" @click="sub">
  152. 提交
  153. </view>
  154. </view>
  155. </view>
  156. </template>
  157. <script>
  158. import { upload } from '@/api/ask.js';
  159. import { getProjectInfo, createProject, getLogistics, getDonationInfo, createUser } from '../../api/money.js';
  160. export default {
  161. data() {
  162. return {
  163. items: [
  164. {
  165. value: '个人',
  166. iid: '0'
  167. },
  168. {
  169. value: '企业(团体)',
  170. iid: '1'
  171. }
  172. ],
  173. IsAnonymous: false,
  174. limit: 1,
  175. type: 0,//捐赠个体0位个人 1为团体(企业)
  176. unit: '',//捐赠单位
  177. contacts: '',//捐赠方联系人
  178. tel: '',//单位电话
  179. log: '',//物流方式
  180. logistics: '',//物流编号
  181. // Logistics: '',//物流方式id
  182. logs: ['顺丰','邮政'],
  183. Isopen: false,//是否开具发票
  184. mask: '',//备注
  185. qyxydm: '',//企业信用代码
  186. name: '',// 捐赠人姓名
  187. phone: '',//捐赠人联系方式
  188. identityNumber: '',//身份证号
  189. wzs: [],//物资分类列表
  190. wzList: [
  191. {
  192. project_donation_id: null,
  193. project_donation_num: null,
  194. project_donation_name: null
  195. }
  196. ],
  197. swimg: [''],//实物照片
  198. yyimg: [''],//营业执照
  199. zlimg: [''],//质量合格证书
  200. jzimg: [''],//价值凭证
  201. true_wzList: [],//最终捐赠的物资列表
  202. hadadd: [],//已添加分类
  203. project_id: 0,//项目ID
  204. }
  205. },
  206. filters:{
  207. much(val) {
  208. let num = 0
  209. val.forEach(item => {
  210. if(item) {
  211. num += 1
  212. }
  213. })
  214. return num
  215. }
  216. },
  217. onLoad(ops) {
  218. if(ops.type) {
  219. this.type = ops.type*1
  220. console.log(this.type,'++++++++')
  221. }
  222. if(ops.id) {
  223. this.project_id = ops.id*1
  224. }
  225. this.getDonationInfo()
  226. this.getLogistics()
  227. },
  228. mounted() {
  229. // this.$set(this,'wzList',[this.wz1,this.wz2])
  230. },
  231. methods: {
  232. //下一页
  233. nextLimit() {
  234. this.limit = 2
  235. },
  236. //下一页
  237. prevLimit() {
  238. this.limit = 1
  239. },
  240. //选择捐赠是个人或团体
  241. typeChange(e) {
  242. this.type = e.detail.value*1
  243. console.log(this.type,'this.typ+++++++++++++++++++++')
  244. },
  245. //选择是否匿名
  246. anonymousChange(e) {
  247. if(e.detail.value !== '1') {
  248. this.IsAnonymous = false
  249. }else {
  250. this.IsAnonymous = true
  251. }
  252. },
  253. //选择物流方式
  254. bindLogChange(e) {
  255. this.log = this.logs[e.detail.value].name
  256. this.logistics = this.logs[e.detail.value].id
  257. },
  258. //选择捐献物资分类
  259. bindWzChange(e){
  260. if(this.hadadd.indexOf(e.detail.value) === -1) {
  261. this.hadadd.push(e.detail.value)
  262. this.wzList[this.currentWzIndex].project_donation_name = this.wzs[e.detail.value].name
  263. this.wzList[this.currentWzIndex].project_donation_id = this.wzs[e.detail.value].id
  264. }else {
  265. this.$api.msg('改分类已添加');
  266. return
  267. }
  268. console.log(this.wzList)
  269. // this.wz = this.logs[e.detail.value].name
  270. },
  271. openChange(e) {
  272. if(e.detail.value !== '1') {
  273. this.Isopen = false
  274. }else {
  275. this.Isopen = true
  276. }
  277. },
  278. imgsub(item,index) {
  279. console.log(index,item)
  280. upload({
  281. filename: ''
  282. }).then(data => {
  283. console.log(data,'6666666666')
  284. this.$set(item,index,data[0].url)
  285. if(index < 2) {
  286. this.$set(item,index+1,'')
  287. }
  288. });
  289. },
  290. dianji(index) {
  291. this.currentWzIndex = index
  292. },
  293. //添加更多
  294. addMore() {
  295. this.wzList.push({
  296. project_donation_id: null,
  297. project_donation_num: null,
  298. project_donation_name: null
  299. })
  300. },
  301. //提交
  302. sub() {
  303. // uni.navigateTo({
  304. // url: '/pages/joinSuc/joinsuccess'
  305. // })
  306. let obj = this;
  307. if(obj.type === 0) {
  308. if (obj.name == '') {
  309. obj.$api.msg('请输入您的姓名');
  310. return;
  311. }
  312. const reg = /^(\+?0?86-?)?1[\d]\d{9}$/;
  313. if (!reg.test(obj.phone)) {
  314. obj.$api.msg('请填写正确的手机号码');
  315. return;
  316. }
  317. }else {
  318. if(obj.unit =='') {
  319. obj.$api.msg('请输入捐赠单位');
  320. return;
  321. }
  322. if(obj.dwPeople =='') {
  323. obj.$api.msg('请输入联系人');
  324. return;
  325. }
  326. if(obj.tel == '') {
  327. obj.$api.msg('请输入单位电话');
  328. return;
  329. }
  330. }
  331. if(obj.log == '') {
  332. obj.$api.msg('请选择物流方式');
  333. return;
  334. }
  335. try{
  336. obj.wzList.forEach( item => {
  337. if(!item.project_donation_id){
  338. throw '请选择物资类别'
  339. }
  340. if(!item.project_donation_num || item.project_donation_num == 0) {
  341. throw '请填写捐赠数量'
  342. }
  343. })
  344. }catch(e) {
  345. obj.$api.msg(e);
  346. return
  347. }
  348. let matter =obj.swimg.toString().replace(/,$/,''),
  349. qc = obj.zlimg.toString().replace(/,$/,''),
  350. worth = obj.jzimg.toString().replace(/,$/,''),
  351. item = obj.wzList
  352. if(matter== ''){
  353. obj.$api.msg('请上传实物照片');
  354. return
  355. }
  356. if(qc == ''){
  357. obj.$api.msg('请上传质量合格证书');
  358. return
  359. }
  360. console.log(matter,'5555555555555555')
  361. createUser({
  362. name: obj.type === 0? obj.name: obj.unit,
  363. phone: obj.phone,
  364. tel: obj.tel,
  365. contacts: obj.contacts,
  366. user_type: obj.type,
  367. logistics: obj.logistics,
  368. anonymous: obj.IsAnonymous? 1:0,
  369. invoice: obj.Isopen? 1:0
  370. }).then( res => {
  371. console.log(JSON.parse(res.msg),'99999999999999999999999999')
  372. let info = JSON.parse(res.msg)
  373. console.log(info.name,'8888888888888')
  374. createProject({
  375. name: obj.type === 0? obj.name: obj.unit,
  376. project_id: obj.project_id,
  377. project_user_id: +info.id,
  378. matter,
  379. qc,
  380. worth,
  381. item
  382. }).then( res => {
  383. console.log(JSON.parse(res.msg),'77777777777777777777')
  384. })
  385. })
  386. },
  387. //获取物资分类列表
  388. getDonationInfo() {
  389. getDonationInfo().then(({data} )=>{
  390. this.wzs = data
  391. console.log(this.wzs,'获取所有物资')
  392. })
  393. },
  394. getLogistics() {
  395. getLogistics().then( ({data}) => {
  396. console.log('88888888888888888888',data)
  397. this.logs = data
  398. })
  399. }
  400. }
  401. }
  402. </script>
  403. <style lang="scss" scoped>
  404. page {
  405. height: 100%;
  406. background-color: #fff;
  407. }
  408. .idonate {
  409. padding: 0 30rpx;
  410. margin-top: 20rpx;
  411. background-color: #fff;
  412. }
  413. .btn {
  414. // height: 196rpx;
  415. // width: 100%;
  416. width: 690rpx;
  417. text-align: center;
  418. display: flex;
  419. justify-content: center;
  420. line-height: 75rpx;
  421. padding-bottom: 54rpx;
  422. // padding-top: 54rpx;
  423. position: fixed;
  424. bottom: 0;
  425. background-color: #fff;
  426. z-index: 9;
  427. .next {
  428. width: 478rpx;
  429. height: 75rpx;
  430. // margin: 0 auto;
  431. background: #FA7E67;
  432. border-radius: 35rpx;
  433. color: #fff;
  434. font-size: 32rpx;
  435. font-family: PingFang SC;
  436. font-weight: 500;
  437. color: #FFFFFF;
  438. }
  439. .prev {
  440. width: 264rpx;
  441. height: 75rpx;
  442. border: 1px solid #FA7E67;
  443. border-radius: 35rpx;
  444. font-size: 32rpx;
  445. font-family: PingFang SC;
  446. font-weight: 500;
  447. color: #FA7E67;
  448. margin-right: 60rpx;
  449. line-height: 70rpx;
  450. }
  451. .sub {
  452. width: 264rpx;
  453. height: 75rpx;
  454. background: #FA7E67;
  455. border-radius: 35rpx;
  456. font-size: 32rpx;
  457. font-family: PingFang SC;
  458. font-weight: 500;
  459. color: #FFFFFF;
  460. line-height: 70rpx;
  461. }
  462. }
  463. .item {
  464. display: flex;
  465. align-items: center;
  466. height: 102rpx;
  467. border-bottom: 1px #ECECEC solid;
  468. font-size: 30rpx;
  469. font-family: PingFang SC;
  470. font-weight: 500;
  471. color: #222222;
  472. line-height: 102rpx;
  473. .item-tit {
  474. flex-shrink: 0;
  475. display: inline-block;
  476. width: 200rpx;
  477. }
  478. text {
  479. color: #F3392C;
  480. }
  481. input {
  482. display: inline-block;
  483. width: 100%;
  484. }
  485. .log {
  486. // display: inline-block;
  487. width: 400rpx;
  488. color: #999;
  489. }
  490. .select {
  491. color: #000;
  492. }
  493. }
  494. .mask {
  495. padding-left: 202rpx;
  496. textarea {
  497. width: 396rpx;
  498. height: 166rpx;
  499. border: 1rpx solid #ccc;
  500. border-radius: 10rpx;
  501. font-size: 24rpx;
  502. font-family: PingFang SC;
  503. font-weight: 500;
  504. color: #000;
  505. line-height: 32rpx;
  506. padding: 24rpx 16rpx;
  507. }
  508. }
  509. .check-box {
  510. flex-grow: 0;
  511. display: flex;
  512. display: inline-block;
  513. }
  514. .no-border-b {
  515. border-bottom: none;
  516. }
  517. .bbtm {
  518. margin-top: 40rpx;
  519. width: 689rpx;
  520. height: 1rpx;
  521. background: #ECECEC;
  522. }
  523. .t-item {
  524. padding: 35rpx 0;
  525. border-bottom: 1px #ECECEC solid;
  526. font-size: 30rpx;
  527. font-family: PingFang SC;
  528. font-weight: 500;
  529. color: #222222;
  530. &:last-of-type {
  531. border-bottom: none;
  532. }
  533. image {
  534. display: block;
  535. width: 160rpx;
  536. height: 160rpx;
  537. // background: red;
  538. border-radius: 5rpx;
  539. // margin: 0 auto;
  540. }
  541. .t-tit {
  542. position: relative;
  543. text {
  544. display: inline-block;
  545. width: 73rpx;
  546. height: 31rpx;
  547. background: #F0433C;
  548. border-radius: 14rpx;
  549. font-size: 24rpx;
  550. font-family: PingFang SC;
  551. font-weight: 500;
  552. color: #FFFFFF;
  553. line-height: 31rpx;
  554. text-align: center;
  555. position: absolute;
  556. right: 0;
  557. // left: 0;
  558. top: 0;
  559. bottom: 0;
  560. margin: auto;
  561. }
  562. }
  563. .img-list {
  564. margin-top: 20rpx;
  565. justify-content: center;
  566. image {
  567. margin-right: 20rpx;
  568. }
  569. }
  570. }
  571. .jzwz {
  572. display: flex;
  573. .item-tit {
  574. font-size: 30rpx;
  575. font-family: PingFang SC;
  576. font-weight: 500;
  577. color: #222222;
  578. padding-top: 39rpx;
  579. line-height: 1;
  580. width: 200rpx;
  581. }
  582. .choose-box {
  583. padding-top: 24rpx;
  584. .choose-item {
  585. display: flex;
  586. margin-bottom: 15rpx;
  587. .wz {
  588. padding-left: 58rpx;
  589. width: 297rpx;
  590. height: 66rpx;
  591. background: #F3F3F3;
  592. border-radius: 5rpx;
  593. font-size: 28rpx;
  594. font-family: PingFang SC;
  595. font-weight: 500;
  596. color: #222222;
  597. line-height: 66rpx;
  598. &::after {
  599. content: '';
  600. width: 0;
  601. height: 0;
  602. border-left: 10rpx solid transparent;
  603. border-right: 10rpx solid transparent;
  604. border-top: 10rpx solid #808080;
  605. position: absolute;
  606. right: 10rpx;
  607. bottom: 26rpx;
  608. }
  609. }
  610. input {
  611. width: 189rpx;
  612. height: 66rpx;
  613. background: #F3F3F3;
  614. border-radius: 5rpx;
  615. line-height: 66rpx;
  616. margin-left: 15rpx;
  617. text-align: center;
  618. }
  619. }
  620. .more {
  621. width: 297rpx;
  622. height: 66rpx;
  623. background: #FFFFFF;
  624. border: 1px solid #FA7E67;
  625. border-radius: 5rpx;
  626. font-size: 24rpx;
  627. font-family: PingFang SC;
  628. font-weight: 500;
  629. color: #FA7E67;
  630. line-height: 66rpx;
  631. text-align: center;
  632. }
  633. }
  634. }
  635. .jg {
  636. height: 150rpx;
  637. background-color: #fff;
  638. }
  639. </style>