hyjj.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. <template>
  2. <view class="content">
  3. <!-- <view class="top">
  4. 爱心捐款
  5. </view> -->
  6. <view class="box">
  7. <!-- <view class="box-item" v-if="!isHelp">
  8. <view class="box-left">
  9. <text class="imp">*</text>捐款意向
  10. </view>
  11. <view class="box-right">
  12. <picker :value="index" @change="PickerDire" :range="chooseDire" class="box-right">
  13. <text>{{ intention || '请选择捐款意向'}}</text>
  14. </picker>
  15. </view>
  16. </view> -->
  17. <view class="box-item">
  18. <view class="box-left">
  19. <text class="imp">*</text>缴交方式
  20. </view>
  21. <view class="box-right">
  22. <input type="text" placeholder="" v-model="jjtype" disabled/>
  23. <!-- <picker @change="PickerType" :value="index" :range="chooseType" class="box-right">
  24. <text>{{ way || '请选择捐缴交方式'}}</text>
  25. </picker> -->
  26. </view>
  27. </view>
  28. <!-- <view class="box-item">
  29. <view class="box-left">
  30. 捐款金额
  31. </view>
  32. <view class="box-right">
  33. <picker @change="PickerMoney" :value="index" :range="chooseMoney" class="box-right">
  34. <text>{{ money || '请选择捐款金额'}}</text>
  35. </picker>
  36. </view>
  37. </view> -->
  38. <view class="box-item1">
  39. <!-- <view class="box-item1" @click="tochooseMoney"> -->
  40. <view class="box-main">
  41. <view class="box-left">
  42. <text class="imp">*</text>缴交金额
  43. </view>
  44. <view class="box-right">
  45. <input type="text" placeholder="请选择金额" v-model="money" disabled />
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- <view class="infoOptional">
  51. 信息(选填)
  52. </view> -->
  53. <view class="box">
  54. <view class="box-item">
  55. <view class="box-left">
  56. <view v-if="jjtype == '个人会员'">
  57. <text class="imp">*</text>姓名
  58. </view>
  59. <view v-if="jjtype == '团体会员'">
  60. <text class="imp">*</text>单位
  61. </view>
  62. </view>
  63. <view class="box-right">
  64. <input type="text" placeholder="请真实填写" v-model="donate_er" />
  65. </view>
  66. </view>
  67. <view class="box-item">
  68. <view class="box-left">
  69. <text class="imp">*</text>手机号
  70. </view>
  71. <view class="box-right">
  72. <input type="text" placeholder="请填写手机号" v-model="mobile" />
  73. </view>
  74. </view>
  75. </view>
  76. <view class="submit" @click="confirm()">
  77. 立即提交
  78. </view>
  79. <uni-popup ref="popup" type="bottom" @click="close">
  80. <view class="popup_row">
  81. <view class="title">
  82. <view class="title-left">
  83. 一份爱心,一份力量!
  84. </view>
  85. <view class="cancel" @click="cancel">
  86. <!-- <image src="../../static/img/取消.png" mode=""></image> -->
  87. </view>
  88. </view>
  89. <view class="money-btn">
  90. <view class="btn" v-for="item in moneyList" :key="item.id">
  91. <button type="default" @click="addmoney(item)">{{ item.money}}</button>
  92. </view>
  93. </view>
  94. <view class="pop-main">
  95. <view class="money-left">
  96. 金额数
  97. </view>
  98. <view class="money-iup">
  99. <input type="text" value="" v-model="popmoney" placeholder="请选择金额或者自定义金额" />
  100. </view>
  101. <view class="">
  102. </view>
  103. </view>
  104. <view class="comfirm">
  105. <view class="comfirm1" @click="comfirm1()">
  106. 确认
  107. </view>
  108. </view>
  109. </view>
  110. </uni-popup>
  111. <uni-popup ref="popup1" type="center">
  112. <view class="popup-box">
  113. <!-- <view class="img">
  114. <image src="../../static/img/WechatIMG662.png" mode=""></image>
  115. </view> -->
  116. <view class="mian">
  117. <view class="delivery">
  118. 支付失败
  119. <!-- {{ i18n.qrhwsdm }} -->
  120. </view>
  121. <view class="nocancel">
  122. 请退出页面,重新登录
  123. <!-- {{ i18n.wfcx }} -->
  124. </view>
  125. <view class="comfirm-box">
  126. <view class="cancel" @click="cancel1">
  127. 取消
  128. </view>
  129. <view class="comfirm" @click="comfirmExit()">
  130. 确认
  131. </view>
  132. </view>
  133. </view>
  134. </view>
  135. </uni-popup>
  136. </view>
  137. </template>
  138. <script>
  139. import {
  140. chosintention,
  141. joinDona
  142. } from '@/api/ask.js';
  143. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  144. import {
  145. computedOrderkey,
  146. balance,
  147. createOrderkey,
  148. orderPay
  149. } from '@/api/money.js';
  150. import {
  151. saveUrl,
  152. interceptor
  153. } from '@/utils/loginUtils.js';
  154. import {
  155. mapState,
  156. mapMutations
  157. } from 'vuex';
  158. import {
  159. userinfo
  160. } from '@/api/user.js';
  161. import { getVipmoney, createOrder } from '@/api/index.js'
  162. export default {
  163. components: {
  164. uniPopup,
  165. // uniLoadMore
  166. },
  167. data() {
  168. return {
  169. mid: '',
  170. jjtype: '',//会员类型
  171. index: 0,
  172. intention: '', // 捐款意向
  173. category_id: '', // 捐款意向ID
  174. way: '', // 捐款方式
  175. way_id: '', // 捐款方式id
  176. money: '', // 捐款金额
  177. // elsemoney: '', // 其他金额
  178. popmoney: '', // 按钮金额 弹窗金额
  179. is_show: true,
  180. moneyList: [{
  181. id: 0,
  182. money: 500
  183. },
  184. {
  185. id: 1,
  186. money: 200
  187. },
  188. {
  189. id: 2,
  190. money: 100
  191. },
  192. {
  193. id: 3,
  194. money: 50
  195. },
  196. {
  197. id: 4,
  198. money: 20
  199. },
  200. ],
  201. is_public: '0', // 是否实名公开
  202. is_receipts: '1', // 是否开发票
  203. public: true, // 是否实名公开
  204. receipts: false, // 是否开发票
  205. donate_er: '', // 捐款人/单位
  206. mobile: '', // 手机号
  207. isshowMoney: false, // 其他金额是否展示
  208. address: '', // 联系地址
  209. // chooseDire: ['请选择捐款意向','红十字人道事业(非定向捐赠)','疫情防控','其他','红十字博爱送万家','AED救护及科普','青少年生命安全教育基地建设项目','关注重度失能老人项目','青少年白血病救护项目','地芯行动-关爱地中海贫血儿童','会费缴纳'],
  210. chooseDire: [],
  211. chooseList: [], //捐款意向真实列表
  212. chooseType: ['个人', '单位'],
  213. chooseMoney: ['5元', '10元', '50元', '其他金额'],
  214. payLoding: false, //判断是否支付中
  215. froms: '', //保存h5中数据来源对象
  216. type: '', //判断是否从订单中进入
  217. payName: 'weixin',
  218. // orderInfo: {},
  219. help_id: 0,
  220. isHelp: false,
  221. order_name: '',
  222. }
  223. },
  224. onLoad(options) {
  225. // console.log(333,options)
  226. if (options.helpid) {
  227. this.help_id = options.helpid
  228. this.order_name = options.order_name
  229. this.isHelp = true
  230. }
  231. if(options.type == 1) {
  232. this.jjtype = '个人会员'
  233. }else {
  234. this.jjtype = '团体会员'
  235. }
  236. },
  237. onShow() {
  238. if (!this.hasLogin) {
  239. // 登录拦截
  240. uni.showModal({
  241. title: '登录',
  242. content: '您未登录,是否马上登陆?',
  243. success: e => {
  244. if (e.confirm) {
  245. saveUrl()
  246. interceptor();
  247. }
  248. },
  249. fail: e => {
  250. console.log(e);
  251. uni.showModal({
  252. title: '错误',
  253. content: JSON.stringify(e),
  254. })
  255. }
  256. });
  257. } else {
  258. // this.loadData();
  259. userinfo({}).then(({
  260. data
  261. }) => {
  262. // this.setUserInfo(data);
  263. // this.to_phone = data.mobile || ''
  264. });
  265. this.getVipmoney()
  266. }
  267. },
  268. computed: {
  269. ...mapState('user', ['userInfo', 'baseURL', 'hasLogin']),
  270. ...mapState(['weichatObj']),
  271. },
  272. methods: {
  273. getVipmoney() {
  274. let obj = this
  275. getVipmoney().then(({
  276. data
  277. }) => {
  278. console.log(data, 'getVipmoney');
  279. data.forEach(e => {
  280. if (e.name == obj.jjtype) {
  281. obj.money = e.pay_price;
  282. obj.mid = e.id;
  283. console.log(obj.money, obj.mid)
  284. }
  285. });
  286. });
  287. },
  288. // 点击捐赠意向
  289. // addType(e) {
  290. // chosintention({}).then(({
  291. // data
  292. // }) => {
  293. // this.chooseDire = data.map(item => {
  294. // console.log(item.name,item.name.indexOf('红十字会'),'++++++++++++')
  295. // if(item.name.indexOf('红十字会') != -1) {
  296. // return item.name
  297. // }
  298. // })
  299. // this.chooseList = data.map(item => {
  300. // if(item.name.indexOf('红十字会') != -1) {
  301. // return item
  302. // }
  303. // })
  304. // }).catch()
  305. // },
  306. // 选择捐赠意向
  307. PickerDire: function(e) {
  308. console.log(334, e)
  309. this.intention = this.chooseDire[e.target.value];
  310. this.category_id = this.chooseList[e.target.value].id;
  311. },
  312. // 选择捐款方式
  313. PickerType: function(e) {
  314. this.way = this.chooseType[e.target.value];
  315. this.way_id = e.target.value;
  316. this.index = e.target.value;
  317. console.log('选择捐款方式', this.way_id)
  318. if (this.index == 1) {
  319. this.is_show = true
  320. } else {
  321. this.is_show = false
  322. }
  323. // if ( )
  324. },
  325. // 选择捐款金额
  326. PickerMoney: function(e) {
  327. this.money = this.chooseMoney[e.target.value];
  328. this.index = e.target.value + 1;
  329. console.log('选择金额', this.money)
  330. if (this.money == '其他金额') {
  331. this.isshowMoney = true
  332. } else {
  333. this.isshowMoney = false
  334. this.elsemoney = ''
  335. }
  336. },
  337. // 其他金额 选择
  338. tochooseMoney: function() {
  339. this.$refs.popup.open();
  340. },
  341. addmoney(mon) {
  342. console.log('点击金额按钮', mon.money)
  343. this.popmoney = mon.money
  344. console.log(123, this.popmoney)
  345. },
  346. cancel() {
  347. this.$refs.popup.close();
  348. },
  349. cancel1() {
  350. this.$refs.popup1.close();
  351. },
  352. comfirm1: function() {
  353. let obj = this
  354. if (obj.popmoney.toString().trim() == '') {
  355. console.log('输入框为空')
  356. } else {
  357. console.log('输入框为不为空')
  358. obj.money = obj.popmoney
  359. obj.popmoney = ''
  360. this.$refs.popup.close();
  361. }
  362. },
  363. comfirmExit() {
  364. console.log('点击comfirmExit')
  365. this.$refs.popup1.close()
  366. uni.switchTab({
  367. url: '/pages/home/home'
  368. });
  369. },
  370. // 是否实名公开
  371. switch1Change(e) {
  372. this.public = e.detail.value
  373. console.log(e.detail.value,'e.detail.value')
  374. if (e.detail.value) {
  375. this.is_public = '1'
  376. } else {
  377. this.is_public = '0'
  378. }
  379. console.log(this.is_public)
  380. },
  381. //是都寄发票
  382. switch2Change(e) {
  383. this.is_receipts = e.detail.value
  384. if (e.detail.value) {
  385. this.is_receipts = '1'
  386. } else {
  387. this.is_receipts = '0'
  388. }
  389. console.log('is_receipts', this.is_receipts)
  390. },
  391. // 提交
  392. confirm: async function() {
  393. let obj = this
  394. if (obj.jjtype == '团体会员') {
  395. if (!obj.donate_er) {
  396. this.$api.msg('请填写您的单位');
  397. return;
  398. }
  399. } else {
  400. if (!obj.donate_er) {
  401. this.$api.msg('请填写您的姓名');
  402. return;
  403. }
  404. }
  405. const reg = /^(\+?0?86-?)?1[\d]\d{9}$/;
  406. if (!reg.test(obj.mobile)) {
  407. obj.$api.msg('请填写正确的手机号码');
  408. return;
  409. }
  410. uni.showModal({
  411. title: '提示',
  412. content: '续费' + obj.jjtype + '需要缴交' + obj.money + '元年费,是否续费',
  413. success: function(res) {
  414. if (res.confirm) {
  415. console.log('用户点击确定');
  416. createOrder({
  417. level_id: obj.mid,
  418. body: '红会年费',
  419. pay_type: 0,
  420. // name: obj.name,
  421. pay_price: obj.money,
  422. from: 'weixin'
  423. }).then(({data}) =>{
  424. let res = data.jsConfig;
  425. obj.weichatObj.chooseWXPay({
  426. timestamp: res.timestamp,
  427. nonceStr: res.nonceStr,
  428. package: res.package,
  429. signType: res.signType,
  430. paySign: res.paySign,
  431. success: function(res) {
  432. // uni.navigateTo({
  433. // url: '../joinSuc/joinNow'
  434. // });
  435. // obj.loadBaseData()
  436. uni.showModal({
  437. title:'提示',
  438. content: '续费成功'
  439. })
  440. },
  441. fail: function(res) {
  442. console.log(res, "失败")
  443. console.log(res.errMsg)
  444. }
  445. });
  446. })
  447. } else if (res.cancel) {
  448. console.log('用户点击取消');
  449. }
  450. }
  451. });
  452. }
  453. },
  454. }
  455. </script>
  456. <style lang="scss">
  457. .content {}
  458. .top {
  459. display: flex;
  460. align-items: center;
  461. justify-content: center;
  462. background-color: #E63931;
  463. color: #FFFFFF;
  464. padding: 22rpx 0;
  465. }
  466. .box {
  467. margin-top: 10rpx;
  468. .box-item2 {
  469. background-color: #FFFFFF;
  470. padding: 18rpx 24rpx;
  471. // display: flex;
  472. border-bottom: 1rpx solid #F2F2F2;
  473. .box-left {
  474. color: #E63931;
  475. }
  476. .box-info {
  477. text-indent: 68rpx;
  478. margin-top: 16rpx;
  479. color: #7b7b7b;
  480. }
  481. .box-phone {
  482. text-indent: 68rpx;
  483. margin-top: 6rpx;
  484. // text-align: center;
  485. color: #7b7b7b;
  486. }
  487. }
  488. .box-item1 {
  489. background-color: #FFFFFF;
  490. padding: 18rpx 24rpx;
  491. // display: flex;
  492. border-bottom: 1rpx solid #F2F2F2;
  493. }
  494. .box-main {
  495. display: flex;
  496. .box-left {
  497. width: 200rpx;
  498. flex-shrink: 0;
  499. // flex: 0;
  500. }
  501. .box-right {
  502. width: 100%;
  503. color: #999999;
  504. text-align: right;
  505. }
  506. }
  507. .box-bottom {
  508. color: #999999;
  509. // padding-left: 12rpx;
  510. padding-top: 12rpx;
  511. font-size: 26rpx;
  512. }
  513. .box-item {
  514. background-color: #FFFFFF;
  515. padding: 24rpx;
  516. display: flex;
  517. border-bottom: 1rpx solid #F2F2F2;
  518. }
  519. .box-left {
  520. width: 200rpx;
  521. flex-shrink: 0;
  522. // flex: 0;
  523. .imp {
  524. color: #E63931;
  525. margin-right: 2rpx;
  526. }
  527. }
  528. .box-right {
  529. width: 100%;
  530. color: #999999;
  531. text-align: right;
  532. }
  533. }
  534. .switch-box {
  535. margin-top: 24rpx;
  536. display: flex;
  537. align-items: center;
  538. padding: 16rpx 24rpx;
  539. color: #7b7b7b;
  540. background-color: #FFFFFF;
  541. border-bottom: 1rpx solid #F2F2F2;
  542. justify-content: space-between;
  543. .switch-right {
  544. // background-color: #E63931;
  545. }
  546. }
  547. .infoOptional {
  548. padding: 20rpx 24rpx;
  549. }
  550. .submit {
  551. position: fixed;
  552. bottom: 0;
  553. left: 0;
  554. right: 0;
  555. width: 750rpx;
  556. height: 100rpx;
  557. background: #FA7E67;
  558. color: #FFFFFF;
  559. display: flex;
  560. align-items: center;
  561. justify-content: center;
  562. }
  563. .popup_row {
  564. height: 500rpx;
  565. width: 100%;
  566. padding: 24rpx;
  567. background-color: #FFFFFF;
  568. .title {
  569. border-bottom: 2rpx solid #F2F2F2;
  570. color: #E63931;
  571. font-size: 32rpx;
  572. padding-left: 4rpx;
  573. padding-bottom: 16rpx;
  574. display: flex;
  575. justify-content: space-between;
  576. // align-items: center;
  577. .cancel {
  578. width: 36rpx;
  579. height: 36rpx;
  580. image {
  581. width: 36rpx;
  582. height: 36rpx;
  583. }
  584. }
  585. }
  586. .money-btn {
  587. display: flex;
  588. justify-content: space-around;
  589. margin-top: 28rpx;
  590. .btn {
  591. // width: 20%;
  592. // display: flex;
  593. // button{
  594. // background-color: #FFFFFF;
  595. // }
  596. }
  597. }
  598. .pop-main {
  599. margin-top: 32rpx;
  600. font-size: 34rpx;
  601. display: flex;
  602. .money-left {
  603. // width: 100rpx;
  604. padding: 0 6rpx;
  605. flex-shrink: 0;
  606. color: #E63931;
  607. // background-color: #457DBF;
  608. }
  609. .money-iup {
  610. width: 100%;
  611. padding-left: 22rpx;
  612. input {
  613. font-size: 32rpx;
  614. // color: #1B1B1B;
  615. color: #FF9797;
  616. .input-placeholder {
  617. // height: 70rpx;
  618. font-size: 32rpx;
  619. color: #FF9797;
  620. }
  621. }
  622. // background-color: pink;
  623. }
  624. }
  625. .comfirm {
  626. display: flex;
  627. justify-content: flex-end;
  628. margin-top: 54rpx;
  629. .comfirm1 {
  630. padding: 12rpx 24rpx;
  631. border-radius: 12rpx;
  632. color: #FFFFFF;
  633. background-color: #E63931;
  634. }
  635. }
  636. }
  637. .popup-box {
  638. width: 522rpx;
  639. height: 605rpx;
  640. background-color: #FFFFFF;
  641. border-radius: 20rpx;
  642. .img {
  643. border-radius: 20rpx 20rpx 0 0;
  644. width: 522rpx;
  645. height: 307rpx;
  646. image {
  647. border-radius: 20rpx 20rpx 0 0;
  648. width: 522rpx;
  649. height: 307rpx;
  650. }
  651. }
  652. .mian {
  653. display: flex;
  654. flex-direction: column;
  655. align-items: center;
  656. padding: 32rpx 32rpx;
  657. background-color: #FFFFFF;
  658. border-radius: 0 0 20rpx 20rpx;
  659. text-align: center;
  660. .delivery {
  661. font-size: 36rpx;
  662. color: #333333;
  663. // margin-top: 46rpx;
  664. }
  665. .nocancel {
  666. font-size: 30rpx;
  667. color: #999999;
  668. margin-top: 26rpx;
  669. }
  670. .comfirm-box {
  671. margin-top: 52rpx;
  672. display: flex;
  673. // margin-bottom: 32rpx;
  674. // justify-content: space-around;
  675. .cancel {
  676. display: flex;
  677. align-items: center;
  678. justify-content: center;
  679. width: 197rpx;
  680. height: 61rpx;
  681. border: 1px solid #C90F1B;
  682. border-radius: 31rpx;
  683. font-size: 24rpx;
  684. color: #C90F1B;
  685. }
  686. .comfirm {
  687. margin-left: 32rpx;
  688. display: flex;
  689. align-items: center;
  690. justify-content: center;
  691. width: 197rpx;
  692. height: 61rpx;
  693. background: #FA7E67;
  694. border-radius: 31px;
  695. font-size: 24rpx;
  696. color: #FFFFFF;
  697. }
  698. }
  699. }
  700. }
  701. </style>