金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

334 lines
9.2 KiB

  1. <template>
  2. <view id="distribution-cash">
  3. <view class="cashContainer">
  4. <picker :value="selectedIndex" :range="nameList" @change="change">
  5. <view class="cash-card content-box">
  6. <view class="card-item">
  7. <!--<image src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3082730538,885471532&fm=27&gp=0.jpg"/>-->
  8. <view style="line-height: 40px;color: #8a8a8a" v-if="!sink">
  9. 您还未选择提现的账户
  10. </view>
  11. <view class="item__ul" v-else>
  12. <view class="item_name">{{bank_name}}</view>
  13. <view class="item_num">{{bank_card_number}}</view>
  14. </view>
  15. </view>
  16. <span class="arrow "></span>
  17. </view>
  18. </picker>
  19. <!--<view class="cash-card content-box" >
  20. <view class="card-item">
  21. &lt;!&ndash;<image src=""/>&ndash;&gt;
  22. <view style="line-height: 40px;color: #8a8a8a" >
  23. 微信账户
  24. </view>
  25. </view>
  26. <span class="arrow "></span>
  27. </view>-->
  28. <view class=" cash-input-container">
  29. <view class="cash-input-title">提现金额</view>
  30. <view class="cash-input-area mx-1px-top-bottom">
  31. <view class="cash-input">
  32. <span class="symbol"></span>
  33. <input type="number" placeholder="请输入提现金额" :value="inputValue" @input="inputMoney"></input>
  34. <span class="delete" @tap="eliminate">×</span>
  35. <span class="cash__input_all" @tap="allMoney">全部提现</span>
  36. </view>
  37. </view>
  38. <view class="cash-input-money">可提现金额{{balance}}</view>
  39. </view>
  40. <view class="cash-card content-box cash_padding" data-url="/pages/distribution/cashRecord/cashRecord" @tap="jumpItem">
  41. <span class="toCashRecord">查看提现记录</span>
  42. <span class="arrow"></span>
  43. </view>
  44. <view class="cash-to-card" :style="'background: ' + config.mainColor" @tap="submit">
  45. 确认提现
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. /**
  52. * Created by lcfevr on 2018/5/8.
  53. */
  54. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  55. export default {
  56. data() {
  57. return {
  58. bankList: '',
  59. selectedIndex: '',
  60. bank_name: '',
  61. bank_card_number: '',
  62. sink: false,
  63. balance: '',
  64. limit: '',
  65. id: '',
  66. cash_type: '',
  67. inputValue: '',
  68. nameList: [],
  69. config: ''
  70. };
  71. },
  72. onLoad() {
  73. // 第三方平台配置颜色
  74. var bgConfig = this.$cookieStorage.get('globalConfig') || '';
  75. this.setData({
  76. config: bgConfig
  77. });
  78. this.queryBalance();
  79. this.queryBankCardList();
  80. },
  81. components: {},
  82. props: {},
  83. methods: {
  84. jumpItem(e) {
  85. var url = e.currentTarget.dataset.url;
  86. wx.navigateTo({
  87. url: url
  88. });
  89. },
  90. change(e) {
  91. console.log(e);
  92. this.setData({
  93. selectedIndex: e.detail.value,
  94. bank_name: this.bankList[e.detail.value].bank.bank_name,
  95. bank_card_number: this.bankList[e.detail.value].bank_card_number,
  96. id: this.bankList[e.detail.value].id,
  97. sink: true
  98. });
  99. },
  100. eliminate() {
  101. this.setData({
  102. inputValue: ''
  103. });
  104. },
  105. allMoney() {
  106. this.setData({
  107. inputValue: this.balance
  108. });
  109. },
  110. inputMoney(e) {
  111. this.setData({
  112. inputValue: e.detail.value
  113. });
  114. },
  115. submit() {
  116. var bank = {
  117. bank_name: this.nameList[this.selectedIndex] || '',
  118. money: Number(this.inputValue),
  119. id: this.id,
  120. cash_type: this.cash_type
  121. };
  122. var message = null;
  123. if (!bank.bank_name) {
  124. message = '请选择账户';
  125. } else if (!bank.money) {
  126. message = '请输入提现金额';
  127. } else if (bank.money > Number(this.balance)) {
  128. message = '可提现金额不足';
  129. } else if (bank.money < Number(this.limit)) {
  130. message = '提现金额不能少于' + this.limit + '元';
  131. }
  132. if (message) {
  133. wx.showModal({
  134. content: message,
  135. showCancel: false
  136. });
  137. } else {
  138. var data = {
  139. amount: Number(this.inputValue),
  140. bank_account_id: this.id,
  141. cash_type: this.cash_type
  142. };
  143. this.applyCash(data);
  144. }
  145. },
  146. // 直接提取到微信钱包,不需要支付宝以及其他渠道 2018.12.28
  147. queryBankCardList() {
  148. this.$http.get({
  149. api: "api/users/BankAccount/show",
  150. header: {
  151. Authorization: this.$cookieStorage.get('user_token')
  152. }
  153. }).then(res => {
  154. if (res.statusCode == 200) {
  155. res = res.data;
  156. if (res.status) {
  157. var arr = [];
  158. var name = [];
  159. this.setData({
  160. cash_type: res.meta.type
  161. });
  162. var info = {
  163. bank: {
  164. id: '',
  165. bank_name: '微信钱包'
  166. },
  167. id: '',
  168. bank_card_number: '微信钱包直接提现到微信钱包'
  169. };
  170. arr.push(info);
  171. name.push('微信钱包');
  172. this.setData({
  173. bankList: arr,
  174. nameList: name
  175. }); //customer_wechat
  176. /* if (res.meta.type == 'customer_wechat') {
  177. var info = {
  178. bank:{
  179. id: '',
  180. bank_name: '微信钱包',
  181. },
  182. id: '',
  183. bank_card_number: '微信钱包直接提现到微信钱包'
  184. };
  185. arr.push(info);
  186. name.push('微信钱包')
  187. this.setData({
  188. bankList: arr,
  189. nameList: name
  190. })
  191. } else {
  192. res.data.forEach((val)=>{
  193. if(val.bank.bank_name == "支付宝"){
  194. arr.push(val);
  195. var list = val.bank.bank_name + val.bank_card_number
  196. name.push(list)
  197. this.setData({
  198. bankList: arr,
  199. nameList: name
  200. })
  201. }
  202. })
  203. }*/
  204. } else {
  205. wx.showModal({
  206. content: res.message || '请求失败',
  207. showCancel: false
  208. });
  209. }
  210. } else {
  211. wx.showModal({
  212. content: res.message || '请求失败',
  213. showCancel: false
  214. });
  215. }
  216. });
  217. },
  218. //分销中心余额
  219. queryBalance() {
  220. this.$http.get({
  221. api: "api/distribution/cash/balanceSum",
  222. header: {
  223. Authorization: this.$cookieStorage.get('user_token')
  224. }
  225. }).then(res => {
  226. if (res.statusCode == 200) {
  227. res = res.data;
  228. if (res.status) {
  229. this.setData({
  230. balance: res.data.sumBalance / 100,
  231. limit: res.data.limit
  232. });
  233. } else {
  234. wx.showModal({
  235. content: res.message || '请求失败',
  236. showCancel: false
  237. });
  238. }
  239. } else {
  240. wx.showModal({
  241. content: res.message || '请求失败',
  242. showCancel: false
  243. });
  244. }
  245. });
  246. },
  247. //提现
  248. applyCash(data) {
  249. this.$http.post({
  250. api: "api/distribution/cash/apply",
  251. header: {
  252. Authorization: this.$cookieStorage.get('user_token')
  253. },
  254. data: data
  255. }).then(res => {
  256. if (res.statusCode == 200) {
  257. res = res.data;
  258. if (res.status) {
  259. wx.showModal({
  260. content: '提现申请已提交,将在7天内到账,请注意查收',
  261. showCancel: false,
  262. success: res => {
  263. if (res.confirm || !res.cancel && !res.confirm) {
  264. wx.redirectTo({
  265. url: '/pages/distribution/distributionCenter/distributionCenter'
  266. });
  267. }
  268. }
  269. });
  270. } else {
  271. wx.showModal({
  272. content: res.message || '请求失败',
  273. showCancel: false
  274. });
  275. }
  276. } else {
  277. wx.showModal({
  278. content: res.message || '请求失败',
  279. showCancel: false
  280. });
  281. }
  282. });
  283. },
  284. setData: function (obj) {
  285. let that = this;
  286. let keys = [];
  287. let val, data;
  288. Object.keys(obj).forEach(function (key) {
  289. keys = key.split('.');
  290. val = obj[key];
  291. data = that.$data;
  292. keys.forEach(function (key2, index) {
  293. if (index + 1 == keys.length) {
  294. that.$set(data, key2, val);
  295. } else {
  296. if (!data[key2]) {
  297. that.$set(data, key2, {});
  298. }
  299. }
  300. data = data[key2];
  301. });
  302. });
  303. }
  304. },
  305. computed: {},
  306. watch: {}
  307. };
  308. </script>
  309. <style rel="stylesheet/less" lang="less">
  310. @import "cash";
  311. </style>