当前位置: 首页 > wzjs >正文

搭建动态网站的步骤百度官网下载安装到桌面上

搭建动态网站的步骤,百度官网下载安装到桌面上,国外做宠物产品的网站,想用自己电脑做服务器做个网站吗历经波折三次成功上岸! 三次经历简单絮叨一下:使用uniAppvue开发的微信小程序,使用蓝牙连接打印机,蓝牙所有的接口都是插件中封装的,用的插件市场中的这个: dothan-lpapi-ble ;所以&#xff0c…

历经波折三次成功上岸!

三次经历简单絮叨一下:使用uniApp+vue开发的微信小程序,使用蓝牙连接打印机,蓝牙所有的接口都是插件中封装的,用的插件市场中的这个: dothan-lpapi-ble ;所以,开发中,主要是看插件文档中使用的API。

首次上线

情况说明: 首次上线微信小程序:直接初始化实例,调用的插件API,测试环境成功连接打印,就上线了。

结果

客户手机一直搜索不到打印机,根据经验发现没执行实例的代码;
想到授权蓝牙也没自动弹框提示,小程序设置中也没有蓝牙开启设置;

问题定位:

那就问 deepseeek 开干呗!
1. 可能是用户手机 鸿蒙系统 问题:在系统设置中找到应用管理,找到微信,然后打开微信的权限管理,查看 附近设备的权限 - 开启(反复开关)。

插件市场遇到的特殊情况
2. 显示授权:必要的权限声明
3. 检查manifest.json配置
4. 微信小程序发版后台 - 设置 - 基本设置 - 服务内容声明 - 用户隐私保护指引 - 添加(蓝牙、微信信息收集)

二次上线

情况说明: 二次上线微信小程序:提交审核是其他同事在做,正常提交

结果

客户手机一直搜索不到打印机,根据经验发现没执行实例的代码;
线上环境用户还是没有触发授权蓝牙、位置信息提示;
审核没通过

问题定位:

1. 提交审核时勾选了:未采集用户隐私
2. 亲自提审、加图片、视频辅佐

三次上线

情况说明:审核通过

结果

线上成功授权、成功搜索打印机!

成功版本代码

manifest.json配置

