detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <template>
  2. <view class="top-cont">
  3. <view :style="{height: statusBarHeight,background: bgColor }"></view>
  4. <u-navbar title="充值" titleStyle="font-weight: 500;" @rightClick="rightClick" :autoBack="true"
  5. :bg-color="bgColor">
  6. </u-navbar>
  7. <view class="top-bg">
  8. <image class="bg" src="https://user.test.ylrztop.com/images/cz_bg.png" mode="widthFix"></image>
  9. <view class="balance">
  10. <view class="title">{{form.rechargeAmount}}元{{form.templateName}}</view>
  11. <view class="align-center justify-between">
  12. <view class="text" v-html="form.benefitDetails"></view>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="content">
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import {
  22. getPayment, toPayment, getTemplatesById
  23. } from '@/api/payment'
  24. import {
  25. getUserInfo
  26. } from '@/api/user'
  27. export default {
  28. data() {
  29. return {
  30. dataList: [
  31. // {id:1,price:66,text:'限时赠送6元现金券',count:'赠10元'},
  32. // {id:2,price:100,text:'限时赠送10元现金券',count:'赠10元'},
  33. // {id:3,price:200,text:'限时赠送20元现金券'},
  34. ],
  35. user:null,
  36. eTime:null,
  37. aIndex:0,
  38. isAgreement: false,
  39. statusBarHeight: '',
  40. top: 0,
  41. companyUserId: null,
  42. companyId: null,
  43. desc: "",
  44. money: null,
  45. wxPay: true,
  46. templateId: 0,
  47. form:{}
  48. }
  49. },
  50. computed: {
  51. // 计算属性的 getter
  52. bgColor: function() {
  53. var top = this.top / 30;
  54. return 'rgba(11,179,242, ' + top + ')';
  55. },
  56. },
  57. onLoad: function(options) {
  58. this.templateId = options.id;
  59. this.getInfo()
  60. },
  61. onShareAppMessage(res) {
  62. return {
  63. title: '云联融智-收款',
  64. path: `/pages_user/user/pay?companyId=` + this.companyId + "&companyUserId=" + this.companyUserId
  65. }
  66. },
  67. methods: {
  68. handleAgreement() {
  69. this.isAgreement = !this.isAgreement;
  70. },
  71. choosePackage(item) {
  72. this.aIndex = item.id
  73. this.templateId=item.id
  74. // let time=this.utils.parseTime(item.endTime)
  75. this.eTime=this.utils.setTime(item.endTime)
  76. },
  77. getUserInfo(){
  78. getUserInfo().then(
  79. res => {
  80. if(res.code==200){
  81. if(res.user!=null){
  82. this.user=res.user;
  83. }
  84. else{
  85. this.utils.loginOut();
  86. }
  87. }else{
  88. uni.showToast({
  89. icon:'none',
  90. title: "请求失败",
  91. });
  92. }
  93. },
  94. rej => {}
  95. );
  96. },
  97. testMoney(e) {
  98. let that = this;
  99. let price = e.detail.value
  100. if (price.indexOf(".") == 0) {
  101. //'首位小数点情况'
  102. price = price.replace(/[^$#$]/g, "0.");
  103. price = price.replace(/\.{2,}/g, ".");
  104. }
  105. price = price.match(/^\d*(\.?\d{0,2})/g)[0] || null;
  106. //重新赋值给input
  107. this.$nextTick(() => {
  108. this.money = price;
  109. });
  110. },
  111. getInfo() {
  112. getTemplatesById(this.templateId).then(
  113. res => {
  114. if(res.code==200){
  115. this.form = res.data
  116. }else{
  117. uni.showToast({
  118. icon:'none',
  119. title: "请求失败",
  120. });
  121. }
  122. },
  123. rej => {}
  124. );
  125. },
  126. showDetail(url) {
  127. if(url){
  128. uni.navigateTo({
  129. url: url
  130. })
  131. }
  132. },
  133. pay() {
  134. if (this.money == null) {
  135. uni.showToast({
  136. icon: 'none',
  137. title: "请输入支付金额"
  138. });
  139. return;
  140. }
  141. uni.login({
  142. success: res => {
  143. console.log(res)
  144. this.payment(res.code);
  145. }
  146. });
  147. },
  148. //充值余额
  149. toPay() {
  150. if(!this.isAgreement){
  151. uni.showToast({
  152. icon:'none',
  153. title: "请先同意协议后再储存",
  154. });
  155. return false;
  156. }
  157. if (this.templateId == 0) {
  158. uni.showToast({
  159. icon: 'none',
  160. title: "请选择储值套餐"
  161. });
  162. return;
  163. }
  164. var data={
  165. userId:this.user.userId||'77632',
  166. templateId:this.templateId
  167. }
  168. var that = this;
  169. uni.showLoading();
  170. toPayment(data).then(
  171. res => {
  172. if (res.code == 200) {
  173. console.log(res);
  174. uni.requestPayment({
  175. provider: 'wxpay',
  176. timeStamp: res.result.timeStamp,
  177. nonceStr: res.result.nonceStr,
  178. // package: res.result.packageValue,
  179. package: res.result.packageStr,
  180. signType: res.result.signType,
  181. paySign: res.result.paySign,
  182. success: function(res) {
  183. uni.hideLoading();
  184. uni.showToast({
  185. icon: 'success',
  186. title: "支付成功",
  187. });
  188. uni.navigateTo({
  189. url: './success'
  190. })
  191. },
  192. fail: function(err) {
  193. console.log('fail:' + JSON.stringify(err));
  194. uni.hideLoading();
  195. }
  196. });
  197. } else {
  198. uni.showToast({
  199. icon: 'none',
  200. title: res.msg,
  201. });
  202. }
  203. },
  204. rej => {}
  205. );
  206. },
  207. payment(code) {
  208. var data = {
  209. payMoney: this.money,
  210. remark: this.desc,
  211. code: code,
  212. companyId: this.companyId,
  213. companyUserId: this.companyUserId
  214. };
  215. var that = this;
  216. uni.showLoading();
  217. payment(data).then(
  218. res => {
  219. if (res.code == 200) {
  220. console.log(res);
  221. uni.requestPayment({
  222. provider: 'wxpay',
  223. timeStamp: res.result.timeStamp,
  224. nonceStr: res.result.nonceStr,
  225. // package: res.result.packageValue,
  226. package: res.result.packageStr,
  227. signType: res.result.signType,
  228. paySign: res.result.paySign,
  229. success: function(res) {
  230. uni.hideLoading();
  231. uni.showToast({
  232. icon: 'success',
  233. title: "支付成功",
  234. });
  235. uni.navigateTo({
  236. url: './success'
  237. })
  238. },
  239. fail: function(err) {
  240. console.log('fail:' + JSON.stringify(err));
  241. uni.hideLoading();
  242. }
  243. });
  244. } else {
  245. uni.showToast({
  246. icon: 'none',
  247. title: res.msg,
  248. });
  249. }
  250. },
  251. rej => {}
  252. );
  253. }
  254. }
  255. }
  256. </script>
  257. <style lang="scss">
  258. page {
  259. height: 100%;
  260. background-color: #F5F7FA;
  261. }
  262. .top-bg {
  263. position: relative;
  264. .bg {
  265. width: 100%;
  266. position: relative;
  267. top: 0;
  268. left: 0;
  269. z-index: -1;
  270. }
  271. .balance {
  272. width: calc(100% - 40rpx);
  273. // height: 206rpx;
  274. background: linear-gradient(180deg, rgba(255, 255, 255, 0.8) 0%, #FFFFFF 100%);
  275. border-radius: 16rpx;
  276. border: 4rpx solid #FFFFFF;
  277. padding: 30rpx;
  278. margin: 0 20rpx;
  279. margin-top: -60rpx;
  280. // position: absolute;
  281. bottom: 0;
  282. box-sizing: border-box;
  283. // margin-top: -214rpx;
  284. .title{
  285. font-family: PingFang SC, PingFang SC;
  286. font-weight: 500;
  287. font-size: 32rpx;
  288. color: #222426;
  289. text-align: left;
  290. margin-bottom: 20rpx;
  291. }
  292. .text {
  293. font-family: PingFang SC, PingFang SC;
  294. font-weight: 400;
  295. font-size: 28rpx;
  296. color: #222426;
  297. text-align: left;
  298. }
  299. .right {
  300. padding: 0 24rpx;
  301. height: 54rpx;
  302. line-height: 54rpx;
  303. font-weight: 400;
  304. font-size: 24rpx;
  305. color: #FFFFFF;
  306. text-align: left;
  307. background: linear-gradient(90deg, #E73823 0%, #FD7620 100%);
  308. border-radius: 28rpx 0rpx 0rpx 28rpx;
  309. margin-right: -30rpx;
  310. }
  311. .num {
  312. font-family: Roboto, Roboto;
  313. font-weight: bold;
  314. font-size: 64rpx;
  315. color: #222426;
  316. }
  317. }
  318. }
  319. .content {
  320. height: 100%;
  321. display: flex;
  322. flex-direction: column;
  323. // padding-top: calc(var(--status-bar-height) + 40rpx) !important;
  324. // margin: 20upx 0upx;
  325. // padding:20upx;
  326. .top {
  327. flex: 1;
  328. padding: 20rpx;
  329. .recharge {
  330. .item {
  331. padding: 30rpx;
  332. background: #FFFFFF;
  333. border-radius: 16rpx 16rpx 16rpx 16rpx;
  334. border: 2rpx solid #EFF3F7;
  335. margin-bottom: 20rpx;
  336. &:last-child {
  337. margin-bottom: 0;
  338. }
  339. &.active {
  340. border: 2rpx solid #F3CDA7;
  341. background: #FFF6EA;
  342. .title {
  343. color: #AF6020;
  344. }
  345. .text {
  346. color: #AF6020;
  347. }
  348. }
  349. .title {
  350. font-family: PingFang SC, PingFang SC;
  351. font-weight: 600;
  352. font-size: 48rpx;
  353. color: #222426;
  354. line-height: 64rpx;
  355. text-align: left;
  356. margin-right: 20rpx;
  357. }
  358. .hot {
  359. margin-right: -20rpx;
  360. z-index: 9;
  361. }
  362. .hot-box {
  363. width: 124rpx;
  364. height: 32rpx;
  365. line-height: 32rpx;
  366. background: linear-gradient(90deg, #E73823 0%, #FD7620 100%);
  367. border-radius: 6rpx 6rpx 6rpx 6rpx;
  368. transform: skew(-10deg);
  369. padding-left: 30rpx;
  370. box-sizing: border-box;
  371. .count {
  372. font-family: PingFang SC, PingFang SC;
  373. font-weight: 500;
  374. font-size: 24rpx;
  375. color: #FEF5EA;
  376. transform: skew(10deg);
  377. }
  378. }
  379. .text {
  380. font-family: PingFang SC, PingFang SC;
  381. font-weight: 400;
  382. font-size: 26rpx;
  383. color: #898E91;
  384. line-height: 48rpx;
  385. text-align: left;
  386. }
  387. .detail {
  388. font-family: PingFang SC, PingFang SC;
  389. font-weight: 400;
  390. font-size: 24rpx;
  391. color: #AF6020;
  392. text-align: right;
  393. }
  394. }
  395. }
  396. .inner {
  397. width: 100%;
  398. display: flex;
  399. flex-direction: column;
  400. align-items: flex-start;
  401. justify-content: center;
  402. .pay {
  403. width: 100%;
  404. box-shadow: 1px 1px 5px #e6e6e6;
  405. background: #FFFFFF;
  406. border-radius: 5upx;
  407. display: flex;
  408. flex-direction: column;
  409. align-items: flex-start;
  410. .title {
  411. display: flex;
  412. flex-direction: column;
  413. align-items: flex-start;
  414. width: 100%;
  415. background-color: #f7f7f7;
  416. padding: 30rpx 0rpx;
  417. .name {
  418. padding: 15rpx 30rpx;
  419. font-size: 32rpx;
  420. }
  421. .desc {
  422. color: #989898;
  423. padding: 15rpx 30rpx;
  424. font-size: 25rpx;
  425. }
  426. }
  427. .pay-money {
  428. padding: 30rpx 0rpx;
  429. width: 100%;
  430. background: #FFFFFF;
  431. border-radius: 5upx;
  432. display: flex;
  433. flex-direction: column;
  434. align-items: flex-start;
  435. .pay-money-title {
  436. padding: 15rpx 30rpx;
  437. font-size: 32rpx;
  438. }
  439. .money {
  440. font-size: 42rpx;
  441. padding: 15rpx 30rpx;
  442. display: flex;
  443. flex-direction: row;
  444. align-items: flex-start;
  445. input {
  446. margin-left: 15rpx;
  447. }
  448. }
  449. .desc {
  450. width: 100%;
  451. padding: 30rpx 30rpx;
  452. border-top: 1rpx solid #e6e6e6;
  453. }
  454. textarea {
  455. height: 50rpx;
  456. line-height: 50rpx;
  457. }
  458. }
  459. }
  460. }
  461. .btn-box {
  462. padding: 30rpx;
  463. // height: 121upx;
  464. // display: flex;
  465. // align-items: center;
  466. // justify-content: center;
  467. background: #FFFFFF;
  468. position: fixed;
  469. z-index: 999;
  470. width: 100%;
  471. bottom: 0;
  472. left: 0;
  473. text-align: center;
  474. box-sizing: border-box;
  475. .text {
  476. font-family: PingFang SC, PingFang SC;
  477. font-weight: 400;
  478. font-size: 24rpx;
  479. color: #626468;
  480. line-height: 56rpx;
  481. &.color {
  482. color: #209DD8;
  483. }
  484. }
  485. .btn {
  486. width: 100%;
  487. height: 88upx;
  488. line-height: 88upx;
  489. font-size: 32upx;
  490. font-family: PingFang SC;
  491. font-weight: bold;
  492. color: #FFFFFF;
  493. text-align: center;
  494. background: #008FD3;
  495. border-radius: 44upx;
  496. }
  497. }
  498. }
  499. .ad {
  500. margin: 0rpx 0rpx 60rpx;
  501. }
  502. }
  503. </style>