recharge.vue 9.4 KB

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