123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- // pages/ride_zige/ride_zige.js
- const util = require('../../utils/utils');
- var app = getApp()
- var url = ''
- Page({
- data: {
- currentItem: 0,
- cardList: [],//骑行卡列表
- deposit: '',//骑行卡
- depositMoney: '',//押金金额
- frame: false,//确认退还退押金弹框
- },
- onLoad: function (options) {
- let deposit = my.getStorageSync({'key':'userState'}).data
- this.setData({
- deposit: my.getStorageSync({'key':'userState'}).data,
- depositMoney: my.getStorageSync({'key':'setting'}).data.deposit
- })
- this.getCard()
- // this.getState()
- },
- //获取免押金卡列表
- getCard() {
- my.showLoading({})
- let data = {
- area_id: my.getStorageSync({'key':'home'}).data.id
- }
- if (my.getStorageSync({'key':'home'}).data.id == undefined) {
- my.hideLoading()
- my.showToast({
- content: '您附近没有运营区域',
- icon: 'none'
- })
- } else {
- //免押金卡
- app.request('/deposit_card/index', data, 'GET').then(res => {
- console.log(res.data);
- this.setData({
- cardList: res.data.data
- })
- my.hideLoading({
- complete: (res) => { },
- })
- console.log(this.data.cardList)
- })
- }
- },
- //选择骑行卡类型
- changeCard: function (e) {
- let that = this
- let id = e.currentTarget.dataset.id
- that.setData({
- currentItem: id
- })
- // if(id==0){
- // }else if (that.data.deposit.is_deposit == 1 && that.data.deposit.deposit_type == 1) {
- // my.showToast({
- // content: '您已缴纳押金无需购买免押金卡',
- // icon: 'none'
- // })
- // return;
- // }
- },
- //立即支付
- pay: util.throttle(function (e) {
- console.log('支付')
- var that = this;
- let url = '';
- var data = '';
- if (app.globalData.req) {
- console.log(that.data.depShow)
- if (that.data.currentItem == 0) { //缴纳押金
- console.log(11111)
- url = "/deposit/pay";
- data = {
- area_id: my.getStorageSync({'key':'home'}).data.id
- }
- } else { //购买免押金卡
- console.log(2222)
- url = "/deposit_card/pay";
- data = {
- area_id: my.getStorageSync({'key':'home'}).data.id,
- id: that.data.currentItem
- }
- }
- if (my.getStorageSync({'key':'setting'}).data == '') {
- my.alert({
- title: '提示',
- content: '您附近暂无运营区域~',
- success: function (res) {
- my.navigateBack()
- }
- })
- } else {
- app.request(url, data, 'POST', app.globalData.req).then(res => {
- console.log(res)
- if (res.status == 200) {
- console.log(res)
- my.tradePay({
- tradeNO: res.data.tradeNo,
- success(res) {
- console.log(res)
- let init = '';
- if (that.data.depShow) {
- init = "购买成功"
- } else {
- init = "支付成功"
- }
- my.showToast({
- content: init,
- icon: 'none',
- duration: 1000,
- success: function () {
- my.reLaunch({
- url: '/pages/depochenSuce/depoSuce',
- })
- }
- })
- that.setData({
- depoSuce: true
- })
- },
- fail(err) {
- // console.log(err)
- // my.showToast({
- // content: '支付失败',
- // icon: 'none'
- // })
- // that.setData({
- // depoSuce: true
- // })
- }
- })
- } else {
- console.log(res)
- that.setData({
- depoSuce: true
- })
- }
- })
- }
- } else {
- my.showToast({
- content: '您的操作过于频繁,请稍后再试~',
- icon: 'none'
- })
- }
- }, 1000),
- //退还押金
- backDeposit: function () {
- this.setData({
- frame: true
- })
- },
- closeFrame: function () {
- this.setData({
- frame: false
- })
- },
- //立即退还
- sureBack:util.throttle(function (e) {
- let setting=my.getStorageSync({'key':'setting'}).data
- var that = this;
- if (setting.deposit_delay_setting.status == true) {
- my.confirm({
- title: '退还押金',
- content: '您这笔退款预计一到三天内到账是否确认退款',
- showCancel: true, //是否显示取消按钮
- cancelButtonText: "取消", //默认是“取消”
- cancelColor: '#000000', //取消文字的颜色
- confirmButtonText: "确认", //默认是“确定”
- confirmColor: '#FF0000', //确定文字的颜色
- success: function (res) {
- if (res.confirm==false) {
- //点击取消,默认隐藏弹框
- } else {
- //点击确定
- app.request('/deposit/refund-job', '', 'POST').then(res => {
- console.log(res,'退还押金');
- if (res.status == 200) {
- my.reLaunch({
- url: '/pages/refund_success/refund_success?number=' + that.data.setting.deposit_delay_setting.day,
- })
- }
- }).catch(err=>{
- console.log('0000')
- })
- }
- }
- })
- } else {
- app.request('/deposit/refund', '', 'POST').then(res => {
- console.log(res);
- if (res.status == 200) {
- my.showToast({
- content: '申请成功,1个工作日内到账!',
- icon: 'none'
- })
- setTimeout(function(){
- my.reLaunch({
- url: '/pages/index/index',
- })
- },1500)
- // this.getState()
- }
- })
- }
- }, 1000),
- onReady: function () {
- },
- onShow: function () {
- },
- onHide: function () {
- },
- onUnload: function () {
- },
- onPullDownRefresh: function () {
- },
- onReachBottom: function () {
- },
- onShareAppMessage: function () {
- }
- })
|