recharge.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <template>
  2. <view class="content">
  3. <view class="now">
  4. <view>当前余额:</view>
  5. <view class="now-money">¥{{new_money}}</view>
  6. </view>
  7. <view class="main-jg"></view>
  8. <view class="add-wrapper">
  9. <view class="add-box">
  10. <view class="add-log">¥</view>
  11. <input type="text" v-model="authCode" placeholder="请输入充值金额" placeholder-class="place" />
  12. </view>
  13. <view class="jg" style="height: 1px; background-color: #E6E6E6;"></view>
  14. <view class="add-tags">
  15. <view class="tag" v-for="(item, index) in addTags" :key="item" @click="tagClick(index)"
  16. :class="{ action: currentIndex === index && money == addTags[index].price }">
  17. <text>{{ item.price }}</text>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="main-jg"></view>
  22. <!-- <view class="btn-wrapper">
  23. <view class="icon iconfont iconweixin1">
  24. <view>微信充值</view>
  25. </view>
  26. <view class="btn" @click="btnClick" :class="{'actiont': isSect}">
  27. <image src="../../static/user/btncz.png" mode="" :class="{'action':!isSect}"></image>
  28. </view>
  29. </view> -->
  30. <view class="btn-wrapper">
  31. <view class="icon iconfont iconweixin1 iconweixin2">
  32. <view>汇付充值</view>
  33. </view>
  34. <view class="btn" @click="btnClick('huifu')" :class="{'actiont': payType == 'huifu'}">
  35. <image src="../../static/user/btncz.png" mode="" :class="{'action':payType !== 'huifu'}"></image>
  36. </view>
  37. </view>
  38. <view class="btn-wrapper">
  39. <view class="icon iconfont iconweixin1 iconweixin2">
  40. <view>汇付充值</view>
  41. </view>
  42. <view class="btn" @click="btnClick('weixin')" :class="{'actiont': payType == 'weixin'}">
  43. <image src="../../static/user/btncz.png" mode="" :class="{'action':payType !== 'weixin'}"></image>
  44. </view>
  45. </view>
  46. <!-- <view class="row-box">
  47. <view class="title">充值金额</view>
  48. <view class="row">
  49. <text class="tit">¥</text>
  50. <input class="input" type="number" v-model="money" placeholder="请输入充值金额" placeholder-class="placeholder" />
  51. </view>
  52. </view> -->
  53. <button class="add-btn up" :class="{ 'active-bg': payLoding }"
  54. @click="!payLoding ? confirm() : ''">立即充值</button>
  55. </view>
  56. </template>
  57. <script>
  58. // #ifdef H5
  59. import * as weichatObj from '@/plugin/jweixin-module/index.js';
  60. // #endif
  61. import {
  62. getMoneyStyle
  63. } from '@/utils/rocessor.js';
  64. // #ifdef H5
  65. import {
  66. rechargeWechat,
  67. userBalance
  68. } from '@/api/wallet.js';
  69. // #endif
  70. // #ifdef MP
  71. import {
  72. rechargeRoutine,
  73. userBalance
  74. } from '@/api/wallet.js';
  75. // #endif
  76. import {
  77. mapState
  78. } from 'vuex';
  79. import {
  80. orderData,
  81. getUserInfo,
  82. getRechangeList,
  83. goChange
  84. } from '@/api/user.js';
  85. export default {
  86. filters: {
  87. getMoneyStyle
  88. },
  89. data() {
  90. return {
  91. type: 'weixin',
  92. money: '', //充值金额
  93. payLoding: false, //是否加载中
  94. addTags: [100, 1000, 5000, 10000, 30000],
  95. currentIndex: 0,
  96. addMoney: 0,
  97. isSect: false, //是否选择微信充值
  98. new_money: 0,
  99. authCode: '',
  100. payType: ''
  101. };
  102. },
  103. onLoad(options) {
  104. this.getRechangeList()
  105. },
  106. computed: {
  107. // #ifdef H5
  108. // ...mapState(['weichatObj'])
  109. // #endif
  110. },
  111. methods: {
  112. getRechangeList() {
  113. getRechangeList().then(res => {
  114. this.addTags = res.data
  115. })
  116. },
  117. // 跳转
  118. navTo(url) {
  119. uni.navigateTo({
  120. url: url
  121. });
  122. },
  123. // 切换选中对象
  124. tabRadio(e) {
  125. this.type = e;
  126. },
  127. // 提交
  128. confirm() {
  129. if (this.money == 0) {
  130. return this.$msg('请输入充值金额');
  131. }
  132. // if(!this.isSect) {
  133. // return this.$msg('请选择支付方式');
  134. // }
  135. let obj = this;
  136. goChange({
  137. rechar_id: 4,
  138. price: obj.money,
  139. // from: obj.type
  140. authCode: obj.authCode,
  141. type: 0, //0 普通充值 1 佣金转余额
  142. // #ifdef APP
  143. from: 'app',
  144. // #endif
  145. // #ifdef MP | H5
  146. from: 'weixin',
  147. // #endif
  148. staffinfo: '',
  149. pay_type: obj.payType
  150. })
  151. .then(e => {
  152. uni.showToast({
  153. title: '充值成功',
  154. duration: 2000,
  155. position: 'top'
  156. });
  157. setTimeout(() => {
  158. uni.navigateBack()
  159. }, 1500)
  160. obj.payLoding = false;
  161. })
  162. .catch(e => {
  163. obj.payLoding = false;
  164. });
  165. },
  166. //获取订单列表
  167. loadData(source) {
  168. console.log(source);
  169. //这里是将订单挂载到tab列表下
  170. let index = this.tabCurrentIndex;
  171. let navItem = this.navList[index];
  172. let state = navItem.state;
  173. if (source === 'tabChange' && navItem.loaded === true) {
  174. //tab切换只有第一次需要加载数据
  175. return;
  176. }
  177. if (navItem.loadingType === 'loading') {
  178. //防止重复加载
  179. return;
  180. }
  181. navItem.loadingType = 'loading';
  182. setTimeout(() => {
  183. let orderList = [];
  184. orderList.forEach(item => {
  185. navItem.orderList.push(item);
  186. });
  187. //loaded新字段用于表示数据加载完毕,如果为空可以显示空白页
  188. this.$set(navItem, 'loaded', true);
  189. //判断是否还有数据, 有改为 more, 没有改为noMore
  190. navItem.loadingType = 'more';
  191. }, 600);
  192. },
  193. tagClick(index) {
  194. this.currentIndex = index;
  195. this.money = this.addTags[index].price;
  196. },
  197. clearNoNum() {
  198. this.money = this.money.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
  199. switch (this.money) {
  200. case '300':
  201. this.currentIndex = 0;
  202. break;
  203. case '200':
  204. this.currentIndex = 1;
  205. break;
  206. case '150':
  207. this.currentIndex = 2;
  208. break;
  209. case '100':
  210. this.currentIndex = 3;
  211. break;
  212. case '50':
  213. this.currentIndex = 4;
  214. break;
  215. }
  216. },
  217. btnClick(type) {
  218. // this.isSect = !this.isSect
  219. this.payType = type
  220. },
  221. }
  222. };
  223. </script>
  224. <style lang="scss">
  225. page {
  226. height: 100%;
  227. background-color: #fff;
  228. }
  229. .add-btn {
  230. &.modified {
  231. color: $base-color;
  232. }
  233. &.up {
  234. background-color: $base-color;
  235. color: #fff;
  236. }
  237. display: flex;
  238. align-items: center;
  239. justify-content: center;
  240. width: 604rpx;
  241. height: 90rpx;
  242. margin: 0 auto;
  243. margin-top: 30rpx;
  244. font-size: $font-lg;
  245. border-radius: 10rpx;
  246. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  247. }
  248. .row-box {
  249. margin-top: 30rpx;
  250. padding: 20rpx 30rpx;
  251. background: #fff;
  252. .title {
  253. font-size: $font-base + 2rpx;
  254. color: $font-color-dark;
  255. }
  256. .row {
  257. display: flex;
  258. align-items: center;
  259. position: relative;
  260. height: 80rpx;
  261. .tit {
  262. flex-shrink: 0;
  263. width: 40rpx;
  264. font-size: 30rpx;
  265. color: $font-color-dark;
  266. }
  267. .input {
  268. flex: 1;
  269. font-size: 30rpx;
  270. color: $font-color-dark;
  271. }
  272. .iconlocation {
  273. font-size: 36rpx;
  274. color: $font-color-light;
  275. }
  276. .buttom {
  277. color: $font-color;
  278. font-size: $font-base;
  279. }
  280. }
  281. }
  282. .list {
  283. padding-left: 30rpx;
  284. margin-top: 30rpx;
  285. background-color: #ffffff;
  286. .box {
  287. display: flex;
  288. align-items: center;
  289. width: 100%;
  290. height: 120rpx;
  291. border-bottom: 1px solid $border-color-light;
  292. .icon {
  293. font-size: 48rpx;
  294. padding-right: 20rpx;
  295. }
  296. .iconweixin1 {
  297. color: #18bf16;
  298. }
  299. .iconzhifubao {
  300. color: #08aaec;
  301. }
  302. .title-box {
  303. flex-grow: 1;
  304. text-align: left;
  305. .title {
  306. font-size: $font-base + 2rpx;
  307. color: $font-color-base;
  308. }
  309. .node {
  310. font-size: $font-sm;
  311. color: $font-color-light;
  312. }
  313. }
  314. }
  315. }
  316. ::v-deep .uni-radio-input {
  317. width: 45rpx;
  318. height: 45rpx;
  319. }
  320. .active-bg {
  321. background-color: $color-gray !important;
  322. }
  323. .now {
  324. width: 100%;
  325. height: 86rpx;
  326. padding: 0 26rpx 0 47rpx;
  327. display: flex;
  328. justify-content: space-between;
  329. line-height: 86rpx;
  330. background-color: #fff;
  331. // margin-bottom: 21rpx;
  332. view {
  333. font-size: 28rpx;
  334. font-weight: 500;
  335. color: #333333;
  336. }
  337. .now-money {
  338. font-size: 32rpx;
  339. font-weight: bold;
  340. color: $base-color;
  341. }
  342. }
  343. .add-wrapper {
  344. width: 750rpx;
  345. height: 338rpx;
  346. padding-left: 30rpx;
  347. background: #ffffff;
  348. display: flex;
  349. flex-direction: column;
  350. align-items: center;
  351. // margin-bottom: 22rpx;
  352. .add-box {
  353. width: 100%;
  354. height: 103rpx;
  355. display: flex;
  356. flex-direction: row;
  357. justify-content: space-between;
  358. padding: 0 39rpx 0 10rpx;
  359. align-items: center;
  360. .add-log {
  361. font-size: 37rpx;
  362. font-weight: bold;
  363. }
  364. input {
  365. width: 218rpx;
  366. height: 30rpx;
  367. font-size: 32rpx;
  368. font-weight: 500;
  369. color: #000;
  370. line-height: 40px;
  371. text-align: right;
  372. .place {
  373. color: #bfbfbf;
  374. }
  375. }
  376. }
  377. .jg {
  378. width: 100%;
  379. }
  380. .add-tags {
  381. height: 234rpx;
  382. padding-top: 47rpx;
  383. padding-bottom: 17rpx;
  384. display: flex;
  385. flex-direction: row;
  386. flex-wrap: wrap;
  387. // justify-content: space-between;
  388. .tag {
  389. width: 210rpx;
  390. height: 70rpx;
  391. background-color: #f0f0f0;
  392. border-radius: 4rpx;
  393. margin: 0 30rpx 30rpx 0;
  394. text-align: center;
  395. line-height: 70rpx;
  396. font-size: 22rpx;
  397. text {
  398. font-size: 32rpx;
  399. font-weight: 500;
  400. }
  401. }
  402. .action {
  403. color: #fff;
  404. background-color: $base-color;
  405. }
  406. }
  407. }
  408. .btn-wrapper {
  409. padding: 40rpx 32rpx 40rpx 40rpx;
  410. // height: 183rpx;
  411. display: flex;
  412. justify-content: space-between;
  413. background-color: #fff;
  414. .iconweixin1 {
  415. color: #18bf16;
  416. font-size: 48rpx;
  417. display: flex;
  418. view {
  419. // display: inline-block;
  420. height: 48rpx;
  421. text-align: 48rpx;
  422. padding-left: 20rpx;
  423. // padding-top: 10rpx;
  424. color: #000000;
  425. font-size: 30rpx;
  426. }
  427. }
  428. .iconweixin2 {
  429. color: #fe8e2e;
  430. }
  431. .btn {
  432. width: 36rpx;
  433. height: 36rpx;
  434. border: 4rpx #3f3f3f solid;
  435. border-radius: 8rpx 8rpx;
  436. image {
  437. // display: none;
  438. width: 100%;
  439. height: 100%;
  440. }
  441. .action {
  442. display: none;
  443. }
  444. }
  445. .actiont {
  446. border: none;
  447. }
  448. }
  449. .main-jg {
  450. width: 100%;
  451. height: 21rpx;
  452. background-color: #f8f6f6;
  453. }
  454. .iconweixin {
  455. color: #36cb59;
  456. }
  457. </style>