From 3ce995eadbfd43adee36e0964a69703d8c85e213 Mon Sep 17 00:00:00 2001 From: pengda <1111@qq.com> Date: Wed, 16 Jul 2025 18:46:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E7=BB=91=E5=AE=9A=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/bindGoods.vue | 104 +++++++++++++++---------------------- src/router/index.js | 13 ++++- src/views/agent/siteAddFinally.vue | 86 ++++++++++++------------------ 3 files changed, 87 insertions(+), 116 deletions(-) diff --git a/src/components/bindGoods.vue b/src/components/bindGoods.vue index 5ee7319..c9e42d8 100644 --- a/src/components/bindGoods.vue +++ b/src/components/bindGoods.vue @@ -1,5 +1,5 @@ @@ -176,6 +155,9 @@ export default { .el-dialog{ min-height: 0; } +.el-empty{ + padding: 20px 0; +} .goods-list{ max-height: 400px; diff --git a/src/router/index.js b/src/router/index.js index c79e389..e8072d9 100755 --- a/src/router/index.js +++ b/src/router/index.js @@ -18,7 +18,7 @@ const blackHeaderList = [ '/franchise' ]; const blackFooterList = [ - '/', '/franchise', '/register', '/agent/siteAdd', '/agent/payInfoSetting','/agent/siteServiceEdit' + '/', '/franchise', '/register', '/agent/siteAdd', '/agent/payInfoSetting','/agent/siteServiceEdit','/agent/siteAddFinally','/agent/siteServiceAdd', ]; // const whiteSlideList = ['/', '/ui', // '/agent/siteList', @@ -129,6 +129,17 @@ const routes = [{ } }, { + path: '/agent/siteAddFinally', + name: '添加站点-添加服务', + isFirst: true, + component: () => import( /* webpackChunkName: "siteList" */ '../views/agent/siteAddFinally.vue'), + meta: { + title: '添加服务', + breadcrumbParent: '添加站点', + // hideBreadcrumb: true // 一级页面不显示面包屑 + } + }, + { path: '/agent/siteServiceList', name: '服务列表', isFirst: true, diff --git a/src/views/agent/siteAddFinally.vue b/src/views/agent/siteAddFinally.vue index 1960c94..4f93203 100644 --- a/src/views/agent/siteAddFinally.vue +++ b/src/views/agent/siteAddFinally.vue @@ -75,12 +75,18 @@ -
- -
- 关联商品 -
-
+
重置 @@ -143,8 +149,7 @@ export default { this.$message.error('非法请求'); this.$router.push('/agent/siteAdd') } - this.initPddSdk2(this.$route.query.uid) - console.log('wwww') + this.loadPddSDK() }, mounted() { store.commit('SET_PAGETITLE', '添加服务'); @@ -156,66 +161,35 @@ export default { bindGoods(type){ this.bindData.uid = this.siteInfo.uid this.bindData.type = type - // if(this.siteInfo.sale_channel == 3){ - // const initData = this.initPddSdk2(this.$route.query.uid) - // this.bindData.type = initData.pageCode - // this.bindData.type = initData.pati - // } - // this.bindComponent = 'bindGoods' + this.bindComponent = 'bindGoods' + }, + loadPddSDK(){ + const script = document.createElement('script'); + script.src = 'https://pfile.pddpic.com/galerie-go/open_sdk/pc.202102201613.js'; + document.head.appendChild(script); }, async getPddPageCode(uid){ - console.log('aaa') const that = this - that.$http('POST', '/agentnew/ajax_get_pdd_page_code', { + return await that.$http('POST', '/agentnew/ajax_get_pdd_page_code', { uid: uid, }, { headers: { 'Auth': this.token } }).then(response => { - console.log(response.data,'bbb') - that.bindData.pageCode = response.data return response.data }).catch(error => { console.error(error, 'error') }) }, - async loadPddSk(pageCode){ - console.log('ccc',pageCode) - const script = document.createElement('script'); - script.src = 'https://pfile.pddpic.com/galerie-go/open_sdk/pc.202102201613.js'; - script.onload = () => { - window.PDD_OPEN_init({ - code: pageCode - // 对于获取 code 接口或未登录态,可不传:PDD_OPEN_init({}, function () { ... }) - }).then(function () { - console.log('ddd') - // 初始化已完成 - window.PDD_OPEN_getPati().then( - function (pati) { - console.log(pati) - // 使用 pati - }).catch(error => console.log(error)) - }) - }; - script.onerror = () => { - console.log('errpr') - console.error('拼多多 SDK 加载失败'); - }; - document.head.appendChild(script); - }, - async initPddSdk2(uid) { - const that = this - try { - const pageCode = await that.getPddPageCode(uid) - // await that.loadPddSk(pageCode) - console.log(pageCode,'eee') - // console.log(that.bindData.pageCode,'bbb') - // that.bindData.pati = await that.loadPddSk(that.bindData.pageCode) - // console.log('aaa') - - } catch (e) { - console.log(e) + async initPddParam(uid) { + if (typeof window.PDD_OPEN_init === 'function') { + this.bindData.pageCode = await this.getPddPageCode(uid) + + await window.PDD_OPEN_init({code: this.bindData.pageCode}) + this.bindData.pati = await window.PDD_OPEN_getPati() + } else { + console.error('PDD_OPEN_init 不存在,SDK 未正确加载'); } }, handleBind(data){ @@ -256,6 +230,10 @@ export default { that.siteInfo = response.data.siteinfo that.serviceAddList = response.data.service_add_list store.commit('SET_BREADRIGHTTEXT', that.siteInfo.short_name); + //拼多多初始化 + if(this.siteInfo.sale_channel == 3){ + this.initPddParam(this.$route.query.uid) + } }) }).catch(error => { console.error(error, 'error')