Browse Source

核销修改

dev_czc
HolyKnightIX 2 years ago
parent
commit
2007c06b93
4 changed files with 120 additions and 117 deletions
  1. +7
    -6
      common/common.js
  2. +9
    -7
      pages/scan/scan.js
  3. +16
    -15
      pages/write0ff/write0ff.ttml
  4. +88
    -89
      pages/writeoffPage/writeoffPage.js

+ 7
- 6
common/common.js View File

@@ -105,7 +105,7 @@ const func = {
/** /**
* 优惠券详情 * 优惠券详情
*/ */
getCouponOrderDetail: function (couponOrderId) {
getCouponOrderDetail: function (couponOrderId, couponTenantId) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
tt.request({ tt.request({
url: config.api.couponOrderDetail, url: config.api.couponOrderDetail,
@@ -115,7 +115,8 @@ const func = {
}, },
method: "get", method: "get",
data: { data: {
couponOrderId: couponOrderId
couponOrderId: couponOrderId,
couponTenantId: couponTenantId
}, },
success: function (res) { success: function (res) {
resolve(res.data) resolve(res.data)
@@ -274,7 +275,7 @@ const func = {
* *
* @param {*换取openId} code * @param {*换取openId} code
*/ */
getOpenId: function (code,bUserId) {
getOpenId: function (code, bUserId) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
tt.request({ tt.request({
url: config.api.getOpenId, url: config.api.getOpenId,
@@ -285,7 +286,7 @@ const func = {
data: { data: {
appId: config.weapp.appId, appId: config.weapp.appId,
code: code, code: code,
bUserId:bUserId
bUserId: bUserId
}, },
method: "POST", method: "POST",
success: function (res) { success: function (res) {
@@ -325,8 +326,8 @@ const func = {
}) })
}, },
/** /**
* 获得手机号
*/
* 获得手机号
*/
getUserPhone: function (encryptedData, iv, superopenId, session_key) { getUserPhone: function (encryptedData, iv, superopenId, session_key) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
tt.request({ tt.request({


+ 9
- 7
pages/scan/scan.js View File

@@ -12,19 +12,22 @@ Page({
data: { data: {


}, },
gotoSaoyiSao: function () {//扫码核销、识别会员码
gotoSaoyiSao: function () { //扫码核销、识别会员码
tt.setStorageSync("verifyRemark", 12) tt.setStorageSync("verifyRemark", 12)
tt.scanCode({ tt.scanCode({
success: function(val) {
success: function (val) {
console.log(val.result); console.log(val.result);
if (util.isJSON(val.result)) { if (util.isJSON(val.result)) {
let value = JSON.parse(val.result); let value = JSON.parse(val.result);
console.log(value, 'value');
if (value.END == 'C' && value.TYPE == 'couponorder' && value.ID.length >= 18) { if (value.END == 'C' && value.TYPE == 'couponorder' && value.ID.length >= 18) {
Http.getRequest(config.api.couponOrderDetail, app.globalData.token, '加载中', { Http.getRequest(config.api.couponOrderDetail, app.globalData.token, '加载中', {
couponOrderId: value.ID
couponOrderId: value.ID,
couponTenantId: value.couponTenantId
}, (res) => { }, (res) => {
tt.setStorageSync("verifyRemark", 12) tt.setStorageSync("verifyRemark", 12)
tt.setStorageSync("couponOrderId", value.ID) tt.setStorageSync("couponOrderId", value.ID)
tt.setStorageSync("couponTenantId", value.couponTenantId)
if (res.code == 200) { if (res.code == 200) {
tt.navigateTo({ tt.navigateTo({
url: `/pages/writeoffPage/writeoffPage` url: `/pages/writeoffPage/writeoffPage`
@@ -71,7 +74,7 @@ Page({
}) })
} }
}, },
fail:function(){
fail: function () {
tt.showToast({ tt.showToast({
title: '请扫描正确的二维码', title: '请扫描正确的二维码',
icon: 'none', icon: 'none',
@@ -81,12 +84,11 @@ Page({
}) })
}, },
// 跳转到手动核销 // 跳转到手动核销
aoto: function() {
aoto: function () {
tt.setStorageSync("verifyRemark", 11) tt.setStorageSync("verifyRemark", 11)
tt.setStorageSync tt.setStorageSync
tt.navigateTo({ tt.navigateTo({
url: '/pages/write0ff/write0ff', url: '/pages/write0ff/write0ff',
}) })
}, },
})

})

+ 16
- 15
pages/write0ff/write0ff.ttml View File

@@ -1,18 +1,19 @@
<!-- <button type="primary" bindtap="getNetWorkType">获取网络类型</button> <!-- <button type="primary" bindtap="getNetWorkType">获取网络类型</button>
<button type="primary" bindtap="getSystemInfo">获取设备信息</button> --> <button type="primary" bindtap="getSystemInfo">获取设备信息</button> -->
<form >
<view class='write0ff'>
<view>
<text>券码</text>
<text class='line'></text>
<!-- <text class='search' bindtap='search' style='color:{{val == "请输券码"?"#ccc":"#666"}};font-size:{{val == "请输券码"?"30rpx":"30rpx"}}'>{{val}}</text> -->
<input class='search' bindinput="setVale" type='number' maxlength='20' focus value='{{inputValue}}' placeholder='请输入券码' placeholder-style='color:#BFBFBF;' />
<!-- <text hover-class='actives' class='iconfont icon-fangdajing' data-id='{{list.id}}'></text> -->
<!-- <button form-type='submit' hover-class='actives' class='iconfont icon-fangdajing' data-id='{{list.id}}'></button> -->
<view class='iconfont icon-fangdajing' bindtap="toWriteoffPage"></view>
</view>
<!-- <view class='softkey' tt:if='{{flag}}'>
<form>
<view class='write0ff'>
<view>
<text>券码</text>
<text class='line'></text>
<!-- <text class='search' bindtap='search' style='color:{{val == "请输券码"?"#ccc":"#666"}};font-size:{{val == "请输券码"?"30rpx":"30rpx"}}'>{{val}}</text> -->
<input class='search' bindinput="setVale" type='number' maxlength='20' focus value='{{inputValue}}'
placeholder='只能输入当前商场的券码' placeholder-style='color:#BFBFBF;' />
<!-- <text hover-class='actives' class='iconfont icon-fangdajing' data-id='{{list.id}}'></text> -->
<!-- <button form-type='submit' hover-class='actives' class='iconfont icon-fangdajing' data-id='{{list.id}}'></button> -->
<view class='iconfont icon-fangdajing' bindtap="toWriteoffPage"></view>
</view>

<!-- <view class='softkey' tt:if='{{flag}}'>
<view> <view>
<text tt:for='{{keyBordList}}' tt:key='{{index}}' hover-class='active' bindtap='onClick' data-val='{{item}}'>{{item.num}}</text> <text tt:for='{{keyBordList}}' tt:key='{{index}}' hover-class='active' bindtap='onClick' data-val='{{item}}'>{{item.num}}</text>
<text hover-class='active' class='iconfont icon-yincangjianpan hideKey' bindtap='hideKey'></text> <text hover-class='active' class='iconfont icon-yincangjianpan hideKey' bindtap='hideKey'></text>
@@ -23,5 +24,5 @@
<text hover-class='active' class='sure' bindtap='toWriteoffPage'>确定</text> <text hover-class='active' class='sure' bindtap='toWriteoffPage'>确定</text>
</view> </view>
</view> --> </view> -->
</view>
</form>
</view>
</form>

+ 88
- 89
pages/writeoffPage/writeoffPage.js View File

@@ -1,4 +1,3 @@

const config = require('../../config/config.js') const config = require('../../config/config.js')
const Common = require('../../common/common.js') const Common = require('../../common/common.js')
const format = require('../../utils/util.js') const format = require('../../utils/util.js')
@@ -8,12 +7,12 @@ Page({
val: '请输入券码', val: '请输入券码',
couponOrderId: null, couponOrderId: null,
couponOrderDetail: null, couponOrderDetail: null,
statusImg: '',
statusImg: '',
statusText: '', statusText: '',
flag: false, flag: false,
detail: '', detail: '',
remark: '', remark: '',
contentType: 0,
contentType: 0,


}, },
rule() { rule() {
@@ -24,108 +23,108 @@ Page({
onLoad(options) { onLoad(options) {
if (tt.getStorageSync("couponOrderId")) { if (tt.getStorageSync("couponOrderId")) {
this.setData({ 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; 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() { user() {
console.log(tt.getStorageSync("verifyRemark")) console.log(tt.getStorageSync("verifyRemark"))
// return // return
Common.couponOrderVerify(this.data.couponOrderId, tt.getStorageSync("verifyRemark")) 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({ tt.showModal({
title: '抱歉', 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() { reBuck() {
tt.switchTab({ tt.switchTab({


Loading…
Cancel
Save