let config = require("../../../config/config.js"); let util = require("../../../utils/util"); let Http = require("../../../utils/HttpBasics"); let app = getApp(); Page({ /** * 页面的初始数据 */ data: { showModalStatus: false, flag: 0 }, /** * 点击弹出二维码 * 然后再关闭 */ powerDrawer: function(e) { var currentStatu = e.currentTarget.dataset.statu; console.log(e.currentTarget.dataset.statu); console.log(e.currentTarget.dataset.quancode); this.utils(currentStatu, e.currentTarget.dataset.quancode); }, utils: function(currentStatu, quancode) { /* 动画部分 */ // 第1步:创建动画实例 var animation = wx.createAnimation({ duration: 200, //动画时长 timingFunction: "linear", //线性 delay: 0 //0则不延迟 }); // 第2步:这个动画实例赋给当前的动画实例 this.animation = animation; // 第3步:执行第一组动画 animation.opacity(0).step(); // 第4步:导出动画对象赋给数据对象储存 this.setData({ animationData: animation.export() }); // 第5步:设置定时器到指定时候后,执行第二组动画 setTimeout( function() { // 执行第二组动画 animation.opacity(1).step(); // 给数据对象储存的第一组动画,更替为执行完第二组动画的动画对象 this.setData({ animationData: animation }); //关闭 if (currentStatu == "close") { this.setData({ showModalStatus: false }); } }.bind(this), 20 ); // 显示 if (currentStatu == "open") { this.setData({ showModalStatus: true }); this.data.flag++; console.log(this.data.flag); util.barcode("barcode" + this.data.flag, quancode, 500, 100); util.qrcode("qrcode" + this.data.flag, quancode, 350, 350); this.setData({ flag: this.data.flag }); } }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { let that = this; console.log(options.orderId); console.log(options.flag + "我是付款的标识"); Http.get({ url: config.api.orderDetail, data: { orderId: options.orderId } }).then(res => { console.log(res); console.log("我是订单详情"); that.setData({ data: res.data }); //createDate 创建时间 var createDate = util.fmtDate(res.data.createDate); console.log(createDate); that.setData({ createDate: createDate }); }); }, /** * 发起支付 */ // orderFunc(e) { // var that = this; // console.log(e.currentTarget.dataset.couponchannelid); // wx.showLoading({ // title: "加载中..." // }); // Http.post({ // url: config.api.checkPhoneStatus, // data: {} // }) // .then(res => { // console.log(res); // /** // * orderSave 下单 // */ // return Http.post({ // url: config.api.orderSave, // data: { // couponChannelId: "" + e.currentTarget.dataset.couponchannelid, // couponId: "" + that.data.couponId // } // }); // }) // .catch(err => { // console.log(err); // if (err.code == 11005) { // // 用户手机未授权 // wx.redirectTo({ // url: // "../../getphoneInfo/index?couponChannelId=" + // that.data.couponChannelId + // "&couponId=" + // that.data.couponId // }); // } // if (err.code == 11006) { // // 用户手机已加密 // wx.redirectTo({ // url: // "../../phoneinput/phoneinput?couponChannelId=" + // that.data.couponChannelId + // "& couponId=" + // that.data.couponId // }); // } // }) // .then(res => { // if (res != "undefined") { // const orderId = "" + res.data.id; // that.setData({ // orderId: orderId // }); // if (res.data.payment > 0) { // // 支付金额不为0 // /** // * 支付订单创建 // */ // Http.post({ // url: config.api.payOrderCreate, // data: { // orderId: orderId // } // }).then(res => { // console.log(res); // /// Begin payment ---- // var payOrderId = "" + res.data.payOrderId; // wx.hideLoading(); // wx.requestPayment({ // timeStamp: res.data.timeStamp, // nonceStr: res.data.nonceStr, // package: res.data.package, // signType: "MD5", // paySign: res.data.paySign, // success: res => { // console.log(res); // console.log("姐在检查付款异常"); // that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功 // console.log(res); // if (res.errMsg == "requestPayment:ok") { // wx.showToast({ // title: "购买成功", // duration: 2500 // }); // } // wx.navigateBack({ // delta: 2 // }); // }, // fail: res => { // that.payOrderUpdate(that.data.orderId, payOrderId, 2); // 支付失败 // console.log(res); // return; // }, // complete: res => { // console.log(res); // console.log("支付完成"); // // var url = res.data.url; // // console.log("get url", url); // if (res.errMsg == "requestPayment:ok") { // wx.showModal({ // title: "提示", // content: "支付成功" // }); // // if (url) { // // setTimeout(function () { // // wx.redirectTo({ // // url: "/pages" + url // // }); // // }, 2000); // // } else { // // setTimeout(() => { // // wx.navigateBack(); // // }, 2000); // // } // } else { // wx.showToast({ // title: "支付失败", // image: "./../../../assets/img/fail.png", // duration: 1500, // mask: false // }); // } // return; // } // }); // /// End payment -------- // ///// virtual pay // //var payOrderId = "" + res.data.out_trade_no; // //that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功 // ///// end virtual pay // }); // } else { // // 免费券 // that // .payOrderUpdate(orderId, "0", 1) // 支付成功 // .then(res => { // wx.showToast({ // title: "支付成功", // duration: 3000 // }); // }); // } // } // }) // .catch(err => { // console.log(err); // }); // }, /** * 支付订单更新 */ // payOrderUpdate: (orderId, payOrderId, status, reason) => { // // 支付成功 // Http.post({ // url: config.api.payOrderUpdate, // data: { // payOrderId: payOrderId, // orderId: orderId, // status: status, // reason: reason // } // }) // .then(res => { // console.log("payOrderUpdate then", res); // // wx.showToast({ // // title: "购买成功", // // duration: 2500 // // }); // }) // .catch(err => { // console.log("payOrderUpdate catch", err); // }); // }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() {}, /** * 生命周期函数--监听页面显示 */ onShow: function(options) {}, /** * 生命周期函数--监听页面隐藏 */ onHide: function() {}, /** * 生命周期函数--监听页面卸载 */ onUnload: function() {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() {}, /** * 用户点击右上角分享 */ onShareAppMessage: function() {} });