idonate.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  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" v-if="wzs.length > wzList.length">
  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. if(ops.wzlist) {
  226. this.wzs = JSON.parse(ops.wzlist)
  227. }else {
  228. this.getDonationInfo()
  229. }
  230. this.getLogistics()
  231. },
  232. mounted() {
  233. // this.$set(this,'wzList',[this.wz1,this.wz2])
  234. },
  235. methods: {
  236. //下一页
  237. nextLimit() {
  238. this.limit = 2
  239. },
  240. //下一页
  241. prevLimit() {
  242. this.limit = 1
  243. },
  244. //选择捐赠是个人或团体
  245. typeChange(e) {
  246. this.type = e.detail.value*1
  247. console.log(this.type,'this.typ+++++++++++++++++++++')
  248. },
  249. //选择是否匿名
  250. anonymousChange(e) {
  251. if(e.detail.value !== '1') {
  252. this.IsAnonymous = false
  253. }else {
  254. this.IsAnonymous = true
  255. }
  256. },
  257. //选择物流方式
  258. bindLogChange(e) {
  259. this.log = this.logs[e.detail.value].name
  260. this.logistics = this.logs[e.detail.value].id
  261. },
  262. //选择捐献物资分类
  263. bindWzChange(e){
  264. if(this.hadadd.indexOf(e.detail.value) === -1) {
  265. this.hadadd.push(e.detail.value)
  266. this.wzList[this.currentWzIndex].project_donation_name = this.wzs[e.detail.value].name
  267. this.wzList[this.currentWzIndex].project_donation_id = this.wzs[e.detail.value].id
  268. }else {
  269. this.$api.msg('该分类已添加');
  270. return
  271. }
  272. console.log(this.wzList)
  273. // this.wz = this.logs[e.detail.value].name
  274. },
  275. openChange(e) {
  276. if(e.detail.value !== '1') {
  277. this.Isopen = false
  278. }else {
  279. this.Isopen = true
  280. }
  281. },
  282. imgsub(item,index) {
  283. console.log(index,item)
  284. upload({
  285. filename: ''
  286. }).then(data => {
  287. console.log(data,'6666666666')
  288. this.$set(item,index,data[0].url)
  289. if(index < 2) {
  290. this.$set(item,index+1,'')
  291. }
  292. });
  293. },
  294. dianji(index) {
  295. this.currentWzIndex = index
  296. },
  297. //添加更多
  298. addMore() {
  299. this.wzList.push({
  300. project_donation_id: null,
  301. project_donation_num: null,
  302. project_donation_name: null
  303. })
  304. },
  305. //提交
  306. sub() {
  307. // uni.navigateTo({
  308. // url: '/pages/joinSuc/joinsuccess'
  309. // })
  310. let obj = this;
  311. if(obj.type === 0) {
  312. if (obj.name == '') {
  313. obj.$api.msg('请输入您的姓名');
  314. return;
  315. }
  316. const reg = /^(\+?0?86-?)?1[\d]\d{9}$/;
  317. if (!reg.test(obj.phone)) {
  318. obj.$api.msg('请填写正确的手机号码');
  319. return;
  320. }
  321. }else {
  322. if(obj.unit =='') {
  323. obj.$api.msg('请输入捐赠单位');
  324. return;
  325. }
  326. if(obj.dwPeople =='') {
  327. obj.$api.msg('请输入联系人');
  328. return;
  329. }
  330. if(obj.tel == '') {
  331. obj.$api.msg('请输入单位电话');
  332. return;
  333. }
  334. }
  335. if(obj.log == '') {
  336. obj.$api.msg('请选择物流方式');
  337. return;
  338. }
  339. try{
  340. obj.wzList.forEach( item => {
  341. if(!item.project_donation_id){
  342. throw '请选择物资类别'
  343. }
  344. if(!item.project_donation_num || item.project_donation_num == 0) {
  345. throw '请填写捐赠数量'
  346. }
  347. })
  348. }catch(e) {
  349. obj.$api.msg(e);
  350. return
  351. }
  352. let matter =obj.swimg.toString().replace(/,$/,''),
  353. qc = obj.zlimg.toString().replace(/,$/,''),
  354. worth = obj.jzimg.toString().replace(/,$/,''),
  355. item = obj.wzList
  356. console.log(item,'物资参数')
  357. if(matter== ''){
  358. obj.$api.msg('请上传实物照片');
  359. return
  360. }
  361. if(qc == ''){
  362. obj.$api.msg('请上传质量合格证书');
  363. return
  364. }
  365. console.log(matter,'5555555555555555')
  366. createUser({
  367. name: obj.type === 0? obj.name: obj.unit,
  368. phone: obj.phone,
  369. tel: obj.tel,
  370. contacts: obj.contacts,
  371. user_type: obj.type,
  372. logistics: obj.logistics,
  373. anonymous: obj.IsAnonymous? 1:0,
  374. invoice: obj.Isopen? 1:0
  375. }).then( res => {
  376. console.log(JSON.parse(res.msg),'99999999999999999999999999')
  377. let info = JSON.parse(res.msg)
  378. console.log(info.name,'8888888888888')
  379. createProject({
  380. name: obj.type === 0? obj.name: obj.unit,
  381. project_id: obj.project_id,
  382. project_user_id: +info.id,
  383. matter,
  384. qc,
  385. worth,
  386. logistics: obj.logistics,
  387. item
  388. }).then( res => {
  389. console.log(JSON.parse(res.msg),'77777777777777777777')
  390. uni.navigateTo({
  391. url: '/pages/joinSuc/joinsuccess'
  392. })
  393. }).catch( err => {
  394. console.log(err)
  395. })
  396. })
  397. },
  398. //获取物资分类列表
  399. getDonationInfo() {
  400. getDonationInfo().then(({data} )=>{
  401. this.wzs = data
  402. console.log(this.wzs,'获取所有物资')
  403. })
  404. },
  405. getLogistics() {
  406. getLogistics().then( ({data}) => {
  407. console.log('88888888888888888888',data)
  408. this.logs = data
  409. })
  410. }
  411. }
  412. }
  413. </script>
  414. <style lang="scss" scoped>
  415. page {
  416. height: 100%;
  417. background-color: #fff;
  418. }
  419. .idonate {
  420. padding: 0 30rpx;
  421. margin-top: 20rpx;
  422. background-color: #fff;
  423. }
  424. .btn {
  425. // height: 196rpx;
  426. // width: 100%;
  427. width: 690rpx;
  428. text-align: center;
  429. display: flex;
  430. justify-content: center;
  431. line-height: 75rpx;
  432. padding-bottom: 54rpx;
  433. // padding-top: 54rpx;
  434. position: fixed;
  435. bottom: 0;
  436. background-color: #fff;
  437. z-index: 9;
  438. .next {
  439. width: 478rpx;
  440. height: 75rpx;
  441. // margin: 0 auto;
  442. background: #FA7E67;
  443. border-radius: 35rpx;
  444. color: #fff;
  445. font-size: 32rpx;
  446. font-family: PingFang SC;
  447. font-weight: 500;
  448. color: #FFFFFF;
  449. }
  450. .prev {
  451. width: 264rpx;
  452. height: 75rpx;
  453. border: 1px solid #FA7E67;
  454. border-radius: 35rpx;
  455. font-size: 32rpx;
  456. font-family: PingFang SC;
  457. font-weight: 500;
  458. color: #FA7E67;
  459. margin-right: 60rpx;
  460. line-height: 70rpx;
  461. }
  462. .sub {
  463. width: 264rpx;
  464. height: 75rpx;
  465. background: #FA7E67;
  466. border-radius: 35rpx;
  467. font-size: 32rpx;
  468. font-family: PingFang SC;
  469. font-weight: 500;
  470. color: #FFFFFF;
  471. line-height: 70rpx;
  472. }
  473. }
  474. .item {
  475. display: flex;
  476. align-items: center;
  477. height: 102rpx;
  478. border-bottom: 1px #ECECEC solid;
  479. font-size: 30rpx;
  480. font-family: PingFang SC;
  481. font-weight: 500;
  482. color: #222222;
  483. line-height: 102rpx;
  484. .item-tit {
  485. flex-shrink: 0;
  486. display: inline-block;
  487. width: 200rpx;
  488. }
  489. text {
  490. color: #F3392C;
  491. }
  492. input {
  493. display: inline-block;
  494. width: 100%;
  495. }
  496. .log {
  497. // display: inline-block;
  498. width: 400rpx;
  499. color: #999;
  500. }
  501. .select {
  502. color: #000;
  503. }
  504. }
  505. .mask {
  506. padding-left: 202rpx;
  507. textarea {
  508. width: 396rpx;
  509. height: 166rpx;
  510. border: 1rpx solid #ccc;
  511. border-radius: 10rpx;
  512. font-size: 24rpx;
  513. font-family: PingFang SC;
  514. font-weight: 500;
  515. color: #000;
  516. line-height: 32rpx;
  517. padding: 24rpx 16rpx;
  518. }
  519. }
  520. .check-box {
  521. flex-grow: 0;
  522. display: flex;
  523. display: inline-block;
  524. }
  525. .no-border-b {
  526. border-bottom: none;
  527. }
  528. .bbtm {
  529. margin-top: 40rpx;
  530. width: 689rpx;
  531. height: 1rpx;
  532. background: #ECECEC;
  533. }
  534. .t-item {
  535. padding: 35rpx 0;
  536. border-bottom: 1px #ECECEC solid;
  537. font-size: 30rpx;
  538. font-family: PingFang SC;
  539. font-weight: 500;
  540. color: #222222;
  541. &:last-of-type {
  542. border-bottom: none;
  543. }
  544. image {
  545. display: block;
  546. width: 160rpx;
  547. height: 160rpx;
  548. // background: red;
  549. border-radius: 5rpx;
  550. // margin: 0 auto;
  551. }
  552. .t-tit {
  553. position: relative;
  554. text {
  555. display: inline-block;
  556. width: 73rpx;
  557. height: 31rpx;
  558. background: #F0433C;
  559. border-radius: 14rpx;
  560. font-size: 24rpx;
  561. font-family: PingFang SC;
  562. font-weight: 500;
  563. color: #FFFFFF;
  564. line-height: 31rpx;
  565. text-align: center;
  566. position: absolute;
  567. right: 0;
  568. // left: 0;
  569. top: 0;
  570. bottom: 0;
  571. margin: auto;
  572. }
  573. }
  574. .img-list {
  575. margin-top: 20rpx;
  576. justify-content: center;
  577. image {
  578. margin-right: 20rpx;
  579. }
  580. }
  581. }
  582. .jzwz {
  583. display: flex;
  584. .item-tit {
  585. font-size: 30rpx;
  586. font-family: PingFang SC;
  587. font-weight: 500;
  588. color: #222222;
  589. padding-top: 39rpx;
  590. line-height: 1;
  591. width: 200rpx;
  592. }
  593. .choose-box {
  594. padding-top: 24rpx;
  595. .choose-item {
  596. display: flex;
  597. margin-bottom: 15rpx;
  598. .wz {
  599. padding-left: 58rpx;
  600. width: 297rpx;
  601. height: 66rpx;
  602. background: #F3F3F3;
  603. border-radius: 5rpx;
  604. font-size: 28rpx;
  605. font-family: PingFang SC;
  606. font-weight: 500;
  607. color: #222222;
  608. line-height: 66rpx;
  609. &::after {
  610. content: '';
  611. width: 0;
  612. height: 0;
  613. border-left: 10rpx solid transparent;
  614. border-right: 10rpx solid transparent;
  615. border-top: 10rpx solid #808080;
  616. position: absolute;
  617. right: 10rpx;
  618. bottom: 26rpx;
  619. }
  620. }
  621. input {
  622. width: 189rpx;
  623. height: 66rpx;
  624. background: #F3F3F3;
  625. border-radius: 5rpx;
  626. line-height: 66rpx;
  627. margin-left: 15rpx;
  628. text-align: center;
  629. }
  630. }
  631. .more {
  632. width: 297rpx;
  633. height: 66rpx;
  634. background: #FFFFFF;
  635. border: 1px solid #FA7E67;
  636. border-radius: 5rpx;
  637. font-size: 24rpx;
  638. font-family: PingFang SC;
  639. font-weight: 500;
  640. color: #FA7E67;
  641. line-height: 66rpx;
  642. text-align: center;
  643. }
  644. }
  645. }
  646. .jg {
  647. height: 150rpx;
  648. background-color: #fff;
  649. }
  650. </style>