123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- const util = require("../../../../utils/util");
- const api = require('../../../../api/api.js');
- var check = require('../../../../utils/check.js');
- import moment from 'moment'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- currentMonth:moment(new Date()).format('YYYY-MM'),
- salaryList: [],
- total: 0,
- month: '',
- type: 1,
- showAuth: false,
- servantType: 0, //servantType 表示服务者身份99是临时服务者 明细页可以显示提现按钮
- blance: 0, //可提现金额
- mobile: '',
- nid: '',
- name: '',
- checked: false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- month: options.month,
- total: options.total,
- type: options.type,
- servantType: options.servantType,
- blance: options.blance
- })
- this.getSalary();
- },
- lastMonth(){
- let params=util.getYearMonth(this.data.month,'-');
- this.setData({
- month:params
- });
- this.getSalary();
- },
- nextMonth(){
- let params=util.getYearMonth(this.data.month,'+');
- this.setData({
- month:params
- });
- this.getSalary();
- },
- onChange(e) {
- console.log(e);
- this.setData({
- checked: e.detail,
- });
- },
- userProtocol() {
- wx.navigateTo({
- url: '/pages/servant/salary/protocol/protocol'
- });
- },
- getSalary() {
- let that = this
- wx.showLoading();
- util.request(api.SalaryDetail, {
- month: that.data.month,
- type: that.data.type,
- salaryType: 0
- }).then(res => {
- wx.hideLoading();
- let sumtotl=0;
- res.data.forEach(r=>{
- sumtotl=r.salary+sumtotl;
- })
- that.setData({
- salaryList: res.data,
- total:sumtotl,
- })
- }).catch(res => {
- wx.hideLoading();
- })
- },
- getSalaryDetail(e) { //获取项目的构成明细 比如工单计提 每单的详细情况
- let that = this
- let salaryType = e.currentTarget.dataset.salarytype;
- let salaryList = that.data.salaryList;
- let salary = null;
- salaryList.forEach(item => {
- if (item.salaryType == salaryType)
- salary = item;
- })
- salary.isShow = !salary.isShow;
- if (salary.details != null && salary.details.length > 0) {
- that.setData({
- salaryList: salaryList
- })
- return;
- }
- wx.showLoading();
- util.request(api.SalaryDetail, {
- month: that.data.month,
- type: 99,
- salaryType: salaryType
- }).then(res => {
- wx.hideLoading();
- salary.details = res.data;
- that.setData({
- salaryList: salaryList
- })
- }).catch(res => {
- wx.hideLoading();
- })
- },
- goCheckAuth() { //是否实名认证过
- let that = this
- util.request(api.ParterAuthCheck, {}).then(function (res) {
- if (res.errno === 0 && res.data) {
- that.goCashout();
- } else {
- that.setData({
- showAuth: true
- })
- }
- })
- },
- goCashout() { //提现申请
- let that = this
- wx.showModal({
- title: '提示',
- content: '提现金额为' + that.data.blance + ',平台通过授权第三方(“云账户”)向您的微信钱包打款,涉及手续费由引荐人自行承担,故最终提现金额应以实际到账金额为准。',
- success: function (sm) {
- if (sm.confirm) {
- util.request(api.ParterCashout, {
- cashout: that.data.blance
- }).then(function (res) {
- console.info(res)
- if (res.errno === 0) {
- wx.showToast({
- title: '提现申请成功',
- icon: 'none',
- duration: 2000
- });
- that.setData({
- showAuth: false,
- blance: 0
- })
- }
- });
- } else if (sm.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- },
- goList() {
- wx.navigateTo({
- url: '/pages/servant/salary/list/list',
- })
- },
- goCancel() {
- this.setData({
- showAuth: false
- })
- },
- bindinputName(e) {
- let val = e.detail.value;
- this.setData({
- name: val
- });
- },
- bindinputNid(e) {
- let val = e.detail.value;
- this.setData({
- nid: val
- })
- },
- cashoutAuth() {
- if (this.data.name == '') {
- wx.showToast({
- title: '请输入真实姓名',
- icon: 'none',
- duration: 2000
- });
- return false;
- } else if (!check.isCardCheck(this.data.nid)) {
- wx.showToast({
- title: '请输入正确的身份证号',
- icon: 'none',
- duration: 2000
- });
- return false;
- } else if (!this.data.checked) {
- wx.showToast({
- title: '请阅读《用户条款》并勾选',
- icon: 'none',
- duration: 2000
- });
- return false;
- }
- util.request(api.ParterAuth, {
- name: this.data.name,
- nid: this.data.nid
- }).then(res => {
- if (res.errno == 0) {
- this.goCashout();
- }
- });
- },
- goBack() {
- wx.navigateBack({
- delta: 1
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|