123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- const Parse = getApp().Parse;
- const company = getApp().globalData.company
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- length: 0,
- earnings: 0,
- list: [
- { 'num': '提现到银行卡' },
- ],
- idx: null,
- id: null,
- name: null,
- price: null,
- checked: true,
- merchant: null,
- names: null,
- bankName: null,
- accountId: null,
- activeColor: getApp().globalData.activeColor,
- titleColor: getApp().globalData.titleColor,
- },
- async getUserAgentWithdraw() {
- let merchant = wx.getStorageSync("merchant");
- if (merchant == "") {
- wx.redirectTo({
- url: '/nova-bzzb/pages/my/login/index'
- });
- return;
- }
- if (this.data.length > 2) {
- wx.showToast({
- title: '您本月的提现次数已到上限',
- icon: 'none',
- });
- return;
- }
- if (!this.data.price) {
- wx.showToast({
- title: '请输入提现金额',
- icon: 'none',
- });
- return
- }
- console.log(this.data.price, this.data.earnings);
- console.log(this.data.price > this.data.earnings)
- if (Number(this.data.price) > Number(this.data.earnings)) {
- wx.showToast({
- title: '您输入的金额超过了您的可提现金额',
- icon: 'none',
- });
- return
- }
- if (this.data.price < 1000) {
- wx.showToast({
- title: '最低提现金额为1000元',
- icon: 'none',
- });
- return
- }
- if (!this.data.name) {
- wx.showToast({
- title: '请选择提现方式',
- icon: 'none',
- });
- return
- }
- if (!this.data.names || !this.data.bankName || !this.data.accountId) {
- wx.showToast({
- title: '请输入完整银行卡信息',
- icon: 'none',
- });
- return
- }
- let UserAgentWithdraw = Parse.Object.extend("UserAgentWithdraw")
- let userAgentWithdraw = new UserAgentWithdraw()
- userAgentWithdraw.set("count", Number(this.data.price))
- userAgentWithdraw.set("type", "bank")
- userAgentWithdraw.set("isVerified", false)
- userAgentWithdraw.set("company", {
- __type: 'Pointer',
- className: 'Company',
- objectId: company
- })
- userAgentWithdraw.set("user", {
- __type: 'Pointer',
- className: '_User',
- objectId: this.data.merchant
- })
- userAgentWithdraw.set("info", [{
- name: this.data.names,
- accountId: this.data.accountId,
- bankName: this.data.bankName,
- storeName: this.data.id,
- }]
- )
- userAgentWithdraw.save().then(res => {
- console.log(res)
- wx.showToast({
- title: '提现成功',
- icon: 'none',
- });
- wx.navigateBack({
- delta: 1
- })
- })
- },
- goIndex(e) {
- let index = e.currentTarget.dataset.index;
- let name = e.currentTarget.dataset.item.num
- if (index == this.data.idx) {
- this.setData({
- idx: null,
- name: null
- })
- } else {
- this.setData({
- idx: index,
- name: name
- })
- }
- },
- blur(e) {
- let name = e.currentTarget.dataset.name
- this.setData({
- [name]: e.detail.value
- })
- },
- async getTotal(startTime, endTime) {
- let UserAgentWithdraw = new Parse.Query('UserAgentWithdraw')
- UserAgentWithdraw.equalTo('user', this.data.merchant)
- UserAgentWithdraw.equalTo('type', 'bank')
- UserAgentWithdraw.greaterThan('createdAt', startTime)
- UserAgentWithdraw.lessThan('createdAt', endTime)
- let userAgentWithdraw = await UserAgentWithdraw.find()
- let length
- if (userAgentWithdraw) {
- console.log(userAgentWithdraw.length);
- length = userAgentWithdraw.length
- }
- this.setData({
- length: length
- })
- console.log(this.data.length);
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- console.log(Parse.User.current().id);
- let earnings = options.earnings
- let id = options.id
- let merchant = wx.getStorageSync('merchant'); //用户
- console.log(merchant);
- console.log(earnings);
- this.setData({
- earnings: earnings,
- merchant: merchant.objectId,
- id: id
- })
- let d = new Date();
- this.date = d
- let data = new Date(d.getFullYear(), d.getMonth() + 1, 0);
- let day = data.getDate();
- this.data.year = d.getFullYear()
- this.data.month = d.getMonth() + 1 > 9 ? d.getMonth() + 1 : "0" + (d.getMonth() + 1)
- let dayArr = []
- for (let i = 0; i < day; i++) {
- if (i < 9) {
- dayArr.push("0" + (i + 1))
- } else {
- dayArr.push((i + 1))
- }
- }
- let startTime = this.data.year + "-" + this.data.month + "-" + "01" + " 00:00:00"
- let endTime = this.data.year + "-" + this.data.month + "-" + dayArr.length + " 23:59:57"
- console.log(startTime, endTime);
- this.getTotal(startTime, endTime)
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|