123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- var app = getApp();
- const util = require('../../utils/utils.js');
- Page({
- data: {
- hot: false,
- index1: null,
- money: '',
- arr: [],
- info: false,
- id: '',
- no: '',
- infoDetail: [],
- hotInfo: [],
- img:app.globalData.imgUrl,
- setting:{}
- },
- onLoad: function (options) {
- var that = this;
- var area_id = ''
- wx.showLoading({
- title: '加载中...',
- })
- if (wx.getStorageSync('home').id != undefined) {
- area_id = wx.getStorageSync('home').id
- }
- var data = {
- 'area_id': area_id
- }
- this.setData({
- setting: wx.getStorageSync('setting')
- })
- app.request("/card_riding/index", data, "GET").then(res => {
- console.log(res)
- wx.hideLoading()
- if (res.data.data == '') {
- return;
- }
- var arr1 = res.data.data.shift()
- console.log(arr1)
- console.log(res.data.data)
- that.setData({
- hotInfo: arr1,
- arr: res.data.data,
- hot: true
- })
- }).catch(err => {
- console.log(err)
- })
- },
- background: function () {
- this.setData({
- info: false
- })
- },
- buy: function (e) {
- var id = e.currentTarget.dataset.id;
- var index = e.currentTarget.dataset.index;
- var arr = this.data.arr;
- this.setData({
- id,
- info: true,
- infoDetail: arr[index]
- })
- },
- buy1: function () {
- this.setData({
- id: this.data.hotInfo.id,
- info: true,
- infoDetail: this.data.hotInfo
- })
- },
- form: util.throttle(function () {
- var that = this;
- that.setData({
- info: false
- })
- var area_id = ''
- if (wx.getStorageSync('home').id != undefined) {
- area_id = wx.getStorageSync('home').id
- } else {
- wx.showToast({
- title: '当前地区暂无运营区域',
- icon: 'none'
- })
- return;
- }
- if (app.globalData.req) {
- var data = {
- 'card_riding_id': that.data.id,
- 'area_id': area_id
- }
- app.request("/card_riding/pay", data, "POST", app.globalData.req).then(res => {
- console.log(res)
- if (res.statusCode == 200) {
- that.setData({
- no: res.data.no
- })
- wx.requestPayment({
- timeStamp: res.data.timeStamp.toString(),
- nonceStr: res.data.nonceStr,
- package: res.data.package,
- signType: res.data.signType,
- paySign: res.data.paySign,
- success(resp) {
- console.log(resp)
- wx.showToast({
- title: '购买成功,请用车',
- icon: 'none',
- mask: true,
- success: function () {
- if(app.globalData.compatible){
- wx.reLaunch({
- url: '/pages/compatible/index/index',
- })
- }else{
- wx.reLaunch({
- url: '/pages/index/index',
- })
- }
- }
- })
- },
- fail(err) {
- console.log(err)
- wx.showToast({
- title: '支付失败',
- icon: 'none'
- })
- var data = {
- no: that.data.no
- }
- app.request("/card_riding/no_pay", data, "POST").then(res => {
- console.log(res)
- })
- }
- })
- }
- })
- } else {
- wx.showToast({
- title: '您的操作过于频繁,请稍后再试~',
- icon: 'none'
- })
- }
- }, 1000),
- onReady: function () {
- },
- onShow: function () {
- },
- onHide: function () {
- },
- onUnload: function () {
- },
- onPullDownRefresh: function () {
- },
- onReachBottom: function () {
- },
- onShareAppMessage: function () {
- }
- })
|