index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <view>
  3. <form @submit="submitSub" report-submit='true'>
  4. <view class="payment-top acea-row row-column row-center-wrapper">
  5. <span class="name">我的余额</span>
  6. <view class="pic">
  7. ¥<span class="pic-font">{{ fen2yuan(wallet.balance || 0) }}</span>
  8. </view>
  9. </view>
  10. <view class="payment">
  11. <view class="nav acea-row row-around row-middle">
  12. <view class="item" :class="active==index?'on':''" v-for="(item,index) in navRecharge" :key="index" @click="navRecharges(index)">{{item}}</view>
  13. </view>
  14. <!-- 充值 -->
  15. <view class='tip picList' v-if='!active'>
  16. <view class="pic-box pic-box-color acea-row row-center-wrapper row-column" :class="activePic === index ? 'pic-box-color-active' : ''"
  17. v-for="(item, index) in picList" :key="index" @click="picCharge(index, item)">
  18. <view class="pic-number-pic">
  19. {{ fen2yuan(item.payPrice) }}<span class="pic-number"> 元</span>
  20. </view>
  21. <view class="pic-number">赠送:{{ fen2yuan(item.bonusPrice) }} 元</view>
  22. </view>
  23. <view class="pic-box pic-box-color acea-row row-center-wrapper" :class="parseFloat(activePic)===parseFloat(picList.length)?'pic-box-color-active':''"
  24. @click="picCharge(picList.length)">
  25. <input type="number" placeholder="其他" v-model="money" :maxlength="50000" class="pic-box-money pic-number-pic uni-input"
  26. :class="parseFloat(activePic) === parseFloat(picList.length) ? 'pic-box-color-active' : ''" />
  27. </view>
  28. <view class="tips-box">
  29. <view class="tips mt-30">注意事项:</view>
  30. <view class="tips-samll" v-for="item in rechargeAttention" :key="item">
  31. {{ item }}
  32. </view>
  33. </view>
  34. <button class='but' formType="submit"> 立即充值 </button>
  35. </view>
  36. <!-- 佣金提现 -->
  37. <view class="tip" v-else>
  38. <view class='input'><text>¥</text><input placeholder="0.00" type='number' placeholder-class='placeholder' :value="number"
  39. name="number"></input></view>
  40. <view class="tips-title">
  41. <view style="font-weight: bold; font-size: 26rpx;">提示:</view>
  42. <view style="margin-top: 10rpx;">当前佣金为 <text class='font-color'>¥{{ fen2yuan(spreadInfo.brokeragePrice || 0) }}</text></view>
  43. </view>
  44. <view class="tips-box">
  45. <view class="tips mt-30">注意事项:</view>
  46. <view class="tips-samll" v-for="item in rechargeAttention" :key="item">
  47. {{ item }}
  48. </view>
  49. </view>
  50. <button class='but' formType="submit"> 立即转入 </button>
  51. </view>
  52. </view>
  53. </form>
  54. <home></home>
  55. </view>
  56. </template>
  57. <script>
  58. import * as WalletApi from '@/api/pay/wallet.js';
  59. import * as BrokerageAPI from '@/api/trade/brokerage.js'
  60. import * as Util from '@/utils/util.js';
  61. import { toLogin } from '@/libs/login.js';
  62. import { mapGetters } from "vuex";
  63. import home from '@/components/home';
  64. export default {
  65. components: {
  66. home
  67. },
  68. data() {
  69. return {
  70. wallet: {},
  71. spreadInfo: {},
  72. now_money: 0,
  73. navRecharge: ['账户充值', '佣金转入'],
  74. active: 0,
  75. number: '',
  76. placeholder: "0.00",
  77. from: '',
  78. picList: [],
  79. activePic: 0,
  80. money: "",
  81. rechar_id: 0, // 选择的套餐编号
  82. rechargeAttention: [
  83. '1、充值金额最少为 1 元',
  84. '2、充值后只能用于消费',
  85. '3、提现金额需要有手续费',
  86. '4、提现到账需要 2~3 天时间'
  87. ]
  88. };
  89. },
  90. computed: mapGetters(['isLogin', 'systemPlatform','userInfo']),
  91. watch:{
  92. isLogin:{
  93. handler: function(newV, oldV) {
  94. if(newV){
  95. this.getRecharge();
  96. }
  97. },
  98. deep:true
  99. }
  100. },
  101. onLoad(options) {
  102. if (!this.isLogin) {
  103. toLogin();
  104. return;
  105. }
  106. this.getRecharge();
  107. },
  108. methods: {
  109. /**
  110. * 选择金额
  111. */
  112. picCharge(idx, item) {
  113. this.activePic = idx;
  114. if (item === undefined) {
  115. this.rechar_id = 0;
  116. } else {
  117. this.money = "";
  118. this.rechar_id = item.id;
  119. }
  120. },
  121. /**
  122. * 充值额度选择
  123. */
  124. getRecharge() {
  125. // 获得钱包
  126. WalletApi.getPayWallet().then(res=>{
  127. this.wallet = res.data;
  128. })
  129. // 获得佣金
  130. BrokerageAPI.getBrokerageUser().then(res => {
  131. this.$set(this,'spreadInfo',res.data);
  132. });
  133. // 获得充值套餐
  134. WalletApi.getWalletRechargePackageList().then(res => {
  135. this.picList = res.data;
  136. if (this.picList.length > 0) {
  137. this.rechar_id = this.picList[0].id;
  138. }
  139. }).catch(res => {
  140. this.$dialog.toast({
  141. mes: res
  142. });
  143. });
  144. },
  145. onLoadFun: function() {
  146. this.getRecharge();
  147. },
  148. navRecharges: function(index) {
  149. this.active = index;
  150. },
  151. /**
  152. * 用户充值
  153. */
  154. submitSub: function(e) {
  155. let that = this
  156. let value = e.detail.value.number;
  157. // 转入余额
  158. if (that.active) {
  159. if (parseFloat(value) < 0 || parseFloat(value) === NaN || value === undefined || value === "") {
  160. return that.$util.Tips({
  161. title: '请输入金额'
  162. });
  163. }
  164. uni.showModal({
  165. title: '转入余额',
  166. content: '转入余额后无法再次转出,确认是否转入余额',
  167. success(res) {
  168. if (!res.confirm) {
  169. return that.$util.Tips({
  170. title: '已取消'
  171. });
  172. }
  173. BrokerageAPI.createBrokerageWithdraw({
  174. type: 1,
  175. price: parseFloat(value) * 100
  176. }).then(res => {
  177. return that.$util.Tips({
  178. title: '转入成功',
  179. icon: 'success'
  180. }, {
  181. tab: 5,
  182. url: '/pages/users/user_money/index'
  183. });
  184. }).catch(err=>{
  185. return that.$util.Tips({
  186. title: err
  187. });
  188. })
  189. },
  190. })
  191. } else {
  192. uni.showLoading({
  193. title: '正在支付',
  194. })
  195. let money = parseFloat(this.money);
  196. if (this.rechar_id === 0) {
  197. if (Number.isNaN(money)) {
  198. return that.$util.Tips({
  199. title: '充值金额必须为数字'
  200. });
  201. }
  202. if (money <= 0) {
  203. return that.$util.Tips({
  204. title: '充值金额不能为 0'
  205. });
  206. }
  207. if (money > 50000) {
  208. return that.$util.Tips({
  209. title: '充值金额最大值为 50000'
  210. });
  211. }
  212. }
  213. WalletApi.createWalletRecharge({
  214. payPrice: money ? money * 100 : undefined,
  215. packageId: this.rechar_id
  216. }).then(res => {
  217. const returnUrl = encodeURIComponent('/pages/users/user_payment/index');
  218. uni.navigateTo({
  219. url: `/pages/goods/cashier/index?order_id=${res.data.payOrderId}&returnUrl=${returnUrl}`
  220. })
  221. }).catch(err => {
  222. uni.hideLoading();
  223. return that.$util.Tips({
  224. title: err
  225. })
  226. });
  227. }
  228. },
  229. fen2yuan(price) {
  230. return Util.fen2yuan(price)
  231. }
  232. }
  233. }
  234. </script>
  235. <style lang="scss">
  236. page {
  237. width: 100%;
  238. height: 100%;
  239. background-color: #fff;
  240. }
  241. .payment {
  242. position: relative;
  243. top: -60rpx;
  244. width: 100%;
  245. background-color: #fff;
  246. border-radius: 10rpx;
  247. padding-top: 25rpx;
  248. border-top-right-radius: 14rpx;
  249. border-top-left-radius: 14rpx;
  250. }
  251. .payment .nav {
  252. height: 75rpx;
  253. line-height: 75rpx;
  254. padding: 0 100rpx;
  255. }
  256. .payment .nav .item {
  257. font-size: 30rpx;
  258. color: #333;
  259. }
  260. .payment .nav .item.on {
  261. font-weight: bold;
  262. border-bottom: 4rpx solid #e83323;
  263. }
  264. .payment .input {
  265. display: flex;
  266. align-items: center;
  267. justify-content: center;
  268. border-bottom: 1px dashed #dddddd;
  269. margin: 60rpx auto 0 auto;
  270. padding-bottom: 20rpx;
  271. font-size: 56rpx;
  272. color: #333333;
  273. flex-wrap: nowrap;
  274. }
  275. .payment .input text {
  276. padding-left: 106rpx;
  277. }
  278. .payment .input input {
  279. padding-right: 106rpx;
  280. width: 300rpx;
  281. height: 94rpx;
  282. text-align: center;
  283. font-size: 70rpx;
  284. }
  285. .payment .placeholder {
  286. color: #d0d0d0;
  287. height: 100%;
  288. line-height: 94rpx;
  289. }
  290. .payment .tip {
  291. font-size: 26rpx;
  292. color: #888888;
  293. padding: 0 30rpx;
  294. margin-top: 25rpx;
  295. }
  296. .payment .but {
  297. color: #fff;
  298. font-size: 30rpx;
  299. width: 700rpx;
  300. height: 86rpx;
  301. border-radius: 43rpx;
  302. margin: 50rpx auto 0 auto;
  303. background: linear-gradient(90deg, #FF7931 0%, #F11B09 100%);
  304. line-height: 86rpx;
  305. }
  306. .payment-top {
  307. width: 100%;
  308. height: 350rpx;
  309. background-color: #e83323;
  310. .name {
  311. font-size: 26rpx;
  312. color: rgba(255, 255, 255, 0.8);
  313. margin-top: -38rpx;
  314. margin-bottom: 30rpx;
  315. }
  316. .pic {
  317. font-size: 32rpx;
  318. color: #fff;
  319. }
  320. .pic-font {
  321. font-size: 78rpx;
  322. color: #fff;
  323. }
  324. }
  325. .picList {
  326. display: flex;
  327. flex-wrap: wrap;
  328. margin: 30rpx 0;
  329. .pic-box {
  330. width: 32%;
  331. height: auto;
  332. border-radius: 20rpx;
  333. margin-top: 21rpx;
  334. padding: 20rpx 0;
  335. margin-right: 12rpx;
  336. &:nth-child(3n) {
  337. margin-right: 0;
  338. }
  339. }
  340. .pic-box-color {
  341. background-color: #f4f4f4;
  342. color: #656565;
  343. }
  344. .pic-number {
  345. font-size: 22rpx;
  346. }
  347. .pic-number-pic {
  348. font-size: 38rpx;
  349. margin-right: 10rpx;
  350. text-align: center;
  351. }
  352. }
  353. .pic-box-color-active {
  354. background-color: #ec3323 !important;
  355. color: #fff !important;
  356. }
  357. .tips-box {
  358. .tips {
  359. font-size: 28rpx;
  360. color: #333333;
  361. font-weight: 800;
  362. margin-bottom: 14rpx;
  363. margin-top: 20rpx;
  364. }
  365. .tips-samll {
  366. font-size: 24rpx;
  367. color: #333333;
  368. margin-bottom: 14rpx;
  369. }
  370. .tip-box {
  371. margin-top: 30rpx;
  372. }
  373. }
  374. .tips-title {
  375. margin-top: 20rpx;
  376. font-size: 24rpx;
  377. color: #333;
  378. }
  379. </style>