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
} 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
})
}
}
})

View File

@ -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);
}
/**
* 提现银行/提现最低金额
*

View File

@ -176,7 +176,7 @@
<view class="title-img">
<image src="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/807b8202403111125379295.webp" mode=""></image>
</view>
<button @click="test">jiaowoanjhsd</button>
<view class="business com special_work" v-if="jurisdiction == false">
<view class="content">
<block v-if="nowMenuList.length > 0">
@ -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) {

View File

@ -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)

View File

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

View File

@ -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')