|
-
- const config = require('../../config/config.js')
- const Common = require('../../common/common.js')
- const format = require('../../utils/util.js')
- var app = getApp()
- Page({
- data: {
- val: '请输入券码',
- couponOrderId: null,
- couponOrderDetail: null,
- statusImg: '',
- statusText: '',
- flag: false,
- detail: '',
- remark: '',
- contentType: 0,
-
- },
- rule() {
- tt.navigateTo({
- url: `/pages/main/rule/rule?detail=${this.data.couponOrderDetail.detail}&remark=${this.data.couponOrderDetail.remark}&contentType=${this.data.contentType}`
- })
- },
- onLoad(options) {
- if (tt.getStorageSync("couponOrderId")) {
- this.setData({
- couponOrderId: tt.getStorageSync("couponOrderId")
- })
- this.detailInfo(tt.getStorageSync("couponOrderId"))
- }
- },
- detailInfo(couponOrderId) {
- var that = this;
- Common.getCouponOrderDetail(couponOrderId)
- .then(res => {
- console.log(res,"res123")
- if (res.code == 200) {
-
- this.setData({
- contentType: res.data.contentType ? res.data.contentType : 0
- })
- console.log(this.data.contentType)
- if (res.data.contentType != undefined && res.data.contentType == 1) {
- Common.getHtml(couponOrderId).then(res => {
- if (res.data.html && res.data.html != '') {
- app.globalData.curHtml = decodeURI(res.data.html);
- }
- })
- }
-
- res.data.createDate = format.formatTime(res.data.createDate, 'yyyy-MM-dddd hh:mm:ss')
- res.data.expiredTime = format.formatTime(res.data.expiredTime, 'yyyy-MM-dddd hh:mm:ss')
- switch (res.data.couponOrderStatus) {
- case 0:
- //待使用
- that.setData({
- statusText: '未核销',
- flag: true
- })
- break;
- case 1:
- //已核销
- that.setData({
- statusImg: '/static/images/use.png',
- statusText: '已核销',
- flag: false
- })
- break;
- case 2:
- that.setData({
- statusImg: '/static/images/beOverdue.png',
- statusText: '已过期',
- flag: false
- })
- //已过期
- break;
- case 3:
- that.setData({
- statusImg: '/static/images/refund.png',
- statusText: '已退款',
- flag: false
- })
- //已作废
- break;
- default:
- tt.showToast({
- title: '数据有误',
- image:'../../static/images/fail.png'
- })
- }
- console.log(res)
- console.log("我是请求回来的数据")
- that.setData({
- couponOrderDetail: res.data
- })
- } else {
- tt.reLaunch({
- url: 'pages/main/writeoffPage/errorPage/errorPage',
- })
- }
- })
- },
- user() {
- console.log(tt.getStorageSync("verifyRemark"))
- // return
- Common.couponOrderVerify(this.data.couponOrderId, tt.getStorageSync("verifyRemark"))
- .then(res => {
- console.log(res)
- if (res.code == 200) {
- tt.redirectTo({
- url: '../success/success',
- })
- }else{
- tt.showModal({
- title: '抱歉',
- content: res.message,
- showCancel:false
- })
- }
- })
- .catch(error=>{
- console.log(error)
- tt.showModal({
- title: '抱歉',
- content: error.message,
- showCancel: false
- })
- })
- },
- reBuck() {
- tt.switchTab({
- url: '/pages/main/main',
- })
- }
- })
|