contribution2.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. 爱心捐款
  5. </view>
  6. <view class="box">
  7. <view class="box-item">
  8. <view class="box-left">
  9. <text class="imp">*</text>捐款意向
  10. </view>
  11. <view class="box-right">
  12. <!-- <input type="text" placeholder="请选择捐款意向" @click="addType"/> -->
  13. <picker :value="index" @change="PickerDire" :range="chooseDire" class="box-right" @click="addType">
  14. <text>{{ intention || '请选择捐款意向'}}</text>
  15. </picker>
  16. </view>
  17. </view>
  18. <view class="box-item">
  19. <view class="box-left">
  20. <text class="imp">*</text>捐款方式
  21. </view>
  22. <view class="box-right">
  23. <!-- <input type="text" placeholder="请选择捐款方式" /> -->
  24. <picker @change="PickerType" :value="index" :range="chooseType" class="box-right">
  25. <text>{{ way || '请选择捐款方式'}}</text>
  26. </picker>
  27. </view>
  28. </view>
  29. <!-- <view class="box-item">
  30. <view class="box-left">
  31. 捐款金额
  32. </view>
  33. <view class="box-right">
  34. <picker @change="PickerMoney" :value="index" :range="chooseMoney" class="box-right">
  35. <text>{{ money || '请选择捐款金额'}}</text>
  36. </picker>
  37. </view>
  38. </view> -->
  39. <view class="box-item1" @click="tochooseMoney">
  40. <!-- <view class="box-item1" @click="tochooseMoney"> -->
  41. <view class="box-main">
  42. <view class="box-left">
  43. <text class="imp">*</text>捐款金额
  44. </view>
  45. <view class="box-right">
  46. <input type="text" placeholder="0.01-不限" v-model="money" disabled/>
  47. <!-- <picker @change="PickerMoney" :value="index" :range="chooseMoney" class="box-right">
  48. <text>{{ money || '请选择捐款金额'}}</text>
  49. </picker> -->
  50. </view>
  51. </view>
  52. <view class="box-bottom">
  53. 个人满500,单位满2000可打印纸质证书
  54. </view>
  55. </view>
  56. </view>
  57. <!-- <view class="infoOptional">
  58. 信息(选填)
  59. </view> -->
  60. <view class="box">
  61. <view class="box-item">
  62. <view class="box-left">
  63. 捐款人/单位
  64. </view>
  65. <view class="box-right">
  66. <input type="text" placeholder="请选择捐款人/单位" v-model="donate_er"/>
  67. </view>
  68. </view>
  69. <view class="box-item">
  70. <view class="box-left">
  71. <text class="imp">*</text>手机号
  72. </view>
  73. <view class="box-right">
  74. <input type="text" placeholder="请填写手机号" v-model="mobile"/>
  75. </view>
  76. </view>
  77. <view class="box-item">
  78. <view class="box-left">
  79. <text class="imp">*</text>联系地址
  80. </view>
  81. <view class="box-right">
  82. <input type="text" placeholder="请输入联系地址(用于寄发票)" v-model="address"/>
  83. </view>
  84. </view>
  85. </view>
  86. <view class="switch-box">
  87. <view class="switch-left">
  88. 是否实名公开
  89. </view>
  90. <view class="switch-right">
  91. <switch :checked="is_public" color='#E63931' style="transform: scale(0.7,0.7)" @change="switch1Change"/>
  92. </view>
  93. </view>
  94. <view class="switch-box">
  95. <view class="switch-left">
  96. 寄发票
  97. </view>
  98. <view class="switch-right">
  99. <switch :checked="is_receipts" color='#E63931' style="transform: scale(0.7,0.7)" @change="switch2Change"/>
  100. </view>
  101. </view>
  102. <view class="submit" @click="!payLoding ? confirm() : ''">
  103. 提交
  104. </view>
  105. <uni-popup ref="popup" type="bottom" @click="close">
  106. <view class="popup_row">
  107. <view class="title">
  108. <view class="title-left">
  109. 一份爱心,一份力量!
  110. </view>
  111. <view class="cancel" @click="cancel">
  112. <image src="../../static/img/取消.png" mode=""></image>
  113. </view>
  114. </view>
  115. <view class="money-btn" >
  116. <view class="btn" v-for="item in moneyList" :key="item.id">
  117. <button type="default" @click="addmoney(item)">{{ item.money}}</button>
  118. </view>
  119. </view>
  120. <view class="pop-main">
  121. <view class="money-left">
  122. 金额数
  123. </view>
  124. <view class="money-iup">
  125. <input type="text" value="" v-model="popmoney" placeholder="请选择金额或者自定义金额" />
  126. </view>
  127. <view class="">
  128. </view>
  129. </view>
  130. <view class="comfirm">
  131. <view class="comfirm1" @click="comfirm1()">
  132. 确认
  133. </view>
  134. </view>
  135. </view>
  136. </uni-popup>
  137. </view>
  138. </template>
  139. <script>
  140. import {
  141. chosintention,
  142. joinDona
  143. } from '@/api/ask.js';
  144. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  145. import { computedOrderkey, balance, createOrderkey, orderPay } from '@/api/money.js';
  146. import {
  147. saveUrl,
  148. interceptor
  149. } from '@/utils/loginUtils.js';
  150. import {
  151. mapState,
  152. mapMutations
  153. } from 'vuex';
  154. import {
  155. userinfo
  156. } from '@/api/user.js';
  157. export default{
  158. components: {
  159. uniPopup,
  160. // uniLoadMore
  161. },
  162. data(){
  163. return{
  164. index: 0,
  165. intention:'', // 捐款意向
  166. way:'', // 捐款方式
  167. money:'', // 捐款金额
  168. elsemoney: '', // 其他金额
  169. popmoney:'', // 按钮金额 弹窗金额
  170. moneyList:[
  171. { id: 0, money: 500 },
  172. { id: 1, money: 200 },
  173. { id: 2, money: 100 },
  174. { id: 3, money: 50 },
  175. { id: 4, money: 20 },
  176. ],
  177. is_public: true, // 是否实名公开
  178. is_receipts: false, // 是否开发票
  179. donate_er: '', // 捐款人/单位
  180. mobile: '', // 手机号
  181. isshowMoney:false, // 其他金额是否展示
  182. address:'', // 联系地址
  183. // chooseDire: ['请选择捐款意向','疫情防控','其他','红十字人道事业(非定向捐赠)','红十字博爱送万家','AED救护及科普','青少年生命安全教育基地建设项目','关注重度失能老人项目','青少年白血病救护项目','地芯行动-关爱地中海贫血儿童','会费缴纳'],
  184. chooseDire:[],
  185. chooseType:['个人','单位'],
  186. chooseMoney:['5元','10元','50元','其他金额'],
  187. payLoding: false, //判断是否支付中
  188. froms: '', //保存h5中数据来源对象
  189. type: '', //判断是否从订单中进入
  190. payName: 'weixin',
  191. // orderInfo: {},
  192. }
  193. },
  194. onLoad(options) {
  195. // console.log(333,options)
  196. },
  197. onShow() {
  198. saveUrl()
  199. // let token = uni.getStorageSync('token');
  200. console.log(1,this);
  201. // uni.showModal({
  202. // title: '判断hasLogin',
  203. // content: JSON.stringify(this.hasLogin),
  204. // })
  205. if (!this.hasLogin) {
  206. // 登录拦截
  207. // interceptor();
  208. uni.showModal({
  209. title: '登录',
  210. content: '您未登录,是否马上登陆?',
  211. success: e => {
  212. if (e.confirm) {
  213. interceptor();
  214. }
  215. },
  216. fail: e => {
  217. console.log(e);
  218. uni.showModal({
  219. title: 'cuowu',
  220. content: JSON.stringify(e),
  221. })
  222. }
  223. });
  224. } else {
  225. // this.loadData();
  226. }
  227. },
  228. computed: {
  229. ...mapState('user', ['userInfo', 'baseURL', 'hasLogin']),
  230. ...mapState(['weichatObj']),
  231. },
  232. methods:{
  233. // 点击捐赠意向
  234. addType(e){
  235. chosintention({}).then(({ data })=>{
  236. console.log(data)
  237. this.chooseDire = data.map(item => item.title)
  238. }).catch()
  239. },
  240. // 选择捐赠意向
  241. PickerDire:function(e) {
  242. console.log(334,this.chooseDire)
  243. this.intention = this.chooseDire[e.target.value];
  244. this.index = e.target.value + 1;
  245. },
  246. // 选择捐款方式
  247. PickerType:function(e) {
  248. this.way = this.chooseType[e.target.value];
  249. this.index = e.target.value + 1;
  250. // if ( )
  251. },
  252. // 选择捐款金额
  253. PickerMoney:function(e) {
  254. this.money = this.chooseMoney[e.target.value];
  255. this.index = e.target.value + 1;
  256. console.log('选择金额',this.money)
  257. if ( this.money == '其他金额' ){
  258. this.isshowMoney = true
  259. } else {
  260. this.isshowMoney = false
  261. this.elsemoney = ''
  262. }
  263. },
  264. // 其他金额 选择
  265. tochooseMoney: function() {
  266. this.$refs.popup.open();
  267. },
  268. addmoney(mon){
  269. console.log('点击金额按钮',mon.money)
  270. this.popmoney = mon.money
  271. console.log(123,this.popmoney)
  272. },
  273. cancel(){
  274. this.$refs.popup.close();
  275. },
  276. comfirm1:function () {
  277. let obj = this
  278. if ( obj.popmoney.toString().trim() == '' ){
  279. console.log('输入框为空')
  280. } else {
  281. console.log('输入框为不为空')
  282. obj.money = obj.popmoney
  283. obj.popmoney = ''
  284. this.$refs.popup.close();
  285. }
  286. },
  287. // 是否实名公开
  288. switch1Change(e){
  289. this.is_public = e.detail.value
  290. console.log(this.is_public )
  291. },
  292. //是都寄发票
  293. switch2Change(e){
  294. this.is_receipts = e.detail.value
  295. console.log('is_receipts',this.is_receipts )
  296. },
  297. // 提交
  298. confirm: async function() {
  299. let obj = this
  300. console.log('点击提交')
  301. if (!obj.intention) {
  302. this.$api.msg('请选择捐款意向!');
  303. return;
  304. }
  305. if (!obj.way) {
  306. this.$api.msg('请选择捐款方式!');
  307. return;
  308. }
  309. if (!obj.money) {
  310. this.$api.msg('请输入捐款金额!');
  311. return;
  312. }
  313. // if (!obj.mobile) {
  314. // this.$api.msg('请输入手机号!');
  315. // return;
  316. // }
  317. const reg = /^(\+?0?86-?)?1[\d]\d{9}$/;
  318. if (!reg.test(obj.mobile)) {
  319. obj.$api.msg('请填写正确的手机号码');
  320. return;
  321. }
  322. if (!obj.address) {
  323. this.$api.msg('请输入联系地址');
  324. return;
  325. }
  326. uni.showModal({
  327. title:'暂未开启捐款,请耐心等待',
  328. })
  329. // console.log('is_receipts',obj.is_receipts)
  330. // createOrderkey({
  331. // money: obj.money, //捐款金额
  332. // intention: obj.intention, //捐款意向
  333. // way: obj.way, //捐款方式
  334. // is_public: obj.is_public, //是否实名公开
  335. // is_receipts: obj.is_receipts, //是否开发票
  336. // donate_er: obj.donate_er, //捐款人/单位
  337. // mobile: obj.mobile, //手机号
  338. // address: obj.address, //联系地址
  339. // }).then(( { data }) => {
  340. // uni.showModal({
  341. // title:'触发点击',
  342. // content:JSON.stringify(data)
  343. // })
  344. // console.log(345,data)
  345. // let res = data.result.jsConfig;
  346. // console.log(res)
  347. // 仅作为示例,非真实参数信息。
  348. // obj.weichatObj.chooseWXPay({
  349. // timestamp: res.timestamp,
  350. // nonceStr: res.nonceStr,
  351. // package: res.package,
  352. // signType: res.signType,
  353. // paySign: res.paySign,
  354. // success: function(res) {
  355. // // obj.$api.msg('支付成功')
  356. // uni.navigateTo({
  357. // url: '/pages/donaSuccess/donaSuccess'
  358. // })
  359. // },
  360. // fail: function(res) {
  361. // console.log(res, "失败")
  362. // console.log(res.errMsg)
  363. // }
  364. // });
  365. // })
  366. // 支付中
  367. obj.payLoding = true;
  368. }
  369. },
  370. }
  371. </script>
  372. <style lang="scss">
  373. .content{
  374. }
  375. .top{
  376. display: flex;
  377. align-items: center;
  378. justify-content: center;
  379. background-color: #E63931;
  380. color: #FFFFFF;
  381. padding: 22rpx 0;
  382. }
  383. .box{
  384. .box-item1{
  385. background-color: #FFFFFF;
  386. padding: 18rpx 24rpx;
  387. // display: flex;
  388. border-bottom: 1rpx solid #F2F2F2;
  389. }
  390. .box-main{
  391. display: flex;
  392. .box-left{
  393. width: 200rpx;
  394. flex-shrink: 0;
  395. // flex: 0;
  396. }
  397. .box-right{
  398. width: 100%;
  399. color: #999999;
  400. text-align: right;
  401. }
  402. }
  403. .box-bottom{
  404. color: #999999;
  405. // padding-left: 12rpx;
  406. padding-top: 12rpx;
  407. font-size: 26rpx;
  408. }
  409. .box-item{
  410. background-color: #FFFFFF;
  411. padding: 24rpx;
  412. display: flex;
  413. border-bottom: 1rpx solid #F2F2F2;
  414. }
  415. .box-left{
  416. width: 200rpx;
  417. flex-shrink: 0;
  418. // flex: 0;
  419. .imp{
  420. color: #E63931;
  421. margin-right: 2rpx;
  422. }
  423. }
  424. .box-right{
  425. width: 100%;
  426. color: #999999;
  427. text-align: right;
  428. }
  429. }
  430. .switch-box{
  431. margin-top: 24rpx;
  432. display: flex;
  433. align-items: center;
  434. padding: 16rpx 24rpx;
  435. color: #7b7b7b;
  436. background-color: #FFFFFF;
  437. border-bottom: 1rpx solid #F2F2F2;
  438. justify-content: space-between;
  439. .switch-right{
  440. // background-color: #E63931;
  441. }
  442. }
  443. .infoOptional{
  444. padding: 20rpx 24rpx;
  445. }
  446. .submit{
  447. background-color: #E63931;
  448. color: #FFFFFF;
  449. padding: 20rpx 0;
  450. display: flex;
  451. align-items: center;
  452. justify-content: center;
  453. border-radius: 12rpx;
  454. margin: 52rpx;
  455. }
  456. .popup_row{
  457. height: 500rpx;
  458. width: 100%;
  459. padding: 24rpx;
  460. background-color: #FFFFFF;
  461. .title{
  462. border-bottom: 2rpx solid #F2F2F2;
  463. color: #E63931;
  464. font-size: 32rpx;
  465. padding-left: 4rpx;
  466. padding-bottom: 16rpx;
  467. display: flex;
  468. justify-content: space-between;
  469. // align-items: center;
  470. .cancel{
  471. width: 36rpx;
  472. height: 36rpx;
  473. image{
  474. width: 36rpx;
  475. height: 36rpx;
  476. }
  477. }
  478. }
  479. .money-btn{
  480. display: flex;
  481. justify-content: space-around;
  482. margin-top: 28rpx;
  483. .btn{
  484. // width: 20%;
  485. // display: flex;
  486. // button{
  487. // background-color: #FFFFFF;
  488. // }
  489. }
  490. }
  491. .pop-main{
  492. margin-top: 32rpx;
  493. font-size: 34rpx;
  494. display: flex;
  495. .money-left{
  496. // width: 100rpx;
  497. padding: 0 6rpx;
  498. flex-shrink: 0;
  499. color: #E63931;
  500. // background-color: #457DBF;
  501. }
  502. .money-iup{
  503. width: 100%;
  504. padding-left: 22rpx;
  505. input{
  506. font-size: 32rpx;
  507. // color: #1B1B1B;
  508. color: #FF9797;
  509. .input-placeholder {
  510. // height: 70rpx;
  511. font-size: 32rpx;
  512. color: #FF9797;
  513. }
  514. }
  515. // background-color: pink;
  516. }
  517. }
  518. .comfirm{
  519. display: flex;
  520. justify-content: flex-end;
  521. margin-top: 54rpx;
  522. .comfirm1{
  523. padding: 12rpx 24rpx;
  524. border-radius: 12rpx;
  525. color: #FFFFFF;
  526. background-color: #E63931;
  527. }
  528. }
  529. }
  530. </style>