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: "", showPhoem: false, couponChannelId: "", showPage: false, data: {}, spuIdObj: {}, priceAndStockObj: {}, mallTenantId: '', imId: "", goodId: "", IMorderId: "", merchantId: "", currentIndex: "", mallList: [], latitude: "", longitude: "", merOrderId: "", shopItem: null }, onLoad: function (options) { console.log(options, 'options!!!!!!!'); if (options.mallTenantId) { this.setData({ mallTenantId: options.mallTenantId, }) } else { this.setData({ mallTenantId: tt.getStorageSync('mallTenantId'), }) } console.log(this.data.mallTenantId, 'mallTenantId'); if (options.merOrderId) { this.setData({ merOrderId: options.merOrderId }) } // this.getCouponMerchant(options.merOrderId) tt.showLoading({ title: "加载中..." }); let that = this if (app.globalData.token) { if (options && options.couponChannelId) { that.setData({ couponChannelId: options.couponChannelId }) that.getDetail(options.couponChannelId, 'notendclock'); } } else { app.tokenCallback = token => { that.setData({ couponChannelId: options.couponChannelId }) if (options && options.couponChannelId) { that.getDetail(options.couponChannelId, 'notendclock'); } } } }, imCallback(e) { console.log("跳转IM客服成功", e); }, setMerchant(e) { console.log(e.detail.value, 'e'); const index = e.detail.value this.setData({ currentIndex: index, merchantId: this.data.mallList[index].id }) console.log(this.data.currentIndex, this.data.merchantId); }, onimError(e) { console.log("拉起IM客服失败", e.detail); }, goInstructions() { tt.navigateTo({ url: '/pages/coupon/instructions/instructions?couponChannelId=' + this.data.couponChannelId, success: (res) => { }, fail: (res) => { }, }); }, getIm() { //获取im客服id const that = this Http.get({ url: config.api.getIm, data: { mallTenantId: this.data.mallTenantId || '' } }).then(res => { console.log(res, 'getIm'); const imId = res.data.imId ? res.data.imId : "" that.setData({ imId: imId }) }).catch(err => { console.log(err, 'res'); }) }, getCouponMerchant(couponChannelId) { //获取适用门店 const that = this Http.get({ url: config.api.couponMerchant, data: { couponChannelId, mallTenantId: that.data.mallTenantId || '' } }).then(res => { const keys = Object.keys(res.data) const mallList = [] let i = 0 keys.forEach(item => { const arr = item.split('|') const obj = { tenantId: arr[0], mallName: arr[1], merchantVoList: res.data[item], expand: false } if (i == 0) { obj.expand = true } mallList.push(obj) i++ }) that.setData({ mallList: mallList[0].merchantVoList }) console.log(that.data.mallList, 'mallList'); that.getLocation() }) }, /** * 获得经纬度 */ getLocation() { console.log('getLocation'); let that = this; tt.getLocation({ type: "wgs84", // isHighAccuracy: true, success: function (res) { console.log(res, 'getLocation') that.setData({ latitude: res.latitude, longitude: res.longitude, }) const latitudeNow = res.latitude const longitudeNow = res.longitude const mallLocationArr = [] const mallList = that.data.mallList mallList.forEach((item, index) => { const obj = { latitude: item.latitude || false, longitude: item.longitude || false, id: item.id, index: index } mallLocationArr.push(obj) }) console.log(mallLocationArr, 'mallLocationArr'); const tempArr = mallList const bloobArr = [] mallLocationArr.forEach((item, index) => { const distanceData = that.getDistances(latitudeNow, longitudeNow, item.latitude, item.longitude) tempArr[index].distance_str = distanceData.distance_str tempArr[index].distance_str = distanceData.distance_str tempArr[index].distanceName = tempArr[index].merchantName + ' ' + distanceData.distance_str tempArr[index].distance = distanceData.distance bloobArr.push(tempArr[index]) }) const finalSortMallList = that.bloob(bloobArr) console.log(finalSortMallList, 'finalSortMallList'); that.setData({ mallList: finalSortMallList }) }, // 拒绝提供定位权限 fail: error => { console.log(error, 'error'); const mallList = that.data.mallList mallList.forEach(item => { item.distanceName = item.merchantName }) that.setData({ mallList }) }, complete: finish => { let isSuccess = 0 const mallList = that.data.mallList mallList.forEach(item => { if (item.distance_str) { isSuccess = 1 } }) if (!isSuccess) { tt.showToast({ title: '定位失败!', icon: "fail" }); } } }) }, /** * @description:根据经纬度计算距离 * @param {*} locationInfo (lat1, lng1, lat2, lng2) * @return: distanceObj: { distance , distance_str } */ getDistances(lat1, lng1, lat2, lng2) { if (lat2 || lng2) { function rad(num) { return num * Math.PI / 180.0; } var radLat1 = rad(lat1); var radLat2 = rad(lat2); var a = radLat1 - radLat2; var b = rad(lng1) - rad(lng2); var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); s = s * 6378.137; s = Math.round(s * 10000) / 10000; var distance = s; var distance_str = ""; if (parseInt(distance) >= 1) { distance_str = distance.toFixed(2) + "km"; } else if (!arseInt(distance)) { return false } else { distance_str = (distance * 1000).toFixed(2) + "m"; } let objData = { distance: distance, distance_str: distance_str } return objData } else { let objData = { distance: Infinity, distance_str: '' } return objData } }, bloob(arr) { const tempArr = arr for (let i = 0; i < tempArr.length - 1; i++) { for (let j = 0; j < tempArr.length - 1 - i; j++) { if (tempArr[j].distance > tempArr[j + 1].distance) { let temp = tempArr[j]; tempArr[j] = tempArr[j + 1]; tempArr[j + 1] = temp; } } } return tempArr }, getSupId(id) { Http.get({ url: config.api.getSpuid, data: { id: id } }).then(res => { if (res.data) { this.setData({ spuIdObj: res.data, goodId: res.data.spuId }) } }).catch(err => { // tt.showToast({ // title: err.message, // icon: 'none', // duration: 2000, // mask: false // }); }) }, setPhone(paramData) { //子组件调用这个方法说明手机号已经授权成功 this.setData({ showPhoem: paramData.detail, }) tt.showToast({ title: '授权成功', // 内容 icon: 'none', // 图标 success: (res) => { }, fail: (res) => { }, }); }, setBox(paramData) { this.setData({ showPhoem: paramData.detail }) tt.showToast({ title: '取消授权', // 内容 icon: 'none', // 图标 success: (res) => { tt.reLaunch({ url: "/index/index", success(res) { console.log(`${res}`); app.globalData.selected = 0 }, fail(err) { console.log(`navigateTo调用失败`, err); }, }); }, fail: (res) => { }, }); }, getCouponPriceAndStock(couponChannelId) { //获取券价格与库存 Http.get({ url: config.api.couponPriceAndStock, data: { couponChannelId, mallTenantId: this.data.mallTenantId || '' } }).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' && item.isRequired) { 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 => { console.log(err, 'err'); tt.showToast({ title: err.message, icon: 'none', duration: 2000, mask: false }); }) }, /** * 支付订单更新 */ payOrderUpdate(orderId, payOrderId, status, reason, type, _this, composeOrderType) { let that = this; console.log(orderId, 'orderId'); // 支付成功 Http.post({ url: config.api.payOrderUpdate, data: { payOrderId: payOrderId, composeOrderId: orderId, status: status, reason: reason, mallTenantId: that.data.mallTenantId } }) .then(res => { tt.hideLoading() // 有价券 tt.setStorageSync('appointment', true); if (!type && type != 'free') { console.log('Over Here! type'); setTimeout(() => { console.log(_this.data.orderFlag, orderId, that.data.mallTenantId, 'notice!!!'); let url = "" if (_this.data.orderFlag) { tt.redirectTo({ url: `/pages/order/detail/index?orderId=${orderId}&dingdan=order&mallTenantId=${that.data.mallTenantId}` }); } else { tt.redirectTo({ url: `/pages/order/detail/index?orderId=${orderId}&mallTenantId=${that.data.mallTenantId}` }); } }, 1600); } else if (type == 'free') { console.log('Over Here! type2'); tt.navigateTo({ url: `/pages/order/detail/index?orderId=${orderId}&mallTenantId=${that.data.mallTenantId}` }); } }) .catch(err => { console.log(err); console.log('Over Here! type3'); if (!type) { setTimeout(function () { _this.payOrderUpdate(orderId, payOrderId, status, reason, type, _this, composeOrderType); }, 2000) } }) }, // 获得未支付的订单 getUnPaidOrder(couponId) { let that = this; Http.get({ url: config.api.getUnPaidOrder, data: { couponId: couponId, mallTenantId: this.data.mallTenantId || '' } }).then(res => { that.setData({ disOrderNumber: res.data.orderNumber, composeOrderType: res.data.composeOrderType }) if (res.data && res.data.pressEndDate) { that.setData({ dispressEndDate: true }) } else { that.setData({ dispressEndDate: false }) } if (that.data.dispressEndDate) { tt.showModal({ title: '提示', content: "您有未支付订单,请到“我的-我的砍价”进行支付", confirmText: "我的砍价", success: function (res) { if (res.confirm) { tt.navigateTo({ url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.disOrderNumber}&composeOrderType=${that.data.composeOrderType}`, }) } } }) } else { tt.showModal({ title: '提示', content: '您有未支付订单,请先进行支付', confirmText: "去支付", success: function (res1) { if (res1.confirm) { if (that.data.composeOrderType > 0) { //券包 tt.navigateTo({ url: `/pages/order/detail/index?orderId=${res.data.composeOrderId}&mallTenantId=${that.data.mallTenantId}`, }) } else { tt.navigateTo({ url: `/pages/order/detail/index?orderId=${res.data.composeOrderId}&mallTenantId=${that.data.mallTenantId}`, }) } } } }) } }).catch(error => { tt.showToast({ title: error.message, icon: "none", duration: 3000 }) }) }, /** * 发起支付 */ orderFunc(discount) { if (this.data.showbutton) return; if (!this.data.merchantId && this.data.data.type == 69) { tt.showToast({ title: '请选择可用商户!', icon: 'fail' }); 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 data.mallTenantId = that.data.mallTenantId || '' if (that.data.data.type == 69) { data.fixMerchantId = that.data.merchantId } } /** * 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 if (tt.canIUse('createOrder')) { Http.post({ url: config.api.payOrderCreate_2, data: { orderId: orderId, composeOrderType: res.data.composeOrderType, mallTenantId: that.data.mallTenantId } }).then(res => { console.log(res, "789789"); let tempCallbackData = res.data.callbackData // tempCallbackData[that.data.data.couponChannel.ttSpuId] = that.data.data.couponChannel.id let options = { callbackData: tempCallbackData, goodsList: res.data.goodsList, payment: res.data.payment, success: res => { console.log('save,success!'); tt.hideLoading(); that.setData({ showbutton: false, }) const { orderId, outOrderNo } = res; that.setData({ orderId, outOrderNo }); that.payOrderUpdate(outOrderNo, outOrderNo, 1, '', '', that, ''); }, fail: res => { console.log('save,fail!'); const { orderId, outOrderNo, errNo, errMsg, errLogId } = res; if (errLogId) { tt.hideLoading(); that.setData({ showbutton: false, }) console.log('预下单失败', errNo, errMsg, errLogId); let tempErrmsg = errMsg.split('开发者拒绝交易:'); tt.showToast({ title: tempErrmsg[tempErrmsg.length - 1], icon: 'none', duration: 2000, mask: false }); } if (orderId || outOrderNo) { tt.hideLoading(); that.setData({ showbutton: false, }) console.log('支付失败', errNo, errMsg, orderId, outOrderNo); console.log(that.payOrderUpdate, "payOrderUpdate"); tt.showToast({ title: "取消支付", icon: 'none', duration: 2000, mask: false }); that.payOrderUpdate(outOrderNo, outOrderNo, 2, '', 'fail') } }, } console.log(options, "options"); tt.createOrder(options) }) } else { //不支持2.0支付 /** * 支付订单创建 */ tt.showToast({ title: '请升级抖音', // 内容 icon: "none" }); return 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.payOrderId, order_token: res.data.payOrderToken, }, 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}`, }) } } }).catch(err => { tt.hideLoading(); that.setData({ showbutton: false, }) if (err.code == 3012) { that.getUnPaidOrder(that.data.couponId); } else { tt.showToast({ title: err.message ? err.message : err.data, icon: 'none', duration: 2000, success(res) { console.log(res); }, fail(res) { console.log("showToast 调用失败", res); }, }); } }) // } 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); // let tempErrmsg = errMsg.split('开发者拒绝交易:'); // tt.showToast({ // title: tempErrmsg[tempErrmsg.length - 1], // icon: 'none', // duration: 2000, // mask: false // }); // } // if (orderId || outOrderNo) { // tt.hideLoading(); // that.setData({ // showbutton: false, // }) // console.log('支付失败', errNo, errMsg, orderId, outOrderNo); // console.log(that.payOrderUpdate, "payOrderUpdate"); // tt.showToast({ // title: "取消支付", // icon: 'none', // duration: 2000, // mask: false // }); // 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) { /** * 将值传到用户手机号授权的页面 * */ if (app.globalData.ifCongPh == 1) { tt.navigateTo({ url: `/pages/getPhone/getPhone?couponChannelId=${that.data.couponChannelId}&mallTenantId=${that.data.mallTenantId}&path=qr`, }); } else { this.setData({ showPhoem: true }) } } else if (err.code == 11006) { // 用户手机已加密 tt.navigateTo({ url: `/pages/getPhone/getPhone?couponChannelId=${that.data.couponChannelId}&mallTenantId=${that.data.mallTenantId}&path=qr` }); } else { tt.showToast({ title: err.message, icon: 'none', duration: 2000, mask: false }); } }) }).catch(err => { tt.hideLoading() that.setData({ showbutton: false, }) console.log(err) if (err.code == 11004) { tt.navigateTo({ url: `/pages/getuserinfo/getuserinfo?fromflag=confirmation&confirmationFlag=${that.data.couponChannelId}&mallTenantId=${that.data.mallTenantId}`, }) } else { tt.showToast({ title: err.message, icon: "none", duration: 2500 }) } }) }, goSelectShop() { const data = this.data const isOrder = true const merOrderId = data.merOrderId tt.navigateTo({ url: `/pages2/shopSelect/shopSelect?isOrder=${isOrder}&merOrderId=${merOrderId}`, }); }, onShow() { this.getIm() const shopItem = app.globalData.shopItem if (shopItem) { this.setData({ shopItem, merchantId: shopItem.id, reservationMerchantName: "" }) console.log(this.data.shopItem, 'shopItem'); app.globalData.shopItem = null } } })