Browse Source

【支付2.0代码提交】

dev
chenshengle 2 years ago
parent
commit
8c44035776
14 changed files with 1474 additions and 480 deletions
  1. +2
    -1
      app.json
  2. +3
    -0
      index/user.ttss
  3. +674
    -0
      pages/coupon/confirmation/confirmation.js
  4. +12
    -0
      pages/coupon/confirmation/confirmation.json
  5. +19
    -0
      pages/coupon/confirmation/confirmation.ttml
  6. +92
    -0
      pages/coupon/confirmation/confirmation.ttss
  7. +400
    -272
      pages/coupon/detail/index.js
  8. +37
    -7
      pages/coupon/detail/index.ttml
  9. +2
    -2
      pages/coupon/detail/index.ttss
  10. +1
    -1
      pages/couponorder/index/index.ttml
  11. +5
    -0
      pages/main/index.js
  12. +190
    -151
      pages/order/detail/index.js
  13. +1
    -1
      pages/order/detail/index.ttml
  14. +36
    -45
      project.config.json

+ 2
- 1
app.json View File

@@ -35,7 +35,8 @@
"pages/paySnapshoot/paySnapshoot",
"pages/refund/refund",
"pages/serviceWebView/serviceWebView",
"pages/liveLsit/liveLsit"
"pages/liveLsit/liveLsit",
"pages/coupon/confirmation/confirmation"
],
"window": {
"backgroundTextStyle": "light",


+ 3
- 0
index/user.ttss View File

@@ -168,6 +168,9 @@ button {
background-color: #ffffff;
border-radius: 10rpx;
overflow: hidden;
left: 5%;
position: absolute;
z-index: 1000;
}
.fuwu{
/* font-size: 28rpx; */


+ 674
- 0
pages/coupon/confirmation/confirmation.js View File

@@ -0,0 +1,674 @@
const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px'
var config = require("../../../config/config.js");
var app = getApp();
const Http = require("../../../utils/HttpBasics");
const util = require("../../../utils/util");
const imgurl = require("../../../utils/imgurl");
Page({
data: {
couponIds:"",
couponChannelId:"",
showPage:false,
data:{},
spuIdObj:{},
priceAndStockObj:{}
},
onLoad: function (options) {
console.log(options);
tt.showLoading({
title: "加载中..."
});
let that = this
if (app.globalData.token){
if (options && (options.couponChannelId || options.couponIds)) {
if (options.couponIds) {
this.setData({
couponIds: options.couponIds
})
that.getDetail(options.couponIds, 'notendclock');
} else {
that.getDetail(options.couponChannelId, 'notendclock');
that.getSupId(options.couponChannelId)
}
}
}else{
app.tokenCallback = token => {

if (options && (options.couponChannelId || options.couponIds)) {
if (options.couponIds) {
this.setData({
couponIds: options.couponIds
})
that.getDetail(options.couponIds, 'notendclock');
} else {
that.getDetail(options.couponChannelId, 'notendclock');
// that.getSupId(options.couponChannelId)
}
}
}
}
},

getSupId(id) {
Http.get({
url: config.api.getSpuid,
data: { id: id }
}).then(res => {
if (res.data) {
this.setData({
spuIdObj: res.data
})
}
}).catch(err => {
// tt.showToast({
// title: err.message,
// icon: 'none',
// duration: 2000,
// mask: false
// });
})
},

getCouponPriceAndStock(couponChannelId) {//获取券价格与库存
Http.get({
url: config.api.couponPriceAndStock,
data: {
couponChannelId
}
}).then(res => {
let tempBoj = JSON.parse(res.data)
console.log(tempBoj, "$");
this.setData({
priceAndStockObj: tempBoj
})
})
},
getDetail: function (couponChannelId, flag) {
let that = this;
let data = {};

that.getCouponPriceAndStock(couponChannelId);//获取券价格和库存
if (that.data.couponIds) {
data.couponId = couponChannelId
} else {
data.couponChannelId = couponChannelId
}
var parmer = {
url: config.api.newCouponDetail,
data: data
};
Http.get(parmer).then(res => {

that.setData({
couponId: res.data.couponId
})
/**
* activityStatus==0 活动未开始
* activityStatus==1 活动已开始
* flag == endclock 说明倒计时已经结束
*/
if (res.data.endTime && res.data.beginTime) {
that.setData({
begin_time: res.data.beginTime,
end_time: res.data.endTime,
activityStatus: res.data.actStatus ? res.data.actStatus : ''
})
if (res.data.actStatus == 0 && flag != 'endclock') {
that.countdown(res.data.beginTime);
} else if (res.data.actStatus != 0 && flag != 'endclock') {
that.countdown(res.data.endTime);
} else {
clearInterval(that.data.setInterval)
}
if (res.data.actStatus == 0) {
var beginTime = util.formatTime(res.data.beginTime, "yyyy-MM-dd hh:mm:ss");
if (util.timechuo(beginTime).indexOf('-') == 0) {
that.setData({
beginTime: "活动已结束",
});
} else {
that.setData({
beginTime: util.timechuo(beginTime)
});
}
} else {
var endTime = util.formatTime(res.data.endTime, "yyyy-MM-dd hh:mm:ss");
if (util.timechuo(endTime).indexOf('-') == 0) {
that.setData({
endtime: "活动已结束",
});
} else {
that.setData({
endtime: util.timechuo(endTime)
});
}
}
}
tt.hideLoading();
that.setData({
data: res.data,
});
if (res.data.type == 10) {
that.setData({
salePriceStr: res.data.salePriceStr,
pickEndDate: util.formatTime(res.data.pickEndDate, "yyyy-MM-dd"),
pickStartDate: util.formatTime(res.data.pickStartDate, "yyyy-MM-dd"),
priceStr: res.data.priceStr,
tailPriceStr: res.data.tailPriceStr,
origPriceStr: res.data.origPriceStr
})
}
if (res.data.validType == 1) {
that.setData({
validStartDate: util.formatTime(res.data.validStartDate, "yyyy-MM-dd"),
validEndDate: util.formatTime(res.data.validEndDate, "yyyy-MM-dd"),
pickStartDate: util.formatTime(res.data.pickStartDate, "yyyy-MM-dd"),
pickEndDate: util.formatTime(res.data.pickEndDate, "yyyy-MM-dd"),
});
} else {
if (res.data.validDays) {
that.setData({
validDays: res.data.validDays
});
}
}

if (res.data.itemGroup) {
let tempObj = this.data.data
tempObj.itemGroup = JSON.parse(tempObj.itemGroup)
this.setData({
data: tempObj
})
console.log(this.data.data, "data");
}

if (res.data.productAttrs && res.data.skuAttrs) {
let tempObj = this.data.data
tempObj.productAttrs = JSON.parse(tempObj.productAttrs)
tempObj.skuAttrs = JSON.parse(tempObj.skuAttrs)
tempObj.productAttrs.map(item => {
if (item.key == "Notification") {
if (item.data != '') {
tempObj.curLsit = JSON.parse(item.data)
}
}
if (item.key == "bring_out_meal") {
tempObj.besides = item.data
}
if (item.key == "free_pack") {
tempObj.pack = item.data
}

if (item.key == "superimposed_discounts") {
tempObj.superimposed_discounts = item.data
}
if (item.key == "private_room") {
tempObj.private_room = item.data
}
if (item.key == "rec_person_num_max") {
tempObj.rec_person_num_max = item.data
}


if (item.key == 'Description') {
tempObj.Description = JSON.parse(item.data)
}
if (item.key == "can_no_use_date") {
tempObj.can_no_use_date = JSON.parse(item.data)
}
})

tempObj.skuAttrs.map(item => {
if (item.key == "commodity") {
if (item.data != '') {
tempObj.itemGroup = JSON.parse(item.data)
}
}
})
this.setData({
data: tempObj
})
console.log(this.data.data, "data");
}
}).catch(err => {
tt.showToast({
title: err.message,
icon: 'none',
duration: 2000,
mask: false
});
})
},
/**
* 支付订单更新
*/
payOrderUpdate: (orderId, payOrderId, status, reason, type, _this, composeOrderType) => {
let that = this;
// 支付成功
Http.post({
url: config.api.payOrderUpdate,
data: {
payOrderId: payOrderId,
composeOrderId: orderId,
status: status,
reason: reason
}
})
.then(res => {
tt.hideLoading()
// 有价券
if (!type && type != 'free') {
tt.navigateTo({
url: `/pages/order/detail/index?orderId=${orderId
}`
});
} else if (type == 'free') {
tt.navigateTo({
url: `/pages/order/detail/index?orderId=${orderId
}`
});
}
})
.catch(err => {
console.log(err);
if (!type) {
setTimeout(function () {
_this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this, composeOrderType);
}, 2000)
}
})
},

/**
* 发起支付
*/
orderFunc(discount) {
if(this.data.showbutton)return;

let that = this;
tt.showLoading({
title: "加载中..."
});
that.setData({
showbutton: true,
})
Http.get({
url: config.api.checkUserStatus,
data: {
token: app.globalData.token
}
}).then(res => {
Http.get({
url: config.api.checkPhoneStatus,
data: {}
}).then(res => {

if ((!tt.canIUse('createOrder')) || that.data.data.type == 50 || that.data.priceAndStockObj.salePrice == 0) {
//积分券和免费券
// 发起砍价
if (discount == 'discount') {
var data = {
couponChannelId: "" + that.data.couponChannelId,
couponId: "" + that.data.couponId,
formId: "" + that.data.formId,
press: true
}
} else if (discount == 'discount1') {
var data = {
couponChannelId: "" + that.data.couponChannelId,
couponId: "" + that.data.couponId,
formId: "" + that.data.formId,
press: false
}
} else if (that.data.couponChannelId == null) {
var data = {
couponId: "" + that.data.couponId,
formId: "" + that.data.formId,
};
} else {
var data = {
couponChannelId: "" + that.data.couponChannelId,
couponId: "" + that.data.couponId,
formId: "" + that.data.formId,
}
}
console.log(data, "data")
let url = ""
let tempObj;
let tempArr = []
if (that.data.data.type == 12) {
url = config.api.couponPackageSave
tempObj = {
signleOrder: {
couponChannelId: "" + that.data.couponChannelId,
couponId: "" + that.data.couponId,
formId: "" + that.data.formId,
},
count: "1"
}
tempArr.push(tempObj)
} else {
url = config.api.orderSave
}
/**
* orderSave 下单
*/
Http.post({
url: url,
data: that.data.data.type == 12 ? JSON.stringify(tempArr) : data
}).then(res => {
if (discount != 'discount') {
if (typeof (res) != "undefined") {
let orderId = "" + res.data.mainOrderId;
that.setData({
orderId: orderId,
composeOrderType: res.data.composeOrderType
});
if (res.data.payment > 0) {
// 支付金额不为0
/**
* 支付订单创建
*/
Http.post({
url: config.api.payOrderCreate,
data: {
orderId: orderId,
composeOrderType: res.data.composeOrderType
}
}).then(res => {
var payOrderId = "" + res.data.outOrderNo;
tt.hideLoading();
tt.pay({
service: 5,
orderInfo: {
order_id: res.data.orderId,
order_token: res.data.token,
},
success: res => {
tt.showLoading({
title: '订单正在处理中...',
})
if (res.code === 0) {
that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that, that.data.composeOrderType);
if (res.errMsg == "requestPayment:ok") {
/**
* 用户支付成功以后跳转到券包列表
*/
if (that.data.cardType == 100) {
tt.setStorage({
key: 'couponNum2',
data: "couponNum2"
})
} else if (that.data.data.type != 5 && that.data.cardType != 100) {
tt.setStorage({
key: 'couponNum',
data: "couponNum"
})
}
}
}
else if (res.code === 1) {
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '支付超时', // 内容
icon: "none"
});

} else if (res.code === 2) {
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '支付失败', // 内容
icon: "none"
});
} else if (res.code === 3) {
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '支付关闭', // 内容
icon: "none"
});
} else if (res.code === 4) {
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '支付取消', // 内容
icon: "none"
});
} else if (res.code === 9) {
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '订单状态开发者自行获取', // 内容
icon: "none"
});
}

},
fail: res => {
tt.hideLoading();
/**
* 支付失败,需要更新订单的状态
*/
that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that, that.data.composeOrderType);
that.setData({
showbutton: false
})
return;
},
complete: res => { }
});
/// End payment --------
})
.catch(err => {
tt.hideLoading();
tt.showToast({
title: err.message,
icon: 'none',
duration: 2000,
mask: false
});
})
} else {
// 免费券
that.payOrderUpdate(orderId, "0", 1, '', 'free', that, that.data.composeOrderType);
if (that.data.cardType == 100) {
tt.setStorage({
key: 'couponNum2',
data: "couponNum2"
})
} else if (that.data.data.type != "5" && that.data.cardType != 100) {
tt.setStorage({
key: 'couponNum',
data: "couponNum"
})
}
}
}
} else {
if (res) {
tt.navigateTo({
url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.mainOrderId}&composeOrderType=${res.data.composeOrderType}`,
})
}
}
})
} else {
//有价券
console.log(tt.canIUse('createOrder'), "是否支持2.0js-api");
if (tt.canIUse('createOrder')) {
//支持 支付2.0 js-api
let tempCallbackData = {}
tempCallbackData[that.data.data.couponChannel.ttSpuId] = that.data.data.couponChannel.id
let options = {
callbackData: tempCallbackData,
goodsList: [
{
quantity: 1, // 购买数量 必填
price: that.data.priceAndStockObj.salePrice, // 商品价格 必填

goodsName: that.data.data.title, // 商品名称 必填
goodsPhoto: that.data.data.coverImg, // 商品图片链接 必填
goodsId: that.data.data.couponChannel.ttSpuId, // 商品ID 必填
goodsType: 1, // 商品类型 必填

goodsLabels: ['过期退', '随时退', '免预约'], // 商品标签 非必填
dateRule: '', // 使用规则 非必填
},
],
payment: {
totalAmount: that.data.priceAndStockObj.salePrice, // 订单总价 必填
},
success: res => {
tt.hideLoading();
that.setData({
showbutton: false,
})
const { orderId, outOrderNo } = res;
that.setData({ orderId, outOrderNo });
that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that, '');
},
fail: res => {
const { orderId, outOrderNo, errNo, errMsg, errLogId } = res;
if (errLogId) {
tt.hideLoading();
that.setData({
showbutton: false,
})
console.log('预下单失败', errNo, errMsg, errLogId);
}
if (orderId || outOrderNo) {
tt.hideLoading();
that.setData({
showbutton: false,
})
console.log('支付失败', errNo, errMsg, orderId, outOrderNo);
console.log(that.payOrderUpdate, "payOrderUpdate");
that.payOrderUpdate(outOrderNo,outOrderNo,2,'','fail')
}
},
}
console.log(options, "options");
tt.createOrder(options)
} else {
//不支持 支付2.0 js -api
}
}

}).catch(err => {
tt.hideLoading()
that.setData({
showbutton: false,
})
if (err.code == 2011) {
tt.showToast({
title: "商户信息没找到",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 2013) {
tt.showToast({
title: "商户信息禁用",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3000) {
tt.showToast({
title: "库存不足",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3001) {
tt.showToast({
title: "您已超过限购",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3002) {
tt.showToast({
title: "订单失败",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3003) {
tt.showToast({
title: "订单不存在",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3004) {
tt.showToast({
title: "订单不存在",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 4003) {
tt.showToast({
title: "卡券已作废",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3012) {
that.getUnPaidOrder(that.data.couponId);
} else if (err.code == 11005) {
/**
* 将值传到用户手机号授权的页面
*
*/
tt.redirectTo({
url: "/pages/getphoneInfo/index?couponChannelId=" +
that.data.couponChannelId
});
} else if (err.code == 11006) {
// 用户手机已加密
tt.redirectTo({
url: "/pages/phoneinput/phoneinput?couponChannelId=" +
that.data.couponChannelId
});
} else {
tt.showToast({
title: err.message,
icon: 'none',
duration: 2000,
mask: false
});
}
})
}).catch(err => {
console.log(err)
if (err.code == 11004) {
tt.redirectTo({
url: `/pages/getuserinfo/index?fromflag=coupondetail&couponChannelIdflag=${that.data.couponChannelId}`,
})
} else {
tt.showToast({
title: err.message,
icon: "none",
duration: 2500
})
}
})
},


})

+ 12
- 0
pages/coupon/confirmation/confirmation.json View File

@@ -0,0 +1,12 @@
{
"usingComponents": {
"navbar": "../../../components/navbar/navbar",
"store": "../../../components/store/index",
"c-coupons": "../../../components/coupons/index",
"phoen":"../../../components/getPhoen/getPhoen"
},
"navigationBarTitleText": "确认订单",
"backgroundColor":"#f4f4f4",
"navigationBarBackgroundColor": "#f4f4f4",
"navigationBarTextStyle": "black"
}

+ 19
- 0
pages/coupon/confirmation/confirmation.ttml View File

@@ -0,0 +1,19 @@
<view class="commodityBox">
<view class="commodityImgBox">
<image class="commodityImg" src="{{data.coverImg}}"></image>
</view>
<view class="contentBox">
<view class="topBox">
<view class="title">{{data.title}}</view>
<view class="unit">¥{{data.salePriceStr}}</view>
</view>
<view class="subhead"> {{data.subTitle}}</view>
</view>

<view class="app-border-topX">
<view class="actually"> 实付 </view>
<view class="payZ">¥</view>
<view class="price">{{data.salePriceStr}}</view>
<view class="buyX" bindtap="orderFunc">提交订单</view>
</view>
</view>

+ 92
- 0
pages/coupon/confirmation/confirmation.ttss View File

@@ -0,0 +1,92 @@
.commodityBox{
background-color: #fff;
width: 96%;
border-radius: 12rpx;
overflow: hidden;
margin: 10rpx auto;
}
.commodityImgBox{
width: 100rpx;
height: 100rpx;
overflow: hidden;
float: left;
margin: 20rpx;
border-radius: 8rpx;
}
.commodityImg{
width: 100%;
height: 100%;
}

.contentBox{
width: 560rpx;
float: left;
height: 100rpx;

margin-top: 20rpx;
}
.topBox{
overflow: hidden;
}

.title{
height: 60rpx;
font-size: 26rpx;
width: 490rpx;
float: left;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2; /* 这里是超出几行省略 */
overflow: hidden;
}
.unit{
float: right;
font-size: 24rpx;
}
.subhead{
margin-top: 4rpx;
color: #a6a6a6;
font-size: 20rpx;
}
.app-border-topX{
width: 100%;
height: 120rpx;
background-color: #fff;
overflow: hidden;
position: fixed;
left: 0;
bottom: 0;
}
.actually{
margin-left: 10%;
font-size: 24rpx;
color: #a6a6a6;
line-height: 120rpx;
float: left;
}
.payZ{
margin-left: 6rpx;
font-size: 20rpx;
color: #d5af67;
line-height: 126rpx;
float: left;
}
.price{
font-size: 26rpx;
color: #d5af67;
line-height: 120rpx;
float: left;
}
.buyX{
float: right;
background: linear-gradient(270deg, #DDAB5A, #B8832D);

/* width: 80rpx; */
color: #fff;
font-size: 28rpx;

border-radius: 60rpx;
margin: 30rpx 40rpx;
padding: 10rpx 20rpx;
}

+ 400
- 272
pages/coupon/detail/index.js View File

@@ -6,7 +6,7 @@ const util = require("../../../utils/util");
const imgurl = require("../../../utils/imgurl");
Page({
data: {
priceAndStockObj:{},//存放价格和库存
priceAndStockObj: {},//存放价格和库存
isGetUser: true,//判断是否授权抖音
mouldType: 0,
navigationBarHeight,
@@ -95,7 +95,7 @@ Page({
page: 1,//查询商户优惠券page
idList: [],
showBox: false,//手机号授权框
spuIdObj:{}
spuIdObj: {}
},

/**
@@ -429,7 +429,7 @@ Page({
url: config.api.checkPhoneStatus,
}).then(res => {
tt.showLoading();
if (e.currentTarget.dataset.type == 51 || e.currentTarget.dataset.type == 50) {
if (e.currentTarget.dataset.type == 51 || e.currentTarget.dataset.type == 50) {
tt.navigateTo({
url: '/pages/integralmall/payIntegcoupondetail/index?couponChannelId=' + that.data.couponChannelId + '&couponId=' + that.data.couponId,
})
@@ -480,18 +480,18 @@ Page({
}
}).catch(err => {
app.globalData.type = ''
app.globalData.skipUrl=""
app.globalData.skipUrl = ""
app.globalData.skip = 'navigateBack'
if(app.globalData.ifCongPh==1){
if (app.globalData.ifCongPh == 1) {
tt.navigateTo({
url: '/pages/getPhone/getPhone?skipUrl=1',
url: '/pages/getPhone/getPhone?skipUrl=1',
});
}else{
} else {
this.setData({
showBox: true
})
}
})
}).catch(err => {
app.globalData.type = ''
@@ -568,7 +568,8 @@ Page({
* 获取用户信息
*/
onLoad(options) {
console.log(options);

this.setData({
mouldType: app.globalData.mouldType,
})
@@ -632,17 +633,17 @@ Page({
}
})
},
getSupId(id){
getSupId(id) {
Http.get({
url:config.api.getSpuid,
data:{id:id}
}).then(res=>{
if(res.data){
url: config.api.getSpuid,
data: { id: id }
}).then(res => {
if (res.data) {
this.setData({
spuIdObj:res.data
spuIdObj: res.data
})
}
}).catch(err=>{
}).catch(err => {
// tt.showToast({
// title: err.message,
// icon: 'none',
@@ -652,27 +653,27 @@ Page({
})
},

getCouponPriceAndStock(couponChannelId){//获取券价格与库存
getCouponPriceAndStock(couponChannelId) {//获取券价格与库存
Http.get({
url:config.api.couponPriceAndStock,
data:{
url: config.api.couponPriceAndStock,
data: {
couponChannelId
}
}).then(res=>{
}).then(res => {
let tempBoj = JSON.parse(res.data)
console.log(tempBoj,"$");
console.log(tempBoj, "$");
this.setData({
priceAndStockObj:tempBoj
priceAndStockObj: tempBoj
})
})
},
getCouponMerchant(couponChannelId){//获取适用门店
getCouponMerchant(couponChannelId) {//获取适用门店
Http.get({
url:config.api.couponMerchant,
data:{
couponChannelId:couponChannelId
url: config.api.couponMerchant,
data: {
couponChannelId: couponChannelId
}
}).then(res=>{
}).then(res => {
if (res.data && res.data.length) {
let merchantVoList = res.data
let idList = []
@@ -838,14 +839,62 @@ Page({
}
}


if(res.data.itemGroup){
if (res.data.itemGroup) {
let tempObj = this.data.data
tempObj.itemGroup = JSON.parse(tempObj.itemGroup)
this.setData({
data:tempObj
data: tempObj
})
console.log(this.data.data, "data");
}

if (res.data.productAttrs && res.data.skuAttrs) {
let tempObj = this.data.data
tempObj.productAttrs = JSON.parse(tempObj.productAttrs)
tempObj.skuAttrs = JSON.parse(tempObj.skuAttrs)
tempObj.productAttrs.map(item => {
if (item.key == "Notification") {
if (item.data != '') {
tempObj.curLsit = JSON.parse(item.data)
}
}
if (item.key == "bring_out_meal") {
tempObj.besides = item.data
}
if (item.key == "free_pack") {
tempObj.pack = item.data
}

if (item.key == "superimposed_discounts") {
tempObj.superimposed_discounts = item.data
}
if (item.key == "private_room") {
tempObj.private_room = item.data
}
if (item.key == "rec_person_num_max") {
tempObj.rec_person_num_max = item.data
}


if (item.key == 'Description') {
tempObj.Description = JSON.parse(item.data)
}
if (item.key == "can_no_use_date") {
tempObj.can_no_use_date = JSON.parse(item.data)
}
})

tempObj.skuAttrs.map(item => {
if (item.key == "commodity") {
if (item.data != '') {
tempObj.itemGroup = JSON.parse(item.data)
}
}
})
this.setData({
data: tempObj
})
console.log(this.data.data,"data");
console.log(this.data.data, "data");
}
}).catch(err => {
tt.showToast({
@@ -940,14 +989,26 @@ Page({
});
}
})
},
},
// 券包支付

/**
* 发起支付
*/
orderFunc(discount) {
tt.navigateTo({
url: `/pages/coupon/confirmation/confirmation?couponChannelId=${this.data.couponChannelId}`,
})
return

let that = this;
tt.showLoading({
title: "加载中..."
});
that.setData({
showbutton: true,
showbutton1: true
})
Http.get({
url: config.api.checkUserStatus,
data: {
@@ -958,7 +1019,9 @@ Page({
url: config.api.checkPhoneStatus,
data: {}
}).then(res => {
console.log(tt.canIUse('createOrder'),"版本号" );

if ((!tt.canIUse('createOrder')) || that.data.data.type == 50 || that.data.priceAndStockObj.salePrice == 0) {
//积分券和免费券
// 发起砍价
if (discount == 'discount') {
var data = {
@@ -1007,245 +1070,310 @@ Page({
/**
* orderSave 下单
*/
return Http.post({
Http.post({
url: url,
data: that.data.data.type == 12 ? JSON.stringify(tempArr) : data
});
}).catch(err => {
tt.hideLoading()
that.setData({
showbutton: false,
showbutton1: false
})
if (err.code == 2011) {
tt.showToast({
title: "商户信息没找到",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 2013) {
tt.showToast({
title: "商户信息禁用",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3000) {
tt.showToast({
title: "库存不足",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3001) {
tt.showToast({
title: "您已超过限购",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3002) {
tt.showToast({
title: "订单失败",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3003) {
tt.showToast({
title: "订单不存在",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3004) {
tt.showToast({
title: "订单不存在",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 4003) {
tt.showToast({
title: "卡券已作废",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3012) {
that.getUnPaidOrder(that.data.couponId);
} else if (err.code == 11005) {
/**
* 将值传到用户手机号授权的页面
*
*/
tt.redirectTo({
url: "/pages/getphoneInfo/index?couponChannelId=" +
that.data.couponChannelId
});
} else if (err.code == 11006) {
// 用户手机已加密
tt.redirectTo({
url: "/pages/phoneinput/phoneinput?couponChannelId=" +
that.data.couponChannelId
});
} else {
tt.showToast({
title: err.message,
icon: 'none',
duration: 2000,
mask: false
});
}
}).then(res => {
if (discount != 'discount') {
if (typeof (res) != "undefined") {
let orderId = "" + res.data.mainOrderId;
that.setData({
orderId: orderId,
composeOrderType: res.data.composeOrderType
});
if (res.data.payment > 0) {
// 支付金额不为0
/**
* 支付订单创建
*/
Http.post({
url: config.api.payOrderCreate,
data: {
orderId: orderId,
composeOrderType: res.data.composeOrderType
}
}).then(res => {
var payOrderId = "" + res.data.outOrderNo;
tt.hideLoading();
tt.pay({
service: 5,
orderInfo: {
order_id: res.data.orderId,
order_token: res.data.token,
},
success: res => {
tt.showLoading({
title: '订单正在处理中...',
})
if (res.code === 0) {
that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that, that.data.composeOrderType);
if (res.errMsg == "requestPayment:ok") {
/**
* 用户支付成功以后跳转到券包列表
*/
if (that.data.cardType == 100) {
tt.setStorage({
key: 'couponNum2',
data: "couponNum2"
})
} else if (that.data.data.type != 5 && that.data.cardType != 100) {
tt.setStorage({
key: 'couponNum',
data: "couponNum"
})
}).then(res => {
if (discount != 'discount') {
if (typeof (res) != "undefined") {
let orderId = "" + res.data.mainOrderId;
that.setData({
orderId: orderId,
composeOrderType: res.data.composeOrderType
});
if (res.data.payment > 0) {
// 支付金额不为0
/**
* 支付订单创建
*/
Http.post({
url: config.api.payOrderCreate,
data: {
orderId: orderId,
composeOrderType: res.data.composeOrderType
}
}).then(res => {
var payOrderId = "" + res.data.outOrderNo;
tt.hideLoading();
tt.pay({
service: 5,
orderInfo: {
order_id: res.data.orderId,
order_token: res.data.token,
},
success: res => {
tt.showLoading({
title: '订单正在处理中...',
})
if (res.code === 0) {
that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that, that.data.composeOrderType);
if (res.errMsg == "requestPayment:ok") {
/**
* 用户支付成功以后跳转到券包列表
*/
if (that.data.cardType == 100) {
tt.setStorage({
key: 'couponNum2',
data: "couponNum2"
})
} else if (that.data.data.type != 5 && that.data.cardType != 100) {
tt.setStorage({
key: 'couponNum',
data: "couponNum"
})
}
}
}
}
else if (res.code === 1) {
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '支付超时', // 内容
icon: "none"
});
else if (res.code === 1) {
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '支付超时', // 内容
icon: "none"
});

} else if (res.code === 2) {
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '支付失败', // 内容
icon: "none"
});
} else if (res.code === 3) {
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '支付关闭', // 内容
icon: "none"
});
} else if (res.code === 4) {
that.setData({
showbutton: false
})
} else if (res.code === 2) {
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '支付失败', // 内容
icon: "none"
});
} else if (res.code === 3) {
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '支付关闭', // 内容
icon: "none"
});
} else if (res.code === 4) {
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '支付取消', // 内容
icon: "none"
});
} else if (res.code === 9) {
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '订单状态开发者自行获取', // 内容
icon: "none"
});
}

},
fail: res => {
tt.hideLoading();
tt.showToast({
title: '支付取消', // 内容
icon: "none"
});
} else if (res.code === 9) {
/**
* 支付失败,需要更新订单的状态
*/
that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that, that.data.composeOrderType);
that.setData({
showbutton: false
})
tt.hideLoading();
tt.showToast({
title: '订单状态开发者自行获取', // 内容
icon: "none"
});
}

},
fail: res => {
tt.hideLoading();
/**
* 支付失败,需要更新订单的状态
*/
that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that, that.data.composeOrderType);
that.setData({
showbutton: false
})
return;
},
complete: res => { }
});
/// End payment --------
})
.catch(err => {
tt.hideLoading();
tt.showToast({
title: err.message,
icon: 'none',
duration: 2000,
mask: false
return;
},
complete: res => { }
});
/// End payment --------
})
} else {
// 免费券
that.payOrderUpdate(orderId, "0", 1, '', 'free', that, that.data.composeOrderType);
if (that.data.cardType == 100) {
tt.setStorage({
key: 'couponNum2',
data: "couponNum2"
.catch(err => {
tt.hideLoading();
tt.showToast({
title: err.message,
icon: 'none',
duration: 2000,
mask: false
});
})
} else {
// 免费券
that.payOrderUpdate(orderId, "0", 1, '', 'free', that, that.data.composeOrderType);
if (that.data.cardType == 100) {
tt.setStorage({
key: 'couponNum2',
data: "couponNum2"
})
} else if (that.data.data.type != "5" && that.data.cardType != 100) {
tt.setStorage({
key: 'couponNum',
data: "couponNum"
})
}
}
}
} else {
if (res) {
tt.navigateTo({
url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.mainOrderId}&composeOrderType=${res.data.composeOrderType}`,
})
}
}
})
} else {
//有价券
console.log(tt.canIUse('createOrder'), "是否支持2.0js-api");
if (tt.canIUse('createOrder')) {
//支持 支付2.0 js-api
let tempCallbackData = {}
tempCallbackData[that.data.data.couponChannel.ttSpuId] = that.data.data.couponChannel.id
let options = {
callbackData: tempCallbackData,
goodsList: [
{
quantity: 1, // 购买数量 必填
price: that.data.priceAndStockObj.salePrice, // 商品价格 必填

goodsName: that.data.data.title, // 商品名称 必填
goodsPhoto: that.data.data.coverImg, // 商品图片链接 必填
goodsId: that.data.data.couponChannel.ttSpuId, // 商品ID 必填
goodsType: 1, // 商品类型 必填

goodsLabels: ['过期退', '随时退', '免预约'], // 商品标签 非必填
dateRule: '', // 使用规则 非必填
},
],
payment: {
totalAmount: that.data.priceAndStockObj.salePrice, // 订单总价 必填
},
success: res => {
tt.hideLoading();
that.setData({
showbutton: false,
showbutton1: false
})
const { orderId, outOrderNo } = res;
that.setData({ orderId, outOrderNo });
that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that, '');
},
fail: res => {
const { orderId, outOrderNo, errNo, errMsg, errLogId } = res;
if (errLogId) {
tt.hideLoading();
that.setData({
showbutton: false,
showbutton1: false
})
} else if (that.data.data.type != "5" && that.data.cardType != 100) {
tt.setStorage({
key: 'couponNum',
data: "couponNum"
console.log('预下单失败', errNo, errMsg, errLogId);
}
if (orderId || outOrderNo) {
tt.hideLoading();
that.setData({
showbutton: false,
showbutton1: false
})
console.log('支付失败', errNo, errMsg, orderId, outOrderNo);
console.log(that.payOrderUpdate, "payOrderUpdate");
that.payOrderUpdate(outOrderNo,outOrderNo,2,'','fail')
}
}
},
}
console.log(options, "options");
tt.createOrder(options)
} else {
if (res) {
tt.navigateTo({
url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${res.data.mainOrderId}&composeOrderType=${res.data.composeOrderType}`,
})
}
//不支持 支付2.0 js -api
}
}

}).catch(err => {
tt.hideLoading()
that.setData({
showbutton: false,
showbutton1: false
})
if (err.code == 2011) {
tt.showToast({
title: "商户信息没找到",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 2013) {
tt.showToast({
title: "商户信息禁用",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3000) {
tt.showToast({
title: "库存不足",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3001) {
tt.showToast({
title: "您已超过限购",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3002) {
tt.showToast({
title: "订单失败",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3003) {
tt.showToast({
title: "订单不存在",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3004) {
tt.showToast({
title: "订单不存在",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 4003) {
tt.showToast({
title: "卡券已作废",
image: './../../../assets/images/fail.png',
duration: 2000,
mask: false
});
} else if (err.code == 3012) {
that.getUnPaidOrder(that.data.couponId);
} else if (err.code == 11005) {
/**
* 将值传到用户手机号授权的页面
*
*/
tt.redirectTo({
url: "/pages/getphoneInfo/index?couponChannelId=" +
that.data.couponChannelId
});
} else if (err.code == 11006) {
// 用户手机已加密
tt.redirectTo({
url: "/pages/phoneinput/phoneinput?couponChannelId=" +
that.data.couponChannelId
});
} else {
tt.showToast({
title: err.message,
icon: 'none',
duration: 2000,
mask: false
});
}
})
}).catch(err => {
console.log(err)
if (err.code == 11004) {
@@ -1328,7 +1456,7 @@ Page({
})
},

onShow() {
this.ifGetUser()//判断是否授权抖音
this.setData({
@@ -1394,23 +1522,23 @@ Page({
},


// onShareAppMessage: function(e) {
// console.log("onShareAppMessage", e);
// return {
// channel: 'video',
// title: "测试小程序分享",
// desc: "这是默认的分享文案,用户可以直接发送,也可以在发布器内修改",
// extra: {
// spu_id:"7091460633887279111" //开发者在抖音开放平台设置的商品id
// },
// success: function(e) {
// console.log("分享成功");
// },
// fail: function(e) {
// console.log(e,"分享成功失败")
// }
// };
// },
// onShareAppMessage: function(e) {
// console.log("onShareAppMessage", e);
// return {
// channel: 'video',
// title: "测试小程序分享",
// desc: "这是默认的分享文案,用户可以直接发送,也可以在发布器内修改",
// extra: {
// spu_id:"7091460633887279111" //开发者在抖音开放平台设置的商品id
// },
// success: function(e) {
// console.log("分享成功");
// },
// fail: function(e) {
// console.log(e,"分享成功失败")
// }
// };
// },

// 下拉刷新
onPullDownRefresh: function () {


+ 37
- 7
pages/coupon/detail/index.ttml View File

@@ -88,12 +88,13 @@
<text class='throgh'>{{priceAndStockObj.price/100}}元</text>

</view>
<view class="sellBox"> {{'已售'+(priceAndStockObj.inventory-priceAndStockObj.remainInventory)+'|'+'库存'+priceAndStockObj.remainInventory}}</view>
</view>

<view class="subTitleBox">
<!-- <view class="subTitleBox">
<text class="subTitle">{{data.subTitle}}</text>
<view class="sellBox"> {{'已售'+(priceAndStockObj.inventory-priceAndStockObj.remainInventory)+'|'+'库存'+priceAndStockObj.remainInventory}}</view>
</view>
</view> -->

</view>
</view>
@@ -107,7 +108,8 @@
</view>
</view>
<vieW class="groupTitleBox">
<view class="groupTitle" tt:if="{{data.itemGroup.length>0}}">团购详情</view>
<view class="groupTitle" tt:if="{{data.itemGroup.length>0}}">餐饮搭配</view>
<view class="groupTitle" tt:if="{{data.Description.length>0}}">商品描述</view>
</vieW>
<view class="groupTextBox" tt:if="{{data.itemGroup.length>0}}" tt:for="{{data.itemGroup}}">
@@ -121,6 +123,12 @@
</view>
</view>
</view>

<view class="groupTextBox" tt:if="{{data.Description.length>0}}" tt:for="{{data.Description}}">
<view class="groupTitleS">{{item}}</view>
</view>


<!-- 适用门店 -->
<store merchantVoList="{{merchantVoList}}" tt:if="{{data.type!=12}}"></store>

@@ -129,15 +137,37 @@
<view class="timeText">有效期</view>
<view class="Hchild">{{validStartDate}}至{{validEndDate}}</view>
<view class="timeText">可用时间</view>
<view class="Hchild">•商家营业时间可用</view>
<view class="Hchild">• 商家营业时间内到店使用</view>
<view class="Hchild" tt:if="{{data.can_no_use_date.weekend}}">• 周末不支持使用</view>
<view class="Hchild" tt:if="{{data.can_no_use_date.HolidaysFlag}}">• 节假日(元旦、春节、清明、劳动节、端午节、中秋节、国庆节、情人节、圣诞节)不支持使用</view>
<view class="timeText">购买限制</view>
<view class="Hchild">• 每个用户限购{{data.useLimitQuantity}}单</view>

<view class="timeText">预约消费</view>
<view class="Hchild">• 不需预约,高峰时段可能需要排队</view>
<view class="Hchild">• 无需预约,高峰时段可能等位</view>

<view class="timeText" tt:if="{{data.rec_person_num_max}}">适用人数</view>
<view class="Hchild" tt:if="{{data.rec_person_num_max}}">• 该团购劵最多{{data.rec_person_num_max}}人使用</view>

<view class="timeText">温馨提示</view>
<view class="Hchild">• 团购券不支持配送或外卖</view>
<view class="timeText">使用规则</view>
<view class="Hchild" tt:if="{{data.pack}}">• 该团购商品{{data.pack=='false'?'不支持':'支持'}}打包</view>
<view class="Hchild" tt:if="{{data.besides}}">• {{data.besides=="false"?'不可以':'可以'}}外带餐食</view>
<view class="Hchild" tt:if="{{data.superimposed_discounts}}">• {{data.superimposed_discounts=="false"?'不可以':'可以'}}享受店内其他优惠</view>
<view class="Hchild" tt:if="{{data.private_room}}">• {{data.private_room=="false"?'不提供':'提供'}}包间</view>

<view class="notesH">使用规则</view>
<text tt:if="{{curHtml==''}}" class="notesText">{{data.remark}}</text>
<view tt:if="{{curHtml!=''}}">
<rich-text nodes="{{curHtml}}"></rich-text>
</view>

<view tt:if="{{data.curLsit}}" tt:for="{{data.curLsit}}" tt:key="{{index}}">
<view class="timeText" tt:if="{{item.title!=''}}">{{item.title}}</view>
<text class="Hchild">{{item.content}}</text>
</view>
</view>
<view tt:if="{{couponList.length!=0}}"


+ 2
- 2
pages/coupon/detail/index.ttss View File

@@ -355,7 +355,7 @@ button::after {
height: 25px;
line-height: 25px;
width: 92%;
margin: 10rpx auto;
margin: 10rpx auto 0 auto;
}
.fl {
float: left;
@@ -1120,7 +1120,7 @@ checkbox-group, radio-group {
color: #333;
letter-spacing: 0;
font-size: 28rpx;
height: 50rpx;
/* height: 50rpx; */
line-height: 50rpx;
width: 90%;
margin: 0 auto;


+ 1
- 1
pages/couponorder/index/index.ttml View File

@@ -2,7 +2,7 @@
<!-- <navbar back home text="我的券包" background='#fff' color="#000"></navbar>
<view style="height:{{navigationBarHeight}} "></view> -->

<view class="boatBoxf" style="top:{{navigationBarHeight}}">
<view class="boatBoxf" >
<view class="boatBox">
<view class="boatItemBox" tt:for="{{boatLsit}}" tt:key="index" bindtap="setBoatFlag" data-index="{{index}}">
<view class="{{boatFlag==item.value? 'boatTitleA':'boatTitle'}}">{{item.name}}</view>


+ 5
- 0
pages/main/index.js View File

@@ -150,6 +150,11 @@ Page({

checkuserstatus(options) {
let that = this;
if(options && options.couponChannelId&&options.type=='orderAffirm'){
tt.redirectTo({
url:`/pages/coupon/confirmation/confirmation?couponChannelId=${options.couponChannelId}`
})
}
if(options && options.couponChannelId && !options.spellGroup && app.globalData.type != 'sd'){
if (options.cuserId) {
tt.redirectTo({


+ 190
- 151
pages/order/detail/index.js View File

@@ -10,9 +10,10 @@ Page({
* 页面的初始数据
*/
data: {
payOrderNo:"",//评价订单id
evaluateFlag:false,//控制评价显隐藏
serviceUrl:'',//客服外部链接
outOrderNo:'',//支付2.0继续支付id
payOrderNo: "",//评价订单id
evaluateFlag: false,//控制评价显隐藏
serviceUrl: '',//客服外部链接
dynamicRq: "",
expiredSeconds: 0,
showhieRq: false,
@@ -90,13 +91,13 @@ Page({
},
});
},
refund(){//退款
refund() {//退款
Http.post({
url:config.api.refund,
data:{
orderId:this.data.order.id
url: config.api.refund,
data: {
orderId: this.data.order.id
}
}).then(res=>{
}).then(res => {
tt.navigateTo({
url: `/pages/refund/refund?id=${this.data.order.id}`,
success: (res) => {
@@ -106,7 +107,7 @@ Page({

},
});
}).catch(err=>{
}).catch(err => {
tt.showToast({
title: err.message ? err.message : err.data, // 内容
icon: "none"
@@ -115,14 +116,14 @@ Page({
},
goRefund(e) {
let this_ = this
if(this_.data.order.couponOrderStatus==0){
if (this_.data.order.couponOrderStatus == 0) {
tt.showModal({
title: "申请退款",
content: "提交申请退款",
confirmText: "确定",
success(res) {
if (res.confirm) {
this_.refund()
console.log("confirm, continued");
} else if (res.cancel) {
@@ -135,7 +136,7 @@ Page({
console.log(`showModal调用失败`);
},
});
}else if(this_.data.order.couponOrderStatus==3){//退款中
} else if (this_.data.order.couponOrderStatus == 3) {//退款中
tt.navigateTo({
url: `/pages/refund/refund?id=${this.data.order.id}`,
success: (res) => {
@@ -146,7 +147,7 @@ Page({
},
});
}

},

@@ -170,12 +171,13 @@ Page({
tempData.validEndDate = util.formatTime(tempData.validEndDate, "yyyy-MM-dd")

that.setData({
outOrderNo:res.data.id,
order: tempData,
showPage: true,
createDate: createDate,
composeOrderType: tempData.composeOrderType,
contentType: tempData.contentType ? tempData.contentType : 0,
orderFlag: tempData.type == 11 ? true : false ,//判断是不是线上配送
orderFlag: tempData.type == 11 ? true : false,//判断是不是线上配送
})
if (tempData.couponOrderId) { //0未付款 1已支付 2已取消 3退款中 4已退款
that.setRq()
@@ -220,7 +222,7 @@ Page({
setInter: setInter
})
}
if(tempData.couponOrderStatus&&tempData.couponOrderStatus==1){//核销后
if (tempData.couponOrderStatus && tempData.couponOrderStatus == 1) {//核销后
that.goIfEvaluate()//判断订单是否能评价
}
})
@@ -327,7 +329,7 @@ Page({
couponOrderId: _this.data.order.couponOrderId
}
}).then(res => {
console.log(res, "res")
console.log(res, "res")
_this.setData({
dynamicRq: res.data.dynamicId,
expiredSeconds: res.data.expiredSeconds
@@ -338,9 +340,9 @@ Page({
TYPE: "couponorder",
ID: _this.data.dynamicRq
})
if(res.data.expiredSeconds==0){
if (res.data.expiredSeconds == 0) {
//倒计时为零直接显示券码
}else{
} else {
let inre = setInterval(() => {
if (_this.data.expiredSeconds > 1) {
_this.setData({
@@ -440,7 +442,7 @@ Page({
console.log(err);
})
},
goEvaluate(){
goEvaluate() {
let _this = this
tt.rateAwemeOrder({
orderId: _this.data.payOrderNo,
@@ -450,10 +452,10 @@ Page({
tt.navigateBack({
delta: 1,
success: (res) => {
},
fail: (res) => {
},
});
// 用户已经评价的逻辑
@@ -467,28 +469,28 @@ Page({
});
},

goIfEvaluate(){
goIfEvaluate() {
let _this = this
Http.get({
url:config.api.getchanId,
data:{
id:_this.data.order.couponOrderId
url: config.api.getchanId,
data: {
id: _this.data.order.couponOrderId
}
}).then(res=>{
}).then(res => {
tt.canRateAwemeOrders({
orderIds: [res.data.payOrderNo],
success({ result }) {
console.log("result", result);
_this.setData({
evaluateFlag:result[0],
payOrderNo:res.data.payOrderNo
evaluateFlag: result[0],
payOrderNo: res.data.payOrderNo
})
},
fail(err) {
console.log(err);
},
});
}).catch(err=>{
}).catch(err => {
tt.showToast({
title: err.message ? err.message : err.data, // 内容
icon: "none"
@@ -521,7 +523,7 @@ Page({
title: "加载中"
});


},
onShow: function () {
@@ -531,32 +533,32 @@ Page({
})
that.updetail()
},
getSeUrl(){//获取客服链接
getSeUrl() {//获取客服链接
const openId = tt.getStorageSync('openId');
Http.post({
url:config.api.getServiceUrl,
data:{
url: config.api.getServiceUrl,
data: {
appid: app.globalData.appId,
openid: openId
}
}).then(res=>{
}).then(res => {
this.setData({
serviceUrl:res.data?res.data:''
serviceUrl: res.data ? res.data : ''
})
if(res.data){
if (res.data) {
tt.setStorageSync('serviceData', res.data);
}
})
},
goWebView(){
goWebView() {
let _this = this
tt.navigateTo({
url: `/pages/serviceWebView/serviceWebView`,
success: (res) => {
},
fail: (res) => {
},
});
},
@@ -589,6 +591,7 @@ Page({
*/
orderFunc(e) {
var that = this;
const orderId = "" + that.data.orderId;
that.setData({
showButton: true
})
@@ -596,134 +599,170 @@ Page({
title: "加载中..."
});

const orderId = "" + that.data.orderId;
if (that.data.order.payment > 0) {
// 支付金额不为0
Http.post({
url: config.api.payOrderCreate,
data: {
orderId: orderId,
composeOrderType: that.data.composeOrderType
}
}).then(res => {
var payOrderId = "" + res.data.outOrderNo;
tt.hideLoading();
tt.pay({
service: 5,
orderInfo: {
order_id: res.data.orderId,
order_token: res.data.token,
},
success: res => {
tt.showLoading({
title: '订单正在处理中...',
})
if (res.code == 0) {
setTimeout(function () {
tt.hideLoading()
}, 5000)
that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that); // 支付成功
if (res.errMsg == "requestPayment:ok") {
if (that.data.order.type == 100) {
tt.setStorage({
key: 'couponNum2',
data: "couponNum2"
})
} else if (that.data.order.type != 5) {
tt.setStorage({
key: 'couponNum',
data: "couponNum"
})
}
}
} else if (res.code === 1) {
that.setData({
showButton: false
if (!tt.canIUse('createOrder')) {//兼容不支持支付2.0 js-api
if (that.data.order.payment > 0) {
// 支付金额不为0
Http.post({
url: config.api.payOrderCreate,
data: {
orderId: orderId,
composeOrderType: that.data.composeOrderType
}
}).then(res => {
var payOrderId = "" + res.data.outOrderNo;
tt.hideLoading();
tt.pay({
service: 5,
orderInfo: {
order_id: res.data.orderId,
order_token: res.data.token,
},
success: res => {
tt.showLoading({
title: '订单正在处理中...',
})
tt.hideLoading();
tt.showToast({
title: '支付超时', // 内容
icon: "none"
});
if (res.code == 0) {
setTimeout(function () {
tt.hideLoading()
}, 5000)
that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that); // 支付成功
if (res.errMsg == "requestPayment:ok") {
if (that.data.order.type == 100) {
tt.setStorage({
key: 'couponNum2',
data: "couponNum2"
})
} else if (that.data.order.type != 5) {
tt.setStorage({
key: 'couponNum',
data: "couponNum"
})
}
}
} else if (res.code === 1) {
that.setData({
showButton: false
})
tt.hideLoading();
tt.showToast({
title: '支付超时', // 内容
icon: "none"
});

} else if (res.code === 2) {
that.setData({
showButton: false
})
tt.hideLoading();
tt.showToast({
title: '支付失败', // 内容
icon: "none"
});
} else if (res.code === 2) {
that.setData({
showButton: false
})
tt.hideLoading();
tt.showToast({
title: '支付失败', // 内容
icon: "none"
});

} else if (res.code === 3) {
} else if (res.code === 3) {
that.setData({
showButton: false
})
tt.hideLoading();
tt.showToast({
title: '支付关闭', // 内容
icon: "none"
});
} else if (res.code === 4) {
that.setData({
showButton: false
})
tt.hideLoading();
tt.showToast({
title: '支付取消', // 内容
icon: "none"
});
} else if (res.code === 9) {
that.setData({
showButton: false
})
tt.hideLoading();
tt.showToast({
title: '订单状态开发者自行获取', // 内容
icon: "none"
});
}
},
fail: res => {
that.setData({
showButton: false
})
tt.hideLoading();
tt.showToast({
title: '支付关闭', // 内容
icon: "none"
});
} else if (res.code === 4) {
that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that);
return;
},
});
}).catch(err => {
tt.hideLoading();
that.setData({
showButton: false
})
tt.showModal({
title: "抱歉",
content: err.message,
showCancel: false
})
});
} else {
// 免费券
that.payOrderUpdate(orderId, "0", 1, '', 'free') // 支付成功
if (that.data.order.type == 100) {
tt.setStorage({
key: 'couponNum2',
data: "couponNum2"
})
} else if (that.data.order.type != "5") {
tt.setStorage({
key: 'couponNum',
data: "couponNum"
})
}
tt.showToast({
title: "支付成功",
duration: 2000,
image: imgurl.success.url,
});
}
}else{//支持 支付2.0 js-api
const outOrderNo = that.data.outOrderNo
console.log(outOrderNo,"outOrderNo");
tt.continueToPay({
outOrderNo: outOrderNo, // 外部订单号 2个订单号必填一个
success: res => {
const { orderId, outOrderNo } = res;
console.log('success res', res);
console.log('orderId', orderId, 'outOrderNo', outOrderNo);
that.setData({
showButton: false
})
tt.hideLoading();
that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that); // 支付成功
},
fail: res => {
const { orderId, outOrderNo, errNo, errMsg, errLogId } = res;
if(errLogId){
console.log('查询订单信息失败',errNo, errMsg, errLogId);
that.setData({
showButton: false
})
tt.hideLoading();
tt.showToast({
title: '支付取消', // 内容
icon: "none"
});
} else if (res.code === 9) {
}
if( orderId || outOrderNo){
console.log('支付失败',errNo, errMsg , orderId, outOrderNo);
that.payOrderUpdate(outOrderNo, outOrderNo, 2, '', 'fail', that);
that.setData({
showButton: false
})
tt.hideLoading();
tt.showToast({
title: '订单状态开发者自行获取', // 内容
icon: "none"
});
}
},
fail: res => {
that.setData({
showButton: false
})
that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that);
return;
},
});
}).catch(err => {
tt.hideLoading();
that.setData({
showButton: false
})
tt.showModal({
title: "抱歉",
content: err.message,
showCancel: false
})
});
} else {
// 免费券
that.payOrderUpdate(orderId, "0", 1, '', 'free') // 支付成功
if (that.data.order.type == 100) {
tt.setStorage({
key: 'couponNum2',
data: "couponNum2"
})
} else if (that.data.order.type != "5") {
tt.setStorage({
key: 'couponNum',
data: "couponNum"
})
}
tt.showToast({
title: "支付成功",
duration: 2000,
image: imgurl.success.url,
}
},
});
}

},
/**
* 支付订单更新


+ 1
- 1
pages/order/detail/index.ttml View File

@@ -37,7 +37,7 @@

<image class="infoArrow" src="{{chevronUrl}}" mode='widthFix'></image>
<view class="goRefund" catchtap="goRefund" data-id="{{order.id}}" tt:if="{{order.couponOrderStatus==0||order.couponOrderStatus==3}}">{{order.couponOrderStatus==0?'申请退款':'退款进度'}}</view>
<view class="goRefund" catchtap="goRefund" data-id="{{order.id}}" tt:if="{{order.payment!=0&&(order.couponOrderStatus==0||order.couponOrderStatus==3)}}">{{order.couponOrderStatus==0?'申请退款':'退款进度'}}</view>
</view>
</view>
</view>


+ 36
- 45
project.config.json View File

@@ -1,49 +1,40 @@
{
"setting": {
"urlCheck": true,
"es6": true,
"newFeature": false,
"postcss": false,
"mockUpdate": false,
"minified": false,
"autoPush": false,
"scripts": false,
"mockLogin": false
},
"appid": "ttde7ca8c141425a2301",
"projectname": "tt富茂C",
"condition": {
"miniprogram": {
"current": -1,
"list": [
{
"id": 1650610427387,
"name": "华莱士",
"pathName": "pages/main/index?type=cd&couponChannelId=123467",
"query": "couponChannelId=676951389111508992",
"scene": "990001",
"launchFrom": "scan",
"location": "qr_code"
},
{
"id": 1649905362371,
"name": "add",
"pathName": "pages/liveLsit/liveLsit",
"query": "",
"scene": "990001",
"launchFrom": "scan",
"location": "qr_code"
},
{
"id": 1653894805719,
"name": "pages/main/index",
"pathName": "pages/main/index",
"query": "type=dt&orderId=1111",
"scene": "990001",
"launchFrom": "scan",
"location": "qr_code"
}
]
"setting": {
"urlCheck": true,
"es6": true,
"newFeature": false,
"postcss": false,
"mockUpdate": false,
"minified": false,
"autoPush": false,
"scripts": false,
"mockLogin": false
},
"appid": "ttde7ca8c141425a2301",
"projectname": "tt富茂C",
"condition": {
"miniprogram": {
"current": 1649905362371,
"list": [
{
"id": 1650610427387,
"name": "华莱士",
"pathName": "pages/main/index?type=cd&couponChannelId=123467",
"query": "couponChannelId=676951389111508992",
"scene": "990001",
"launchFrom": "scan",
"location": "qr_code"
},
{
"id": 1649905362371,
"name": "add",
"pathName": "pages/main/index",
"query": "couponChannelId=697253188828323840&type=orderAffirm",
"scene": "990001",
"launchFrom": "scan",
"location": "qr_code"
}
]
}
}
}

Loading…
Cancel
Save