recharge.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. <template>
  2. <view class="content">
  3. <view class="top_box">
  4. <text class="yue-tit">当前余额:</text>
  5. <text class="yue-num">¥{{ now_money | parseFloatNum }}</text>
  6. </view>
  7. <view class="line_box"></view>
  8. <view class="cz_box">
  9. <view class="cz_wrap">
  10. <text class="cz_tit">¥</text>
  11. <input class="cz_input" type="number" v-model="money" @focus="changeNum()" placeholder="请输入充值金额" placeholder-class="placeholder" />
  12. </view>
  13. <view class="zc_list_box">
  14. <view class="zc_list_price" :class="{ seletPrice: seletNum == item }" @click="seletChange(item, index)" v-for="(item, index) in list" :key="index">
  15. {{ item | parseFloatNum }}元
  16. </view>
  17. </view>
  18. </view>
  19. <!-- <view class="line_box"></view> -->
  20. <!-- <view class="row-box">
  21. <view class="title">充值金额</view>
  22. <view class="row">
  23. <text class="tit">¥</text>
  24. <input class="input" type="number" v-model="money" placeholder="请输入充值金额" placeholder-class="placeholder" />
  25. </view>
  26. </view> -->
  27. <!-- <view class="rechar-box">
  28. <view class="rechar-title">注意事项</view>
  29. <view class="rechar-text" v-for="(item, index) in zhuyi" :key="index">
  30. <text>{{ index + 1 }}.{{item}}</text>
  31. </view>
  32. </view> -->
  33. <view class="line_box"></view>
  34. <view class="cz-type">
  35. <view class="type-left">
  36. <view class="icon iconfont iconweixin"></view>
  37. <view class="tit">微信支付</view>
  38. </view>
  39. <view class="type-right"><image src="https://zhibo.liuniu946.com/img/checked.png" mode=""></image></view>
  40. </view>
  41. <button class="add-btn up" :class="{ 'active-bg': payLoding }" @click="!payLoding ? confirm() : ''">立即充值</button>
  42. </view>
  43. </template>
  44. <script>
  45. import { getMoneyStyle } from '@/utils/rocessor.js';
  46. // #ifdef H5
  47. import { rechargeWechat, rechargeIndex } from '@/api/wallet.js';
  48. // #endif
  49. // #ifdef MP
  50. import { rechargeWechat, rechargeRoutine, rechargeIndex } from '@/api/wallet.js';
  51. // #endif
  52. import { mapState } from 'vuex';
  53. import { spreadCommission, userBalance } from '@/api/wallet.js';
  54. export default {
  55. filters: {
  56. getMoneyStyle,
  57. // 去处小数点后的0
  58. parseFloatNum(clock) {
  59. return parseFloat(clock);
  60. }
  61. },
  62. data() {
  63. return {
  64. type: 'weixin',
  65. money: 300, //充值金额
  66. payLoding: false ,//是否加载中
  67. list: [
  68. '300',
  69. '200',
  70. '150',
  71. '100',
  72. '50'
  73. ],
  74. now_money:'',
  75. seletNum: '300', // 选中
  76. zhuyi: [],
  77. quota: '', // 送的钱
  78. typeText: 0, // 0-微信 1-佣金
  79. };
  80. },
  81. onLoad(options) {
  82. this.loadData();
  83. },
  84. computed: {
  85. // #ifdef H5
  86. ...mapState(['weichatObj', 'userInfo'])
  87. // #endif
  88. // #ifdef MP
  89. ...mapState(['userInfo'])
  90. // #endif
  91. },
  92. methods: {
  93. // 跳转
  94. navTo(url) {
  95. uni.navigateTo({
  96. url: url
  97. });
  98. },
  99. changeNum() {
  100. this.seletNum = this.money = '';
  101. console.log(this.seletNum, this.money);
  102. },
  103. seletChange(item, index) {
  104. this.seletNum = item;
  105. this.seletMoney = item;
  106. console.log(this.seletNum);
  107. this.money = item
  108. },
  109. // 切换选中对象
  110. tabRadio(e) {
  111. this.type = e.detail.value;
  112. if ( e.detail.value == 'weixin' ) {
  113. this.typeText = 0
  114. } else {
  115. this.typeText = 1
  116. }
  117. },
  118. // 充值金额
  119. rechargeXuan(item) {
  120. this.money = item.price;
  121. this.quota = item.quota;
  122. },
  123. loadData() {
  124. userBalance({}).then(({ data }) => {
  125. this.now_money = data.now_money;
  126. });
  127. },
  128. // 提交
  129. confirm() {
  130. let obj = this;
  131. obj.payLoding = true;
  132. if( !obj.money ) {
  133. obj.$api.msg('请输入金额');
  134. obj.payLoding = false;
  135. return;
  136. }
  137. // #ifdef H5
  138. rechargeWechat({
  139. price: this.money,
  140. from: this.type ,
  141. }).then(e => {
  142. let da = e.data.data;
  143. obj.weichatObj.chooseWXPay({
  144. timestamp: da.timestamp,
  145. nonceStr: da.nonceStr,
  146. package: da.package,
  147. signType: da.signType,
  148. paySign: da.paySign,
  149. success: function(res) {
  150. uni.showToast({
  151. title: '充值成功',
  152. duration: 2000,
  153. position: 'top',
  154. success: function(res) {
  155. uni.navigateBack()
  156. }
  157. });
  158. }
  159. });
  160. obj.payLoding = false;
  161. })
  162. .catch(e => {
  163. obj.payLoding = false;
  164. console.log(e);
  165. });
  166. // #endif
  167. // #ifdef MP
  168. rechargeRoutine({ price: this.money})
  169. .then(e => {
  170. let da = e.data;
  171. wx.requestPayment({
  172. timeStamp: da.timestamp,
  173. nonceStr: da.nonceStr,
  174. package: da.package,
  175. signType: da.signType,
  176. paySign: da.paySign,
  177. success: function(res) {
  178. uni.showToast({
  179. title: '充值成功',
  180. duration: 2000,
  181. position: 'top',
  182. success: function(res) {
  183. uni.navigateBack()
  184. }
  185. });
  186. },
  187. })
  188. obj.payLoding = false;
  189. })
  190. .catch(e => {
  191. obj.payLoding = false;
  192. console.log(e);
  193. });
  194. // #endif
  195. },
  196. }
  197. };
  198. </script>
  199. <style lang="scss">
  200. page {
  201. height: 100%;
  202. background: #ffffff;
  203. }
  204. .top_box {
  205. padding: 20rpx 26rpx 20rpx 47rpx;
  206. display: flex;
  207. align-items: center;
  208. justify-content: space-between;
  209. .yue-tit {
  210. font-size: 28rpx;
  211. font-family: PingFang SC;
  212. font-weight: 500;
  213. color: #333333;
  214. }
  215. .yue-num {
  216. font-size: 30rpx;
  217. font-family: PingFang SC;
  218. font-weight: bold;
  219. color: #ff6f0f;
  220. }
  221. }
  222. .line_box {
  223. width: 100%;
  224. height: 20rpx;
  225. background: #f8f8f8;
  226. }
  227. .cz_box {
  228. padding: 40rpx 20rpx 20rpx;
  229. .cz_wrap {
  230. display: flex;
  231. align-items: center;
  232. justify-content: space-between;
  233. padding-bottom: 20rpx;
  234. border-bottom: 1px solid #e6e6e6;
  235. .cz_tit {
  236. font-size: 32rpx;
  237. font-family: PingFang SC;
  238. font-weight: 500;
  239. }
  240. .cz_input {
  241. text-align: right;
  242. font-size: 32rpx;
  243. font-family: PingFang SC;
  244. font-weight: 500;
  245. // color: #BFBFBF;
  246. }
  247. }
  248. .zc_list_box {
  249. display: flex;
  250. flex-wrap: wrap;
  251. .zc_list_price {
  252. width: 202rpx;
  253. height: 60rpx;
  254. background: #f0f0f0;
  255. border-radius: 8rpx;
  256. margin-top: 36rpx;
  257. margin-right: 50rpx;
  258. display: flex;
  259. align-items: center;
  260. justify-content: center;
  261. &:nth-child(3n) {
  262. margin-right: 0;
  263. }
  264. }
  265. .seletPrice {
  266. background: linear-gradient(180deg, #08c4e6, #50ead2);
  267. color: #ffffff;
  268. }
  269. }
  270. }
  271. .recha-box {
  272. padding: 50rpx 30rpx 0;
  273. display: flex;
  274. flex-wrap: wrap;
  275. .recha-frame {
  276. width: 210rpx;
  277. height: 181rpx;
  278. border: 1px solid #dbdede;
  279. border-radius: 20rpx;
  280. display: flex;
  281. align-items: center;
  282. flex-direction: column;
  283. justify-content: center;
  284. margin-right: 30rpx;
  285. margin-bottom: 30rpx;
  286. &:nth-child(3n) {
  287. margin-right: 0;
  288. }
  289. .recha-top {
  290. display: flex;
  291. align-items: center;
  292. .recha-img {
  293. width: 64rpx;
  294. height: 62rpx;
  295. }
  296. .recha-tit {
  297. margin-left: 10rpx;
  298. font-size: 36rpx;
  299. font-family: PingFang SC;
  300. font-weight: bold;
  301. color: #333333;
  302. }
  303. }
  304. .recha-song {
  305. margin-top: 20rpx;
  306. font-size: $font-base;
  307. font-family: PingFang SC;
  308. font-weight: bold;
  309. color: #ff9900;
  310. }
  311. }
  312. .select-frame {
  313. border: 1px solid #ef041f;
  314. }
  315. }
  316. .rechar-box {
  317. padding: 30rpx 20rpx 0;
  318. .rechar-title {
  319. font-size: 32rpx;
  320. font-family: PingFang SC;
  321. font-weight: bold;
  322. color: #333333;
  323. margin-bottom: 10rpx;
  324. }
  325. .rechar-text {
  326. font-size: 28rpx;
  327. font-family: PingFang SC;
  328. font-weight: bold;
  329. color: #333333;
  330. }
  331. }
  332. .cz-type {
  333. margin-top: 22rpx;
  334. display: flex;
  335. justify-content: space-between;
  336. padding: 32rpx;
  337. align-items: center;
  338. .type-left {
  339. display: flex;
  340. align-items: center;
  341. .icon {
  342. height: 38rpx;
  343. image {
  344. width: 48rpx;
  345. height: 38rpx;
  346. }
  347. }
  348. .iconweixin {
  349. color: #36cb59;
  350. }
  351. .tit {
  352. margin-left: 12rpx;
  353. font-size: 30rpx;
  354. color: #333333;
  355. }
  356. }
  357. .type-right {
  358. image {
  359. width: 36rpx;
  360. height: 36rpx;
  361. }
  362. }
  363. }
  364. .add-btn {
  365. &.modified {
  366. color: $base-color;
  367. }
  368. &.up {
  369. // background:$base-color;
  370. color: #fff;
  371. }
  372. display: flex;
  373. align-items: center;
  374. justify-content: center;
  375. width: 560rpx;
  376. height: 80rpx;
  377. margin: 0 auto;
  378. margin-top: 120rpx;
  379. font-size: $font-lg;
  380. background: linear-gradient(90deg, #08C4E6, #50EAD2);
  381. box-shadow: 0px 12rpx 45rpx 5rpx rgba(36, 17, 2, 0.04);
  382. border-radius: 8rpx;
  383. }
  384. .row-box {
  385. margin-top: 30rpx;
  386. padding: 20rpx 30rpx;
  387. background: #fff;
  388. .title {
  389. font-size: $font-base + 2rpx;
  390. color: $font-color-dark;
  391. }
  392. .row {
  393. display: flex;
  394. align-items: center;
  395. position: relative;
  396. height: 80rpx;
  397. .tit {
  398. flex-shrink: 0;
  399. width: 40rpx;
  400. font-size: 30rpx;
  401. color: $font-color-dark;
  402. }
  403. .input {
  404. flex: 1;
  405. font-size: 30rpx;
  406. color: $font-color-dark;
  407. }
  408. .iconlocation {
  409. font-size: 36rpx;
  410. color: $font-color-light;
  411. }
  412. .buttom {
  413. color: $font-color;
  414. font-size: $font-base;
  415. }
  416. }
  417. }
  418. .list {
  419. padding-left: 30rpx;
  420. margin-top: 30rpx;
  421. background-color: #ffffff;
  422. .box {
  423. display: flex;
  424. align-items: center;
  425. width: 100%;
  426. height: 120rpx;
  427. border-bottom: 1px solid $border-color-light;
  428. padding-right: 25rpx;
  429. .icon {
  430. font-size: 48rpx;
  431. padding-right: 20rpx;
  432. display: flex;
  433. }
  434. .yongjing {
  435. width: 48rpx;
  436. height: 48rpx;
  437. }
  438. .iconweixin1 {
  439. color: #18bf16;
  440. }
  441. .iconzhifubao {
  442. color: #08aaec;
  443. }
  444. .title-box {
  445. flex-grow: 1;
  446. text-align: left;
  447. .title {
  448. font-size: $font-base + 2rpx;
  449. color: $font-color-base;
  450. }
  451. .node {
  452. font-size: $font-sm;
  453. color: $font-color-light;
  454. }
  455. }
  456. }
  457. }
  458. /deep/ .uni-radio-input {
  459. width: 45rpx;
  460. height: 45rpx;
  461. }
  462. .active-bg {
  463. background-color: $color-gray !important;
  464. }
  465. </style>