diff --git a/pages.json b/pages.json index ea7b74a..d5010bf 100644 --- a/pages.json +++ b/pages.json @@ -196,6 +196,13 @@ { "navigationBarTitleText" : "" } + }, + { + "path" : "pages/payCoupons/payCoupons", + "style" : + { + "navigationBarTitleText" : "" + } } ], diff --git a/pages/payCoupons/payCoupons.vue b/pages/payCoupons/payCoupons.vue new file mode 100644 index 0000000..8cc05aa --- /dev/null +++ b/pages/payCoupons/payCoupons.vue @@ -0,0 +1,467 @@ + + + + + \ No newline at end of file diff --git a/stor/Coupons/coupons.js b/stor/Coupons/coupons.js index 4fd7855..bc183e9 100644 --- a/stor/Coupons/coupons.js +++ b/stor/Coupons/coupons.js @@ -4,6 +4,7 @@ import { import { ref } from 'vue' + import { getCouponList, getyouHui, @@ -16,7 +17,10 @@ import { getShopid, getTimeOrder } from '../../api/api.js' - +import { + appSecret, + appid +} from '../../common/baseurl.js' export const coupons = defineStore('coupons', () => { const couponsData = ref([]) @@ -27,6 +31,8 @@ export const coupons = defineStore('coupons', () => { const isShow = ref() const que = ref(0) const id = ref() + const p = ref(0) + const orderid = ref() const getcouponsData = async () => { couponsData.value = await getCouponList({ phoneNumber: uni.getStorageSync('phoneNumber') @@ -99,20 +105,25 @@ export const coupons = defineStore('coupons', () => { uni.setStorageSync('mid', mid) console.log(mid); } - getShopid({ - mid: uni.getStorageSync('mid'), - phone: uni.getStorageSync('phoneNumber') - }).then((res) => { - console.log(res); - console.log(res.data.networkId); - id.value = res.data.networkId - que.value = 1 - - }) + console.log(resDats.value); + if (resDats.value.amount > 0) { + uni.navigateTo({ + url: "/pages/payCoupons/payCoupons" + }) + } else { + getShopid({ + mid: uni.getStorageSync('mid'), + phone: uni.getStorageSync('phoneNumber') + }).then((res) => { + console.log(res); + console.log(res.data.networkId); + id.value = res.data.networkId + que.value = 1 + }) + } // const mids = Number(mid) - } } const scanQrcode = (data) => { @@ -170,14 +181,15 @@ export const coupons = defineStore('coupons', () => { uni.setStorageSync('orderid', res5) uni.setStorageSync('msg', '拉新券') const orderRes = await getTimeOrder({ - phoneNumber: uni.getStorageSync('phoneNumber'), + phoneNumber: uni.getStorageSync( + 'phoneNumber'), amount: 0, goodsId: resDats.value.id, goodsType: 3, //洗车订单 networkId: id.value, payType: 4, // deviceId: uni.getStorageSync('mid'), - orderId:orderid.value + orderId: res5 }) uni.redirectTo({ url: '/pages/complete/complete' @@ -208,6 +220,172 @@ export const coupons = defineStore('coupons', () => { } }) } + + // 洗车费-微信支付-套餐6元 + const wxPlay = async (datas) => { + console.log(datas); + if (!uni.getStorageSync('phoneNumber')) { + uni.showToast({ + icon: 'none', + title: "账号未登录,请先登录", + duration: 1000 + }) + return + } + //处理用户多次点击 + if (p.value == 1) { + return + } + p.value = 1 + + const res = await getTimeStamps() + // { + // phoneNumber: uni.getStorageSync('phoneNumber'), + // amount: datas.amount, + // goodsId: datas.id, + // goodsType: 3, //洗车订单 + // networkId: datas.networkId, + // payType: 1, //微信支付, + // deviceId: uni.getStorageSync('mid') + // } + orderid.value = res + if (res === "机器正在工作") { + uni.showToast({ + icon: "none", + title: `${res}` + }) + p.value = 0 + } else { + console.log("out_trade_no", res); + console.log('这是订单号' + res); + const res1 = await getWxPlay({ + appId: appid, + phone: uni.getStorageSync('phoneNumber'), + openId: uni.getStorageSync('openid'), + out_trade_no: res, + amount: datas.amount, + description: '拉新券洗车', + shopId: datas.id, + machineId: datas.networkId + }) + console.log(res1); + + + uni.requestPayment({ + provider: 'wxpay', + timeStamp: res1.timeStamp, + nonceStr: res1.nonceStr, + package: res1.package, + signType: res1.signType, + paySign: res1.paySign, + //付款成功进入执行启动设备 + success: async (res2) => { + console.log('用户付款成功', res2); + //获取扫码后的设备id和手机号验证传入订单信息启动设备 + + const res4 = await start({ + mid: uni.getStorageSync('mid'), + price: 100, + time: datas.freeTime*60, + description: '拉新券洗车', + orderId: orderid.value, + phone: uni.getStorageSync('phoneNumber'), + openId: uni.getStorageSync('openid') + }) + console.log(res4); + + if (res4.code == 200 || res4.code == 0) { + uni.showToast({ + icon: 'none', + title: '启动设备成功', + duration: 1000, + success: async (res) => { + p.value = 0 + uni.setStorageSync( + 'orderid', + orderid + .value) + uni.setStorageSync('msg','拉新券洗车') + const orderRes = await getTimeOrder({ + phoneNumber: uni.getStorageSync('phoneNumber'), + amount: datas.amount, + goodsId: datas.id, + goodsType: 3, //洗车订单 + networkId: datas.networkId, + payType: 4, //微信支付, + deviceId: uni.getStorageSync('mid'), + orderId: orderid.value + }) + uni.redirectTo({ + url: '/pages/complete/complete' + }) + const qaq = await getTincheCoupons({ + phoneNumber: uni.getStorageSync('phoneNumber'), + oderId: orderid.value + }) + uni.showToast({ + icon: "none", + title: `${qaq.msg}` + }) + const currentDate = new Date(); + const year = currentDate.getFullYear(); + const month = String(currentDate.getMonth() + 1) + .padStart(2, '0'); + const day = String(currentDate.getDate()) + .padStart(2, '0'); + const hours = String(currentDate.getHours()) + .padStart(2, '0'); + const minutes = String(currentDate.getMinutes()) + .padStart(2, '0'); + const seconds = String(currentDate.getSeconds()) + .padStart(2, '0'); + const formattedDate = + `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; + const qaq1 = await getExcellent({ + time: formattedDate, + networkId: datas.networkId + }) + console.log(qaq1) + } + }) + //不为200或者0的时候启动失败并提示原因。 + } else { + console.log(res4); + uni.showToast({ + icon: 'none', + title: `请在我的页面联系客服解决`, + duration: 1200, + success: (res) => { + p.value = 0 + uni.setStorageSync( + 'orderid', + orderid + .value) + uni.setStorageSync('msg','拉新券洗车') + + + } + }) + } + }, + //付款失败 提示原因 + fail: (err) => { + p.value = 0 + console.log("用户付款失败", err); + if (err) { + uni.showToast({ + title: '用户付款失败', + icon: 'none', + duration: 1000 + }) + } + } + }) + } + p.value = 0 + + } + return { couponsData, getcouponsData, @@ -217,6 +395,7 @@ export const coupons = defineStore('coupons', () => { quexio, goStar, isShowCoupons, - isShow + isShow, + wxPlay } }) \ No newline at end of file diff --git a/unpackage/dist/dev/mp-weixin/app.js b/unpackage/dist/dev/mp-weixin/app.js index 16253b5..5acb617 100644 --- a/unpackage/dist/dev/mp-weixin/app.js +++ b/unpackage/dist/dev/mp-weixin/app.js @@ -32,6 +32,7 @@ if (!Math) { "./pages/yijian/yijian.js"; "./pages/tuan/tuan.js"; "./pages/demo copy/index.js"; + "./pages/payCoupons/payCoupons.js"; } const _sfc_main = { onLaunch: function() { diff --git a/unpackage/dist/dev/mp-weixin/app.json b/unpackage/dist/dev/mp-weixin/app.json index 99460c8..d73cbd0 100644 --- a/unpackage/dist/dev/mp-weixin/app.json +++ b/unpackage/dist/dev/mp-weixin/app.json @@ -27,7 +27,8 @@ "pages/guanyuMy/guanyuMy", "pages/yijian/yijian", "pages/tuan/tuan", - "pages/demo copy/index" + "pages/demo copy/index", + "pages/payCoupons/payCoupons" ], "window": { "navigationBarTextStyle": "black", diff --git a/unpackage/dist/dev/mp-weixin/pages/payCoupons/payCoupons.js b/unpackage/dist/dev/mp-weixin/pages/payCoupons/payCoupons.js new file mode 100644 index 0000000..aa61407 --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/pages/payCoupons/payCoupons.js @@ -0,0 +1,105 @@ +"use strict"; +const common_vendor = require("../../common/vendor.js"); +const stor_Coupons_coupons = require("../../stor/Coupons/coupons.js"); +if (!Array) { + const _easycom_windows2 = common_vendor.resolveComponent("windows"); + _easycom_windows2(); +} +const _easycom_windows = () => "../../components/windows/windows.js"; +if (!Math) { + _easycom_windows(); +} +const _sfc_main = { + __name: "payCoupons", + setup(__props) { + const c = stor_Coupons_coupons.coupons(); + const { + isShowCoupons, + couponsData, + que, + isShow + } = common_vendor.storeToRefs(c); + c.getcouponsData(); + common_vendor.onLoad(() => { + console.log(isShowCoupons, isShow); + }); + const headerindex = common_vendor.ref(1); + common_vendor.ref("券列表"); + common_vendor.ref("#fff"); + common_vendor.ref("#000"); + const ccc = common_vendor.ref(0); + const quan = common_vendor.ref(0); + const couponsIndex = common_vendor.ref(0); + const checkCoupons = (index) => { + couponsIndex.value = index; + }; + const goPlays = () => { + c.wxPlay(couponsData.value[quan.value]); + }; + return (_ctx, _cache) => { + return common_vendor.e({ + a: common_vendor.o((...args) => _ctx.getNavs && _ctx.getNavs(...args)), + b: common_vendor.f(common_vendor.unref(couponsData), (item, index, i0) => { + return common_vendor.e({ + a: item.status === 1 && headerindex.value === 1 && item.couponName + }, item.status === 1 && headerindex.value === 1 && item.couponName ? common_vendor.e({ + b: item.couponName === "拉新洗车券" + }, item.couponName === "拉新洗车券" ? {} : {}, { + c: item.couponName === "拉新洗车券" + }, item.couponName === "拉新洗车券" ? {} : {}, { + d: item.couponName === "停车场优惠卷" + }, item.couponName === "停车场优惠卷" ? {} : {}, { + e: item.couponName === "停车场优惠卷" + }, item.couponName === "停车场优惠卷" ? {} : {}, { + f: item.couponName === "拉新折扣券" + }, item.couponName === "拉新折扣券" ? {} : {}, { + g: item.couponName === "拉新折扣券" + }, item.couponName === "拉新折扣券" ? {} : {}, { + h: common_vendor.t(item.couponName), + i: common_vendor.t(item.endTime), + j: common_vendor.t(item.rule), + k: common_vendor.t(item.freeTime), + l: common_vendor.t(item.freeTime), + m: couponsIndex.value === index ? 1 : "" + }) : {}, { + n: item.status === 0 && headerindex.value === 2 + }, item.status === 0 && headerindex.value === 2 ? common_vendor.e({ + o: item.couponName === "拉新洗车券" + }, item.couponName === "拉新洗车券" ? {} : {}, { + p: item.couponName === "拉新洗车券" + }, item.couponName === "拉新洗车券" ? {} : {}, { + q: item.couponName === "停车场优惠卷" + }, item.couponName === "停车场优惠卷" ? {} : {}, { + r: item.couponName === "停车场优惠卷" + }, item.couponName === "停车场优惠卷" ? {} : {}, { + s: common_vendor.t(item.couponName), + t: common_vendor.t(item.endTime), + v: common_vendor.t(item.rule), + w: item.status === 2 ? 1 : "", + x: item.status === 0 ? 1 : "" + }) : {}, { + y: item.id, + z: common_vendor.o(($event) => checkCoupons(index), item.id) + }); + }), + c: headerindex.value === 1 && common_vendor.unref(isShow) === 3 + }, headerindex.value === 1 && common_vendor.unref(isShow) === 3 ? {} : {}, { + d: headerindex.value === 2 && common_vendor.unref(isShowCoupons) === 0 + }, headerindex.value === 2 && common_vendor.unref(isShowCoupons) === 0 ? {} : {}, { + e: common_vendor.t(common_vendor.unref(couponsData)[couponsIndex.value].rule), + f: common_vendor.t(common_vendor.unref(couponsData)[couponsIndex.value].freeTime), + g: common_vendor.t(common_vendor.unref(couponsData)[couponsIndex.value].amount), + h: common_vendor.o(goPlays), + i: ccc.value === 1 + }, ccc.value === 1 ? { + j: common_vendor.o(_ctx.cloSe), + k: common_vendor.o(_ctx.oks), + l: common_vendor.p({ + titleMsg: _ctx.titleMsg + }) + } : {}); + }; + } +}; +const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/carwashingThree/pages/payCoupons/payCoupons.vue"]]); +wx.createPage(MiniProgramPage); diff --git a/unpackage/dist/dev/mp-weixin/pages/payCoupons/payCoupons.json b/unpackage/dist/dev/mp-weixin/pages/payCoupons/payCoupons.json new file mode 100644 index 0000000..7fe3cfc --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/pages/payCoupons/payCoupons.json @@ -0,0 +1,6 @@ +{ + "navigationBarTitleText": "", + "usingComponents": { + "windows": "../../components/windows/windows" + } +} \ No newline at end of file diff --git a/unpackage/dist/dev/mp-weixin/pages/payCoupons/payCoupons.wxml b/unpackage/dist/dev/mp-weixin/pages/payCoupons/payCoupons.wxml new file mode 100644 index 0000000..1a976fb --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/pages/payCoupons/payCoupons.wxml @@ -0,0 +1 @@ + 拉新券使用 拉新券停车券拉新折扣券{{item.h}}{{item.i}}{{item.j}}({{item.k}}分钟) {{item.l}}分钟 拉新券停车券{{item.s}} 有效期:{{item.t}}{{item.v}} 暂无数据 暂无数据 {{e}}可洗车{{f}}分钟 微信支付支付:{{g}} 去支付 \ No newline at end of file diff --git a/unpackage/dist/dev/mp-weixin/pages/payCoupons/payCoupons.wxss b/unpackage/dist/dev/mp-weixin/pages/payCoupons/payCoupons.wxss new file mode 100644 index 0000000..4dee4d2 --- /dev/null +++ b/unpackage/dist/dev/mp-weixin/pages/payCoupons/payCoupons.wxss @@ -0,0 +1,266 @@ +/** + * 这里是uni-app内置的常用样式变量 + * + * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量 + * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App + * + */ +/** + * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能 + * + * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件 + */ +/* 颜色变量 */ +/* 行为相关颜色 */ +/* 文字基本颜色 */ +/* 背景颜色 */ +/* 边框颜色 */ +/* 尺寸变量 */ +/* 文字尺寸 */ +/* 图片尺寸 */ +/* Border Radius */ +/* 水平间距 */ +/* 垂直间距 */ +/* 透明度 */ +/* 文章场景相关 */ +.charge { + width: 100%; + height: 100%; + position: absolute; + background-color: #f2f2f2; +} +.charge .tops { + width: 100%; + position: fixed; + height: 318rpx; + background-image: url("https://www.jiubaotongxue.love/image/demo56.png"); + background-size: 100% 100%; +} +.charge .tops .nav-img { + width: 64rpx; + height: 64rpx; + position: absolute; + top: 100rpx; + left: 20rpx; +} +.charge .tops .title { + width: 100%; + height: 50rpx; + line-height: 50rpx; + font-size: 36rpx; + position: absolute; + top: 108rpx; + left: 304rpx; +} +.charge .topss { + width: 100%; + height: 260rpx; +} +.charge .scrol { + width: 100%; + height: 60%; +} +.charge .scrol .big { + width: 100%; + height: 100%; +} +.charge .scrol .big .card { + width: 694rpx; + margin-left: 50%; + transform: translateX(-50%); +} +.charge .scrol .big .card .boxs { + width: 694rpx; + height: 208rpx; + margin-top: 20rpx; + border-radius: 20rpx 20rpx 20rpx 20rpx; + display: flex; + justify-content: space-between; + align-items: center; + position: relative; +} +.charge .scrol .big .card .boxs .boxs-left { + width: 234rpx; + height: 208rpx; + background-image: url("https://www.jiubaotongxue.love/image/demo43.png"); + background-size: 100% 100%; +} +.charge .scrol .big .card .boxs .boxs-left .boxs-left-top { + display: block; + width: 100%; + height: 66rpx; + line-height: 66rpx; + text-align: center; + margin-top: 46rpx; + font-size: 48rpx; + color: white; +} +.charge .scrol .big .card .boxs .boxs-left .boxs-left-tops { + display: block; + width: 100%; + height: 40rpx; + line-height: 40rpx; + text-align: center; + font-size: 28rpx; + color: white; + margin-top: 12rpx; +} +.charge .scrol .big .card .boxs .boxs-right { + width: 460rpx; + height: 208rpx; + background-image: url("https://www.jiubaotongxue.love/image/demo44.png"); + background-size: 100% 100%; + box-sizing: border-box; + padding-left: 28rpx; +} +.charge .scrol .big .card .boxs .boxs-right .boxs-right-top { + width: 100%; + height: 42rpx; + font-weight: 500; + font-size: 30rpx; + color: #242526; + line-height: 42rpx; + margin-top: 34rpx; + font-weight: 700; +} +.charge .scrol .big .card .boxs .boxs-right .boxs-right-tops { + width: 100%; + height: 34rpx; + font-weight: 400; + font-size: 24rpx; + color: rgba(36, 37, 38, 0.5); + line-height: 34rpx; + font-style: normal; + margin-top: 14rpx; +} +.charge .scrol .big .card .boxs .boxs-right .line { + width: 100%; + height: 2rpx; + border-top: 1rpx solid #E6E6E6; + margin-top: 16rpx; +} +.charge .scrol .big .card .boxs .boxs-right .boxs-right-bottom { + width: 100%; + height: 34rpx; + font-weight: 400; + font-size: 24rpx; + color: rgba(36, 37, 38, 0.5); + line-height: 34rpx; + margin-top: 16rpx; +} +.charge .scrol .big .card .boxs .boxs-Btn { + position: absolute; + right: 28rpx; + top: 28rpx; + width: 88rpx; + height: 48rpx; + text-align: center; + line-height: 48rpx; + font-size: 22rpx; + color: white; + background: linear-gradient(135deg, #FEB44C 0%, #FF8833 100%); + border-radius: 25rpx 25rpx 25rpx 25rpx; +} +.charge .scrol .big .card .boxs .boxs-Btns { + position: absolute; + right: 24rpx; + top: 24rpx; + width: 88rpx; + height: 88rpx; + border-radius: 50%; + background-size: 100% 100%; +} +.charge .scrol .big .card .boxs .boxsBtnsActive { + background-image: url("https://www.jiubaotongxue.love/image/demo45.png"); +} +.charge .scrol .big .card .boxs .boxsBtnsActives { + background-image: url("https://www.jiubaotongxue.love/image/demo46.png"); +} +.charge .scrol .big .card .couponsActive { + border: 1rpx solid #3f95ff; +} +.charge .charge-play { + width: 92%; + height: 200rpx; + margin-left: 50%; + transform: translateX(-50%); + border-radius: 20rpx 20rpx 20rpx 20rpx; +} +.charge .charge-play .charge-body-title { + width: 100%; + height: 80rpx; + box-sizing: border-box; + line-height: 80rpx; + padding-left: 20rpx; + font-size: 32rpx; + font-weight: 700; + color: #666; +} +.charge .charge-play .charge-play-icon { + width: 100%; + height: 110rpx; + margin-top: 15rpx; + display: flex; + justify-content: space-between; + align-items: center; + background-color: white; + border-radius: 20rpx 20rpx 20rpx 20rpx; +} +.charge .charge-play .charge-play-icon .icon-left { + width: 260rpx; + height: 90rpx; + display: flex; + justify-content: space-between; + align-items: center; + font-size: 28rp; +} +.charge .charge-play .charge-play-icon .icon-left .icon-img { + width: 60rpx; + height: 60rpx; + border-radius: 50%; + margin-left: 30rpx; +} +.charge .charge-play .charge-play-icon .icon-right { + width: 44rpx; + height: 44rpx; + border-radius: 50%; + border: 1rpx solid #666; + margin-right: 50rpx; +} +.charge .charge-play .charge-play-icon .icon-active { + border: none; + background-size: 100% 100%; + background-image: url("https://www.jiubaotongxue.love/image/xuanzhong.png"); +} +.charge .charge-btnPlay { + position: fixed; + bottom: 0rpx; + width: 100%; + height: 140rpx; + background-color: white; + line-height: 140rpx; + color: white; + display: flex; + justify-content: space-between; + box-sizing: border-box; + padding-left: 30rpx; +} +.charge .charge-btnPlay .charge-btnPlay-left { + color: black; + font-size: 30rpx; +} +.charge .charge-btnPlay .charge-btnPlay-left .pricess { + font-size: 40rpx; + color: #FF7733; +} +.charge .charge-btnPlay .plays { + width: 280rpx; + height: 96rpx; + background: linear-gradient(135deg, #4D97FF 0%, #3377FF 100%), linear-gradient(276deg, #1C9FF7 0%, #1275F7 100%); + box-shadow: 0rpx 8rpx 18rpx 0rpx rgba(5, 128, 255, 0.2); + border-radius: 50rpx; + text-align: center; + line-height: 96rpx; + margin-right: 30rpx; + margin-top: 20rpx; +} \ No newline at end of file diff --git a/unpackage/dist/dev/mp-weixin/project.private.config.json b/unpackage/dist/dev/mp-weixin/project.private.config.json index 36595b8..bfae202 100644 --- a/unpackage/dist/dev/mp-weixin/project.private.config.json +++ b/unpackage/dist/dev/mp-weixin/project.private.config.json @@ -7,6 +7,13 @@ "condition": { "miniprogram": { "list": [ + { + "name": "", + "pathName": "pages/payCoupons/payCoupons", + "query": "", + "launchMode": "default", + "scene": null + }, { "name": "", "pathName": "pages/secondaryCard/secondaryCard", diff --git a/unpackage/dist/dev/mp-weixin/stor/Coupons/coupons.js b/unpackage/dist/dev/mp-weixin/stor/Coupons/coupons.js index 01b2d50..87cd6a0 100644 --- a/unpackage/dist/dev/mp-weixin/stor/Coupons/coupons.js +++ b/unpackage/dist/dev/mp-weixin/stor/Coupons/coupons.js @@ -1,6 +1,7 @@ "use strict"; const common_vendor = require("../../common/vendor.js"); const api_api = require("../../api/api.js"); +const common_baseurl = require("../../common/baseurl.js"); const coupons = common_vendor.defineStore("coupons", () => { const couponsData = common_vendor.ref([]); const ups = common_vendor.ref([]); @@ -10,6 +11,8 @@ const coupons = common_vendor.defineStore("coupons", () => { const isShow = common_vendor.ref(); const que = common_vendor.ref(0); const id = common_vendor.ref(); + const p = common_vendor.ref(0); + const orderid = common_vendor.ref(); const getcouponsData = async () => { couponsData.value = await api_api.getCouponList({ phoneNumber: common_vendor.index.getStorageSync("phoneNumber") @@ -72,15 +75,22 @@ const coupons = common_vendor.defineStore("coupons", () => { common_vendor.index.setStorageSync("mid", mid); console.log(mid); } - api_api.getShopid({ - mid: common_vendor.index.getStorageSync("mid"), - phone: common_vendor.index.getStorageSync("phoneNumber") - }).then((res) => { - console.log(res); - console.log(res.data.networkId); - id.value = res.data.networkId; - que.value = 1; - }); + console.log(resDats.value); + if (resDats.value.amount > 0) { + common_vendor.index.navigateTo({ + url: "/pages/payCoupons/payCoupons" + }); + } else { + api_api.getShopid({ + mid: common_vendor.index.getStorageSync("mid"), + phone: common_vendor.index.getStorageSync("phoneNumber") + }).then((res) => { + console.log(res); + console.log(res.data.networkId); + id.value = res.data.networkId; + que.value = 1; + }); + } } }; const scanQrcode = (data) => { @@ -126,7 +136,9 @@ const coupons = common_vendor.defineStore("coupons", () => { common_vendor.index.setStorageSync("orderid", res5); common_vendor.index.setStorageSync("msg", "拉新券"); await api_api.getTimeOrder({ - phoneNumber: common_vendor.index.getStorageSync("phoneNumber"), + phoneNumber: common_vendor.index.getStorageSync( + "phoneNumber" + ), amount: 0, goodsId: resDats.value.id, goodsType: 3, @@ -135,7 +147,7 @@ const coupons = common_vendor.defineStore("coupons", () => { payType: 4, // deviceId: common_vendor.index.getStorageSync("mid"), - orderId: orderid.value + orderId: res5 }); common_vendor.index.redirectTo({ url: "/pages/complete/complete" @@ -166,6 +178,145 @@ const coupons = common_vendor.defineStore("coupons", () => { } }); }; + const wxPlay = async (datas) => { + console.log(datas); + if (!common_vendor.index.getStorageSync("phoneNumber")) { + common_vendor.index.showToast({ + icon: "none", + title: "账号未登录,请先登录", + duration: 1e3 + }); + return; + } + if (p.value == 1) { + return; + } + p.value = 1; + const res = await api_api.getTimeStamps(); + orderid.value = res; + if (res === "机器正在工作") { + common_vendor.index.showToast({ + icon: "none", + title: `${res}` + }); + p.value = 0; + } else { + console.log("out_trade_no", res); + console.log("这是订单号" + res); + const res1 = await api_api.getWxPlay({ + appId: common_baseurl.appid, + phone: common_vendor.index.getStorageSync("phoneNumber"), + openId: common_vendor.index.getStorageSync("openid"), + out_trade_no: res, + amount: datas.amount, + description: "拉新券洗车", + shopId: datas.id, + machineId: datas.networkId + }); + console.log(res1); + common_vendor.index.requestPayment({ + provider: "wxpay", + timeStamp: res1.timeStamp, + nonceStr: res1.nonceStr, + package: res1.package, + signType: res1.signType, + paySign: res1.paySign, + //付款成功进入执行启动设备 + success: async (res2) => { + console.log("用户付款成功", res2); + const res4 = await api_api.start({ + mid: common_vendor.index.getStorageSync("mid"), + price: 100, + time: datas.freeTime * 60, + description: "拉新券洗车", + orderId: orderid.value, + phone: common_vendor.index.getStorageSync("phoneNumber"), + openId: common_vendor.index.getStorageSync("openid") + }); + console.log(res4); + if (res4.code == 200 || res4.code == 0) { + common_vendor.index.showToast({ + icon: "none", + title: "启动设备成功", + duration: 1e3, + success: async (res3) => { + p.value = 0; + common_vendor.index.setStorageSync( + "orderid", + orderid.value + ); + common_vendor.index.setStorageSync("msg", "拉新券洗车"); + await api_api.getTimeOrder({ + phoneNumber: common_vendor.index.getStorageSync("phoneNumber"), + amount: datas.amount, + goodsId: datas.id, + goodsType: 3, + //洗车订单 + networkId: datas.networkId, + payType: 4, + //微信支付, + deviceId: common_vendor.index.getStorageSync("mid"), + orderId: orderid.value + }); + common_vendor.index.redirectTo({ + url: "/pages/complete/complete" + }); + const qaq = await api_api.getTincheCoupons({ + phoneNumber: common_vendor.index.getStorageSync("phoneNumber"), + oderId: orderid.value + }); + common_vendor.index.showToast({ + icon: "none", + title: `${qaq.msg}` + }); + const currentDate = /* @__PURE__ */ new Date(); + const year = currentDate.getFullYear(); + const month = String(currentDate.getMonth() + 1).padStart(2, "0"); + const day = String(currentDate.getDate()).padStart(2, "0"); + const hours = String(currentDate.getHours()).padStart(2, "0"); + const minutes = String(currentDate.getMinutes()).padStart(2, "0"); + const seconds = String(currentDate.getSeconds()).padStart(2, "0"); + const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; + const qaq1 = await getExcellent({ + time: formattedDate, + networkId: datas.networkId + }); + console.log(qaq1); + } + }); + } else { + console.log(res4); + common_vendor.index.showToast({ + icon: "none", + title: `请在我的页面联系客服解决`, + duration: 1200, + success: (res3) => { + p.value = 0; + common_vendor.index.setStorageSync( + "orderid", + orderid.value + ); + common_vendor.index.setStorageSync("msg", "拉新券洗车"); + } + }); + } + }, + //付款失败 提示原因 + fail: (err) => { + p.value = 0; + console.log("用户付款失败", err); + if (err) { + common_vendor.index.showToast({ + title: "用户付款失败", + icon: "none", + duration: 1e3 + }); + } + } + }); + } + p.value = 0; + }; return { couponsData, getcouponsData, @@ -175,7 +326,8 @@ const coupons = common_vendor.defineStore("coupons", () => { quexio, goStar, isShowCoupons, - isShow + isShow, + wxPlay }; }); exports.coupons = coupons;