From 4e6414d8c8b1fefafaf95cf0241c17942b4014e7 Mon Sep 17 00:00:00 2001 From: fhysy <1149505133@qq.com> Date: Fri, 7 Mar 2025 14:24:56 +0800 Subject: [PATCH] =?UTF-8?q?refactor(order):=20=E4=BC=98=E5=8C=96=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD=20-=20materialEdi?= =?UTF-8?q?t=20=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E5=BC=B9=E7=AA=97,=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3=20-=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20order/detail=20=E9=A1=B5=E9=9D=A2=E5=B8=83=E5=B1=80=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8E=BB=E6=94=AF=E4=BB=98=E6=8C=89=E9=92=AE?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0h5=E8=8E=B7=E5=8F=96code=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=88=E6=9C=AA=E5=AE=8C=E5=96=84=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E6=9C=AA=E5=AE=8C=E6=88=90=EF=BC=89=20-=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20product/detail=20=E9=A1=B5=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=AB=8B=E5=8D=B3=E8=B4=AD=E4=B9=B0=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E6=A0=B7=E5=BC=8F=20-=20=E5=9C=A8=20tabBar/order=20?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0=E9=BB=98=E8=AE=A4=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=AF=A6=E6=83=85=E8=B7=B3=E8=BD=AC=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/api/module/orderApi.js | 4 +- pages/fun/materialEdit.vue | 64 ++++++++++--------------- pages/order/detail.vue | 88 +++++++++++++++++++++++++++++++++++ pages/product/detail.vue | 2 +- pages/tabBar/order.vue | 2 +- 5 files changed, 116 insertions(+), 44 deletions(-) diff --git a/common/api/module/orderApi.js b/common/api/module/orderApi.js index 628c3e0..322502e 100644 --- a/common/api/module/orderApi.js +++ b/common/api/module/orderApi.js @@ -112,9 +112,9 @@ export default { }) }, // 提交商品素材列表(完成) - mallMaterialCommit(orderId,productId){ + mallMaterialCommit(orderItemId){ return new Promise((resolve, reject) => { - request.put('/mall/material/commit/' + orderId + '/' + productId) + request.put('/mall/material/commit/' + orderItemId ) .then((res) =>{ resolve(res); }).catch(err =>{ diff --git a/pages/fun/materialEdit.vue b/pages/fun/materialEdit.vue index 06d434b..ca5ab1d 100644 --- a/pages/fun/materialEdit.vue +++ b/pages/fun/materialEdit.vue @@ -21,7 +21,7 @@ - + {{ item.attrValue ? '重新上传' : '上传图片' }} @@ -33,7 +33,7 @@ {{ shortenFileName(item.fileName,20) || '已上传音频文件' }} - + {{ item.attrValue ? '重新上传' : '上传音频' }} @@ -48,7 +48,7 @@ {{ shortenFileName(item.fileName,20) || '已上传音频文件' }} - + {{ item.attrValue ? '重新上传' : '上传视频' }} @@ -64,8 +64,8 @@ - 暂存 - 提交 + 暂存 + 提交 @@ -381,7 +381,7 @@ current: 0 }); }, - async submitForm(status) { + verifyForm(status){ console.log('提交的表单数据:', this.materialTemplateList); if(!this.materialfrom.dictId && this.commitState === 'add'){ this.$refs.uToast.show({ @@ -398,6 +398,20 @@ }) return; } + let btnTitle = status==='draft' ?'暂存':'提交' + uni.showModal({ + title: '操作确认', + content: '是否要'+ btnTitle +'素材?', + success: (res) => { + if (res.confirm) { + this.submitForm(status) + } + } + }); + + }, + + async submitForm(status) { try { this.buttonLoading = true; // 这里添加实际的提交逻辑 @@ -411,6 +425,7 @@ }); this.buttonLoading = false; this.materialfrom.flowId = res.data.id; + this.getProductDetail(); }else{ res = await this.$api.orderApi.mallMaterialUpdateBatch(this.materialTemplateList); this.buttonLoading = false; @@ -427,47 +442,16 @@ delta: 1 }) } else { + this.buttonLoading = true; // 提交,调用完成接口 - let res1 = await this.$api.orderApi.mallMaterialCommit(this.orderId, this.productId); + let res1 = await this.$api.orderApi.mallMaterialCommit(this.orderItemId); if (res1.code === 200) { this.$refs.uToast.show({ title: '提交成功', type: 'success', }) } - - let res2 = await this.$api.orderApi.startWorkFlow({ - businessKey: this.materialfrom.flowId, - tableName: 'biz_order_material', - variables: { - entity: { - id: this.materialfrom.flowId, - status: 'waiting', - orderId: this.orderId, - productId: this.productId, - orderItemId: this.orderItemId - } - } - }); - if (res2.code === 200) { - this.$refs.uToast.show({ - title: '提交成功', - type: 'success', - }) - let res3 = await this.$api.orderApi.completeTask({ - messageType: ['1'], - taskId: res2.data.taskId, - taskVariables: { - entity: { - id: this.materialfrom.flowId, - status: 'waiting', - orderId: this.orderId, - productId: this.productId, - orderItemId: this.orderItemId - } - } - }); - } + this.buttonLoading = false; uni.navigateBack({ delta: 1 diff --git a/pages/order/detail.vue b/pages/order/detail.vue index eaebcdb..793f8ab 100644 --- a/pages/order/detail.vue +++ b/pages/order/detail.vue @@ -75,6 +75,10 @@ {{ orderInfo.orderNote || '无' }} + + + 去支付 + @@ -122,15 +126,38 @@ export default { mall_order_status:[], mall_source_type:[], mall_pay_type:[], + buttonLoading:false, + officialAccount:{ + appid:'wx80a304ffbfb30995', + appsecret:'ca307cfb6c94e8ac015e26cfd717a91c', + }, + code:'', + openId:'', } }, onLoad(option) { + this.getDictDataList('mall_order_status'); this.getDictDataList('mall_source_type'); this.getDictDataList('mall_pay_type'); console.log("option",option) this.orderId = option.id; this.getOrderDetail(option.id); + let res = uni.getStorageSync('openid'); + if (res.length == 2) { + this.openid = res[1].data; + }else{ + // #ifdef H5 + let code = this.getUrlCode('code') + if(code || this.code){ + this.code = code; + this.getOpenidAndUserinfo(code) + }else{ + console.log("当前网址",window.location.href) + this.getH5Code() + } + // #endif + } }, methods:{ // 获取订单详情 @@ -166,6 +193,45 @@ export default { current: '', // 当前显示图片的 http 链接 urls: [url] // 需要预览的图片 http 链接列表 }); + }, + handlePay() { + // 处理购买逻辑 + uni.showToast({ + title: '正在开发中...', + icon: 'none' + }) + // openid获取支付参数、调用支付 + + }, + getH5Code(){ + if(this.isWechat()) { + // 截取地址中的code,如果没有code就去微信授权,如果已经获取到code了就直接把code传给后台获取openId + window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+this.officialAccount.appid+'&redirect_uri=' + encodeURIComponent(window.location.href) + '&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect' + console.log("跳转授权页面") + // redirect_uri是授权成功后,跳转的url地址,微信会帮我们跳转到该链接,并且通过?的形式拼接code,这里需要用encodeURIComponent对链接进行处理。 + // 如果配置参数一一对应,那么此时已经通过回调地址刷新页面后,你就会再地址栏中看到code了。 + // http://127.0.0.1/pages/views/profile/login/login?code=001BWV4J1lRzz00H4J1J1vRE4J1BWV4q&state=1 + } + }, + getUrlCode(name){ + return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || null + }, + isWechat(){ + return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger"; + }, + getOpenidAndUserinfo(code){ + console.log("code换openid") + uni.request({ + url: 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='+this.officialAccount.appid+'&secret='+this.officialAccount.secret +'&grant_type=authorization_code&code='+code, + success: (res) => { + console.log('通过code获取openid和accessToken', res) + // if(res.data.code === 200) { + // // 登录成功,可以将用户信息和token保存到缓存中 + // uni.setStorageSync('userInfo', res.data.result.userInfo) + // uni.setStorageSync('token', res.data.result.token) + // } + } + }) } } } @@ -177,6 +243,7 @@ export default { min-height: 100vh; background-color: #f5f5f5; padding: 20rpx; + padding-bottom: 120rpx; } .info-card { @@ -302,5 +369,26 @@ export default { .status { color: #19be6b; } + +.btn-box { + display: flex; + justify-content: space-around; + align-items: center; + height: 120rpx; + position: fixed; + left: 0; + right: 0; + bottom: 0; + background: #fff; + z-index: 999; + button{ + width: 680rpx; + height: 85rpx; + border-radius: 10rpx; + display: flex; + justify-content: center; + align-items: center; + } +} diff --git a/pages/product/detail.vue b/pages/product/detail.vue index f339f34..9863eb3 100644 --- a/pages/product/detail.vue +++ b/pages/product/detail.vue @@ -32,7 +32,7 @@ - 立即购买 + 立即购买 diff --git a/pages/tabBar/order.vue b/pages/tabBar/order.vue index d8eb096..5402860 100644 --- a/pages/tabBar/order.vue +++ b/pages/tabBar/order.vue @@ -22,7 +22,7 @@ :up="upOption" > - + 订单号:{{item.orderSn}} {{getDictName('mall_order_status',item.orderStatus,'dictLabel')}}