From 2007c06b93cd70521038fe45f721f9442d9088a2 Mon Sep 17 00:00:00 2001 From: YWQ HK IX <568170040@qq.com> Date: Thu, 1 Dec 2022 22:27:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B8=E9=94=80=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/common.js | 13 ++- pages/scan/scan.js | 16 +-- pages/write0ff/write0ff.ttml | 31 ++--- pages/writeoffPage/writeoffPage.js | 177 ++++++++++++++--------------- 4 files changed, 120 insertions(+), 117 deletions(-) diff --git a/common/common.js b/common/common.js index b65402e..50955d7 100644 --- a/common/common.js +++ b/common/common.js @@ -105,7 +105,7 @@ const func = { /** * 优惠券详情 */ - getCouponOrderDetail: function (couponOrderId) { + getCouponOrderDetail: function (couponOrderId, couponTenantId) { return new Promise((resolve, reject) => { tt.request({ url: config.api.couponOrderDetail, @@ -115,7 +115,8 @@ const func = { }, method: "get", data: { - couponOrderId: couponOrderId + couponOrderId: couponOrderId, + couponTenantId: couponTenantId }, success: function (res) { resolve(res.data) @@ -274,7 +275,7 @@ const func = { * * @param {*换取openId} code */ - getOpenId: function (code,bUserId) { + getOpenId: function (code, bUserId) { return new Promise((resolve, reject) => { tt.request({ url: config.api.getOpenId, @@ -285,7 +286,7 @@ const func = { data: { appId: config.weapp.appId, code: code, - bUserId:bUserId + bUserId: bUserId }, method: "POST", success: function (res) { @@ -325,8 +326,8 @@ const func = { }) }, /** - * 获得手机号 - */ + * 获得手机号 + */ getUserPhone: function (encryptedData, iv, superopenId, session_key) { return new Promise((resolve, reject) => { tt.request({ diff --git a/pages/scan/scan.js b/pages/scan/scan.js index 36275b6..c8f32c9 100644 --- a/pages/scan/scan.js +++ b/pages/scan/scan.js @@ -12,19 +12,22 @@ Page({ data: { }, - gotoSaoyiSao: function () {//扫码核销、识别会员码 + gotoSaoyiSao: function () { //扫码核销、识别会员码 tt.setStorageSync("verifyRemark", 12) tt.scanCode({ - success: function(val) { + success: function (val) { console.log(val.result); if (util.isJSON(val.result)) { let value = JSON.parse(val.result); + console.log(value, 'value'); if (value.END == 'C' && value.TYPE == 'couponorder' && value.ID.length >= 18) { Http.getRequest(config.api.couponOrderDetail, app.globalData.token, '加载中', { - couponOrderId: value.ID + couponOrderId: value.ID, + couponTenantId: value.couponTenantId }, (res) => { tt.setStorageSync("verifyRemark", 12) tt.setStorageSync("couponOrderId", value.ID) + tt.setStorageSync("couponTenantId", value.couponTenantId) if (res.code == 200) { tt.navigateTo({ url: `/pages/writeoffPage/writeoffPage` @@ -71,7 +74,7 @@ Page({ }) } }, - fail:function(){ + fail: function () { tt.showToast({ title: '请扫描正确的二维码', icon: 'none', @@ -81,12 +84,11 @@ Page({ }) }, // 跳转到手动核销 - aoto: function() { + aoto: function () { tt.setStorageSync("verifyRemark", 11) tt.setStorageSync tt.navigateTo({ url: '/pages/write0ff/write0ff', }) }, -}) - +}) \ No newline at end of file diff --git a/pages/write0ff/write0ff.ttml b/pages/write0ff/write0ff.ttml index e4c30ac..592c94c 100644 --- a/pages/write0ff/write0ff.ttml +++ b/pages/write0ff/write0ff.ttml @@ -1,18 +1,19 @@ -
- - - 券码 - - - - - - - - - + + + + + + + - -
\ No newline at end of file + + \ No newline at end of file diff --git a/pages/writeoffPage/writeoffPage.js b/pages/writeoffPage/writeoffPage.js index 5923773..22f3b9d 100644 --- a/pages/writeoffPage/writeoffPage.js +++ b/pages/writeoffPage/writeoffPage.js @@ -1,4 +1,3 @@ - const config = require('../../config/config.js') const Common = require('../../common/common.js') const format = require('../../utils/util.js') @@ -8,12 +7,12 @@ Page({ val: '请输入券码', couponOrderId: null, couponOrderDetail: null, - statusImg: '', + statusImg: '', statusText: '', flag: false, detail: '', remark: '', - contentType: 0, + contentType: 0, }, rule() { @@ -24,108 +23,108 @@ Page({ onLoad(options) { if (tt.getStorageSync("couponOrderId")) { this.setData({ - couponOrderId: tt.getStorageSync("couponOrderId") + couponOrderId: tt.getStorageSync("couponOrderId"), + couponTenantId: tt.getStorageSync("couponTenantId") }) - this.detailInfo(tt.getStorageSync("couponOrderId")) + this.detailInfo(tt.getStorageSync("couponOrderId"), tt.getStorageSync("couponTenantId")) } }, - detailInfo(couponOrderId) { + detailInfo(couponOrderId, couponTenantId) { 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); - } + Common.getCouponOrderDetail(couponOrderId, couponTenantId) + .then(res => { + console.log(res, "res123") + if (res.code == 200) { + this.setData({ + contentType: res.data.contentType ? res.data.contentType : 0 }) - } - - 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(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', + }) } - 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{ + .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: res.message, - showCancel:false + content: error.message, + showCancel: false }) - } - }) - .catch(error=>{ - console.log(error) - tt.showModal({ - title: '抱歉', - content: error.message, - showCancel: false }) - }) }, reBuck() { tt.switchTab({