This commit is contained in:
zmj 2024-04-29 23:05:04 +08:00
parent 03b6683aac
commit 8084522158
8 changed files with 2051 additions and 193 deletions

21
App.vue
View File

@ -13,6 +13,7 @@
initEvent initEvent
} from "@/utils/uniMPevent.js"; } from "@/utils/uniMPevent.js";
let jpushModule = uni.requireNativePlugin("JG-JPush"); let jpushModule = uni.requireNativePlugin("JG-JPush");
import uniMP from '@/utils/uniMP.js';
// #endif // #endif
import { import {
checkLogin checkLogin
@ -130,9 +131,7 @@
let messageID = result.messageID let messageID = result.messageID
let title = result.title let title = result.title
let content = result.content let content = result.content
let extras = result.extras let extras = result.extras.type
console.log("通知", result)
if (result.extras.type == 'ORDER_CREATE' && result.extras.mp3.length > 0) { if (result.extras.type == 'ORDER_CREATE' && result.extras.mp3.length > 0) {
if (result.extras.mp3[0] == '微信') this.audioTeam.push('/static/audio/wechat.MP3') if (result.extras.mp3[0] == '微信') this.audioTeam.push('/static/audio/wechat.MP3')
@ -166,9 +165,19 @@
} }
// //
if (notificationEventType == 'notificationOpened') { if (notificationEventType == 'notificationOpened') {
uni.navigateTo({ if (result.extras.type == 2) {
url: result.extras.route let data = result.extras.group_data
}) data.type = 2
uniMP.loadAppletMP(data)
} else {
uni.navigateTo({
url: result.extras.route
})
}
} }
}) })

View File

