index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <view class="container">
  3. <view class="content">
  4. <view class="moeny flex_r flex_ae">¥
  5. <input type="number" :maxlength="12" v-model="inputMoney" placeholder="请输入提现金额" />
  6. </view>
  7. <view class="option flex_r flex_ac flex_jb">
  8. <view class="balance flex_r flex_ac">账户余额¥{{ user_money }}</view>
  9. <view class="option_text" @tap="getListPage">提现记录</view>
  10. </view>
  11. <view class="hint">支持余额提现</view>
  12. </view>
  13. <view class="upload flex_c flex_jc flex_ac">
  14. <block v-if="imgs == '' || imgs == undefined">
  15. <view class="upload_con flex_c flex_ac flex_jc" @tap="uploadImg"><text>+</text></view>
  16. </block>
  17. <block v-else>
  18. <image class="upload_img" :src="imgs" mode="" @tap="uploadImg"></image>
  19. </block>
  20. <view class="upload_text">请上传本人收款码</view>
  21. </view>
  22. <view class="btn flex_r flex_ac flex_jc" @tap="onSubForm">申请提现</view>
  23. <view class="showlist" v-for="(item, index) in show" :key="index">{{ item }}</view>
  24. </view>
  25. </template>
  26. <script>
  27. let app = getApp();
  28. var appEv = app.$vm.$options;
  29. import { post } from "@/request/api.js";
  30. export default {
  31. data() {
  32. return {
  33. show: [],
  34. inputMoney: "",
  35. imgs: "",
  36. index: 0,
  37. userinfo: undefined, // 获取用户信息
  38. local_uinfo: undefined,
  39. user_money: 0, //余额
  40. islocal: false
  41. };
  42. },
  43. onLoad: function(e) {
  44. if (e.type == "local") {
  45. this.getLU();
  46. this.islocal = true;
  47. } else {
  48. this.getU();
  49. this.islocal = false;
  50. }
  51. this.getExolain();
  52. },
  53. methods: {
  54. getExolain() {
  55. let url = this.islocal ? "local/withdrawDesc" : "v1/withdrawdesc"
  56. post(url).then(res => {
  57. this.show = this.islocal ? res.data[0] : res.data.data[0]
  58. })
  59. },
  60. onSubForm() {
  61. let that = this;
  62. let url = this.islocal ? "local/withdraw" : "v1/user/withdraw"
  63. if (this.inputMoney == "") {
  64. appEv.errTips("请输入金额");
  65. return;
  66. }
  67. if (!this.imgs) {
  68. uni.showModal({
  69. content: `请上传您的收款码`,
  70. showCancel: false,
  71. success(res) {},
  72. });
  73. return;
  74. }
  75. if (Number(this.inputMoney) > Number(this.user_money)) {
  76. uni.showModal({
  77. content: `当前可提现${that.user_money}`,
  78. showCancel: false,
  79. success(res) {},
  80. });
  81. return;
  82. }
  83. uni.showLoading({
  84. mask: true,
  85. });
  86. let data = {
  87. money: this.inputMoney,
  88. pay_code: this.imgs,
  89. w_type: 1,
  90. };
  91. post(url, data).then((res) => {
  92. uni.hideLoading();
  93. if (res.code === 0) {
  94. this.inputMoney = "";
  95. uni.showModal({
  96. content: `提交成功,请等待审核!`,
  97. confirmText: "知道了",
  98. showCancel: false,
  99. success(res) {},
  100. });
  101. if (this.islocal) this.getLU()
  102. else this.getU()
  103. } else {
  104. appEv.errTips(res.msg || "");
  105. }
  106. });
  107. },
  108. // 上传图片uploadImg
  109. uploadImg() {
  110. let that = this;
  111. uni.chooseImage({
  112. count: 1, // 最多可以选择的图片张数,默认9
  113. sizeType: ["compressed"], // original 原图,compressed 压缩图,默认二者都有
  114. sourceType: ["album", "camera"], // album 从相册选图,camera 使用相机,默认二者都有
  115. success: function(res) {
  116. var arr = res.tempFiles;
  117. that.uploadImgs(arr[0].path);
  118. },
  119. });
  120. },
  121. uploadImgs(img) {
  122. var that = this;
  123. uni.uploadFile({
  124. url: that.$hosts.Hhost + "v1/user/upload",
  125. filePath: img,
  126. name: "image",
  127. header: {
  128. token: uni.getStorageSync("token"),
  129. },
  130. success: function(res) {
  131. uni.hideToast();
  132. let resTwo = JSON.parse(decodeURIComponent(res.data))
  133. if (resTwo.code === 0) {
  134. that.imgs = resTwo.data.src;
  135. } else {
  136. appEv.errTips(resTwo.msg);
  137. }
  138. },
  139. });
  140. },
  141. getListPage() {
  142. uni.navigateTo({
  143. url: "/pages/accountDetails/withdraw",
  144. });
  145. },
  146. async getU() {
  147. this.userinfo = await uni.userfun();
  148. this.user_money = this.userinfo.user_money;
  149. },
  150. async getLU() {
  151. this.local_uinfo = await uni.Luserfun()
  152. this.user_money = this.local_uinfo.property;
  153. },
  154. },
  155. };
  156. </script>
  157. <style lang="scss" scoped>
  158. // 页面配置
  159. .container {
  160. border-top: 20rpx solid #f5f5f5;
  161. padding: 43rpx 30rpx;
  162. box-sizing: border-box;
  163. }
  164. // 页面配置-end
  165. .title_select {
  166. margin-left: 36rpx;
  167. }
  168. .upload {
  169. width: 100%;
  170. overflow: hidden;
  171. }
  172. .balance {
  173. font-size: 28rpx;
  174. color: #7c838d;
  175. }
  176. .option_text {
  177. font-size: 28rpx;
  178. color: #18bb88;
  179. }
  180. .upload_con text {
  181. color: #898989;
  182. font-size: 40rpx;
  183. }
  184. .hint {
  185. font-size: 26rpx;
  186. color: #8f8f8f;
  187. margin-top: 40rpx;
  188. }
  189. .upload_img {
  190. width: 200rpx;
  191. height: 200rpx;
  192. margin-top: 60rpx;
  193. }
  194. .title {
  195. font-size: 28rpx;
  196. color: #7c838d;
  197. margin-bottom: 40rpx;
  198. }
  199. .upload_text {
  200. font-size: 26rpx;
  201. color: #898989;
  202. margin-top: 20rpx;
  203. }
  204. .showlist {
  205. font-size: 26rpx;
  206. color: #7c838d;
  207. margin-bottom: 20rpx;
  208. }
  209. .moeny input {
  210. color: #121922;
  211. font-size: 56rpx;
  212. height: 56rpx;
  213. margin-left: 10rpx;
  214. }
  215. .upload_con {
  216. width: 200rpx;
  217. height: 200rpx;
  218. border: 3rpx solid #898989;
  219. border-radius: 10rpx;
  220. margin-top: 60rpx;
  221. }
  222. .moeny {
  223. font-size: 42rpx;
  224. color: #121922;
  225. line-height: 1;
  226. height: 56rpx;
  227. border-bottom: 3rpx solid #e4e4ee;
  228. margin-bottom: 70rpx;
  229. padding: 37rpx 0;
  230. }
  231. .content {
  232. box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.1);
  233. width: 100%;
  234. overflow: hidden;
  235. padding: 40rpx;
  236. box-sizing: border-box;
  237. border-radius: 20rpx;
  238. }
  239. .btn {
  240. width: 348rpx;
  241. height: 80rpx;
  242. background: #18bb88;
  243. color: #fff;
  244. font-size: 40rpx;
  245. border-radius: 10rpx;
  246. box-shadow: 0px 8px 22px 2px rgba(24, 187, 136, 0.22);
  247. margin: 64rpx auto;
  248. }
  249. </style>