| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- var _request = require('../../../../utils/request.js')
- Page({
- data: {
- inputValue: '',
- balance: '',
- buttonClicked: false,
- orderId: '',
- path: '',
- luoboCount: '',
- countMoney: '0.00'
- },
- onLoad: function (options) {
- this.data.orderId = options.orderId
- this.data.path = options.path
- // this.data.luoboCount = options.luoboCount
- // this.setData({
- // luoboCount: options.luoboCount
- // })
- // this.setData({
- // countMoney: options.countMoney
- // })
- this.checkbalance()
- },
- bindKeyInput: function(e) {
- this.setData({
- inputValue: e.detail.value
- })
- if (!this.data.inputValue) {
- this.setData({
- countMoney:'0.00'
- })
- }
- },
- toWeixin (e) {
- var count = parseInt(e.currentTarget.dataset.text) || this.data.inputValue || this.data.luoboCount
- var that = this
- that.buttonClicked()
- var url = 'v1/balance_order/generate'
- var params = {
- count: count*100,
- payway: 'service_wxpay'
- }
- var success = function (val) {
- that.topay(val.data)
- }
- _request.$post(url, params, success)
- },
- topay (res) {
- var that = this
- var url = 'v1/pay'
- var params = {
- order_id: res.order_id,
- pay_way: res.pay_way
- }
- var success = function (val) {
- wx.requestPayment({
- 'timeStamp': val.data.pay_data.timeStamp,
- 'nonceStr': val.data.pay_data.nonceStr,
- 'package': val.data.pay_data.package,
- 'signType': val.data.pay_data.signType,
- 'paySign': val.data.pay_data.paySign,
- 'success':function(res){
- wx.showToast({
- title: '支付成功',
- icon: 'success',
- duration: 1000
- })
- that.checkbalance()
- wx.navigateTo({
- url: that.data.path + '?orderId=' + that.data.orderId
- })
- },
- 'fail':function(res){
- }
- })
- }
- _request.$post(url, params, success)
- },
- checkbalance () {
- var that = this
- var url = 'v1/user/balance/info'
- var params = {
- }
- var success = function (res) {
- var result = res.data.total
- that.setData({
- balance: result,
- invitemode: res.data.show_invite_mode
- })
- }
- _request.$get(url, params, success)
- },
- buttonClicked () {
- var that = this
- that.setData({
- buttonClicked: true
- })
- setTimeout(function () {
- that.setData({
- buttonClicked: false
- })
- }, 3000)
- },
- onShareAppMessage: function (val) {
- return _request.share({
- sc: 'xcx_user_rabbitbuy'
- })
- }
- })
|