@ -270,6 +270,13 @@ export function extractCash(data) {
export function getAdminApplyAPI(merId, data) { export function getAdminApplyAPI(merId, data) {
return request.get(`admin/${merId}/apply`, data); return request.get(`admin/${merId}/apply`, data);
} }
/**
* 新商户
*/
export function isNewMer(uid, mer_id, data) {
return request.post(`auth/guide/${uid}/${mer_id}`, data);
}
/** /**
* 提现银行/提现最低金额 * 提现银行/提现最低金额
* *

View File

@ -176,7 +176,7 @@
<view class="title-img"> <view class="title-img">
<image src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/807b8202403111125379295.webp" mode=""></image> <image src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/807b8202403111125379295.webp" mode=""></image>
</view> </view>
<button @click="test">jiaowoanjhsd</button>
<view class="business com special_work" v-if="jurisdiction == false"> <view class="business com special_work" v-if="jurisdiction == false">
<view class="content"> <view class="content">
<block v-if="nowMenuList.length > 0"> <block v-if="nowMenuList.length > 0">
@ -356,6 +356,17 @@
uni.$emit('showLoading', false); uni.$emit('showLoading', false);
}, },
methods: { 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() { openDiver() {
this.subNVue.show('zoom-out', 300) this.subNVue.show('zoom-out', 300)
uni.$emit('diverGatherEmit', this.elInfo); uni.$emit('diverGatherEmit', this.elInfo);
@ -440,7 +451,7 @@
this.initMenu(); this.initMenu();
this.showControllerAllLet(); this.showControllerAllLet();
}).catch(e => { }).catch(e => {
console.log(e); // console.log(e);
}) })
}, },
// //
@ -466,7 +477,7 @@
}) })
// if() // if()
if (uni.getStorageSync('is_new_user') && !now.length) now[0] = all[0]; if (uni.getStorageSync('is_new_user') && !now.length) now[0] = all[0];
console.log(all, now) // console.log(all, now)
this.AllMenuList = all; this.AllMenuList = all;
this.nowMenuList = now; this.nowMenuList = now;
@ -498,7 +509,6 @@
}, },
getUniMp(data) { getUniMp(data) {
let that = this; let that = this;
// #ifdef APP-PLUS // #ifdef APP-PLUS
if (data.version) return uniMP.loadAppletMP(data); if (data.version) return uniMP.loadAppletMP(data);
else switch (data.type) { else switch (data.type) {

View File

@ -276,7 +276,8 @@
var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px'; var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
let app = getApp(); let app = getApp();
import { import {
getUserInfo getUserInfo,
isNewMer
} from '@/api/user.js'; } from '@/api/user.js';
import { import {
getDiy, getDiy,
@ -597,9 +598,16 @@
}, },
// #endif // #endif
onLoad(options) { onLoad(options) {
// #ifdef APP // #ifdef APP
this.subNVue = uni.getSubNVueById('concatIndex') 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 // #endif
let that = this let that = this
@ -626,22 +634,27 @@
}, },
onShow() { onShow() {
let that = this; let that = this;
if (this.diverFlag && uni.getStorageSync('is_new_user')) { // console.log()
setTimeout(() => { if (this.$store.state.app.userInfo.service?.mer_id) {
that.openDiver() isNewMer(this.$store.state.app.userInfo.uid, this.$store.state.app.userInfo.service?.mer_id).then(res => {
that.diverFlag = false if (res.data == 'true') {
}, 500) this.openDiver()
uni.$on('diverIndexSubEmit', function(data) { }
console.log("收到关闭通知")
that.subNVue.hide('slide-out-right', 300)
setTimeout(() => {
uni.switchTab({
url: '/pages/gather/gather'
})
}, 400)
}) })
} }
// 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') that.isIntegral = uni.getStorageSync('isIntegral')
// #ifdef APP-PLUS // #ifdef APP-PLUS
if (that.appUpdate.openUpgrade == '1') { if (that.appUpdate.openUpgrade == '1') {
@ -685,6 +698,7 @@
}, 50) }, 50)
// #endif // #endif
}, },
methods: { methods: {
openDiver() { openDiver() {
this.subNVue.show('slide-in-left', 300) this.subNVue.show('slide-in-left', 300)

View File

@ -6,39 +6,19 @@
<view class="next-btn" :style="{top:(offsetY-250)+'px'}"> <view class="next-btn" :style="{top:(offsetY-250)+'px'}">
<text class="next-btn-text font" @click="next">下一步(1/4)</text> <text class="next-btn-text font" @click="next">下一步(1/4)</text>
</view> </view>
<view class="tips center" :style="{top:(offsetY-178)+'px'}">
<view class="tips center" v-if='isStore' :style="{top:(offsetY-178)+'px'}">
<view class="tras" :class="{act:isActive}"> <view class="tras" :class="{act:isActive}">
<text class="font" style="line-height: 106rpx;">点击生产页面,进入办公助手</text> <text class="font" style="line-height: 106rpx;">点击生产页面,进入办公助手</text>
</view> </view>
</view> </view>
<view style="position: absolute;" class="center" :style="{top:(offsetY-120)+'px'}">
<view class="tips" v-else :style="{top:(offsetY-178)+'px',left:(screenWidth/4-50)+'px'}">
<view class="tras" :class="{act:isActive}">
<text class="font" style="line-height: 106rpx;">点击生产页面,进入办公助手</text>
</view>
</view>
<view class="center" v-if="isStore" :style="{top:(offsetY-120)+'px'}">
<image src="/static/images/greenLine.png" style="width:35px;height: 60px;" mode=""></image> <image src="/static/images/greenLine.png" style="width:35px;height: 60px;" mode=""></image>
</view> </view>
<view v-else style="position: absolute;" :style="{top:(offsetY-120)+'px',left:(screenWidth/4+16)+'px'}"> <view class="tabbar2 center" :style="{top:(offsetY-68)+'px'}">
<image src="/static/images/greenLine.png" style="width:35px;height: 60px;" mode=""></image>
</view>
<view v-if='isStore' class="tabbar" :style="{top:(offsetY-68)+'px'}">
<image src="/static/images/fabu.png" class="tab-icon"></image> <image src="/static/images/fabu.png" class="tab-icon"></image>
<text class="te">工作台</text> <text class="te">工作台</text>
</view> </view>
<view v-else class="tabbar2" :style="{top:(offsetY-68)+'px',left:(screenWidth/4)+'px'}"> <view class="pointe2" :style="{top:(offsetY-58)+'px'}">
<image src="/static/images/fabu.png" class="tab-icon"></image>
<text class="te">工作台</text>
</view>
<view v-if='isStore' class="pointe" :style="{top:(offsetY-58)+'px'}">
<image src="/static/images/pointer.png" style="width: 254rpx;height: 254rpx;" mode=""></image>
</view>
<view v-else class="pointe2" :style="{top:(offsetY-58)+'px',left:(screenWidth/4)+'px'}">
<image src="/static/images/pointer.png" style="width: 254rpx;height: 254rpx;" mode=""></image> <image src="/static/images/pointer.png" style="width: 254rpx;height: 254rpx;" mode=""></image>
</view> </view>
</view> </view>
@ -150,6 +130,9 @@
.pointe2 { .pointe2 {
position: absolute; position: absolute;
left: 420rpx;
transform: translateX(-50%);
/* left: 150rpx; */
} }
.tras { .tras {

File diff suppressed because it is too large Load Diff

View File

@ -32,11 +32,8 @@ function compareVersions(version1, version2) {
const loadMP = async (id) => { const loadMP = async (id) => {
appid = id; appid = id;
let info = await getGXconfig(); let info = await getGXconfig();
console.log('最新版本', info.data);
// return ;
uni.$emit('showLoading', true, '初始化中'); uni.$emit('showLoading', true, '初始化中');
mp.getUniMPVersion(id, (ret) => { mp.getUniMPVersion(id, (ret) => {
console.log('当前版本', ret);
let flag; let flag;
if (ENV == 'prod') { if (ENV == 'prod') {
flag = false flag = false
@ -47,18 +44,18 @@ const loadMP = async (id) => {
true) { true) {
let count = 0; let count = 0;
timer = setInterval(() => { 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%`) else uni.$emit('showLoading', true, `初始化中... 99%`)
}, 200) }, 200)
let downloadTask = uni.downloadFile({ let downloadTask = uni.downloadFile({
url: info.data.version_info?.dow_url, url: info.data.version_info?.dow_url,
success(res) { success(res) {
wgtFile = res.tempFilePath; wgtFile = res.tempFilePath;
console.log('初始化完成', wgtFile); setTimeout(() => {
setTimeout(()=>{ installMP();
installMP(); clearInterval(timer);
clearInterval(timer); timer = null;
timer = null;
}, 700) }, 700)
}, },
fail(res) { fail(res) {
@ -83,7 +80,7 @@ const loadMP = async (id) => {
//加载商城小程序 //加载商城小程序
const loadMPx = async (id) => { const loadMPx = async (id) => {
appid = id; appid = id;
let info = await miniapp(); let info = await miniapp();
console.log('最新版本', info.data); console.log('最新版本', info.data);
@ -103,7 +100,8 @@ const loadMPx = async (id) => {
true) { true) {
let count = 0; let count = 0;
timer = setInterval(() => { 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%`) else uni.$emit('showLoading', true, `初始化中... 99%`)
}, 200) }, 200)
@ -112,10 +110,10 @@ const loadMPx = async (id) => {
success(res) { success(res) {
wgtFile = res.tempFilePath; wgtFile = res.tempFilePath;
console.log('初始化完成', wgtFile); console.log('初始化完成', wgtFile);
setTimeout(()=>{ setTimeout(() => {
installMP(); installMP();
clearInterval(timer); clearInterval(timer);
timer = null; timer = null;
}, 700) }, 700)
}, },
fail(res) { fail(res) {
@ -125,7 +123,6 @@ const loadMPx = async (id) => {
} }
}); });
downloadTask.onProgressUpdate((res) => { downloadTask.onProgressUpdate((res) => {
// console.log('初始化进度' + res.progress);
if (res.progress > count) count += 10; if (res.progress > count) count += 10;
if (count >= 90) { if (count >= 90) {
clearInterval(timer); clearInterval(timer);
@ -141,63 +138,65 @@ const loadMPx = async (id) => {
// 按信息接口加载小程序 // 按信息接口加载小程序
const loadMPurl = async (e) => { const loadMPurl = async (e) => {
appid = e.id; appid = e.id;
let FURL = e.url; let FURL = e.url;
uni.$emit('showLoading', true, `初始化中...`) uni.$emit('showLoading', true, `初始化中...`)
uni.request({ uni.request({
url: FURL, url: FURL,
method: 'GET', method: 'GET',
success: (fileInfo) => { success: (fileInfo) => {
mp.getUniMPVersion(appid, (ret) => { mp.getUniMPVersion(appid, (ret) => {
console.log('当前版本', ret); console.log('当前版本', ret);
let flag; let flag;
if (ENV == 'prod') { if (ENV == 'prod') {
flag = false flag = false
} else { } else {
flag = true flag = true
} }
if (0 != ret.code || compareVersions(fileInfo.data?.data?.version, ret.versionInfo.name) == 1 || flag == if (0 != ret.code || compareVersions(fileInfo.data?.data?.version, ret
true) { .versionInfo.name) == 1 || flag ==
let count = 0; true) {
timer = setInterval(() => { let count = 0;
if (count < 100 && count > 0) uni.$emit('showLoading', true, `初始化中... ${count}%`) timer = setInterval(() => {
else uni.$emit('showLoading', true, `初始化中... 99%`) if (count < 100 && count > 0) uni.$emit('showLoading', true,
}, 200) `初始化中... ${count}%`)
let downloadTask = uni.downloadFile({ else uni.$emit('showLoading', true, `初始化中... 99%`)
url: fileInfo.data?.data?.down_url, }, 200)
success(res) { let downloadTask = uni.downloadFile({
wgtFile = res.tempFilePath; url: fileInfo.data?.data?.down_url,
console.log('初始化完成', wgtFile); success(res) {
setTimeout(()=>{ wgtFile = res.tempFilePath;
installMP(); console.log('初始化完成', wgtFile);
clearInterval(timer); setTimeout(() => {
timer = null; installMP();
}, 700) clearInterval(timer);
}, timer = null;
fail(res) { }, 700)
clearInterval(timer); },
timer = null; fail(res) {
uni.hideLoading(); clearInterval(timer);
} timer = null;
}); uni.hideLoading();
downloadTask.onProgressUpdate((res) => { }
// console.log('初始化进度' + res.progress); });
if (res.progress > count) count += 10; downloadTask.onProgressUpdate((res) => {
if (count >= 90) { // console.log('初始化进度' + res.progress);
clearInterval(timer); if (res.progress > count) count += 10;
timer = null; if (count >= 90) {
} clearInterval(timer);
}); timer = null;
} else { }
open() });
} } else {
}); open()
}
}, });
fail:(err)=> {
console.log('错误:', err); },
} fail: (err) => {
}) console.log('错误:', err);
}
})
}; };
// 商城配置的小程序 // 商城配置的小程序
@ -216,7 +215,8 @@ const loadAppletMP = async (data) => {
true) { true) {
let count = 0; let count = 0;
timer = setInterval(() => { 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%`) else uni.$emit('showLoading', true, `初始化中... 99%`)
}, 200) }, 200)
let downloadTask = uni.downloadFile({ let downloadTask = uni.downloadFile({
@ -224,10 +224,10 @@ const loadAppletMP = async (data) => {
success(res) { success(res) {
wgtFile = res.tempFilePath; wgtFile = res.tempFilePath;
console.log('初始化完成', wgtFile); console.log('初始化完成', wgtFile);
setTimeout(()=>{ setTimeout(() => {
installMP(); installMP(data);
clearInterval(timer); clearInterval(timer);
timer = null; timer = null;
}, 700) }, 700)
}, },
fail(res) { fail(res) {
@ -253,39 +253,38 @@ const loadAppletMP = async (data) => {
// 按远程文件地址加载小程序 // 按远程文件地址加载小程序
const loadMPdns = async (e) => { const loadMPdns = async (e) => {
appid = e.id; appid = e.id;
let FURL = e.url; let FURL = e.url;
uni.$emit('showLoading', true, `初始化中...`) uni.$emit('showLoading', true, `初始化中...`)
let count = 0; let count = 0;
timer = setInterval(() => { 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%`) else uni.$emit('showLoading', true, `初始化中... 99%`)
}, 200) }, 200)
let downloadTask = uni.downloadFile({ let downloadTask = uni.downloadFile({
url: FURL, url: FURL,
success(res) { success(res) {
wgtFile = res.tempFilePath; wgtFile = res.tempFilePath;
console.log('初始化完成', wgtFile); console.log('初始化完成', wgtFile);
setTimeout(()=>{ setTimeout(() => {
installMP(); installMP();
clearInterval(timer); clearInterval(timer);
timer = null; timer = null;
}, 700) }, 700)
}, },
fail(res) { fail(res) {
clearInterval(timer); clearInterval(timer);
timer = null; timer = null;
uni.hideLoading(); uni.hideLoading();
} }
}); });
downloadTask.onProgressUpdate((res) => { downloadTask.onProgressUpdate((res) => {
// console.log('初始化进度' + res.progress); if (res.progress > count) count += 10;
if (res.progress > count) count += 10; if (count >= 90) {
if (count >= 90) { clearInterval(timer);
clearInterval(timer); timer = null;
timer = null; }
} });
});
}; };
// 小程序版本信息 // 小程序版本信息
@ -298,19 +297,19 @@ const getVersion = (id) => {
}) })
} }
// 初始化小程序 // 初始化小程序
const installMP = () => { const installMP = (data) => {
mp.getUniMPVersion(appid, (ret) => { mp.getUniMPVersion(appid, (ret) => {
doInstallMP(); doInstallMP(data);
console.log('getUniMPVersion: ' + JSON.stringify(ret)); console.log('getUniMPVersion: ' + JSON.stringify(ret));
}); });
}; };
const doInstallMP = () => { const doInstallMP = (data) => {
mp.installUniMP({ mp.installUniMP({
appid: appid, appid: appid,
wgtFile: wgtFile wgtFile: wgtFile
}, (r) => { }, (r) => {
if (0 == r.code) { if (0 == r.code) {
open(); open(data);
} else { } else {
uni.hideLoading(); uni.hideLoading();
clearInterval(timer); clearInterval(timer);
@ -326,7 +325,7 @@ const doInstallMP = () => {
}; };
const open = (id = null) => { const open = (id = null) => {
uni.$emit('showLoading', false); uni.$emit('showLoading', false);
let token = uni.getStorageSync('LOGIN_STATUS_TOKEN'); let token = uni.getStorageSync('LOGIN_STATUS_TOKEN');
if (!token) return uni.showToast({ if (!token) return uni.showToast({
icon: 'none', icon: 'none',
@ -334,13 +333,12 @@ const open = (id = null) => {
}) })
let avatar = store?.state?.userInfo?.avatar; let avatar = store?.state?.userInfo?.avatar;
mp.openUniMP({ mp.openUniMP({
appid: id || appid, appid: typeof(id) == 'object' ? appid : (id || appid),
extraData: { extraData: {
uniMP: true, uniMP: true,
token: token, token: token,
avatar: avatar, avatar: avatar,
}, },
// path: '/pages/index/index?unimp=true'
}, (ret) => { }, (ret) => {
uni.hideLoading(); uni.hideLoading();
if (0 != ret.code) { if (0 != ret.code) {
@ -350,6 +348,16 @@ const open = (id = null) => {
showCancel: false 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)); console.log('openUniMP: ' + JSON.stringify(ret));
}); });
} }
@ -358,9 +366,9 @@ export default {
loadMP, loadMP,
loadMPurl, loadMPurl,
loadMPx, loadMPx,
loadMPdns, loadMPdns,
installMP, installMP,
loadAppletMP, loadAppletMP,
doInstallMP, doInstallMP,
getVersion, getVersion,
open open

View File

@ -4,10 +4,9 @@ import {
test test
} from "@/utils/uniMPfunction.js" } from "@/utils/uniMPfunction.js"
export const initEvent = () => { export const initEvent = (data) => {
mp.onUniMPEventReceive(async (ret) => { mp.onUniMPEventReceive(async (ret) => {
console.log('小程序事件: ', ret); console.log('小程序事件: ', data);
// 用户如果没有注册商户 从小程序返回 入驻页面 // 用户如果没有注册商户 从小程序返回 入驻页面
if (ret.event == 'closeAppToOpenShop') { if (ret.event == 'closeAppToOpenShop') {
mp.closeUniMP(ret.fromAppid, (ret) => { mp.closeUniMP(ret.fromAppid, (ret) => {
@ -34,20 +33,6 @@ export const initEvent = () => {
console.log('获取定位'); console.log('获取定位');
let res = await uniMPgetLocation(); let res = await uniMPgetLocation();
console.log(res); 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( mp.sendUniMPEvent(
ret.fromAppid, ret.fromAppid,
'getLocation', { 'getLocation', {
@ -72,6 +57,10 @@ export const initEvent = () => {
console.log('Host sendEvent: ' + JSON.stringify(ret)); console.log('Host sendEvent: ' + JSON.stringify(ret));
}); });
} }
if (ret.event == 'log') { if (ret.event == 'log') {
// console.log('2222222') // console.log('2222222')