123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- const app = getApp();
- Page({
- data: {
- OccupationArray: [],
- Price: '',
- Originalprice: '',
- day: '',
- Priceid: '',
- memberstatus:'',
- },
- onLoad: function (options) {
- var that =this;
-
- let Occupation_url = 'pay/recharge/setmealinfo';
- let Occupation_data = {
- pid: '0'
- };
- app.postRequest(Occupation_url, Occupation_data, function (res) {
- if (res.code == 201) {
-
- var arrData = res.data;
-
- var averageprice ='';
- for ( var i in res.data){
- if (arrData[i].day && arrData[i].day != 0) {
-
-
- averageprice = Number(arrData[i].total_price / arrData[i].day);
- averageprice = averageprice.toFixed(2);
- arrData[i].average_price = averageprice;
-
- }
- }
- that.setData({
- OccupationArray: arrData,
- })
- }
-
- })
-
- let memberstatus_url = 'pay/recharge/memberstatus';
- let memberstatus_data = {
- };
- app.postRequest(memberstatus_url, memberstatus_data, function (res) {
- if (res.code == 201) {
-
- that.setData({
- memberstatus: res.data
- })
- }
- })
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- checkboxChange: function (e) {
- console.log(e.detail.value)
- var that =this;
- var Price= ''
- var Originalprice=''
- var day=''
- var dataid = e.detail.value;
- var data = that.data.OccupationArray;
-
- for (let i = 0; i < data.length; i++) {
- if (data[i].id == dataid) {
- Price = data[i].discount_peice
- Originalprice = data[i].total_price
- day = data[i].time
- }
- }
- this.setData({
- Priceid: dataid,
- Price: Price,
- Originalprice: Originalprice,
- day: day,
- })
-
- console.log(day);
- console.log(Originalprice);
- console.log(Price);
- console.log('checkbox发生change事件,携带value值为:', e.detail.value);
- },
- pay: function () {
- let _that = this;
- wx.login({
- success: function (res) {
- console.log(res.code)
- if (res.code) {
- var _Priceid = _that.data.Priceid
- let payment_url = 'pay/wxpay/index';
- let payment_data = {
- rid: _that.data.Priceid,
- total_price: _that.data.Price,
- discount_peice: _that.data.Originalprice,
- code: res.code
- };
- app.postRequest(payment_url, payment_data, function (res) {
- console.log(res.data)
- if (res.code == 201) {
- wx.requestPayment({
- timeStamp: res.data.timeStamp,
- nonceStr: res.data.nonceStr,
- package: res.data.package,
- signType: res.data.signType,
- paySign: res.data.paySign,
- success(res) {
- wx.showToast({
- title: '支付成功',
- icon: 'success',
- duration: 2000
- })
- _that.onLoad();
- },
- fail(res) {
- getApp().Tips('支付失败');
- }
- })
- return
- }
- getApp().Tips('支付失败');
- })
-
-
-
-
-
- }
- }
- })
- },
-
- })
|