recharge.vue 8.7 KB

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