index.vue 7.5 KB

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