From 616a6d3fe6d308a27c14782a92e22fe882e7d1ea Mon Sep 17 00:00:00 2001 From: maclien <421129572@qq.com> Date: Sun, 26 May 2024 18:12:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E5=88=B0=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 3 +- commons/css/base/imgSize.wxss | 2 + commons/js/utils/user-manager.js | 236 +++++++++++++++++++++++++++++++ components/navBar/navBar.js | 13 +- components/navBar/navBar.wxml | 3 +- pages/signup/code.js | 35 ++--- pages/signup/code.json | 6 + pages/signup/code.wxml | 32 ++++- pages/signup/index.js | 29 +--- pages/signup/index.json | 6 + pages/signup/index.wxml | 10 +- pages/signup/status.js | 72 ++++++++++ pages/signup/status.json | 9 ++ pages/signup/status.wxml | 10 ++ pages/signup/status.wxss | 1 + 15 files changed, 417 insertions(+), 50 deletions(-) create mode 100644 pages/signup/status.js create mode 100644 pages/signup/status.json create mode 100644 pages/signup/status.wxml create mode 100644 pages/signup/status.wxss diff --git a/app.json b/app.json index 05bbbce..81b42cb 100644 --- a/app.json +++ b/app.json @@ -65,7 +65,8 @@ "pages/order/editBuyer/index", "pages/storeData/subData/index", "pages/signup/code", - "pages/signup/index" + "pages/signup/index", + "pages/signup/status" ], "echarts": [ { diff --git a/commons/css/base/imgSize.wxss b/commons/css/base/imgSize.wxss index 60498b7..6853128 100644 --- a/commons/css/base/imgSize.wxss +++ b/commons/css/base/imgSize.wxss @@ -25,6 +25,8 @@ .img-250x445{width:250rpx;height:445rpx;box-sizing:border-box;} .img-300x200{width:300rpx;height:200rpx;box-sizing:border-box;} .img-300x230{width:300rpx;height:230rpx;box-sizing:border-box;} +.img-400x400{width:400rpx;height:400rpx;box-sizing:border-box;} +.img-500x500{width:500rpx;height:500rpx;box-sizing:border-box;} .img-750x250{width:750rpx;height:250rpx;box-sizing:border-box;} .img-750x422{width:100%;height:422rpx;box-sizing:border-box;} diff --git a/commons/js/utils/user-manager.js b/commons/js/utils/user-manager.js index c29193b..d52900c 100644 --- a/commons/js/utils/user-manager.js +++ b/commons/js/utils/user-manager.js @@ -47,9 +47,245 @@ function isOpenCard() { }) } +const getUserLocation = function () { + return new Promise(function (resolve, reject) { + wx.getLocation({ + type: 'gcj02', //wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 + success(res) { + app.setStorage('u_lat', res.latitude) + app.setStorage('u_lng', res.longitude) + resolve({ + lat: res.latitude, + lng: res.longitude, + from_storage: false, + }); + }, + fail(res) { + app.printErrorClient('userLocationFail', ['错误信息:' + JSON.stringify(res)]) + console.log(res) + _ModelForGetLocationModel(resolve, reject, res.errMsg); + } + }) + }) +} + + +function _ModelForGetLocationModel(resolve, reject, errMsg) { + if (errMsg && errMsg.indexOf('auth') > -1) { + wx.showModal({ + title: '', + content: '检测到你未打开地理位置的权限,是否前往开启', + confirmText: '前往开启', + showCancel: false, + success(res) { + if (res.confirm) { + //成功的时候只执行一次(通过手动的时候就没执行了) + wx.openSetting({ + success(res) { + wx.authorize({ + scope: 'scope.userLocation', + success() { + // resolve("toggle"); + wx.getLocation({ + type: 'wgs84', + success(res) { + app.setStorage('u_lat', res.latitude) + app.setStorage('u_lng', res.longitude) + resolve({ + lat: res.latitude, + lng: res.longitude, + from_storage: false, + }); + } + }) + }, + fail() { + app.printErrorClient('userLocationFail', ['错误信息:打开打开地理位置的权限,未设置']) + // _ModelForGetLocationModel(resolve, reject); + getUserLocation() + reject() + } + }) + } + }) + } else if (res.cancel) { + app.printErrorClient('userLocationFail', ['错误信息:用户点击取消']) + reject() + } + } + }) + } else if (errMsg && (!wx.getSystemInfoSync().locationEnabled || errMsg.indexOf('system') > -1 || errMsg.indexOf('fail authorize no response') > -1)) { + wx.showModal({ + title: '获取定位失败', + content: '请在系统设置中\n打开定位服务后刷新页面', + confirmText: '确定', + showCancel: false, + complete: res => { + reject() + // _ModelForGetLocationModel(resolve, reject,res.errMsg) + } + }) + } else { + wx.showToast({ + title: '请刷新页面,重新授权地理位置信息', + // content: '请刷新页面\n重新授权地理位置信息', + // confirmText: '确定', + // showCancel: false, + icon: 'none', + success: res => { + reject() + //_ModelForGetLocationModel(resolve, reject,res.errMsg) + } + }) + } +} + + +const getUserAuthLocation = () => { + let that = this + return new Promise(function (resolve, reject) { + if (app.getStorageByKey('isAgreeAuthLocation')) { + wx.startLocationUpdate({ + success() { + wx.onLocationChange(function (res) { + app.setStorage('u_lat', res.latitude) + app.setStorage('u_lng', res.longitude) + resolve({ + lat: res.latitude, + lng: res.longitude, + from_storage: false, + }); + wx.stopLocationUpdate() + }) + }, + fail(){ + app.printErrorClient('userLocationFail', ['错误信息:用户拒绝授权LocationUpdate']) + getCityLocation().then(res => { + app.setStorage('isAgreeAuthLocation', 1) + resolve({ + lat: res.lat, + lng: res.lng, + from_storage: false, + }) + }) + } + }) + } else if(app.getStorageByKey('isRefuseAuthLocation')) { + wx.showModal({ + title: '', + content: '开启地理位置权限,获得更精准的体验哦~', + showCancel: true, + cancelText: '我再想想', + confirmText: '前往开启', + success(res) { + if (res.confirm) { + //成功的时候只执行一次(通过手动的时候就没执行了) + wx.openSetting({ + success(res) { + wx.authorize({ + scope: 'scope.userLocation', + success() { + // resolve("toggle"); + wx.getLocation({ + type: 'gcj02', + success(res) { + app.setStorage('u_lat', res.latitude) + app.setStorage('u_lng', res.longitude) + app.setStorage('isAgreeAuthLocation', 1) + resolve({ + lat: res.latitude, + lng: res.longitude, + from_storage: false, + }); + } + }) + + }, + fail() { + app.printErrorClient('userLocationFail', ['错误信息:打开打开地理位置的权限,未设置']) + // _ModelForGetLocationModel(resolve, reject); + getIpCtiy().then(res => { + getCityLocation(res.cname).then(res => { + app.setStorage('isRefuseAuthLocation', 1) + resolve({ + lat: res.lat, + lng: res.lng, + from_storage: false, + }) + }) + }) + } + }) + } + }) + } else if (res.cancel) { + app.printErrorClient('userLocationFail', ['错误信息:用户点击取消']) + getIpCtiy().then(res => { + getCityLocation(res.cname).then(res => { + app.setStorage('isRefuseAuthLocation', 1) + resolve({ + lat: res.lat, + lng: res.lng, + from_storage: false, + }) + }) + }).catch(res=>{ + console.log(1) + }) + } + } + }) + }else{ + wx.getLocation({ + type: 'gcj02', //wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 + success(res) { + app.setStorage('u_lat', res.latitude) + app.setStorage('u_lng', res.longitude) + app.setStorage('isAgreeAuthLocation', 1) + resolve({ + lat: res.latitude, + lng: res.longitude, + from_storage: false, + }); + }, + fail(res) { + console.log(res) + app.printErrorClient('userLocationFail', ['错误信息:' + JSON.stringify(res)]) + getIpCtiy().then(res => { + getCityLocation(res.cname).then(res => { + app.setStorage('isRefuseAuthLocation', 1) + resolve({ + lat: res.lat, + lng: res.lng, + from_storage: false, + }) + }) + }).catch(res=>{ + getCityLocation().then(res => { + app.setStorage('isRefuseAuthLocation', 1) + resolve({ + lat: res.lat, + lng: res.lng, + from_storage: false, + }) + }).catch(res=>{ + console.log(2) + }) + }) + // _ModelForGetLocationModel(resolve, reject,res.errMsg); + + } + }) + } + + }) +} + module.exports = { getAjaxUserInfo, isAuthUserInfo, isBindMobile, isOpenCard, + getUserLocation, + getUserAuthLocation } \ No newline at end of file diff --git a/components/navBar/navBar.js b/components/navBar/navBar.js index 538f358..d16b01e 100644 --- a/components/navBar/navBar.js +++ b/components/navBar/navBar.js @@ -35,7 +35,15 @@ Component({ homeShowTitle:{ type: Boolean, value: false - } + }, + showHomeIcon:{ + type: Boolean, + value: true + }, + showLeftIcon:{ + type: Boolean, + value: true + }, }, attached: function () { this.setNavSize() @@ -88,9 +96,10 @@ Component({ }) }, home: function () { - wx.switchTab({ + wx.reLaunch({ url: '/pages/index/index' }) + wx.re } } }) \ No newline at end of file diff --git a/components/navBar/navBar.wxml b/components/navBar/navBar.wxml index 43f4e0f..4351bd7 100644 --- a/components/navBar/navBar.wxml +++ b/components/navBar/navBar.wxml @@ -15,7 +15,7 @@ - + @@ -23,4 +23,5 @@ {{titleText}} + \ No newline at end of file diff --git a/pages/signup/code.js b/pages/signup/code.js index 8729256..fe2d1bd 100644 --- a/pages/signup/code.js +++ b/pages/signup/code.js @@ -1,11 +1,22 @@ // pages/signup/code.js +import _ from '../../commons/js/commons' +const timer = require('../../commons/js/lib/wxTimer'); +var wxTimer = null Page({ /** * 页面的初始数据 */ data: { - + navBar: { + title: '客户签到', + txtColor: '#fff', + bgColor: '#1a1c26', + isShowBg: true, + showHomeIcon: true + }, + qrcode_img: 'http://qnimg.banping.com/20240511/171539407575215900.png', + qrcode_count_time: 30 }, /** @@ -41,26 +52,6 @@ Page({ */ onUnload() { - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - } + }) \ No newline at end of file diff --git a/pages/signup/code.json b/pages/signup/code.json index 8835af0..2f8b4c5 100644 --- a/pages/signup/code.json +++ b/pages/signup/code.json @@ -1,3 +1,9 @@ { + "navigationBarTitleText": "客户签到", + "navigationBarTextStyle": "white", + "navigationStyle": "custom", + "navigationBarBackgroundColor": "#1a1c26", + "backgroundColor": "#ffffff", + "backgroundColorTop": "#1a1c26", "usingComponents": {} } \ No newline at end of file diff --git a/pages/signup/code.wxml b/pages/signup/code.wxml index 027f96d..d84fd5b 100644 --- a/pages/signup/code.wxml +++ b/pages/signup/code.wxml @@ -1,2 +1,32 @@ -pages/signup/code.wxml \ No newline at end of file + + + + + + 2024-05-24 14:13 + + + 车管家 XXX + 长沙- 长沙店 + + + + + 邀请客户微信扫码 + + + + + 30秒后失效立即刷新 + + 客户点击签到,授权手机号及地理位置方可签到成功 + + + + + 本期到店礼 + + + + \ No newline at end of file diff --git a/pages/signup/index.js b/pages/signup/index.js index 58be060..eb1ee85 100644 --- a/pages/signup/index.js +++ b/pages/signup/index.js @@ -5,7 +5,13 @@ Page({ * 页面的初始数据 */ data: { - + navBar: { + title: '签到', + txtColor: '#fff', + bgColor: '#1a1c26', + isShowBg: true, + showHomeIcon: false + } }, /** @@ -42,25 +48,4 @@ Page({ onUnload() { }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - } }) \ No newline at end of file diff --git a/pages/signup/index.json b/pages/signup/index.json index 8835af0..3336aa0 100644 --- a/pages/signup/index.json +++ b/pages/signup/index.json @@ -1,3 +1,9 @@ { + "navigationBarTitleText": "签到", + "navigationBarTextStyle": "white", + "navigationStyle": "custom", + "navigationBarBackgroundColor": "#1a1c26", + "backgroundColor": "#ffffff", + "backgroundColorTop": "#1a1c26", "usingComponents": {} } \ No newline at end of file diff --git a/pages/signup/index.wxml b/pages/signup/index.wxml index 3687fd5..ac6a734 100644 --- a/pages/signup/index.wxml +++ b/pages/signup/index.wxml @@ -1,2 +1,10 @@ -pages/signup/index.wxml \ No newline at end of file + + + + + + + + + \ No newline at end of file diff --git a/pages/signup/status.js b/pages/signup/status.js new file mode 100644 index 0000000..95d25ce --- /dev/null +++ b/pages/signup/status.js @@ -0,0 +1,72 @@ +// pages/signup/status.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + navBar: { + title: '签到', + txtColor: '#fff', + bgColor: '#1a1c26', + isShowBg: true, + showHomeIcon: false + } + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/signup/status.json b/pages/signup/status.json new file mode 100644 index 0000000..3336aa0 --- /dev/null +++ b/pages/signup/status.json @@ -0,0 +1,9 @@ +{ + "navigationBarTitleText": "签到", + "navigationBarTextStyle": "white", + "navigationStyle": "custom", + "navigationBarBackgroundColor": "#1a1c26", + "backgroundColor": "#ffffff", + "backgroundColorTop": "#1a1c26", + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/signup/status.wxml b/pages/signup/status.wxml new file mode 100644 index 0000000..279addf --- /dev/null +++ b/pages/signup/status.wxml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/pages/signup/status.wxss b/pages/signup/status.wxss new file mode 100644 index 0000000..524bc4a --- /dev/null +++ b/pages/signup/status.wxss @@ -0,0 +1 @@ +/* pages/signup/status.wxss */ \ No newline at end of file