|
- const util = require("../../../utils/util");
- const config = require("../../../config/config.js");
- const Http = require("../../../utils/HttpBasics");
-
- //券详情页面
- Page({
- data: {
- code: "",
- data: {
- salePrice:null,
- price: null,
- usePrice: null
- },
- createDate: "",
- expiredTime: "",
- updateDate: "",
- //存储计时器
- setInter: "",
- staticGamedata: {},
- showIf:false,
- },
- onUnload: function() {
- let that = this;
- clearInterval(that.data.setInter);
- wx.setScreenBrightness({
- value: that.data.sight,
- })
- },
- gotogame: function () {
- let that = this;
- wx.navigateTo({
- url: '/pages/game/index?url=' + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
- })
- },
- // 获取游戏
- getStaticGame(token) {
- let _this = this;
- Http.get({
- url: config.api.getGame,
- data: {
- triggleAction: 3
- }
- }).then(res => {
- if (res.data.id) {
- _this.setData({
- showIf: true
- })
- }
- _this.setData({
- staticGamedata: res.data
- })
- })
- },
- onLoad: function(options) {
- let that = this;
- console.log(options.sight);
- setTimeout(function() {
- wx.setScreenBrightness({
- value: 0.7,
- })
- }, 200),
- that.setData({
- sight: options.sight,
- code: options.quancode,
- couponorderstatus: options.couponorderstatus
- });
-
-
- //获得优惠券的详情
- that.data.setInter = setInterval(function() {
- if (
- options.quancode &&
- that.data.couponorderstatus == 0
- ) {
- Http.get({
- url: config.api.couponOrderDetail,
- data: {
- couponOrderId: options.quancode
- }
- }).then(res => {
- console.log(res);
- that.setData({
- couponorderstatus: res.data.couponOrderStatus,
- data: res.data
- });
- if (res.data.couponOrderStatus == 1) {
- /**
- * 动态改变上一级页面的核销状态
- */
-
- that.getStaticGame()
- var pages = getCurrentPages();
- var prevPage = pages[pages.length - 2]; //上一个页面
- //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
- prevPage.setData({
- mystatus: res.data.couponOrderStatus
- });
- }
- that.setData({
- expiredTime: util.formatTime(that.data.data.expiredTime, "yyyy-MM-dd hh:mm:ss"),
- updateDate: util.formatTime(that.data.data.updateDate, "yyyy-MM-dd hh:mm:ss"),
- createDate: util.formatTime(that.data.data.createDate, "yyyy-MM-dd hh:mm:ss")
- });
- });
- }
- }, 2000);
-
- /**
- * 页面需要初始渲染的效果
- */
- Http.get({
- url: config.api.couponOrderDetail,
- data: {
- couponOrderId: options.quancode
- }
- }).then(res => {
- console.log(res);
- that.setData({
- couponorderstatus: res.data.couponOrderStatus,
- data: res.data
- });
- that.setData({
- expiredTime: util.formatTime(that.data.data.expiredTime, "yyyy-MM-dd hh:mm:ss"),
- updateDate: util.formatTime(that.data.data.updateDate, "yyyy-MM-dd hh:mm:ss"),
- createDate: util.formatTime(that.data.data.createDate, "yyyy-MM-dd hh:mm:ss")
- });
- util.barcode("barcode", options.quancode, 510, 100);
- util.qrcode("qrcode", options.quancode, 350, 350);
- })
- },
- phone: function() {
- let that = this;
- console.log(that.data);
- if (that.data.data.merchantLinkPhone) {
- wx.makePhoneCall({
- phoneNumber: that.data.data.merchantLinkPhone
- });
- }
- }
- });
|