balance-exchange.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view>
  3. <navbar :config="config" backColor="#999999"></navbar>
  4. <view class="usable-integrate">
  5. <text class="usable-title">可用余额(元)</text>
  6. <text class="usable-nums">{{ $addDecimals(balance , 2) }}</text>
  7. </view>
  8. <view class="box">
  9. <view class="usable-hint">
  10. <text>转赠余额</text>
  11. </view>
  12. <view class="usable-input">
  13. <text class="iconfont usable-hint-icon">¥</text>
  14. <u-input type="number" v-model="value" placeholder="请输入转赠金额" :clearable="false"/>
  15. </view>
  16. <mobilemapname ref="mobilemapname"></mobilemapname>
  17. <view class="usable-hint-info">
  18. <view class="usable-btn" @click.stop="openHintPopup()">
  19. 确认转赠
  20. </view>
  21. </view>
  22. </view>
  23. <exchange-hint ref="exchangeHint" :params="pointGiveAwayApi" :type="2" :useNums="value" :resultNum="`手机号为“${receiveUser.phone}”的用户`"></exchange-hint>
  24. </view>
  25. </template>
  26. <script>
  27. import { balanceGiveAway } from "@/api/personal-center.js"
  28. export default {
  29. data() {
  30. return {
  31. pointGiveAwayApi: {
  32. url: balanceGiveAway,
  33. mode: 'post',
  34. data: {
  35. value: '',
  36. user_obj_id: ''
  37. }
  38. },
  39. balance:0,
  40. value: '',
  41. config: {
  42. back: true, //false是tolbar页面 是则不写
  43. title: '余额转赠',
  44. color: '#1A1A1A',
  45. // autoBack:true,
  46. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  47. backgroundColor: [1, "#fff"],
  48. statusBarFontColor: '#1A1A1A'
  49. },
  50. receiveUser: {
  51. phone: '',
  52. name: '',
  53. user_obj_id: ''
  54. },
  55. };
  56. },
  57. onShow() {
  58. this.getUserInfo()
  59. },
  60. watch:{
  61. value(newVal){
  62. if(newVal > this.balance){
  63. this.$mUtil.toast("转赠余额不能大于当前余额")
  64. }
  65. }
  66. },
  67. methods: {
  68. // if (!(this.form.identityNumber.match(this.$mConfig.twoMinNum))) {
  69. // this.$mUtil.toast("请输入正确的身份证号")
  70. // return false
  71. // }
  72. //获取个人信息
  73. getUserInfo() {
  74. let personal = uni.getStorageSync('personal');
  75. this.balance = personal ? personal.balance : '';
  76. },
  77. openHintPopup() {
  78. // console.log('this.value.match(this.$mConfig.twoMinNum) = ' , this.value , this.value.match(this.$mConfig.twoMinNum) , this.$mConfig.twoMinNum.test(this.value))
  79. if(!this.value){
  80. this.$mUtil.toast("请输入赠送金额")
  81. return false
  82. }else if(!this.$mConfig.twoMinNum.test(this.value)){
  83. this.$mUtil.toast("最多输入两位小数")
  84. return false
  85. }
  86. this.$refs.mobilemapname.getObjUserId().then(res => {
  87. this.receiveUser = res;
  88. this.pointGiveAwayApi.data = {
  89. value: this.value,
  90. user_obj_id: res.user_obj_id
  91. }
  92. this.$refs.exchangeHint.open()
  93. })
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. @import "~./common.scss";
  100. </style>