From 8084522158f21c1ada6fad2e6adcf83d8d073726 Mon Sep 17 00:00:00 2001 From: zmj <1493694146@qq.com> Date: Mon, 29 Apr 2024 23:05:04 +0800 Subject: [PATCH] add --- App.vue | 21 +- api/user.js | 7 + pages/gather/gather.vue | 18 +- pages/index/index.vue | 46 +- pages/index/subnvue/concat.nvue | 31 +- pages/store/settled/index.vue | 1854 ++++++++++++++++++++++++++++++- utils/uniMP.js | 244 ++-- utils/uniMPevent.js | 23 +- 8 files changed, 2051 insertions(+), 193 deletions(-) diff --git a/App.vue b/App.vue index 3705ce8..5f67ab3 100644 --- a/App.vue +++ b/App.vue @@ -13,6 +13,7 @@ initEvent } from "@/utils/uniMPevent.js"; let jpushModule = uni.requireNativePlugin("JG-JPush"); + import uniMP from '@/utils/uniMP.js'; // #endif import { checkLogin @@ -130,9 +131,7 @@ let messageID = result.messageID let title = result.title let content = result.content - let extras = result.extras - - console.log("通知", result) + let extras = result.extras.type if (result.extras.type == 'ORDER_CREATE' && result.extras.mp3.length > 0) { if (result.extras.mp3[0] == '微信') this.audioTeam.push('/static/audio/wechat.MP3') @@ -166,9 +165,19 @@ } // 点击事件 if (notificationEventType == 'notificationOpened') { - uni.navigateTo({ - url: result.extras.route - }) + if (result.extras.type == 2) { + let data = result.extras.group_data + data.type = 2 + uniMP.loadAppletMP(data) + + } else { + uni.navigateTo({ + url: result.extras.route + }) + + } + + } }) diff --git a/api/user.js b/api/user.js index 585f6b6..d0119f2 100644 --- a/api/user.js +++ b/api/user.js @@ -270,6 +270,13 @@ export function extractCash(data) { export function getAdminApplyAPI(merId, data) { return request.get(`admin/${merId}/apply`, data); } + +/** + * 新商户 + */ +export function isNewMer(uid, mer_id, data) { + return request.post(`auth/guide/${uid}/${mer_id}`, data); +} /** * 提现银行/提现最低金额 * diff --git a/pages/gather/gather.vue b/pages/gather/gather.vue index f7c86fa..c73835d 100644 --- a/pages/gather/gather.vue +++ b/pages/gather/gather.vue @@ -176,7 +176,7 @@ - + jiaowoanjhsd @@ -356,6 +356,17 @@ uni.$emit('showLoading', false); }, methods: { + test() { + let data = { + "name": "供销助农平台", + "app_id": "__UNI__1EE148C", + "pic": "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/0fa43202312291702314919.png", + "url": "https://lihai001.oss-cn-chengdu.aliyuncs.com/attach/457d9202404291733397921.wgt", + "version": "1.4.5" + } + uniMP.loadAppletMP(data) + + }, openDiver() { this.subNVue.show('zoom-out', 300) uni.$emit('diverGatherEmit', this.elInfo); @@ -440,7 +451,7 @@ this.initMenu(); this.showControllerAllLet(); }).catch(e => { - console.log(e); + // console.log(e); }) }, // 根据类型来判断是否显示 @@ -466,7 +477,7 @@ }) // if() if (uni.getStorageSync('is_new_user') && !now.length) now[0] = all[0]; - console.log(all, now) + // console.log(all, now) this.AllMenuList = all; this.nowMenuList = now; @@ -498,7 +509,6 @@ }, getUniMp(data) { let that = this; - // #ifdef APP-PLUS if (data.version) return uniMP.loadAppletMP(data); else switch (data.type) { diff --git a/pages/index/index.vue b/pages/index/index.vue index 2927ced..c206e70 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -276,7 +276,8 @@ var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px'; let app = getApp(); import { - getUserInfo + getUserInfo, + isNewMer } from '@/api/user.js'; import { getDiy, @@ -597,9 +598,16 @@ }, // #endif onLoad(options) { - // #ifdef APP this.subNVue = uni.getSubNVueById('concatIndex') + uni.$on('diverIndexSubEmit', function(data) { + that.subNVue.hide('slide-out-right', 300) + setTimeout(() => { + uni.switchTab({ + url: '/pages/gather/gather' + }) + }, 400) + }) // #endif let that = this @@ -626,22 +634,27 @@ }, onShow() { let that = this; - if (this.diverFlag && uni.getStorageSync('is_new_user')) { - setTimeout(() => { - that.openDiver() - that.diverFlag = false - }, 500) - uni.$on('diverIndexSubEmit', function(data) { - console.log("收到关闭通知") - that.subNVue.hide('slide-out-right', 300) - setTimeout(() => { - uni.switchTab({ - url: '/pages/gather/gather' - }) - }, 400) - + // console.log() + if (this.$store.state.app.userInfo.service?.mer_id) { + isNewMer(this.$store.state.app.userInfo.uid, this.$store.state.app.userInfo.service?.mer_id).then(res => { + if (res.data == 'true') { + this.openDiver() + } }) } + // if (this.$store.state.app.userInfo) { + // console.log(this.$store.state.app.userInfo.service?.mer_id, 'sdsd') + + // } + // isNewMer(this.$store) + + // if (this.diverFlag && uni.getStorageSync('is_new_user')) { + // setTimeout(() => { + // that.openDiver() + // that.diverFlag = false + // }, 500) + + // } that.isIntegral = uni.getStorageSync('isIntegral') // #ifdef APP-PLUS if (that.appUpdate.openUpgrade == '1') { @@ -685,6 +698,7 @@ }, 50) // #endif }, + methods: { openDiver() { this.subNVue.show('slide-in-left', 300) diff --git a/pages/index/subnvue/concat.nvue b/pages/index/subnvue/concat.nvue index ff2eecc..4dac274 100644 --- a/pages/index/subnvue/concat.nvue +++ b/pages/index/subnvue/concat.nvue @@ -6,39 +6,19 @@ 下一步(1/4) - - + 点击生产页面,进入办公助手 - - - - 点击生产页面,进入办公助手 - - - - + - - - - - + 工作台 - - - 工作台 - - - - - - + @@ -150,6 +130,9 @@ .pointe2 { position: absolute; + left: 420rpx; + transform: translateX(-50%); + /* left: 150rpx; */ } .tras { diff --git a/pages/store/settled/index.vue b/pages/store/settled/index.vue index ba62e3b..4862f3e 100644 --- a/pages/store/settled/index.vue +++ b/pages/store/settled/index.vue @@ -1,7 +1,7 @@ - + + + + + + + + 商家入驻 + + + + + + + + + + + + 商家入驻 + + + + + + + + + + + + + 申请记录 + + + + 商家入驻 + + + 商户名称 + + + + + + + + + 商户分类 + + + + + + + + + + + + + 店铺类型 + ? + + + + + + + + + + + + + + 店铺所在地 + + + {{(business_name == '' || business_name.length == 5)?'请选择商圈':business_name}} + + + + + + + + + + + + + 公司性质 + + + + + + + + + + + 请上传营业执照 + (图片格式支持JPG、PNG、JPEG) + + + + + + + 上传图片 + + + + + + + + + 详细地址 + + + + + + + + + + 公司名称 + + + + + + + + 法人名称 + + + + + + + + 社会信用代码 + + + + + + + + 请上传行业相关其他资质证明图片 + (图片最多可上传10张,图片格式支持JPG、PNG、JPEG) + + + + + + + + 上传图片 + + + + + + + + 联系电话 + + + + + + 验证码 + + + {{ text }} + + + + + + 验证码 + + + + + + + + + + 已阅读并同意 + + 《入驻协议》 + + + + 提交申请 + + + + + + + + + + {{isType ? '店铺类型说明' : '商户入驻协议'}} + + + + + + + + + + + + {{detail.title}} + + + + + + + + + + + + + + 请仔细阅读协议 {{num}}秒后可提交 + 同意本协议 + + + + + + + + + + + + + + + + 恭喜,您的资料提交成功! + 预计15个工作日内审核完毕,平台客服会及时与您联系! + + 返回首页 + + + + + + + + \ No newline at end of file diff --git a/utils/uniMP.js b/utils/uniMP.js index 7ac5c78..64a7bb5 100644 --- a/utils/uniMP.js +++ b/utils/uniMP.js @@ -32,11 +32,8 @@ function compareVersions(version1, version2) { const loadMP = async (id) => { appid = id; let info = await getGXconfig(); - console.log('最新版本', info.data); - // return ; uni.$emit('showLoading', true, '初始化中'); mp.getUniMPVersion(id, (ret) => { - console.log('当前版本', ret); let flag; if (ENV == 'prod') { flag = false @@ -47,18 +44,18 @@ const loadMP = async (id) => { true) { let count = 0; timer = setInterval(() => { - if (count < 100 && count > 0) uni.$emit('showLoading', true, `初始化中... ${count}%`) + if (count < 100 && count > 0) uni.$emit('showLoading', true, + `初始化中... ${count}%`) else uni.$emit('showLoading', true, `初始化中... 99%`) }, 200) let downloadTask = uni.downloadFile({ url: info.data.version_info?.dow_url, success(res) { wgtFile = res.tempFilePath; - console.log('初始化完成', wgtFile); - setTimeout(()=>{ - installMP(); - clearInterval(timer); - timer = null; + setTimeout(() => { + installMP(); + clearInterval(timer); + timer = null; }, 700) }, fail(res) { @@ -83,7 +80,7 @@ const loadMP = async (id) => { //加载商城小程序 const loadMPx = async (id) => { - + appid = id; let info = await miniapp(); console.log('最新版本', info.data); @@ -103,7 +100,8 @@ const loadMPx = async (id) => { true) { let count = 0; timer = setInterval(() => { - if (count < 100 && count > 0) uni.$emit('showLoading', true, `初始化中... ${count}%`) + if (count < 100 && count > 0) uni.$emit('showLoading', true, + `初始化中... ${count}%`) else uni.$emit('showLoading', true, `初始化中... 99%`) }, 200) @@ -112,10 +110,10 @@ const loadMPx = async (id) => { success(res) { wgtFile = res.tempFilePath; console.log('初始化完成', wgtFile); - setTimeout(()=>{ - installMP(); - clearInterval(timer); - timer = null; + setTimeout(() => { + installMP(); + clearInterval(timer); + timer = null; }, 700) }, fail(res) { @@ -125,7 +123,6 @@ const loadMPx = async (id) => { } }); downloadTask.onProgressUpdate((res) => { - // console.log('初始化进度' + res.progress); if (res.progress > count) count += 10; if (count >= 90) { clearInterval(timer); @@ -141,63 +138,65 @@ const loadMPx = async (id) => { // 按信息接口加载小程序 const loadMPurl = async (e) => { appid = e.id; - let FURL = e.url; + let FURL = e.url; uni.$emit('showLoading', true, `初始化中...`) - uni.request({ - url: FURL, - method: 'GET', - success: (fileInfo) => { - mp.getUniMPVersion(appid, (ret) => { - console.log('当前版本', ret); - let flag; - if (ENV == 'prod') { - flag = false - } else { - flag = true - } - if (0 != ret.code || compareVersions(fileInfo.data?.data?.version, ret.versionInfo.name) == 1 || flag == - true) { - let count = 0; - timer = setInterval(() => { - if (count < 100 && count > 0) uni.$emit('showLoading', true, `初始化中... ${count}%`) - else uni.$emit('showLoading', true, `初始化中... 99%`) - }, 200) - let downloadTask = uni.downloadFile({ - url: fileInfo.data?.data?.down_url, - success(res) { - wgtFile = res.tempFilePath; - console.log('初始化完成', wgtFile); - setTimeout(()=>{ - installMP(); - clearInterval(timer); - timer = null; - }, 700) - }, - fail(res) { - clearInterval(timer); - timer = null; - uni.hideLoading(); - } - }); - downloadTask.onProgressUpdate((res) => { - // console.log('初始化进度' + res.progress); - if (res.progress > count) count += 10; - if (count >= 90) { - clearInterval(timer); - timer = null; - } - }); - } else { - open() - } - }); - - }, - fail:(err)=> { - console.log('错误:', err); - } - }) - + uni.request({ + url: FURL, + method: 'GET', + success: (fileInfo) => { + mp.getUniMPVersion(appid, (ret) => { + console.log('当前版本', ret); + let flag; + if (ENV == 'prod') { + flag = false + } else { + flag = true + } + if (0 != ret.code || compareVersions(fileInfo.data?.data?.version, ret + .versionInfo.name) == 1 || flag == + true) { + let count = 0; + timer = setInterval(() => { + if (count < 100 && count > 0) uni.$emit('showLoading', true, + `初始化中... ${count}%`) + else uni.$emit('showLoading', true, `初始化中... 99%`) + }, 200) + let downloadTask = uni.downloadFile({ + url: fileInfo.data?.data?.down_url, + success(res) { + wgtFile = res.tempFilePath; + console.log('初始化完成', wgtFile); + setTimeout(() => { + installMP(); + clearInterval(timer); + timer = null; + }, 700) + }, + fail(res) { + clearInterval(timer); + timer = null; + uni.hideLoading(); + } + }); + downloadTask.onProgressUpdate((res) => { + // console.log('初始化进度' + res.progress); + if (res.progress > count) count += 10; + if (count >= 90) { + clearInterval(timer); + timer = null; + } + }); + } else { + open() + } + }); + + }, + fail: (err) => { + console.log('错误:', err); + } + }) + }; // 商城配置的小程序 @@ -216,7 +215,8 @@ const loadAppletMP = async (data) => { true) { let count = 0; timer = setInterval(() => { - if (count < 100 && count > 0) uni.$emit('showLoading', true, `初始化中... ${count}%`) + if (count < 100 && count > 0) uni.$emit('showLoading', true, + `初始化中... ${count}%`) else uni.$emit('showLoading', true, `初始化中... 99%`) }, 200) let downloadTask = uni.downloadFile({ @@ -224,10 +224,10 @@ const loadAppletMP = async (data) => { success(res) { wgtFile = res.tempFilePath; console.log('初始化完成', wgtFile); - setTimeout(()=>{ - installMP(); - clearInterval(timer); - timer = null; + setTimeout(() => { + installMP(data); + clearInterval(timer); + timer = null; }, 700) }, fail(res) { @@ -253,39 +253,38 @@ const loadAppletMP = async (data) => { // 按远程文件地址加载小程序 const loadMPdns = async (e) => { appid = e.id; - let FURL = e.url; + let FURL = e.url; uni.$emit('showLoading', true, `初始化中...`) - let count = 0; - timer = setInterval(() => { - if (count < 100 && count > 0) uni.$emit('showLoading', true, `初始化中... ${count}%`) - else uni.$emit('showLoading', true, `初始化中... 99%`) - }, 200) - let downloadTask = uni.downloadFile({ - url: FURL, - success(res) { - wgtFile = res.tempFilePath; - console.log('初始化完成', wgtFile); - setTimeout(()=>{ - installMP(); - clearInterval(timer); - timer = null; - }, 700) - }, - fail(res) { - clearInterval(timer); - timer = null; - uni.hideLoading(); - } - }); - downloadTask.onProgressUpdate((res) => { - // console.log('初始化进度' + res.progress); - if (res.progress > count) count += 10; - if (count >= 90) { - clearInterval(timer); - timer = null; - } - }); - + let count = 0; + timer = setInterval(() => { + if (count < 100 && count > 0) uni.$emit('showLoading', true, `初始化中... ${count}%`) + else uni.$emit('showLoading', true, `初始化中... 99%`) + }, 200) + let downloadTask = uni.downloadFile({ + url: FURL, + success(res) { + wgtFile = res.tempFilePath; + console.log('初始化完成', wgtFile); + setTimeout(() => { + installMP(); + clearInterval(timer); + timer = null; + }, 700) + }, + fail(res) { + clearInterval(timer); + timer = null; + uni.hideLoading(); + } + }); + downloadTask.onProgressUpdate((res) => { + if (res.progress > count) count += 10; + if (count >= 90) { + clearInterval(timer); + timer = null; + } + }); + }; // 小程序版本信息 @@ -298,19 +297,19 @@ const getVersion = (id) => { }) } // 初始化小程序 -const installMP = () => { +const installMP = (data) => { mp.getUniMPVersion(appid, (ret) => { - doInstallMP(); + doInstallMP(data); console.log('getUniMPVersion: ' + JSON.stringify(ret)); }); }; -const doInstallMP = () => { +const doInstallMP = (data) => { mp.installUniMP({ appid: appid, wgtFile: wgtFile }, (r) => { if (0 == r.code) { - open(); + open(data); } else { uni.hideLoading(); clearInterval(timer); @@ -326,7 +325,7 @@ const doInstallMP = () => { }; const open = (id = null) => { - uni.$emit('showLoading', false); + uni.$emit('showLoading', false); let token = uni.getStorageSync('LOGIN_STATUS_TOKEN'); if (!token) return uni.showToast({ icon: 'none', @@ -334,13 +333,12 @@ const open = (id = null) => { }) let avatar = store?.state?.userInfo?.avatar; mp.openUniMP({ - appid: id || appid, + appid: typeof(id) == 'object' ? appid : (id || appid), extraData: { uniMP: true, token: token, avatar: avatar, }, - // path: '/pages/index/index?unimp=true' }, (ret) => { uni.hideLoading(); if (0 != ret.code) { @@ -350,6 +348,16 @@ const open = (id = null) => { showCancel: false }); } + + if (id.type == 2) { + console.log("yaofasong1", appid) + mp.sendUniMPEvent(appid, 'tocustomlist', { + path: 'sdsd' + }, (ret) => { + console.log("开始发送消息") + }); + } + console.log('openUniMP: ' + JSON.stringify(ret)); }); } @@ -358,9 +366,9 @@ export default { loadMP, loadMPurl, loadMPx, - loadMPdns, + loadMPdns, installMP, - loadAppletMP, + loadAppletMP, doInstallMP, getVersion, open diff --git a/utils/uniMPevent.js b/utils/uniMPevent.js index 5f38d08..50efc13 100644 --- a/utils/uniMPevent.js +++ b/utils/uniMPevent.js @@ -4,10 +4,9 @@ import { test } from "@/utils/uniMPfunction.js" -export const initEvent = () => { +export const initEvent = (data) => { mp.onUniMPEventReceive(async (ret) => { - console.log('小程序事件: ', ret); - + console.log('小程序事件: ', data); // 用户如果没有注册商户 从小程序返回 入驻页面 if (ret.event == 'closeAppToOpenShop') { mp.closeUniMP(ret.fromAppid, (ret) => { @@ -34,20 +33,6 @@ export const initEvent = () => { console.log('获取定位'); let res = await uniMPgetLocation(); console.log(res); - // plus.geolocation.getCurrentPosition(function(position) { - // console.log('经度:' + position.coords.longitude); - // console.log('纬度:' + position.coords.latitude); - // // that.markers[1].latitude = position.coords.longitude; - // // that.markers[1].longitude = position.coords.longitude; - // mp.sendUniMPEvent( - // ret.fromAppid, - // 'getLocation', {...position.coords}, - // (ret) => { - // console.log('Host sendEvent: ' + JSON.stringify(ret)); - // }); - // }, function(error) { - // console.error('获取位置失败:', error.message); - // }, {provider:'gps'}); mp.sendUniMPEvent( ret.fromAppid, 'getLocation', { @@ -72,6 +57,10 @@ export const initEvent = () => { console.log('Host sendEvent: ' + JSON.stringify(ret)); }); } + + + + if (ret.event == 'log') { // console.log('2222222')