"mp-weixin": {"appid": "...",//  添加..."permission": {"scope.bluetooth": {"desc": "用于连接蓝牙设备"},"scope.userLocation": {"desc": "你的位置信息将用于蓝牙设备连接"}},"requiredPrivateInfos": ["getLocation"]},

授权提示 - deepseek友情提供

// 使用-获取蓝牙权限
await this.bringBluetoothRight();// 方法 methods: 
bringBluetoothRight() {let _this = this;return new Promise((resolve, reject) => {uni.getSetting({success: async (res) => {try {console.log(res, 'res')// 1. 同时检查蓝牙和位置权限const needBluetooth = !res.authSetting['scope.bluetooth'];const needLocation = !res.authSetting['scope.userLocation'];if (!needBluetooth && !needLocation) {// 已有全部权限return resolve(await _this.wechatBluetoothAuthUtils());}// 2. 显示预授权提示(合并说明)await _this.showPreAuthorizeModal('需要蓝牙和位置权限','连接打印机需要以下权限:\n\n1. 蓝牙权限 - 用于设备配对\n2. 位置权限 - 用于搜索设备');// 3. 按顺序请求权限if (needBluetooth) {await _this.requestPermission('scope.bluetooth', '蓝牙');}if (needLocation) {await _this.requestPermission('scope.userLocation', '位置');}// 4. 验证权限获取结果const currentSettings = await _this.getSettingWithRetry();console.log(currentSettings, 'currentSettings')if ((!needBluetooth || currentSettings['scope.bluetooth']) &&(!needLocation || currentSettings['scope.userLocation'])) {console.log('.......')resolve(await _this.wechatBluetoothAuthUtils());} else {console.log('1111111')// 5. 有权限未被授予,引导去设置页await _this.showGoSettingModal();const finalSettings = await _this.getSettingWithRetry();if ((!needBluetooth || finalSettings['scope.bluetooth']) &&(!needLocation || finalSettings['scope.userLocation'])) {resolve(await _this.wechatBluetoothAuthUtils());} else {reject(new Error('权限未完全授予'));}}} catch (error) {reject(error);}},fail: reject});});
},
// 新增:带重试的获取设置
getSettingWithRetry(retry = 2) {return new Promise((resolve, reject) => {const tryGet = (attempt) => {uni.getSetting({success: resolve,fail: attempt > 0 ?() => setTimeout(() => tryGet(attempt - 1), 500) : reject});};tryGet(retry);});
},// 改进:通用权限请求方法
requestPermission(scope, permissionName) {let _this = this;// 添加最大重试次数控制const MAX_RETRY = 1; // 最多重试1次(即总共2次机会)return new Promise((resolve, reject) => {const tryAuthorize = (retryCount = 0) => {uni.authorize({scope,success: resolve,fail: async () => {// 第一次拒绝时显示提示,后续直接引导去设置页if (retryCount < MAX_RETRY) {const confirmed = await _this.showPreAuthorizeModal(`${permissionName}权限被拒绝`,`需要${permissionName}权限才能连接打印机,是否重新授权?`,'重新授权','取消');if (confirmed) {tryAuthorize(retryCount + 1); // 增加重试计数return;}}// 达到最大重试或用户取消,引导去设置页const goSetting = await _this.showPreAuthorizeModal('权限不足',`需要${permissionName}权限才能使用打印机功能,是否去设置页开启?`,'去设置','暂不开启');if (goSetting) {uni.openSetting({success: (res) => {res.authSetting[scope] ? resolve() :reject(new Error(`用户未授权${permissionName}权限`));},fail: () => reject(new Error('打开设置页失败'))});} else {reject(new Error(`用户取消${permissionName}权限授权`));}}});};tryAuthorize(); // 开始首次授权尝试});
},
// 改进:预授权弹窗(返回Promise<boolean>)
showPreAuthorizeModal(title, content) {return new Promise((resolve) => {uni.showModal({title,content,confirmText: '继续',cancelText: '取消',success: (res) => {resolve(!!res.confirm);},fail: () => resolve(false)});});
},// 改进:去设置页弹窗
showGoSettingModal() {return this.showPreAuthorizeModal('需要权限','需要前往设置页手动开启权限,是否现在去设置?').then((confirm) => {if (confirm) {return new Promise((resolve) => {uni.openSetting({success: resolve,fail: resolve});});}return Promise.reject(new Error('用户取消设置'));});
},wechatBluetoothAuthUtils() {let _this = this;const {bluetoothEnabled,platform} = uni.getSystemInfoSync();console.log(bluetoothEnabled,platform)// 设备为IOS时,微信蓝牙是否开启if (platform === 'ios') {return new Promise((resolve, reject) => {// 初始化蓝牙模块(用openBluetoothAdapter 方法解决部分ios设备,授权蓝牙失败的问题)uni.openBluetoothAdapter({success: () => {// 开启蓝牙功能 =》 初始化拾果sdkresolve(true);},fail: (openBlueFail) => {if (openBlueFail.state === 3) {// 说明微信应用蓝牙未授权uni.showModal({content: '检测到您未允许微信访问手机蓝牙权限,是否打开系统设置?',showCancel: false,confirmText: '前往设置',success: () => {// 跳转微信应用权限uni.openAppAuthorizeSetting();},});} else if (openBlueFail.state === 4) {// 说明系统蓝牙未开启uni.showModal({content: '蓝牙设置 - 小程序需要通过蓝牙搜索和连接设备,请确认手机蓝牙功能是否已开启?',showCancel: false,confirmText: '我已开启',success: async () => {const {bluetoothEnabled,platform} = uni.getSystemInfoSync();if (bluetoothEnabled) {// 开启蓝牙功能resolve(true);} else {uni.showToast({icon: 'none',title: '手机蓝牙未开启'})}},});}},});});} else {return new Promise(function(resolve, reject) {// andriodif (!bluetoothEnabled) {// 说明系统蓝牙未开启uni.showModal({content: '蓝牙设置 - 小程序需要通过蓝牙搜索和连接设备,请确认手机蓝牙功能是否已开启?',showCancel: false,confirmText: '我已开启',success: async () => {const {bluetoothEnabled,platform} = uni.getSystemInfoSync();if (bluetoothEnabled) {// 开启蓝牙功能resolve(true);} else {toast({title: '手机蓝牙未开启'});}},});} else {// 开启蓝牙功能resolve(true);}});}
},

额外关闭提示:

<button class="search-btn" type="default" @click="toggleLocationTracking">{{ isTrackingLocation ? '关闭位置追踪' : '开启位置追踪' }}</button>// data
isTrackingLocation:false// methods
toggleLocationTracking() {if (this.isTrackingLocation) {this.stopLocationTracking();} else {this.startLocationTracking();}},
startLocationTracking() {uni.authorize({scope: 'scope.userLocation',success: () => {this.isTrackingLocation = true;uni.showToast({title: '已开启位置服务',icon: 'success'});},fail: () => {uni.showModal({title: '提示',content: '需要位置权限才能搜索蓝牙设备',confirmText: '去设置',success: (res) => {if (res.confirm) uni.openSetting();}});}});},
stopLocationTracking() {uni.getSetting({success: (res) => {if (res.authSetting['scope.userLocation']) {uni.showModal({title: '确认',content: '确定要关闭位置服务吗?关闭后将无法搜索新设备',success: (res) => {if (res.confirm) {// 实际微信小程序无法直接关闭权限,引导用户去设置页uni.openSetting({success: () => {this.isTrackingLocation = false;}});}}});}}});},
http://www.dtcms.com/wzjs/187739.html

相关文章:

  • 可登录的网站有哪些竞价外包推广
  • 建网站学什么seo推广工具
  • 网站应该如何推广百度竞价开户哪家好
  • 提供佛山顺德网站建设怎么快速优化网站
  • 网站怎么做抽奖数据网站有哪些
  • 真实的企业微信开发天津seo排名扣费
  • 宝鸡企业网站建设官方百度平台
  • 传奇发布网站排行获客
  • 商标设计一般多少钱seo网络推广专员
  • 网页游戏排行榜前十名3dseo外包如何
  • 建设网站的网站外贸怎么建立自己的网站
  • 桂城网站设计做公司网站
  • 广西造建设工程协会网站免费企业建站
  • 网站建设 的介绍5118数据分析平台官网
  • 做网站用什么程序品牌宣传
  • wordpress自适应网站博客模板最新天津百度网站快速排名
  • 做微商网站设计网站营销策略有哪些
  • 建设部精神文明建设网站网络优化工程师工作内容
  • 做网站买了域名后市场营销比较好写的论文题目
  • 成都网站建设小程序百度排行
  • 渠道建设网站app拉新推广赚佣金
  • 开发公司综合部内部管理章程杭州seo网站优化
  • 俄罗斯免费网站推广seo站内优化最主要的是什么
  • 做中学数学教案有哪些好的网站西seo优化排名
  • 南山网站建设公司全网万能搜索引擎
  • 任何查询网站有没有做404百度搜索智能精选
  • 电子商务网站建设 论文seo怎么才能做好
  • 网站建设工作推进会上的讲话哪有免费的网站
  • 邢台地区网站建设搜索关键词然后排名怎样提升
  • 广州做网站基本流程网站关键词排名seo