recharge.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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="money" placeholder="请输入充值金额" placeholder-class="place" @keyup="clearNoNum()"/>
  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: check.id == item.id }">
  17. <view>{{ item.price*1 }}</view>
  18. <view class="tip">赠送:{{ item.gift_price*1 }}</view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="main-jg"></view>
  23. <!-- <view class="btn-wrapper">
  24. <view class="icon iconfont iconweixin1">
  25. <view>微信充值</view>
  26. </view>
  27. <view class="btn" @click="btnClick" :class="{'actiont': isSect}">
  28. <image src="../../static/user/btncz.png" mode="" :class="{'action':!isSect}"></image>
  29. </view>
  30. </view> -->
  31. <view class="btn-wrapper">
  32. <view class="icon iconfont iconweixin1 iconweixin2">
  33. <view>汇付充值</view>
  34. </view>
  35. <view class="btn" @click="btnClick('huifu')" :class="{'actiont': payType == 'huifu'}">
  36. <image src="../../../static/user/btncz.png" mode="" :class="{'action':payType !== 'huifu'}"></image>
  37. </view>
  38. </view>
  39. <view class="btn-wrapper">
  40. <view class="icon iconfont iconweixin1">
  41. <view>微信充值</view>
  42. </view>
  43. <view class="btn" @click="btnClick('weixin')" :class="{'actiont': payType == 'weixin'}">
  44. <image src="../../../static/user/btncz.png" mode="" :class="{'action':payType !== 'weixin'}"></image>
  45. </view>
  46. </view>
  47. <!-- <view class="row-box">
  48. <view class="title">充值金额</view>
  49. <view class="row">
  50. <text class="tit">¥</text>
  51. <input class="input" type="number" v-model="money" placeholder="请输入充值金额" placeholder-class="placeholder" />
  52. </view>
  53. </view> -->
  54. <button class="add-btn up" :class="{ 'active-bg': payLoding }"
  55. @click="!payLoding ? confirm() : ''">立即充值</button>
  56. </view>
  57. </template>
  58. <script>
  59. // #ifdef H5
  60. import * as weichatObj from '@/plugin/jweixin-module/index.js';
  61. // #endif
  62. import {
  63. getMoneyStyle
  64. } from '@/utils/rocessor.js';
  65. // #ifdef H5
  66. import {
  67. rechargeWechat,
  68. userBalance
  69. } from '@/api/wallet.js';
  70. // #endif
  71. // #ifdef MP
  72. import {
  73. rechargeRoutine,
  74. userBalance
  75. } from '@/api/wallet.js';
  76. // #endif
  77. import {
  78. mapState
  79. } from 'vuex';
  80. import {
  81. orderData,
  82. getUserInfo,
  83. getRechangeList,
  84. goChange
  85. } from '@/api/user.js';
  86. export default {
  87. filters: {
  88. getMoneyStyle
  89. },
  90. data() {
  91. return {
  92. check: {id: 0},
  93. type: 'weixin',
  94. money: '', //充值金额
  95. payLoding: false, //是否加载中
  96. addTags: [],
  97. currentIndex: 0,
  98. addMoney: 0,
  99. isSect: false, //是否选择微信充值
  100. new_money: 0,
  101. authCode: '',
  102. payType: ''
  103. };
  104. },
  105. onLoad(options) {
  106. this.getRechangeList()
  107. },
  108. computed: {
  109. // #ifdef H5
  110. // ...mapState(['weichatObj'])
  111. // #endif
  112. },
  113. methods: {
  114. getRechangeList() {
  115. getRechangeList().then(res => {
  116. this.addTags = res.data
  117. })
  118. },
  119. // 跳转
  120. navTo(url) {
  121. uni.navigateTo({
  122. url: url
  123. });
  124. },
  125. // 切换选中对象
  126. tabRadio(e) {
  127. this.type = e;
  128. },
  129. // 提交
  130. confirm() {
  131. if (this.money == 0) {
  132. return this.$msg('请输入充值金额');
  133. }
  134. // if(!this.isSect) {
  135. // return this.$msg('请选择支付方式');
  136. // }
  137. let obj = this;
  138. goChange({
  139. rechar_id: obj.check && obj.check.id ? obj.check.id : '',
  140. price: obj.money,
  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. tagClick(index) {
  167. this.currentIndex = index;
  168. this.money = this.addTags[index].price;
  169. this.check = this.addTags[index]
  170. },
  171. clearNoNum() {
  172. this.money = this.money.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
  173. console.log(this.money)
  174. const fi = this.addTags.find(item => item.price*1 == this.money )
  175. if(fi && fi.id) {
  176. this.check = fi
  177. }else {
  178. this.check = {id: 0}
  179. }
  180. console.log(fi)
  181. },
  182. btnClick(type) {
  183. // this.isSect = !this.isSect
  184. this.payType = type
  185. },
  186. }
  187. };
  188. </script>
  189. <style lang="scss">
  190. page {
  191. height: 100%;
  192. background-color: #fff;
  193. }
  194. .add-btn {
  195. &.modified {
  196. color: $base-color;
  197. }
  198. &.up {
  199. background-color: $base-color;
  200. color: #fff;
  201. }
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. width: 604rpx;
  206. height: 90rpx;
  207. margin: 0 auto;
  208. margin-top: 30rpx;
  209. font-size: $font-lg;
  210. border-radius: 10rpx;
  211. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  212. }
  213. .row-box {
  214. margin-top: 30rpx;
  215. padding: 20rpx 30rpx;
  216. background: #fff;
  217. .title {
  218. font-size: $font-base + 2rpx;
  219. color: $font-color-dark;
  220. }
  221. .row {
  222. display: flex;
  223. align-items: center;
  224. position: relative;
  225. height: 80rpx;
  226. .tit {
  227. flex-shrink: 0;
  228. width: 40rpx;
  229. font-size: 30rpx;
  230. color: $font-color-dark;
  231. }
  232. .input {
  233. flex: 1;
  234. font-size: 30rpx;
  235. color: $font-color-dark;
  236. }
  237. .iconlocation {
  238. font-size: 36rpx;
  239. color: $font-color-light;
  240. }
  241. .buttom {
  242. color: $font-color;
  243. font-size: $font-base;
  244. }
  245. }
  246. }
  247. .list {
  248. padding-left: 30rpx;
  249. margin-top: 30rpx;
  250. background-color: #ffffff;
  251. .box {
  252. display: flex;
  253. align-items: center;
  254. width: 100%;
  255. height: 120rpx;
  256. border-bottom: 1px solid $border-color-light;
  257. .icon {
  258. font-size: 48rpx;
  259. padding-right: 20rpx;
  260. }
  261. .iconweixin1 {
  262. color: #18bf16;
  263. }
  264. .iconzhifubao {
  265. color: #08aaec;
  266. }
  267. .title-box {
  268. flex-grow: 1;
  269. text-align: left;
  270. .title {
  271. font-size: $font-base + 2rpx;
  272. color: $font-color-base;
  273. }
  274. .node {
  275. font-size: $font-sm;
  276. color: $font-color-light;
  277. }
  278. }
  279. }
  280. }
  281. ::v-deep .uni-radio-input {
  282. width: 45rpx;
  283. height: 45rpx;
  284. }
  285. .active-bg {
  286. background-color: $color-gray !important;
  287. }
  288. .now {
  289. width: 100%;
  290. height: 86rpx;
  291. padding: 0 26rpx 0 47rpx;
  292. display: flex;
  293. justify-content: space-between;
  294. line-height: 86rpx;
  295. background-color: #fff;
  296. // margin-bottom: 21rpx;
  297. view {
  298. font-size: 28rpx;
  299. font-weight: 500;
  300. color: #333333;
  301. }
  302. .now-money {
  303. font-size: 32rpx;
  304. font-weight: bold;
  305. color: $base-color;
  306. }
  307. }
  308. .add-wrapper {
  309. width: 750rpx;
  310. padding-left: 30rpx;
  311. background: #ffffff;
  312. display: flex;
  313. flex-direction: column;
  314. align-items: center;
  315. // margin-bottom: 22rpx;
  316. .add-box {
  317. width: 100%;
  318. height: 103rpx;
  319. display: flex;
  320. flex-direction: row;
  321. justify-content: space-between;
  322. padding: 0 39rpx 0 10rpx;
  323. align-items: center;
  324. .add-log {
  325. font-size: 37rpx;
  326. font-weight: bold;
  327. }
  328. input {
  329. width: 218rpx;
  330. height: 30rpx;
  331. font-size: 32rpx;
  332. font-weight: 500;
  333. color: #000;
  334. line-height: 40px;
  335. text-align: right;
  336. .place {
  337. color: #bfbfbf;
  338. }
  339. }
  340. }
  341. .jg {
  342. width: 100%;
  343. }
  344. .add-tags {
  345. padding-top: 47rpx;
  346. padding-bottom: 17rpx;
  347. display: flex;
  348. flex-direction: row;
  349. flex-wrap: wrap;
  350. // justify-content: space-between;
  351. .tag {
  352. width: 210rpx;
  353. height: 140rpx;
  354. background-color: #f0f0f0;
  355. border-radius: 4rpx;
  356. margin: 0 30rpx 30rpx 0;
  357. text-align: center;
  358. font-size: 32rpx;
  359. font-weight: bold;
  360. display: flex;
  361. flex-direction: column;
  362. justify-content: center;
  363. align-items: center;
  364. .tip {
  365. font-weight: 500;
  366. font-size: 24rpx;
  367. }
  368. }
  369. .action {
  370. color: #fff;
  371. background-color: $base-color;
  372. }
  373. }
  374. }
  375. .btn-wrapper {
  376. padding: 40rpx 32rpx 40rpx 40rpx;
  377. // height: 183rpx;
  378. display: flex;
  379. justify-content: space-between;
  380. background-color: #fff;
  381. .iconweixin1 {
  382. color: #18bf16;
  383. font-size: 48rpx;
  384. display: flex;
  385. view {
  386. // display: inline-block;
  387. height: 48rpx;
  388. text-align: 48rpx;
  389. padding-left: 20rpx;
  390. // padding-top: 10rpx;
  391. color: #000000;
  392. font-size: 30rpx;
  393. }
  394. }
  395. .iconweixin2 {
  396. color: #fe8e2e;
  397. }
  398. .btn {
  399. width: 36rpx;
  400. height: 36rpx;
  401. border: 4rpx #3f3f3f solid;
  402. border-radius: 8rpx 8rpx;
  403. image {
  404. // display: none;
  405. width: 100%;
  406. height: 100%;
  407. }
  408. .action {
  409. display: none;
  410. }
  411. }
  412. .actiont {
  413. border: none;
  414. }
  415. }
  416. .main-jg {
  417. width: 100%;
  418. height: 21rpx;
  419. background-color: #f8f6f6;
  420. }
  421. .iconweixin {
  422. color: #36cb59;
  423. }
  424. </style>