Explorar el Código

1. 新增插件:OAID 与 Keychain 实现获取android或IOS的设备ID
2. 收银扫码付款也能发起跑腿
3. 清除APP角标修改

shizhongqi hace 6 meses
padre
commit
2597fc824b

+ 9 - 0
ghsApp/.hbuilderx/launch.json

@@ -25,6 +25,15 @@
         {
             "playground" : "custom",
             "type" : "uni-app:app-ios"
+        },
+        {
+            "playground" : "custom",
+            "type" : "uni-app:app-android"
+        },
+        {
+            "customPlaygroundType" : "device",
+            "playground" : "custom",
+            "type" : "uni-app:app-ios_simulator"
         }
     ]
 }

+ 6 - 21
ghsApp/src/App.vue

@@ -8,6 +8,9 @@ export default {
 	// 有坑 分包里的页面访问不到
 	globalData: {},
 	onLaunch() {
+		// 清除角标数字
+		plus.runtime.setBadgeNumber(0);
+	
 		uni.onPushMessage((res) => {
 			console.log("收到推送消息:",res) //监听推送消息
 			let message = res.data;
@@ -29,27 +32,6 @@ export default {
 			}
 			console.log('推送消息跳转页面:', url);
 			
-			// uni.showModal({
-			// 	title: title || '收到一条推送消息',
-			// 	content: content,
-			// 	showCancel: !!pagePath, // 如果有页面路径,显示取消按钮
-			// 	confirmText: pagePath ? '查看详情' : '确定',
-			// 	success: (modalRes) => {
-			// 		if (modalRes.confirm && pagePath) {
-			// 			// 使用 navigateTo 跳转
-			// 			uni.navigateTo({
-			// 				url: url,
-			// 				fail: (err) => {
-			// 					console.error('页面跳转失败:', err);
-			// 					uni.showToast({
-			// 						title: '页面跳转失败',
-			// 						icon: 'none'
-			// 					});
-			// 				}
-			// 			});
-			// 		}
-			// 	}
-			// });
 			// 使用 navigateTo 跳转
 			uni.navigateTo({
 				url: url,
@@ -90,6 +72,9 @@ export default {
 
 	},
 	onShow() {
+		// 清除角标数字
+		plus.runtime.setBadgeNumber(0);
+		
 		// permissionEnums枚举建议单独一个js文件,然后引入
 		const permissionEnums = {
 			// 取android.permission.ACCESS_COARSE_LOCATION后面那个

+ 4 - 4
ghsApp/src/admin/billing/affirm.vue

@@ -1061,10 +1061,10 @@ export default {
       }
 
       if(this.form.callErrand == 1){
-        if(this.form.sendType == 2 && this.form.hasPay == 0){
-          this.$msg('待付款,暂不支持马上发跑腿')
-          return false
-        }
+        // if(this.form.sendType == 2 && this.form.hasPay == 0){
+        //   this.$msg('待付款,暂不支持马上发跑腿')
+        //   return false
+        // }
         if (this.$util.isEmpty(this.customInfo.long) || this.$util.isEmpty(this.customInfo.lat) || this.$util.isEmpty(this.customInfo.address)) {
           this.$msg('客户地址不完整,不支持马上发跑腿')
           return false

+ 218 - 126
ghsApp/src/admin/home/login.vue

@@ -67,6 +67,7 @@ import {appLogin} from '@/api/common'
 import { getDictionaries,postWxCode } from '@/api/mini'
 import { replaceClientId } from '@/api/admin'
 import { phoneLogin,wxMobileLogin } from "@/api/auth";
+
 export default {
 	name: "login",
 	components: {},
@@ -113,7 +114,6 @@ export default {
 			}  
 		})
 		// #endif
-
 	},
 	onUnload(){
 		uni.offNetworkStatusChange(this.dealLogin)
@@ -148,6 +148,17 @@ export default {
 				this.agree = 0
 			}else{
 				this.agree = 1
+
+				//获取设备ID,并保存到storage
+				console.log('agreeItem -- 获取设备ID');
+				const systemInfo = uni.getSystemInfoSync();
+				if (systemInfo.platform === 'ios') {
+					this.getIosDeviceId()
+				} else if (systemInfo.platform === 'android') {
+					this.androidRegister();
+					//this.androidGetIdCodes();
+					this.androidGetOAID()
+				}
 			}
 		},
 		// 检查并提示用户阅读协议
@@ -161,6 +172,17 @@ export default {
 					cancelText: '不同意',
 					success(res) {
 						if (res.confirm) {
+							//获取设备ID,并保存到storage
+							console.log('checkAgreement -- 获取设备ID');
+							const systemInfo = uni.getSystemInfoSync();
+							if (systemInfo.platform === 'ios') {
+								that.getIosDeviceId()
+							} else if (systemInfo.platform === 'android') {
+								that.androidRegister();
+								//that.androidGetIdCodes();
+								that.androidGetOAID()
+							}
+
 							// 用户选择同意
 							that.agree = 1
 							that.$forceUpdate()
@@ -202,143 +224,155 @@ export default {
 					that.hasMobileNet = false
 			}
 		},
-	wxPhoneLogin(e){
-		let that = this
-		let currentMiniOpenId = uni.getStorageSync('currentMiniOpenId')
-		if (e.detail.errMsg === "getPhoneNumber:ok") {
-			wxMobileLogin({ iv: e.detail.iv, encryptedData: e.detail.encryptedData,miniOpenId:currentMiniOpenId }).then(subRes => {
-						uni.hideLoading()
-						if(subRes.data && subRes.data.hasNoOpenId && subRes.data.hasNoOpenId ==1){
-							that.$util.confirmModal({content:'网络异常,请重新操作'},() => {
-								// #ifdef MP-WEIXIN
-								uni.clearStorage()
-								that.$store.commit("setLoginInfo", {})
-								that.$util.pageTo({url: "/admin/home/workbench",type: 3})
-								// #endif
-								// #ifdef APP-PLUS
-								uni.clearStorage()
-								that.$store.commit("setLoginInfo", {})
-								plus.runtime.restart()
-								// #endif
-							})
-							return false
-						}
-						let token = subRes.data.token || ''
-						if (that.$util.isEmpty(token)) {
-							that.$msg('请先注册')
-							return false
-						}
-						//有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
-						if(subRes.code == 1){
-							if (that.$util.isEmpty(subRes)) {
+		wxPhoneLogin(e){
+			let that = this
+			let currentMiniOpenId = uni.getStorageSync('currentMiniOpenId')
+			if (e.detail.errMsg === "getPhoneNumber:ok") {
+				wxMobileLogin({ iv: e.detail.iv, encryptedData: e.detail.encryptedData,miniOpenId:currentMiniOpenId }).then(subRes => {
+							uni.hideLoading()
+							if(subRes.data && subRes.data.hasNoOpenId && subRes.data.hasNoOpenId ==1){
+								that.$util.confirmModal({content:'网络异常,请重新操作'},() => {
+									// #ifdef MP-WEIXIN
+									uni.clearStorage()
+									that.$store.commit("setLoginInfo", {})
+									that.$util.pageTo({url: "/admin/home/workbench",type: 3})
+									// #endif
+									// #ifdef APP-PLUS
+									uni.clearStorage()
+									that.$store.commit("setLoginInfo", {})
+									plus.runtime.restart()
+									// #endif
+								})
+								return false
+							}
+							let token = subRes.data.token || ''
+							if (that.$util.isEmpty(token)) {
+								that.$msg('请先注册')
 								return false
 							}
-							uni.setStorageSync('token', subRes.data.token)
-							uni.setStorageSync('shopId', subRes.data.admin.currentGhsShopId)
-							getDictionaries({ token: subRes.data.token }).then(res => {
-								if (that.$util.isEmpty(res)) {
+							//有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
+							if(subRes.code == 1){
+								if (that.$util.isEmpty(subRes)) {
 									return false
 								}
-								that.$store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
-								that.$store.commit('setMyShopInfo', { ...res.data.shop, ...res.data })
-							})
-					that.$store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
-					getShopInfo(true).then(res => { uni.setNavigationBarTitle({ title: res.name }) })
-					that.setUserShopAll()
+								uni.setStorageSync('token', subRes.data.token)
+								uni.setStorageSync('shopId', subRes.data.admin.currentGhsShopId)
+								getDictionaries({ token: subRes.data.token }).then(res => {
+									if (that.$util.isEmpty(res)) {
+										return false
+									}
+									that.$store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
+									that.$store.commit('setMyShopInfo', { ...res.data.shop, ...res.data })
+								})
+						that.$store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
+						getShopInfo(true).then(res => { uni.setNavigationBarTitle({ title: res.name }) })
+						that.setUserShopAll()
 
-					uni.navigateBack()
-				}
-			});
-		} else {
-			this.$msg("登录失败");
-		}
-	},
-	mobileLogin(){
-		let that = this
+						uni.navigateBack()
+					}
+				});
+			} else {
+				this.$msg("登录失败");
+			}
+		},
+		mobileLogin(){
+			let that = this
 
-		uni.showLoading({mask:true})
-		uni.preLogin({
-			provider: 'univerify',
-			success:()=>{
-				uni.hideLoading() 
-				uni.login({
-							provider: 'univerify',
-							// 自定义登录框样式
-							univerifyStyle: {
-								"fullScreen": true,
-								"privacyTerms": {  
-									"defaultCheckBoxState":false,
-									"checkBoxSize":18
+			uni.showLoading({mask:true})
+			uni.preLogin({
+				provider: 'univerify',
+				success:()=>{
+					uni.hideLoading() 
+					uni.login({
+						provider: 'univerify',
+						// 自定义登录框样式
+						univerifyStyle: {
+							"fullScreen": true,
+							"privacyTerms": {  
+								"defaultCheckBoxState":false,
+								"checkBoxSize":18
+							}
+						},
+						// 登录成功
+						success:(res)=>{
+							//获取设备ID,并保存到storage
+							console.log('GlobalMixins -- 获取设备ID');
+							const systemInfo = uni.getSystemInfoSync();
+							if (systemInfo.platform === 'ios') {
+								that.getIosDeviceId()
+							} else if (systemInfo.platform === 'android') {
+								that.androidRegister();
+								//that.androidGetIdCodes();
+								that.androidGetOAID()
+							}
+								
+							let openid = res.authResult.openid
+							let access_token = res.authResult.access_token
+							phoneLogin({openid,access_token}).then(subRes=>{
+								let token = subRes.data.token || ''
+								if (that.$util.isEmpty(token)) {
+									that.$msg('请先注册')
+									return false
 								}
-							},
-							// 登录成功
-							success:(res)=>{
-								let openid = res.authResult.openid
-								let access_token = res.authResult.access_token
-								phoneLogin({openid,access_token}).then(subRes=>{
-									let token = subRes.data.token || ''
-									if (that.$util.isEmpty(token)) {
-										that.$msg('请先注册')
+								//有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
+								if(subRes.code == 1){
+									if (that.$util.isEmpty(subRes)) {
 										return false
 									}
-									//有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
-									if(subRes.code == 1){
-										if (that.$util.isEmpty(subRes)) {
+									uni.setStorageSync('token', subRes.data.token)
+									uni.setStorageSync('shopId', subRes.data.admin.currentGhsShopId)
+									getDictionaries({ token: subRes.data.token }).then(res => {
+										if (that.$util.isEmpty(res)) {
 											return false
 										}
-										uni.setStorageSync('token', subRes.data.token)
-										uni.setStorageSync('shopId', subRes.data.admin.currentGhsShopId)
-										getDictionaries({ token: subRes.data.token }).then(res => {
-											if (that.$util.isEmpty(res)) {
-												return false
-											}
-											that.$store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
-											that.$store.commit('setMyShopInfo', { ...res.data.shop, ...res.data })
-										})
-										that.$store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
-										getShopInfo(true).then(res => { uni.setNavigationBarTitle({ title: res.name }) })
-										that.setUserShopAll()
-										uni.navigateBack()
+										that.$store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
+										that.$store.commit('setMyShopInfo', { ...res.data.shop, ...res.data })
+									})
+									that.$store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
+									getShopInfo(true).then(res => { uni.setNavigationBarTitle({ title: res.name }) })
+									that.setUserShopAll()
+									uni.navigateBack()
 
-										// #ifdef APP-PLUS
-										//保存 clientId
-										//let hasClientId = !that.$util.isEmpty(subRes.data.admin.clientId) ? subRes.data.admin.clientId : ''
-										const clientInfo = plus.push.getClientInfo()
-										let currentClientId = !that.$util.isEmpty(clientInfo.clientid) ? clientInfo.clientid : ''
-										if(currentClientId != ''){
-											replaceClientId({id:currentClientId, auto:0})
-										}
-										// #endif
+									// #ifdef APP-PLUS
+									//保存 clientId
+									//let hasClientId = !that.$util.isEmpty(subRes.data.admin.clientId) ? subRes.data.admin.clientId : ''
+									const clientInfo = plus.push.getClientInfo()
+									let currentClientId = !that.$util.isEmpty(clientInfo.clientid) ? clientInfo.clientid : ''
+									const deviceId = uni.getStorageSync('deviceId')
+									if(currentClientId != ''){
+										replaceClientId({id:currentClientId, deviceId:deviceId, auto:0})
 									}
-								})
-							},
-							fail(res){
-								uni.showToast({title:'已取消', duration: 3000, icon:'none'})
-								//关闭一键登录弹出窗口
-								uni.closeAuthView()
-								console.log(res)
-							},
-							complete: (res) => {
-								uni.hideLoading()
-								uni.closeAuthView()
-							}
-						})
-					},
-					fail(res){  
-						//如果手机没有插入有效的sim卡,或者手机蜂窝数据网络关闭,都有可能造成预登录校验失败
-						if (res.code == 30005) {
-							uni.showToast({title: '请关闭WIFI,打开移动流量', duration: 3000, icon:'none'})
-						} else if(res.code == 1000) {
-							uni.showToast({title: '即将开通', duration: 3000, icon:'none'})
-						} else if(res.code == 40004) {
-							uni.showToast({title: '即将开通...', duration: 3000, icon:'none'})
-						} else {
-							uni.showToast({title: '登录失败...', duration: 3000, icon:'none'})
+									// #endif
+								}
+							})
+						},
+						fail(res){
+							uni.showToast({title:'已取消', duration: 3000, icon:'none'})
+							//关闭一键登录弹出窗口
+							uni.closeAuthView()
+							console.log(res)
+						},
+						complete: (res) => {
+							uni.hideLoading()
+							uni.closeAuthView()
 						}
-				console.log(res)
-			}
-		})
-	},
+					})
+				},
+				fail(res){  
+					//如果手机没有插入有效的sim卡,或者手机蜂窝数据网络关闭,都有可能造成预登录校验失败
+					if (res.code == 30005) {
+						uni.showToast({title: '请关闭WIFI,打开移动流量', duration: 3000, icon:'none'})
+					} else if(res.code == 1000) {
+						uni.showToast({title: '即将开通', duration: 3000, icon:'none'})
+					} else if(res.code == 40004) {
+						uni.showToast({title: '即将开通...', duration: 3000, icon:'none'})
+					} else {
+						uni.showToast({title: '登录失败...', duration: 3000, icon:'none'})
+					}
+					console.log(res)
+				}
+			})
+		},
 		loginFun(){
 			let that = this
 			let mobile = this.mobile
@@ -360,7 +394,7 @@ export default {
 			this.checkAgreement(function(){
 				uni.showLoading({mask:true})
 				//有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
-				appLogin({mobile, password}).then(subRes=>{
+				appLogin({mobile, password, deviceId: uni.getStorageSync('deviceId')}).then(subRes=>{
 					uni.hideLoading()
 					if(subRes.code == 1){
 						if (that.$util.isEmpty(subRes)) {
@@ -383,16 +417,74 @@ export default {
 						// #ifdef APP-PLUS
 						//保存 clientId
 						const clientInfo = plus.push.getClientInfo()
+						const deviceId = uni.getStorageSync('deviceId')
 						let currentClientId = !that.$util.isEmpty(clientInfo.clientid) ? clientInfo.clientid : ''
 						if(currentClientId != ''){
-							replaceClientId({id:currentClientId, auto:0})
+							replaceClientId({id:currentClientId, deviceId:deviceId, auto:0})
 						}
 						// #endif
 					}
 				})
 			})
+		},
+	},
+	// #ifdef APP-PLUS
+	getIosDeviceId() {
+		const keychain = uni.requireNativePlugin('Univalsoft-DeviceId'); 
+		keychain.getDeviceIDCallback((ret)=>{
+		let deviceId = ret ? ret : '';
+		if(deviceId != ''){
+			uni.setStorageSync('deviceId', deviceId)
 		}
+		// uni.showToast({
+		// 	title:'GlobalMixins -- 调用方法 uuid ' + ret,
+		// 	icon: "none"
+		// })
+		})
+	},
+	androidRegister() {
+		const idCode = uni.requireNativePlugin('Ba-IdCode');
+		idCode.register(res => {
+		console.log('Ba-IdCode register', res);
+		});
+	},
+	androidGetIdCodes() {
+		const idCode = uni.requireNativePlugin('Ba-IdCode');
+		idCode.getIdCodes(res => {
+			console.log(res);
+			// if (res.data) {
+			// 	this.msgList.unshift(JSON.stringify(res.data))
+			// }
+			if(res.data.AndroidID && res.data.AndroidID != ''){
+				uni.setStorageSync('deviceId', res.data.AndroidID)
+				return
+			}
+			if(res.data.GUID && res.data.GUID != ''){
+				uni.setStorageSync('deviceId', res.data.GUID)
+				return
+			}
+			if(res.data.IMEI && res.data.IMEI != ''){
+				uni.setStorageSync('deviceId', res.data.IMEI)
+			}
+		});
+	},
+	androidGetOAID() {
+		const idCode = uni.requireNativePlugin('Ba-IdCode');
+		idCode.getOAID((res) => {
+			let OAID = (res.data && res.data.OAID) ? res.data.OAID : '';
+			
+			//OAID为空 或 OAID 只包含有0、-字符,不包含其他字符,则调用 getIdCodes 方法获取设备ID
+			if (OAID == '' || (!/^(0|-)$/.test(OAID)) ) {
+				this.androidGetIdCodes()
+				return
+			}
+
+			if (OAID) {
+				uni.setStorageSync('deviceId', OAID);
+			}
+		});
 	}
+	// #endif
 };
 </script>
 <style lang="scss" scoped>

+ 9 - 8
ghsApp/src/admin/home/me.vue

@@ -492,21 +492,22 @@ export default {
     loginOut(){
       let that = this
       that.$util.confirmModal({content:'确认退出?'},() => {
-        // #ifdef APP-PLUS
-        uni.clearStorage()
-        that.$store.commit("setLoginInfo", {})
-        plus.runtime.restart()
-        // #endif
-        // #ifdef MP-WEIXIN
-        clearLogin().then(res=>{
+        const deviceId = uni.getStorageSync('deviceId')
+        clearLogin({deviceId: deviceId}).then(res=>{
           uni.hideLoading()
           if(res.code == 1){
             uni.clearStorage()
             that.$store.commit("setLoginInfo", {})
+
+            // #ifdef APP-PLUS
+            plus.runtime.restart()
+            // #endif
+
+            // #ifdef MP-WEIXIN
             uni.reLaunch({url:'/admin/home/workbench'})
+            // #endif
           }
         })
-        // #endif
       })
     },
     // #ifdef APP-PLUS

+ 5 - 1
ghsApp/src/admin/shop/myShop.vue

@@ -48,19 +48,23 @@ export default {
 	methods: {
 		async selectShopFn (shopId) {
 			uni.showLoading({mask:true})
-			await toggleShop({ shopId: shopId })
+			const deviceId = uni.getStorageSync('deviceId')
+			await toggleShop({ shopId: shopId, deviceId: deviceId })
 			uni.hideLoading()
+
 			// #ifdef MP-WEIXIN
 			this.$store.commit("setLoginInfo", {})
 			this.$store.commit("setMyShopInfo", {})
 			this.$util.pageTo({url: "/admin/home/workbench",type: 3})
 			// #endif
+
 			// #ifdef APP-PLUS
 			this.$store.commit("setLoginInfo", {})
 			this.$store.commit("setDictionariesInfo", {})
 			this.$store.commit("setMyShopInfo", {})
 			plus.runtime.restart()
 			// #endif
+
 			getShopInfo(true)
 		},
 		init(){

+ 1 - 1
ghsApp/src/api/admin/index.js

@@ -1,7 +1,7 @@
 import https from "@/plugins/luch-request_0.0.7/request";
 
 export const clearLogin = data => {
-	return https.get("/admin/clear-login", data);
+	return https.post("/admin/clear-login", data);
 };
 
 export const getInfo = data => {

+ 29 - 1
ghsApp/src/manifest.json

@@ -183,6 +183,34 @@
                     "pid" : "",
                     "parameters" : {}
                 }
+            },
+            "Ba-IdCode" : {
+                "__plugin_info__" : {
+                    "name" : "获取设备唯一标识(OAID、AAID、IMEI等) Ba-IdCode",
+                    "description" : "Ba-IdCode 是一款可以获取国内各大手机厂商 OAID 及海外手机平台 AAID 的插件。另外也支持 IMEI/MEID、AndroidID、WidevineID、PseudoID、GUID 等",
+                    "platforms" : "Android",
+                    "url" : "https://ext.dcloud.net.cn/plugin?id=10318",
+                    "android_package_name" : "zhh.huahuibao.app",
+                    "ios_bundle_id" : "com.zhh.xhb",
+                    "isCloud" : true,
+                    "bought" : 1,
+                    "pid" : "10318",
+                    "parameters" : {}
+                }
+            },
+            "Univalsoft-DeviceId" : {
+                "__plugin_info__" : {
+                    "name" : "iOS 手机唯一标识 keychain 唯一标识 设备id UUID",
+                    "description" : "获取iOS设备唯一id,设备与账号绑定,卸载重装app后唯一标识不变。",
+                    "platforms" : "iOS",
+                    "url" : "https://ext.dcloud.net.cn/plugin?id=11231",
+                    "android_package_name" : "zhh.huahuibao.app",
+                    "ios_bundle_id" : "com.zhh.xhb",
+                    "isCloud" : true,
+                    "bought" : 1,
+                    "pid" : "11231",
+                    "parameters" : {}
+                }
             }
         },
         "uniStatistics" : {
@@ -207,7 +235,7 @@
         "optimization" : {
             "subPackages" : true
         },
-        "lazyCodeLoading":"requiredComponents",
+        "lazyCodeLoading" : "requiredComponents",
         "uniStatistics" : {
             "enable" : false
         },

+ 72 - 4
ghsApp/src/mixins/globalMixins.js

@@ -86,11 +86,10 @@ export default {
           this.setUserShopAll()
           
           this.init()
-          
         })
       }
       // #endif
-
+      
       //#ifdef APP-PLUS
       //有token重新获取登陆信息!!!
       const appToken = uni.getStorageSync('token')
@@ -100,6 +99,18 @@ export default {
           if(subRes.code != 1){
             return
           }
+
+          //获取设备ID,并保存到storage
+          console.log('GlobalMixins -- 获取设备ID');
+          const systemInfo = uni.getSystemInfoSync();
+          if (systemInfo.platform === 'ios') {
+            this.getIosDeviceId()
+          } else if (systemInfo.platform === 'android') {
+            this.androidRegister();
+            //this.androidGetIdCodes();
+            this.androidGetOAID()
+          }
+
 					getDictionaries({ token: subRes.data.token }).then(res => {
 						if (!that.$util.isEmpty(res)) {
               store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
@@ -112,12 +123,13 @@ export default {
           this.listenPDAkd()
           this.setUserShopAll()
           this.init()
-          
+
           //更新 clientId
           const clientInfo = plus.push.getClientInfo()
           let currentClientId = !that.$util.isEmpty(clientInfo.clientid) ? clientInfo.clientid : ''
+          const deviceId = uni.getStorageSync('deviceId')
           if(currentClientId != ''){
-            replaceClientId({id:currentClientId, auto: 1})
+            replaceClientId({id:currentClientId, deviceId:deviceId, auto: 1})
           }
         })
       }
@@ -232,6 +244,62 @@ export default {
         uni.reLaunch({url:'/admin/home/workbench'})
       })
     },
+    // #ifdef APP-PLUS
+    getIosDeviceId() {
+      const keychain = uni.requireNativePlugin('Univalsoft-DeviceId'); 
+      keychain.getDeviceIDCallback((ret)=>{
+        let deviceId = ret ? ret : '';
+        if(deviceId != ''){
+          uni.setStorageSync('deviceId', deviceId)
+        }
+        // uni.showToast({
+        //   title:'GlobalMixins -- 调用方法 uuid ' + ret,
+        //   icon: "none"
+        // })
+      })
+    },
+    androidRegister() {
+      const idCode = uni.requireNativePlugin('Ba-IdCode');
+      idCode.register(res => {
+        console.log('Ba-IdCode register', res);
+      });
+    },
+    androidGetIdCodes() { //获取设备的各种标识码
+      const idCode = uni.requireNativePlugin('Ba-IdCode');
+      idCode.getIdCodes(res => {
+          console.log(res);
+          // if (res.data) {
+          //     this.msgList.unshift(JSON.stringify(res.data))
+          // }
+          if(res.data.AndroidID && res.data.AndroidID != ''){
+            uni.setStorageSync('deviceId', res.data.AndroidID)
+            return
+          }
+          if(res.data.GUID && res.data.GUID != ''){
+            uni.setStorageSync('deviceId', res.data.GUID)
+            return
+          }
+          if(res.data.IMEI && res.data.IMEI != ''){ // 注意:Android 10+取消了获取IMEI的API
+            uni.setStorageSync('deviceId', res.data.IMEI)
+          }
+      });
+    },
+    androidGetOAID() {
+      const idCode = uni.requireNativePlugin('Ba-IdCode');
+      idCode.getOAID((res) => {
+        let OAID = (res.data && res.data.OAID) ? res.data.OAID : '';
+        
+        //OAID为空 或 OAID 只包含有0、-字符,不包含其他字符,则调用 getIdCodes 方法获取设备ID
+				if (OAID == '' || (!/^(0|-)$/.test(OAID)) ) {
+					this.androidGetIdCodes()
+					return
+				}
+        if (OAID) {
+          uni.setStorageSync('deviceId', OAID);
+        }
+      });
+    },
+    // #endif
 	},
 	mounted() {
 		if (this.mInit) {

+ 4 - 4
ghsPad/src/pages/home/components/settlePop.vue

@@ -676,10 +676,10 @@ export default {
             }
 
             if(this.form.callErrand == 1){
-                if(this.form.sendType == 2 && this.form.hasPay == 0){
-                    this.$msg('扫码付款,暂不支持马上发跑腿')
-                    return false
-                }
+                // if(this.form.sendType == 2 && this.form.hasPay == 0){
+                //     this.$msg('扫码付款,暂不支持马上发跑腿')
+                //     return false
+                // }
                 if(this.$util.isEmpty(this.custom.long) || this.$util.isEmpty(this.custom.lat) || this.$util.isEmpty(this.custom.address)){
                     this.$msg('客户地址不完整,请选择先不要叫跑腿')
                     return false

+ 16 - 10
hdApp/src/App.vue

@@ -13,15 +13,18 @@ export default {
   // 有坑 分包里的页面访问不到
   globalData: {},
   onLaunch () {
-			uni.removeStorageSync('suitInfoList');
-			uni.removeStorageSync('productInfoList');
-			uni.removeStorageSync('pxClassInfoList');
+	uni.removeStorageSync('suitInfoList');
+	uni.removeStorageSync('productInfoList');
+	uni.removeStorageSync('pxClassInfoList');
+
+	// 清除角标数字
+	plus.runtime.setBadgeNumber(0);
 
     uni.onPushMessage((res) => {
 			console.log("收到推送消息:",res) //监听推送消息
 			let message = res.data;
-		  // 提取页面路径(支持 pagesOrder/detail 这样的格式)
-      let pagePath = message.payload && message.payload.page;
+		  	// 提取页面路径(支持 pagesOrder/detail 这样的格式)
+      		let pagePath = message.payload && message.payload.page;
 			// 用户点击查看详情,跳转到指定页面
 			// 检查是否需要添加 / 前缀
 			let url = pagePath.startsWith('/') ? pagePath : `/${pagePath}`;
@@ -68,10 +71,10 @@ export default {
           ...res.data.dict,
           ...res.data
         })
-							store.commit('setMyShopInfo', {
-								...res.data.shop,
-								...res.data
-							})
+		store.commit('setMyShopInfo', {
+			...res.data.shop,
+			...res.data
+		})
       })
     }
     // #endif
@@ -96,9 +99,12 @@ export default {
     // console.log(1111,url)
   },
   onShow (extraData) {
+	// 清除角标数字
+	plus.runtime.setBadgeNumber(0);
+	
   	if(extraData){
   		uni.setStorageSync('extraData',extraData)
-		}
+	}
 
 		// permissionEnums枚举建议单独一个js文件,然后引入
 		const permissionEnums = {

+ 101 - 3
hdApp/src/admin/home/login.vue

@@ -156,6 +156,18 @@ export default {
 				this.agree = 0
 			}else{
 				this.agree = 1
+
+				//获取设备ID,并保存到storage
+				console.log('GlobalMixins -- 获取设备ID');
+				const systemInfo = uni.getSystemInfoSync();
+				if (systemInfo.platform === 'ios') {
+					this.getIosDeviceId()
+				} else if (systemInfo.platform === 'android') {
+					this.androidRegister();
+					//this.androidGetIdCodes();
+					this.androidGetOAID()
+				}
+				console.log('GlobalMixins -- 获取设备ID 结束');
 			}
 		},
 		// 检查并提示用户阅读协议
@@ -169,6 +181,18 @@ export default {
 					cancelText: '不同意',
 					success(res) {
 						if (res.confirm) {
+							//获取设备ID,并保存到storage
+							console.log('GlobalMixins -- 获取设备ID');
+							const systemInfo = uni.getSystemInfoSync();
+							if (systemInfo.platform === 'ios') {
+								that.getIosDeviceId()
+							} else if (systemInfo.platform === 'android') {
+								that.androidRegister();
+								//that.androidGetIdCodes();
+								that.androidGetOAID()
+							}
+							console.log('GlobalMixins -- 获取设备ID 结束6666');
+
 							// 用户选择同意
 							that.agree = 1
 							that.$forceUpdate()
@@ -304,6 +328,17 @@ export default {
 								}
 							},
 							success:(res)=>{ // 登录成功
+								//获取设备ID,并保存到storage
+								console.log('GlobalMixins -- 获取设备ID');
+								const systemInfo = uni.getSystemInfoSync();
+								if (systemInfo.platform === 'ios') {
+									that.getIosDeviceId()
+								} else if (systemInfo.platform === 'android') {
+									that.androidRegister();
+									//that.androidGetIdCodes();
+									that.androidGetOAID()
+								}
+								
 								console.log(res)
 								let openid = res.authResult.openid
 								let access_token = res.authResult.access_token
@@ -344,8 +379,9 @@ export default {
 										//保存安卓的clientId
 										const clientInfo = plus.push.getClientInfo()
 										let currentClientId = !that.$util.isEmpty(clientInfo.clientid) ? clientInfo.clientid : ''
+										const deviceId = uni.getStorageSync('deviceId')
 										if(currentClientId != ''){
-											replaceClientId({id:currentClientId, auto:0})
+											replaceClientId({id:currentClientId, deviceId:deviceId, auto:0})
 											console.log("mobileLogin - clientId ---------- ", currentClientId)
 										}
 										// #endif
@@ -402,13 +438,16 @@ export default {
 			// 检查协议
 			this.checkAgreement(function(){
 				uni.showLoading({mask:true})
+
 				//有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
-				appLogin({mobile,password}).then(subRes=>{
+				appLogin({mobile,password,deviceId: uni.getStorageSync('deviceId')}).then(subRes=>{
 					uni.hideLoading()
+					
 					if(subRes.code == 1){
 						if (that.$util.isEmpty(subRes)) {
 							return false
 						}
+
 						uni.setStorageSync('token', subRes.data.token)
 						uni.setStorageSync('shopId', subRes.data.admin.currentShopId)
 						getDictionaries({ token: subRes.data.token }).then(res => {
@@ -433,8 +472,10 @@ export default {
 						//保存安卓的clientId
 						const clientInfo = plus.push.getClientInfo()
 						let currentClientId = !that.$util.isEmpty(clientInfo.clientid) ? clientInfo.clientid : ''
+						const deviceId = uni.getStorageSync('deviceId')
+						console.log("loginFun - deviceId ---------- ", deviceId)
 						if(currentClientId != ''){
-							replaceClientId({id:currentClientId, auto:0})
+							replaceClientId({id:currentClientId, deviceId:deviceId, auto:0})
 							console.log("loginFun - clientId ---------- ", currentClientId)
 						}
 						// #endif
@@ -443,7 +484,64 @@ export default {
 			})
 
 		}
+	},
+	// #ifdef APP-PLUS
+	getIosDeviceId() {
+		const keychain = uni.requireNativePlugin('Univalsoft-DeviceId'); 
+		keychain.getDeviceIDCallback((ret)=>{
+		let deviceId = ret ? ret : '';
+		if(deviceId != ''){
+			uni.setStorageSync('deviceId', deviceId)
+		}
+		// uni.showToast({
+		// 	title:'GlobalMixins -- 调用方法 uuid ' + ret,
+		// 	icon: "none"
+		// })
+		})
+	},
+	androidRegister() {
+		const idCode = uni.requireNativePlugin('Ba-IdCode');
+		idCode.register(res => {
+			console.log('Ba-IdCode register', res);
+		});
+	},
+	androidGetIdCodes() {
+		const idCode = uni.requireNativePlugin('Ba-IdCode');
+		idCode.getIdCodes(res => {
+			console.log(res);
+			// if (res.data) {
+			// 	this.msgList.unshift(JSON.stringify(res.data))
+			// }
+			if(res.data.AndroidID && res.data.AndroidID != ''){
+				uni.setStorageSync('deviceId', res.data.AndroidID)
+				return
+			}
+			if(res.data.GUID && res.data.GUID != ''){
+				uni.setStorageSync('deviceId', res.data.GUID)
+				return
+			}
+			if(res.data.IMEI && res.data.IMEI != ''){
+				uni.setStorageSync('deviceId', res.data.IMEI)
+			}
+		});
+	},
+	androidGetOAID() {
+		const idCode = uni.requireNativePlugin('Ba-IdCode');
+		idCode.getOAID((res) => {
+			let OAID = (res.data && res.data.OAID) ? res.data.OAID : '';
+			
+			//OAID为空 或 OAID 只包含有0、-字符,不包含其他字符,则调用 getIdCodes 方法获取设备ID
+			if (OAID == '' || (!/^(0|-)$/.test(OAID)) ) {
+				this.androidGetIdCodes()
+				return
+			}
+
+			if (OAID) {
+				uni.setStorageSync('deviceId', OAID);
+			}
+		});
 	}
+	// #endif
 };
 </script>
 <style lang="scss" scoped>

+ 12 - 11
hdApp/src/admin/home/me.vue

@@ -285,23 +285,24 @@ export default {
       this.$util.pageTo({ url: '/admin/home/close'})
     },
     loginOut(){
-        let that = this
-        that.$util.confirmModal({content:'确认退出?'},() => {
-            // #ifdef APP-PLUS
+      let that = this
+      that.$util.confirmModal({content:'确认退出?'},() => {
+        const deviceId = uni.getStorageSync('deviceId')
+        clearLogin({deviceId: deviceId}).then(res=>{
+          if(res.code == 1){
             uni.clearStorage()
-            that.$store.commit("setLoginInfo", {})
+            that.$store.commit("setLoginInfo", {})
+
+            // #ifdef APP-PLUS
             plus.runtime.restart()
             // #endif
+
             // #ifdef MP-WEIXIN
-            clearLogin().then(res=>{
-              if(res.code == 1){
-                uni.clearStorage()
-                that.$store.commit("setLoginInfo", {})
-                uni.reLaunch({url:'/admin/home/workbench'})
-              }
-            })
+            uni.reLaunch({url:'/admin/home/workbench'})
             // #endif
+          }
         })
+      })
     },
     // #ifdef APP-PLUS
     closeApp(){

+ 2 - 1
hdApp/src/admin/shop/myShop.vue

@@ -48,7 +48,8 @@ export default {
 	methods: {
 		async changeShop(shopId) {
 			uni.showLoading({mask:true})
-			await toggleShop({ shopId: shopId })
+			const deviceId = uni.getStorageSync('deviceId')
+			await toggleShop({ shopId: shopId, deviceId: deviceId })
 			uni.hideLoading()
 			// #ifdef MP-WEIXIN
 			this.$store.commit("setLoginInfo", {})

+ 1 - 1
hdApp/src/api/admin/index.js

@@ -1,7 +1,7 @@
 import https from '@/plugins/luch-request_0.0.7/request'
 
 export const clearLogin = data => {
-	return https.get("/admin/clear-login", data);
+	return https.post("/admin/clear-login", data);
 };
 
 export const getInfo = data => {

+ 30 - 2
hdApp/src/manifest.json

@@ -163,6 +163,34 @@
                     "pid" : "462",
                     "parameters" : {}
                 }
+            },
+            "Ba-IdCode" : {
+                "__plugin_info__" : {
+                    "name" : "获取设备唯一标识(OAID、AAID、IMEI等) Ba-IdCode",
+                    "description" : "Ba-IdCode 是一款可以获取国内各大手机厂商 OAID 及海外手机平台 AAID 的插件。另外也支持 IMEI/MEID、AndroidID、WidevineID、PseudoID、GUID 等",
+                    "platforms" : "Android",
+                    "url" : "https://ext.dcloud.net.cn/plugin?id=10318",
+                    "android_package_name" : "zhh.huahuibao.hhb.app",
+                    "ios_bundle_id" : "com.zhh.hhb",
+                    "isCloud" : true,
+                    "bought" : 1,
+                    "pid" : "10318",
+                    "parameters" : {}
+                }
+            },
+            "Univalsoft-DeviceId" : {
+                "__plugin_info__" : {
+                    "name" : "iOS 手机唯一标识 keychain 唯一标识 设备id UUID",
+                    "description" : "获取iOS设备唯一id,设备与账号绑定,卸载重装app后唯一标识不变。",
+                    "platforms" : "iOS",
+                    "url" : "https://ext.dcloud.net.cn/plugin?id=11231",
+                    "android_package_name" : "zhh.huahuibao.hhb.app",
+                    "ios_bundle_id" : "com.zhh.hhb",
+                    "isCloud" : true,
+                    "bought" : 1,
+                    "pid" : "11231",
+                    "parameters" : {}
+                }
             }
         },
         "uniStatistics" : {
@@ -191,8 +219,8 @@
         "optimization" : {
             "subPackages" : true
         },
-        "lazyCodeLoading":"requiredComponents",
-       "uniStatistics" : {
+        "lazyCodeLoading" : "requiredComponents",
+        "uniStatistics" : {
             "enable" : false
         },
         "unipush" : {

+ 69 - 2
hdApp/src/mixins/globalMixins.js

@@ -84,10 +84,22 @@ export default {
 			// #endif
 
 			//#ifdef APP-PLUS
+			//有token重新获取登陆信息!!!
 			if(!this.$util.isEmpty(token)){
 				hasTokenAutoLogin().then(subRes=>{
 					//有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
 					if(subRes.code == 1){
+						//获取设备ID,并保存到storage
+						console.log('GlobalMixins -- 获取设备ID');
+						const systemInfo = uni.getSystemInfoSync();
+						if (systemInfo.platform === 'ios') {
+							this.getIosDeviceId()
+						} else if (systemInfo.platform === 'android') {
+							this.androidRegister();
+							//this.androidGetIdCodes();
+							this.androidGetOAID()
+						}
+						
 						uni.setStorageSync('shopId', subRes.data.admin.currentShopId)
 						getDictionaries({ token: subRes.data.token }).then(res => {
 							if (that.$util.isEmpty(res)) {
@@ -106,8 +118,9 @@ export default {
 						//更新 clientId
 						const clientInfo = plus.push.getClientInfo()
 						let currentClientId = !that.$util.isEmpty(clientInfo.clientid) ? clientInfo.clientid : ''
+						const deviceId = uni.getStorageSync('deviceId')
 						if(currentClientId != ''){
-							replaceClientId({id:currentClientId, auto: 1})
+							replaceClientId({id:currentClientId, deviceId:deviceId, auto: 1})
 						}
 					}
 				})
@@ -118,6 +131,60 @@ export default {
 		}
 	},
 	methods: {
-    ...mapActions(['setUserShopAll'])
+		...mapActions(['setUserShopAll']),
+
+		// #ifdef APP-PLUS
+		getIosDeviceId() {
+			const keychain = uni.requireNativePlugin('Univalsoft-DeviceId'); 
+			keychain.getDeviceIDCallback((ret)=>{
+				let deviceId = ret ? ret : '';
+				if(deviceId != ''){
+					uni.setStorageSync('deviceId', deviceId)
+				}
+			})
+		},
+		androidRegister() {
+			const idCode = uni.requireNativePlugin('Ba-IdCode');
+			idCode.register(res => {
+			console.log('Ba-IdCode register', res);
+			});
+		},
+		androidGetIdCodes() {
+			const idCode = uni.requireNativePlugin('Ba-IdCode');
+			idCode.getIdCodes(res => {
+				console.log(res);
+				// if (res.data) {
+				// 	this.msgList.unshift(JSON.stringify(res.data))
+				// }
+				if(res.data.AndroidID && res.data.AndroidID != ''){
+					uni.setStorageSync('deviceId', res.data.AndroidID)
+					return
+				}
+				if(res.data.GUID && res.data.GUID != ''){
+					uni.setStorageSync('deviceId', res.data.GUID)
+					return
+				}
+				if(res.data.IMEI && res.data.IMEI != ''){
+					uni.setStorageSync('deviceId', res.data.IMEI)
+				}
+			});
+		},
+		androidGetOAID() {
+			const idCode = uni.requireNativePlugin('Ba-IdCode');
+			idCode.getOAID((res) => {
+				let OAID = (res.data && res.data.OAID) ? res.data.OAID : '';
+				
+				//OAID为空 或 OAID 只包含有0、-字符,不包含其他字符,则调用 getIdCodes 方法获取设备ID
+				if (OAID == '' || (!/^(0|-)$/.test(OAID)) ) {
+					this.androidGetIdCodes()
+					return
+				}
+
+				if (OAID) {
+					uni.setStorageSync('deviceId', OAID);
+				}
+			});
+		}
+		// #endif
 	}
 }

+ 4 - 4
hdPad/src/pages/home/components/settlePop.vue

@@ -926,10 +926,10 @@ export default {
             }
 
             if(this.form.callErrand == 1){
-                if(this.form.sendType == 2 && this.form.hasPay == 0){
-                    this.$msg('扫码付款,暂不支持马上发跑腿')
-                    return false
-                }
+                // if(this.form.sendType == 2 && this.form.hasPay == 0){
+                //     this.$msg('扫码付款,暂不支持马上发跑腿')
+                //     return false
+                // }
                 if(this.$util.isEmpty(this.custom.long) || this.$util.isEmpty(this.custom.lat) || this.$util.isEmpty(this.custom.address)){
                     this.$msg('客户地址不完整,请选择先不要叫跑腿')
                     return false