123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- // pages/temp/cash/index.js
- const app = getApp()
- const util = require("../../../utils/jmsUtil.js");
- const util2 = require("../../../utils/util.js");
- const api = require('../../../api/jms.js');
- const user = require('../../../utils/user.js');
- const check = require('../../../utils/check.js');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- workerFee: {},
- worker: '',
- workerFeeList: [],
- pageIndex: 1,
- showAuth: false,
- code: '',
- checked: false
- },
- userProtocol() {
- wx.navigateTo({
- url: '/pages/temp/cash/protocol'
- });
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.getBlance();
- this.getWorkerFeeList();
- this.getLoginCode();
- },
- getBlance(){
- util.request(api.getWorkerFee, {}, 'GET').then(res => {
- this.setData({
- workerFee: res.data.fee,
- worker: res.data.worker
- })
- });
- },
- goCancel() {
- this.setData({
- showAuth: false
- })
- },
- goCashout() { //去提现
- let that = this
- //是否认证过
- if (!this.data.worker.signStatus || this.data.worker.signStatus == false) {
- this.setData({
- showAuth: true
- })
- return;
- }
- if(that.data.workerFee.blance<=0){
- util.showErrorToast("无可提现金额");
- return;
- }
- wx.showModal({
- title: '提示',
- confirmText:'提现',
- content: '提现金额为' + that.data.workerFee.blance + ',平台通过授权第三方(“云账户”)向您的微信钱包打款',
- success: function (sm) {
- if (sm.confirm) {
- util.request(api.Cashout, {
- amount: that.data.workerFee.blance
- }).then(function (res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '提现申请成功,请查看【微信支付】',
- icon: 'none',
- duration: 2000
- });
- that.setData({
- showAuth: false
- })
- that.getBlance();
- }else{
- util.showErrorToast(res.errmsg);
- }
- });
- } else if (sm.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- },
- goDeductDetail() {
- wx.navigateTo({
- url: '/pages/temp/cash/cashList',
- })
- },
- getWorkerFeeList(e) { //扣款明细
- let that = this;
- util.request(api.getWorkerFeeList, {
- pageIndex: that.data.pageIndex,
- pageSize: 10
- }, 'GET').then(res => {
- if (res.data.list.length == 0) {
- util2.showErrorToast("没有更多数据");
- } else {
- let list = that.data.workerFeeList;
- list = list.concat(res.data.list);
- that.setData({
- workerFeeList: list,
- pageIndex: that.data.pageIndex + 1
- })
- console.info(that.data.workerFeeList)
- }
- });
- },
- bindinputName(e) {
- let val = e.detail.value;
- this.setData({
- ['worker.name']: val
- });
- },
- bindinputNid(e) {
- let val = e.detail.value;
- this.setData({
- ['worker.idCard']: val
- })
- },
- onChange(e) {
- console.log(e);
- this.setData({
- checked: e.detail,
- });
- },
- cashoutAuth() {
- if (this.data.worker.name == '') {
- wx.showToast({
- title: '请输入真实姓名',
- icon: 'none',
- duration: 2000
- });
- return false;
- } else if (!check.isCardCheck(this.data.worker.idCard)) {
- wx.showToast({
- title: '请输入正确的身份证号',
- icon: 'none',
- duration: 2000
- });
- return false;
- } else if (!this.data.checked) {
- wx.showToast({
- title: '请阅读《用户条款》并勾选',
- icon: 'none',
- duration: 2000
- });
- return false;
- }
- let that = this;
- util.request(api.getSign, {
- tempWorkerId: this.data.worker.id,
- name: this.data.worker.name,
- idCard: this.data.worker.idCard,
- phone: this.data.worker.tel,
- code: this.data.code
- }, "POST").then(res => {
- if (res.errno == 0) {
- that.setData({
- showAuth: false,
- 'worker.signStatus':true
- })
- that.goCashout();
- } else {
- that.getLoginCode();
- util.showErrorToast(res.errmsg);
- }
- });
- },
- getLoginCode() {
- let that = this;
- user.login().then(res => {
- console.info(res)
- that.setData({
- code: res.code
- })
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- this.getWorkerFeeList();
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|