From ac5bea9660227796fd69a43af9661c56c2611843 Mon Sep 17 00:00:00 2001 From: Tuzki <1720599558@qq.com> Date: Mon, 14 Aug 2023 08:51:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=8C=20=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E8=8E=B7?= =?UTF-8?q?=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 6 +- common/param.js | 4 +- manifest.json | 2 +- pages/personcenter/personcenter.vue | 454 +++++++++++++++------------- pages/suggest/sug_from.vue | 61 ++-- 5 files changed, 270 insertions(+), 257 deletions(-) diff --git a/App.vue b/App.vue index 04894b7..e48f0b6 100644 --- a/App.vue +++ b/App.vue @@ -6,11 +6,11 @@ const aes = require('./common/aes.js'); onLaunch: function() { console.log("App Launch") var that = this; - util.userLocation();//进来先调一次android定位方法 - + // util.userLocation();//进来先调一次android定位方法 + //检查缓存中userid的存储格式 var userStorageSync = aes.aesDecrypt(uni.getStorageSync("userid")) - if(userStorageSync.indexOf("data")){ + if(userStorageSync.indexOf("data")&&userStorageSync!=null&&userStorageSync!=""){ var json = JSON.parse(userStorageSync); uni.setStorageSync("userid",aes.aesMinEncrypt(json.data)); } diff --git a/common/param.js b/common/param.js index bdc6c3a..3b17508 100644 --- a/common/param.js +++ b/common/param.js @@ -5,7 +5,7 @@ module.exports = { clng: 114.489380, //当前经度 clat: 38.042040 ,//当前纬度 update_oauthTime: 1000*60*60*12 ,//更新时间 - appid: "wxaf70a5cd03b06c19", + appid: "wx111bbea67d1b06d5", user_info:null ,//用户信息 cityName:"雄安", cityPy:"xiongan", @@ -65,4 +65,4 @@ module.exports = { YXJD:"2930", hotScenicGuid:"79", videoFLType:"54"//视频分类 -} \ No newline at end of file +} diff --git a/manifest.json b/manifest.json index 44949a7..6091668 100644 --- a/manifest.json +++ b/manifest.json @@ -60,7 +60,7 @@ "quickapp" : {}, /* 小程序特有相关 */ "mp-weixin" : { - "appid" : "wxaf70a5cd03b06c19", + "appid" : "wx111bbea67d1b06d5", "setting" : { "urlCheck" : false, "minified" : true, diff --git a/pages/personcenter/personcenter.vue b/pages/personcenter/personcenter.vue index d3ed163..aa5ac28 100644 --- a/pages/personcenter/personcenter.vue +++ b/pages/personcenter/personcenter.vue @@ -5,10 +5,10 @@ - + - @@ -47,7 +47,7 @@ 客服电话 - + 退出登录 @@ -89,110 +89,109 @@ export default { }; }, onShow() { - if (!this.$util.isBlack(aes.aesDecrypt(uni.getStorageSync('unionid')))) { this.isLogin = true; that.nickname = aes.aesDecrypt(uni.getStorageSync('nickname')); that.headimgurl = aes.aesDecrypt(uni.getStorageSync('headimgurl')); } - if ( - aes.aesDecrypt(uni.getStorageSync('adminId')) != undefined && - aes.aesDecrypt(uni.getStorageSync('adminId')) != null && - aes.aesDecrypt(uni.getStorageSync('adminId')) != '' - ) { - this.adminId = uni.getStorageSync('adminId'); - this.isAdminLogin = true; - } + // if ( + // aes.aesDecrypt(uni.getStorageSync('adminId')) != undefined && + // aes.aesDecrypt(uni.getStorageSync('adminId')) != null && + // aes.aesDecrypt(uni.getStorageSync('adminId')) != '' + // ) { + // this.adminId = uni.getStorageSync('adminId'); + // this.isAdminLogin = true; + // } }, onLoad(options) { - if ( - aes.aesDecrypt(uni.getStorageSync('adminId')) != undefined && - aes.aesDecrypt(uni.getStorageSync('adminId')) != null && - aes.aesDecrypt(uni.getStorageSync('adminId')) != '' - ) { - this.adminId = aes.aesDecrypt(uni.getStorageSync('adminId')); - this.isAdminLogin = true; - } - // options = this.$param.user_info; - var that = this; - this.getIsShow(); - // #ifdef H5 - if (this.$wechat.isWechat()) { - //weixin 是否显示更新 - this.isUpdate = false; - } else { - this.isUpdate = true; - } - // #endif + // if ( + // aes.aesDecrypt(uni.getStorageSync('adminId')) != undefined && + // aes.aesDecrypt(uni.getStorageSync('adminId')) != null && + // aes.aesDecrypt(uni.getStorageSync('adminId')) != '' + // ) { + // this.adminId = aes.aesDecrypt(uni.getStorageSync('adminId')); + // this.isAdminLogin = true; + // } + // // options = this.$param.user_info; + // var that = this; + // this.getIsShow(); + // // #ifdef H5 + // if (this.$wechat.isWechat()) { + // //weixin 是否显示更新 + // this.isUpdate = false; + // } else { + // this.isUpdate = true; + // } + // // #endif if (uni.getStorageSync('oauthTime') + this.$param.update_oauthTime < new Date().getTime()) { // uni.removeStorageSync("user_token"); uni.removeStorageSync('nickname'); uni.removeStorageSync('unionid'); uni.removeStorageSync('headimgurl'); } - uni.showLoading({ - mask: true, - title: '授权中', - success() { - setTimeout(function () { - uni.hideLoading(); - }, 3000); - } - }); - if (this.$util.isBlack(aes.aesDecrypt(uni.getStorageSync('unionid')))) { - if (options == null || options.unionid == null || options.unionid == '' || options.unionid == undefined) { - if (this.$wechat.isWechat()) { - //weixin 授权 - that.$util.getUser(that, 'person', '', ''); - } else { - switch (uni.getSystemInfoSync().platform) { - case 'android': - //安卓授权 - var that = this; - this.$util.bindGpsObj(that); - Android.gotoDetial('WxUserInfo', ''); - break; - case 'ios': - //ios授权 - var that = this; - this.$util.bindGpsObj(that); - window.location.href = 'https://www.baidu.com?url=wechat'; - break; - } - } - } else { - // clearTimeout(timer); - //登陆后返回回来的界面 - uni.setStorageSync('oauthTime', new Date().getTime()); - uni.setStorageSync('nickname', aes.aesMinEncrypt(options.nickname)); - uni.setStorageSync('openid', aes.aesMinEncrypt(options.openid)); - uni.setStorageSync('unionid', aes.aesMinEncrypt(options.unionid)); - uni.setStorageSync('headimgurl', aes.aesMinEncrypt(options.headimgurl)); - that.nickname = aes.aesDecrypt(uni.getStorageSync('nickname')); - that.headimgurl = aes.aesDecrypt(uni.getStorageSync('headimgurl')); - that.isLogin = true; - that.getUserInterest(); //回显兴趣定制数据 - // this.$util.getUserInfo(that,options.unionid,function(){ - uni.hideLoading(); - // }); - } - } else { - // if(uni.getStorageSync("user_token") == undefined || uni.getStorageSync("user_token") == null || uni.getStorageSync("user_token") == ""){ - // this.$util.getUserInfo(that,uni.getStorageSync("unionid"),function(){ - // that.isLogin = true; - // that.nickname = uni.getStorageSync("nickname"); - // that.headimgurl = uni.getStorageSync("headimgurl"); - // uni.hideLoading(); - // }); - // }else{ - this.isLogin = true; - this.nickname = aes.aesDecrypt(uni.getStorageSync('nickname')); - this.headimgurl = aes.aesDecrypt(uni.getStorageSync('headimgurl')); - that.getUserInterest(); //回显兴趣定制数据 - that.getAndroidUserKey(); //推送 - uni.hideLoading(); - // } - } + // uni.showLoading({ + // mask: true, + // title: '授权中', + // success() { + // setTimeout(function () { + // uni.hideLoading(); + // }, 3000); + // } + // }); + // if (this.$util.isBlack(aes.aesDecrypt(uni.getStorageSync('unionid')))) { + // if (options == null || options.unionid == null || options.unionid == '' || options.unionid == undefined) { + // if (this.$wechat.isWechat()) { + // //weixin 授权 + // that.$util.getUser(that, 'person', '', ''); + // } else { + // switch (uni.getSystemInfoSync().platform) { + // case 'android': + // //安卓授权 + // var that = this; + // this.$util.bindGpsObj(that); + // Android.gotoDetial('WxUserInfo', ''); + // break; + // case 'ios': + // //ios授权 + // var that = this; + // this.$util.bindGpsObj(that); + // window.location.href = 'https://www.baidu.com?url=wechat'; + // break; + // } + // } + // } else { + // // clearTimeout(timer); + // //登陆后返回回来的界面 + // uni.setStorageSync('oauthTime', new Date().getTime()); + // uni.setStorageSync('nickname', aes.aesMinEncrypt(options.nickname)); + // uni.setStorageSync('openid', aes.aesMinEncrypt(options.openid)); + // uni.setStorageSync('unionid', aes.aesMinEncrypt(options.unionid)); + // uni.setStorageSync('headimgurl', aes.aesMinEncrypt(options.headimgurl)); + // that.nickname = aes.aesDecrypt(uni.getStorageSync('nickname')); + // that.headimgurl = aes.aesDecrypt(uni.getStorageSync('headimgurl')); + // that.isLogin = true; + // that.getUserInterest(); //回显兴趣定制数据 + // // this.$util.getUserInfo(that,options.unionid,function(){ + // uni.hideLoading(); + // // }); + // } + // } else { + // // if(uni.getStorageSync("user_token") == undefined || uni.getStorageSync("user_token") == null || uni.getStorageSync("user_token") == ""){ + // // this.$util.getUserInfo(that,uni.getStorageSync("unionid"),function(){ + // // that.isLogin = true; + // // that.nickname = uni.getStorageSync("nickname"); + // // that.headimgurl = uni.getStorageSync("headimgurl"); + // // uni.hideLoading(); + // // }); + // // }else{ + // this.isLogin = true; + // this.nickname = aes.aesDecrypt(uni.getStorageSync('nickname')); + // this.headimgurl = aes.aesDecrypt(uni.getStorageSync('headimgurl')); + // that.getUserInterest(); //回显兴趣定制数据 + // that.getAndroidUserKey(); //推送 + // uni.hideLoading(); + // // } + // } }, methods: { saveLoginLog: function (unionid) { @@ -215,7 +214,7 @@ export default { } }); }, - /* 是否显示投诉功能 */ + /* 是否显示投诉功能 */ getIsShow: function () { this.$Request.post(this.$config.getYbsjSysParam, {}).then((res) => { var d = res.data; @@ -224,60 +223,61 @@ export default { }, oauthUser: function () { // #ifdef MP-WEIXIN - wx.login({ - success:(res) => { - console.log(res,'登录获取的code') - this.code = res.code; - wx.request({ - url:"https://api.weixin.qq.com/sns/jscode2session?appid=wxaf70a5cd03b06c19&secret=7ae3b6e164593cf30acfd3f5b8cbea0c&js_code="+this.code+"&grant_type=authorization_code", - success:function(res){ - console.log(res) - }, - fail: function(err){ - console.log(err)//App.json中默认超时时间为60秒 - } - }) - console.log(this.code,res); - }, - fail: function (error) { - console.log('login failed ' + error); - } - }); - wx.getUserProfile({ - desc: '用于完善会员资料', - success:(res) => { - console.log(this.code,res); - }, - fail: function (error) { - console.log('login failed ' + error); - } - }) - wx.getUserInfo({ - provider: 'weixin', - success:(res) => { - console.log(this.code,res); - }, - fail: function (error) { - console.log('login failed ' + error); - } - }) - uni.login({ - "provider": "weixin", - "onlyAuthorize": true, // 微信登录仅请求授权认证 - success: function(event){ - console.log(event) - //客户端成功获取授权临时票据(code),向业务服务器发起登录请求。 + // wx.login({ + // success:(res) => { + // console.log(res,'登录获取的code') + // this.code = res.code; + // wx.request({ + // url:"https://api.weixin.qq.com/sns/jscode2session?appid=wx111bbea67d1b06d5&secret=5d5a1ac827c9eab437a90927ebb8a47d&js_code="+this.code+"&grant_type=authorization_code", + // success:function(res){ + // console.log(res) + // }, + // fail: function(err){ + // console.log(err)//App.json中默认超时时间为60秒 + // } + // }) + // console.log(this.code,res); + // }, + // fail: function (error) { + // console.log('login failed ' + error); + // } + // }); + // wx.getUserProfile({ + // desc: '用于完善会员资料', + // success:(res) => { + // console.log(this.code,res); + // }, + // fail: function (error) { + // console.log('login failed ' + error); + // } + // }) + // wx.getUserInfo({ + // provider: 'weixin', + // success:(res) => { + // console.log(this.code,res); + // }, + // fail: function (error) { + // console.log('login failed ' + error); + // } + // }) + // uni.login({ + // "provider": "weixin", + // "onlyAuthorize": true, // 微信登录仅请求授权认证 + // success: function(event){ + // console.log(event) + // //客户端成功获取授权临时票据(code),向业务服务器发起登录请求。 - }, - fail: function (err) { - // 登录授权失败 - // err.code是错误码 - } - }) - that.$util.getUser(that, 'person', '', ''); + // }, + // fail: function (err) { + // // 登录授权失败 + // // err.code是错误码 + // } + // }) + // that.$util.getUser(that, 'person', '', ''); // #endif - // #ifndef MP-WEIXIN - if (this.isLogin) { + // #ifdef MP-WEIXIN + let this_ = this; + if (this_.isLogin) { return; } else { uni.showLoading({ @@ -285,34 +285,54 @@ export default { title: '授权中', success() { setTimeout(function () { + wx.login({ + success: (res) => { + console.log(res, '登录获取的code'); + this.code = res.code; + wx.request({ + url: + 'https://api.weixin.qq.com/sns/jscode2session?appid=wx111bbea67d1b06d5&secret=5d5a1ac827c9eab437a90927ebb8a47d&js_code=' + + this.code + + '&grant_type=authorization_code', + success: function (res) { + console.log(res); + uni.setStorageSync('unionid', aes.aesMinEncrypt(res.data.openid)); + }, + fail: function (err) { + console.log(err); //App.json中默认超时时间为60秒 + } + }); + console.log(this.code, res); + }, + fail: function (error) { + console.log('login failed ' + error); + } + }); + wx.getUserInfo({ + provider: 'weixin', + success: (res) => { + console.log(this.code, res); + uni.setStorageSync('nickname', aes.aesMinEncrypt(res.userInfo.nickName)); + uni.setStorageSync('headimgurl', aes.aesMinEncrypt(res.userInfo.avatarUrl)); + uni.setStorageSync('oauthTime', new Date().getTime()); + this_.nickName = res.userInfo.nickName; + this_.headimgurl = res.userInfo.avatarUrl; + }, + fail: function (error) { + console.log('login failed ' + error); + } + }); // uni.showToast({ // title:"授权失败,点击"+that.nickname+"重新授权", // icon:"none", // duration: 1500 // }) + this_.isLogin = true; + this_.$forceUpdate() uni.hideLoading(); }, 3000); } }); - if (this.$wechat.isWechat()) { - //weixin 授权 - that.$util.getUser(this, 'person', '', ''); - } else { - switch (uni.getSystemInfoSync().platform) { - case 'android': - //安卓授权 - var that = this; - this.$util.bindGpsObj(that); - Android.gotoDetial('WxUserInfo', ''); - break; - case 'ios': - //ios授权 - var that = this; - this.$util.bindGpsObj(that); - window.location.href = 'https://www.baidu.com?url=wechat'; - break; - } - } } // #endif @@ -332,39 +352,41 @@ export default { uni.navigateTo({ url: '/pages/personcenter/aboutus' }); - } else if (obj == 'yuyue') { - // if (this.$util.isBlack(aes.aesDecrypt(uni.getStorageSync('unionid')))) { - // uni.showToast({ - // title: '请先授权', - // icon: 'none' - // }); - // return; - // } + } else if (obj == 'yuyue') { + if (this.$util.isBlack(aes.aesDecrypt(uni.getStorageSync('unionid')))) { + uni.showToast({ + title: '请先授权', + icon: 'none' + }); + return; + } uni.navigateTo({ url: '/sunPackIndex/scenic/subscribe/yuyue/yue_list_js' }); } else if (obj == 'tousu') { - // if (this.$util.isBlack(aes.aesDecrypt(uni.getStorageSync('unionid')))) { - // uni.showToast({ - // title: '请先授权', - // icon: 'none' - // }); - // return; - // } + if (this.$util.isBlack(aes.aesDecrypt(uni.getStorageSync('unionid')))) { + uni.showToast({ + title: '请先授权', + icon: 'none' + }); + return; + } uni.navigateTo({ url: '/pages/suggest/sug_list' }); } else if (obj == 'myReserve') { - /* if (this.$util.isBlack(aes.aesDecrypt(uni.getStorageSync('unionid')))) { + if (this.$util.isBlack(aes.aesDecrypt(uni.getStorageSync('unionid')))) { uni.showToast({ title: '请先授权', icon: 'none' }); return; - } */ + } + console.log('90909090') uni.navigateTo({ - url: '/pages/myReserve/myReserve' + url: '/pages/myReserve/myResesrve' }); + console.log('jjijsdjifi') } else if (obj == 'admin') { uni.navigateTo({ url: '/pages/personcenter/adminLogin/adminLogin' @@ -391,8 +413,8 @@ export default { uni.removeStorageSync('oauthTime'); uni.removeStorageSync('openid'); uni.removeStorageSync('unionid'); - this.nickname = "点击头像授权"; - this.headimgurl = "../../static/images/adm_img.png"; + this.nickname = '点击头像授权'; + this.headimgurl = '../../static/images/adm_img.png'; this.isLogin = false; } } else if (obj == 'myComment') { @@ -408,39 +430,43 @@ export default { }); } else if (obj == 'delete') { var that = this; - uni.showModal({ - title: '提示', - icon: 'none', - content:"该操作将会清空所有用户数据!是否注销账户", - success: function (res) { - if (res.confirm) { - that.deleteUserApp(); - this.scenicGZType = 'NO', - this.lineGZType = 'NO', - this.foodGZType = 'NO', - this.methodGZType = 'NO', - uni.removeStorageSync('nickname'); - uni.removeStorageSync('headimgurl'); - uni.removeStorageSync('oauthTime'); - uni.removeStorageSync('openid'); - uni.removeStorageSync('unionid'); - this.nickname = "点击头像授权"; - this.headimgurl = "../../static/images/adm_img.png"; - this.isLogin = false; - } else if (res.cancel) { + if (that.isLogin == true) { + uni.showModal({ + title: '提示', + icon: 'none', + content: '该操作将会清空所有用户数据!是否注销账户', + success: function (res) { + if (res.confirm) { + that.deleteUserApp(); + (this.scenicGZType = 'NO'), (this.lineGZType = 'NO'), (this.foodGZType = 'NO'), (this.methodGZType = 'NO'), uni.removeStorageSync('nickname'); + uni.removeStorageSync('headimgurl'); + uni.removeStorageSync('oauthTime'); + uni.removeStorageSync('openid'); + uni.removeStorageSync('unionid'); + that.nickname = '点击头像授权'; + that.headimgurl = '../../static/images/adm_img.png'; + that.isLogin = false; + } else if (res.cancel) { + } } - } - }); + }); + }else{ + uni.showToast({ + title: '您还未登录!', + icon: 'none' + }); + return; + } } }, - getUserInterest: function () { + getUserInterest: function () { var that = this; var data = { userid: aes.aesDecrypt(uni.getStorageSync('unionid')), userkey: this.$param.userkey //userid: "2" }; - this.$Request.post(this.$config.getUserInterest, data).then(res => { + this.$Request.post(this.$config.getUserInterest, data).then((res) => { var data = res.data; that.scenicGZType = data.scenic_isShow; that.lineGZType = data.line_isShow; @@ -466,9 +492,9 @@ export default { userid: aes.aesDecrypt(uni.getStorageSync('unionid')), userkey: this.$param.userkey }; - this.$Request.post(this.$config.deleteUserApp, data).then(res => { + this.$Request.post(this.$config.deleteUserApp, data).then((res) => { uni.showToast({ - title: "注销成功!", + title: '注销成功!', duration: 2000 }); }); @@ -500,9 +526,9 @@ export default { userid: aes.aesDecrypt(uni.getStorageSync('unionid')), pageType: '' }; - this.$Request.post(this.$config.imgPushFun, data).then(res => {}); + this.$Request.post(this.$config.imgPushFun, data).then((res) => {}); } - }, + } } }; diff --git a/pages/suggest/sug_from.vue b/pages/suggest/sug_from.vue index 1f945ba..0a76196 100644 --- a/pages/suggest/sug_from.vue +++ b/pages/suggest/sug_from.vue @@ -5,8 +5,8 @@ 事故发生地(必填) - - 当前位置> + + 当前位置 @@ -43,7 +43,7 @@ 上传证据 - + @@ -85,7 +85,7 @@ --> - + @@ -95,11 +95,11 @@ - + - + - + *联系方式 @@ -107,11 +107,11 @@ - + - + - + @@ -141,7 +141,7 @@ var value = e.detail.value if(value == ""){ return; - } + } if(!value.match("^[a-zA-Z0-9_\u4e00-\u9fa5]+$")){ uni.showToast({ icon:"none", @@ -185,7 +185,7 @@ return; } } - + if(e.detail.value.creason.length == 0){ uni.showModal({ title: '温馨提示', @@ -201,7 +201,7 @@ return; } } - + if(e.detail.value.lineuser.length==0){ uni.showModal({ title: '温馨提示', @@ -259,7 +259,7 @@ } }); }, - + beforeUpload: function(){ var that = this; var url = this.$config.getMessageInfoFormFilter; @@ -333,7 +333,7 @@ var that = this; var pics = that.pics; if(pics.length < 9){ - + uni.chooseImage({ count: 9, // 最多可以选择的图片张数,默认9 sizeType: ['original','compressed'], // original 原图,compressed 压缩图,默认二者都有 @@ -392,30 +392,17 @@ title: "定位中", mask: true }) - this.$util.bindGpsObj(that); - this.$util.getLocation( - function(res) { - if (that.$wechat.isWechat()) { - that.latitude = res.latitude; - that.longitude = res.longitude; - } - var data = { - lat: that.latitude, - lng: that.longitude, - poi:"0", - key:"Z2IBZ-6BRKG-Z52QT-IU3J2-6P3QO-WIBII" - } - that.$Request.post(that.$config.getAddressByLatLng,data).then(res => { - if(res.status == 0){ - that.address = res.result.address; - } - }); + uni.getLocation({ + type: 'gcj02', + altitude:true, + success: function (res) { + console.log('当前位置的经度:' + res.longitude); + console.log('当前位置的纬度:' + res.latitude); + that.address = res.longitude+','+res.latitude; uni.hideLoading(); }, - function() { - console.log('location error---'); - } - ); + + }); }, callGpsSuccess: function(lat, lng){ var that = this;