调整授权登录接口
parent
3401446e65
commit
d9a876a4ce
21
App.vue
21
App.vue
|
@ -4,11 +4,28 @@
|
|||
projectname:'', // 项目名称
|
||||
lat:'', // 公司地址维度
|
||||
lng:'' ,// 公司地址经度
|
||||
hostapi:'https://www.baidu.com' // 域名配置
|
||||
hostapi:'http://caimall.scdxtc.cn' // 域名配置
|
||||
},
|
||||
// 优先于show方法
|
||||
onLaunch: function() {
|
||||
|
||||
uni.login({
|
||||
success: (res) => {
|
||||
uni.request({
|
||||
url: this.globalData.hostapi +'/api/user/login',
|
||||
data:{code:res.code},
|
||||
success: (result) => {
|
||||
console.log(result);
|
||||
uni.setStorageSync('userId',result.data.account_id);
|
||||
uni.setStorageSync('token',result.data.data.token);//缓存token
|
||||
uni.setStorageSync('openid',result.data.data.openid);//缓存openid
|
||||
uni.setStorageSync('expire',result.data.data.expire);//缓存失效时间(时间戳格式)
|
||||
uni.setStorageSync('phone_active',result.data.data.phone_active);//是否授权手机号
|
||||
uni.setStorageSync('is_active',result.data.data.is_active);//是否授权头像和昵称
|
||||
uni.setStorageSync('invite_code',result.data.data.invite_code);//缓存邀请码
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
onShow: function() {
|
||||
if(uni.getStorageSync('token')){
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
if(index==0){
|
||||
uni.reLaunch({url:'/pages/tabbar/pagehome/pagehome'})
|
||||
} else {
|
||||
// if(!this.$toolAll.tools.judgeAuth()) {
|
||||
if(this.$toolAll.tools.judgeAuth()) {
|
||||
// 已授权
|
||||
switch (index){
|
||||
case 1:
|
||||
|
@ -122,12 +122,7 @@
|
|||
uni.reLaunch({url:'/pages/tabbar/my/my'})
|
||||
break;
|
||||
}
|
||||
// } else {
|
||||
// // 未授权
|
||||
// uni.navigateTo({
|
||||
// url:'/pages/login/login'
|
||||
// })
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -383,10 +383,11 @@ const tools = {
|
|||
judgeAuth(){
|
||||
let auth = false;
|
||||
clearTimeout(this.authTimer);
|
||||
console.log(uni.getStorageSync('token'),1234);
|
||||
if(!uni.getStorageSync('token')) {
|
||||
this.showToast('请登录');
|
||||
this.showToast('请授权登录');
|
||||
this.authTimer = setTimeout(()=>{
|
||||
uni.navigateTo({url:'/pages/login/login'});
|
||||
uni.reLaunch({url:'/pagesB/login/login'});
|
||||
},2000)
|
||||
} else {
|
||||
auth = true;
|
||||
|
|
|
@ -45,16 +45,16 @@
|
|||
padt:uni.getSystemInfoSync().statusBarHeight + 50,
|
||||
headHeight:'',//头部导航高
|
||||
list:[
|
||||
{url:'/pages/tabbar/cate/cate?index=0',iconsrc:'/static/deleteImg/icon-ge-01.png',iconWidth:60,iconHeight:60,title:'推荐套装'},
|
||||
{url:'/pages/tabbar/cate/cate?index=1',iconsrc:'/static/deleteImg/icon-ge-02.png',iconWidth:60,iconHeight:60,title:'喜糖组合'},
|
||||
{url:'/pages/tabbar/cate/cate?index=2',iconsrc:'/static/deleteImg/icon-ge-03.png',iconWidth:60,iconHeight:60,title:'喜盒自选'},
|
||||
{url:'/pages/tabbar/cate/cate?index=3',iconsrc:'/static/deleteImg/icon-ge-04.png',iconWidth:60,iconHeight:60,title:'喜糖自选'},
|
||||
{url:'/pages/tabbar/cate/cate?index=4',iconsrc:'/static/deleteImg/icon-ge-05.png',iconWidth:60,iconHeight:60,title:'迎宾糖散糖'},
|
||||
{url:'/pages/tabbar/cate/cate?index=5',iconsrc:'/static/deleteImg/icon-ge-06.png',iconWidth:60,iconHeight:60,title:'瓜子花生'},
|
||||
{url:'/pages/tabbar/cate/cate?index=6',iconsrc:'/static/deleteImg/icon-ge-07.png',iconWidth:60,iconHeight:60,title:'伴手礼'},
|
||||
{url:'/pagesB/buy-read/buy-read',iconsrc:'/static/deleteImg/icon-ge-08.png',iconWidth:60,iconHeight:60,title:'购买须知'},
|
||||
{url:'/pagesB/business-profile/business-profile',iconsrc:'/static/deleteImg/icon-ge-09.png',iconWidth:60,iconHeight:60,title:'商家简介'},
|
||||
{url:'/pages/tabbar/cate/cate?index=0',iconsrc:'/static/deleteImg/icon-ge-10.png',iconWidth:60,iconHeight:60,title:'其他推荐'},
|
||||
{url:'/pages/tabbar/cate/cate?index=0',iconsrc:'/static/deleteImg/icon-ge-01.png',iconWidth:48,iconHeight:50,title:'推荐套装'},
|
||||
{url:'/pages/tabbar/cate/cate?index=1',iconsrc:'/static/deleteImg/icon-ge-02.png',iconWidth:56,iconHeight:54,title:'喜糖组合'},
|
||||
{url:'/pages/tabbar/cate/cate?index=2',iconsrc:'/static/deleteImg/icon-ge-03.png',iconWidth:64,iconHeight:46,title:'喜盒自选'},
|
||||
{url:'/pages/tabbar/cate/cate?index=3',iconsrc:'/static/deleteImg/icon-ge-04.png',iconWidth:48,iconHeight:48,title:'喜糖自选'},
|
||||
{url:'/pages/tabbar/cate/cate?index=4',iconsrc:'/static/deleteImg/icon-ge-05.png',iconWidth:56,iconHeight:58,title:'迎宾糖散糖'},
|
||||
{url:'/pages/tabbar/cate/cate?index=5',iconsrc:'/static/deleteImg/icon-ge-06.png',iconWidth:58,iconHeight:52,title:'瓜子花生'},
|
||||
{url:'/pages/tabbar/cate/cate?index=6',iconsrc:'/static/deleteImg/icon-ge-07.png',iconWidth:48,iconHeight:54,title:'伴手礼'},
|
||||
{url:'/pagesB/buy-read/buy-read',iconsrc:'/static/deleteImg/icon-ge-08.png',iconWidth:44,iconHeight:56,title:'购买须知'},
|
||||
{url:'/pagesB/business-profile/business-profile',iconsrc:'/static/deleteImg/icon-ge-09.png',iconWidth:54,iconHeight:50,title:'商家简介'},
|
||||
{url:'/pages/tabbar/cate/cate?index=0',iconsrc:'/static/deleteImg/icon-ge-10.png',iconWidth:52,iconHeight:52,title:'其他推荐'},
|
||||
],
|
||||
keyword:'',
|
||||
isplay:false,
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<template>
|
||||
<view>
|
||||
<status-nav :titleVal="'登录'" :tabcolor="'rgba(244, 244, 244,1)'" :whereCome="1*1" :statusTitle="true" :backgroudColor="'rgba(244, 244, 244,1)'"></status-nav>
|
||||
<!-- <view class='login-header'>
|
||||
<image class="infoImg" :style="{boxShadow: '0px 0px 20px '+ publicColor}" mode="aspectFit" :src="userInfo.avatarUrl || imgSrc"></image>
|
||||
<view class="logo-name">恒美植发</view>
|
||||
<view class='login-header'>
|
||||
<image class="infoImg" :style="{boxShadow: '0px 0px 20px rgba(0,0,0,.8)'}" mode="aspectFill" :src="userInfo.avatarUrl || imgSrc"></image>
|
||||
<view class="logo-name">{{appletName}}</view>
|
||||
</view>
|
||||
<view class="login-box">
|
||||
<button class='login-btn' :style="{background:publicColor}" type='primary' @click="bindGetUserInfo">微信授权</button>
|
||||
<button class='login-btn' :style="{background:publicColor || 'linear-gradient(to right, #ff3772 0%,#fd5548 100%)'}" type='primary' @click="bindGetUserInfo">微信授权</button>
|
||||
<view class="xie-box">登录代表您已同意<text @tap="goXie" class="xieCon">《用户服务协议》</text></view>
|
||||
</view>
|
||||
<view v-if="isShowP" class="disjcac posAll">
|
||||
<!-- <view v-if="isShowP" class="disjcac posAll">
|
||||
<view class="bacf radius20 width100 tank-box">
|
||||
<view class="tc tank-box-itemone">请授权绑定手机号</view>
|
||||
<view class="fon28 colf pad-x30 pad-zy30 tc disjb">
|
||||
|
@ -21,13 +21,13 @@
|
|||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class='login-header'>
|
||||
<image class="infoImg" :style="{boxShadow: '0px 0px 20px '+ publicColor}" mode="aspectFit" :src="userInfo.avatarUrl || imgSrc"></image>
|
||||
<!-- <view class='login-header'>
|
||||
<image class="infoImg" :style="{boxShadow: '0px 0px 20px rgba(0,0,0,.8)'}" mode="aspectFill" :src="userInfo.avatarUrl || imgSrc"></image>
|
||||
<view class="logo-name">{{appletName}}</view>
|
||||
</view>
|
||||
<view class="login-box">
|
||||
<view @tap="setMiniColor">
|
||||
<button class='login-btn' open-type="getPhoneNumber" @getphonenumber="getphonenumber" :style="{background:publicColor}" type='primary'>手机号授权登录</button>
|
||||
<view>
|
||||
<button class='login-btn' open-type="getPhoneNumber" @getphonenumber="getphonenumber" :style="{background:publicColor || 'linear-gradient(to right, #ff3772 0%,#fd5548 100%)'}" type='primary'>手机号授权登录</button>
|
||||
</view>
|
||||
<view class="xie-box">登录代表您已同意<text @tap="goXie" class="xieCon">《用户服务协议》</text></view>
|
||||
</view>
|
||||
|
@ -42,7 +42,7 @@
|
|||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
|
@ -51,37 +51,16 @@
|
|||
return {
|
||||
userInfo: {},//用户信息
|
||||
canIGetUserProfile: false,
|
||||
imgSrc: '/static/public/logo.png',//默认logo头像
|
||||
appletName:'恒美植发',//小程序名称
|
||||
imgSrc: 'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg',//默认logo头像
|
||||
appletName:'商城小程序',//小程序名称
|
||||
isShowP:false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 主题颜色
|
||||
publicColor() {
|
||||
return this.$store.state.publicColor
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// 检测当前运行环境并缓存域名
|
||||
this.$toolAll.tools.currentContext();
|
||||
this.setLogo();
|
||||
this.$toolAll.tools.isVedio();
|
||||
// let ya = this;
|
||||
// // 微信扫码后会自动编码,所以需要解码
|
||||
// if (options && options.q) {
|
||||
// let arr = decodeURIComponent(options.q).split('?')[1].split('&')
|
||||
// let obj = {}
|
||||
// arr.forEach(item => {
|
||||
// let brr = item.split('=')
|
||||
// obj[brr[0]] = brr[1]
|
||||
// })
|
||||
// // console.log(obj) //得到参数组成的对象
|
||||
// ya.invite_code = obj.invite_code
|
||||
// }
|
||||
onLoad() {
|
||||
if (uni.getUserProfile) {
|
||||
this.canIGetUserProfile = true;
|
||||
}
|
||||
// this.setLogo();
|
||||
},
|
||||
methods: {
|
||||
// 设置logo图
|
||||
|
@ -96,18 +75,11 @@
|
|||
this.$toolAll.tools.showToast('登录成功','success')
|
||||
uni.reLaunch({url:'/pages/tabbar/pagehome/pagehome'})
|
||||
},
|
||||
// 设置主题色
|
||||
setMiniColor(){
|
||||
this.$requst.get(`index/mini-program-setting`).then(res=>{
|
||||
this.publicColor = res.data.mainColor;
|
||||
uni.setStorageSync('publicColor', res.data.mainColor) //#3875F6 #2E8B57
|
||||
})
|
||||
},
|
||||
getphonenumber(e){//授权绑定手机号
|
||||
let ya = this;
|
||||
wx.login({
|
||||
success:(res)=>{
|
||||
this.$requst.post('user/login',{code:res.code}).then(result => {
|
||||
this.$requst.post('/api/user/login',{code:res.code}).then(result => {
|
||||
if(e.detail.errMsg=="getPhoneNumber:ok"){
|
||||
this.$requst.post('user/bind-phone',{openid: result.data.openid,session_key:result.data.session_key, iv:e.detail.iv,encryptedData:e.detail.encryptedData}).then(res=>{
|
||||
console.log('手机号信息:',res);
|
||||
|
@ -128,7 +100,7 @@
|
|||
},
|
||||
goXie(){
|
||||
uni.navigateTo({
|
||||
url:'/pages/login/xiey'
|
||||
url:'/pagesB/login/xiey'
|
||||
})
|
||||
},
|
||||
//调起登录授权
|
||||
|
@ -176,30 +148,24 @@
|
|||
language:ya.userInfo.language,//语言
|
||||
is_active:1
|
||||
}
|
||||
this.$requst.post('user/login',params).then(res => {
|
||||
this.$requst.post('/api/user/login',params).then(res => {
|
||||
if(res.data.token!=''){
|
||||
uni.setStorageSync('params',params)
|
||||
uni.setStorageSync('userId',res.data.account_id)
|
||||
uni.setStorageSync('token',res.data.token)//缓存token
|
||||
uni.setStorageSync('openid',res.data.openid)//缓存openid
|
||||
uni.setStorageSync('expire',res.data.expire)//缓存失效时间(时间戳格式)
|
||||
uni.setStorageSync('phone_active',res.data.phone_active)//是否第一次授权
|
||||
uni.setStorageSync('is_active',res.data.is_active)//是否第一次授权
|
||||
uni.setStorageSync('invite_code',res.data.invite_code)
|
||||
uni.hideToast()
|
||||
// if(res.data.phone_active!=1){
|
||||
// this.isShowP = true;
|
||||
// } else {
|
||||
if(uni.getStorageSync('urlparams')) {
|
||||
uni.reLaunch({ // 重新进入当前页面
|
||||
url:uni.getStorageSync('urlparams')
|
||||
})
|
||||
} else {
|
||||
uni.reLaunch({
|
||||
url:'/pages/tabbar/pagehome/pagehome'
|
||||
})
|
||||
}
|
||||
// }
|
||||
uni.setStorageSync('phone_active',res.data.phone_active)//是否授权手机号
|
||||
uni.setStorageSync('is_active',res.data.is_active)//是否授权头像和昵称
|
||||
uni.setStorageSync('invite_code',res.data.invite_code)//缓存邀请码
|
||||
if(uni.getStorageSync('page-path-options')) {
|
||||
uni.reLaunch({ // 重新进入当前页面
|
||||
url:uni.getStorageSync('page-path-options')
|
||||
})
|
||||
} else {
|
||||
uni.reLaunch({
|
||||
url:'/pages/tabbar/pagehome/pagehome'
|
||||
})
|
||||
}
|
||||
}
|
||||
},error => {})
|
||||
}
|
||||
|
@ -211,9 +177,9 @@
|
|||
@tcolorp:#3875F6;
|
||||
.login-header {display: flex;justify-content: center;align-items: center;flex-direction: column;margin-top: 40%;}
|
||||
.infoImg {width: 192rpx;height: 192rpx;border-radius: 100%;}
|
||||
.logo-name {font-size: 30rpx;font-weight: bold;margin-top: 20rpx;color: @tcolor;}
|
||||
.logo-name {font-size: 30rpx;font-weight: bold;margin-top: 30rpx;color: @tcolor;}
|
||||
.login-box {margin-top: 60rpx;text-align: center;}
|
||||
.login-btn {width: 80%;margin-top: 50%;}
|
||||
.login-btn {width: 80%;margin-top: 50%;box-shadow: 0rpx 6rpx 10rpx rgba(255, 55, 114, .6);}
|
||||
.xie-box{display: flex;justify-content: center;align-items: center;color: @tcolor;margin-top: 30rpx;}
|
||||
.xieCon{color: @tcolorp;}
|
||||
</style>
|
||||
|
|
|
@ -1,49 +1,35 @@
|
|||
<template>
|
||||
<view>
|
||||
<status-nav :titleVal="'用户协议及隐私声明'" :statusTitle="true"></status-nav>
|
||||
<view :style="{paddingTop: statusHeight+'px'}" class="mar20 line-h50 fon30">
|
||||
<!-- <rich-text :nodes="content"></rich-text> -->
|
||||
<view class="text2">本协议为您与本小程序管理者之间所订立的契约,具有合同的法律效力,请您仔细阅读。</view>
|
||||
<view>一、本协议内容、生效、变更。本协议内容包括协议正文及所有本小程序已经发布的或将来可能发布的各类规则。所有规则为本协议不可分割的组成部分,与协议正文具有同等法律效力。如您对协议有任何疑问,应向本小程序咨询。您在同意所有协议条款并完成注册程序,才能成为本站的正式用户,您登录即代表同意“用户服务协议”,本协议即生效,对双方产生约束力。只要您使用本小程序平台服务,则本协议即对您产生约束,届时您不应以未阅读本协议的内容或者未获得本小程序对您问询的解答等理由,主张本协议无效,或要求撤销本协议。您确认:本协议条款是处理双方权利义务的契约,始终有效,法律另有强制性规定或双方另有特别约定的,依其规定。 您承诺接受并遵守本协议的约定。如果您不同意本协议的约定,您应立即停止注册程序或停止使用本小程序平台服务。本小程序有权根据需要不定期地制订、修改本协议及/或各类规则,并在本小程序平台公示,不再另行单独通知用户。变更后的协议和规则一经在网站公布,立即生效。如您不同意相关变更,应当立即停止使用本小程序平台服务。您继续使用本小程序平台服务的,即表明您接受修订后的协议和规则。</view>
|
||||
<view>二、注册资格用户须具有法定的相应权利能力和行为能力的自然人、法人或其他组织,能够独立承担法律责任。您完成注册程序或其他本小程序平台同意的方式实际使用本平台服务时,即视为您确认自己具备主体资格,能够独立承担法律责任。若因您不具备主体资格,而导致的一切后果,由您及您的监护人自行承担。</view>
|
||||
<view class="text2">
|
||||
<view class="text2">2.1用户应自行诚信向本站提供注册资料,用户同意其提供的注册资料真实、准确、完整、合法有效,用户注册资料如有变动的,应及时更新其注册资料。如果用户提供的注册资料不合法、不真实、不准确、不详尽的,用户需承担因此引起的相应责任及后果,并且本小程序保留终止用户使用本平台各项服务的权利。</view>
|
||||
<view class="text2">2.2用户在本站进行浏览等活动时,涉及用户真实姓名/名称、通信地址、联系电话、电子邮箱等隐私信息的,本站将予以严格保密,除非得到用户的授权或法律另有规定,本站不会向外界披露用户隐私信息。为完成创建账号,用户需提供以下信息:用户的微信昵称、性别、姓名、手机号等信息。用户提供的上述信息,将在用户使用本服务期间持续授权我们使用。在用户注销账号时,我们将停止使用并删除上述信息。上述信息将存储于中华人民共和国境内。如需跨境传输,我们将会单独征得用户的授权同意。</view>
|
||||
<status-container titlet="用户服务协议" :ifCustomer='false'>
|
||||
<view slot="content">
|
||||
<rich-text :nodes="richText" class="fon30 line-h50" style="color: #8c8c9b;"></rich-text>
|
||||
</view>
|
||||
<view>三、账户</view>
|
||||
<view>
|
||||
<view class="text2">3.1您注册成功后,即成为本小程序平台的用户,将持有本小程序平台唯一编号的账户信息。</view>
|
||||
<view class="text2">3.2您设置的姓名为真实姓名,不得侵犯或涉嫌侵犯他人合法权益。否则,本小程序有权终止向您提供服务,注销您的账户。</view>
|
||||
<view class="text2">3.3您应谨慎合理的保存、使用您的会员名和密码,应对通过您的会员名和密码实施的行为负责。除非有法律规定或司法裁定,且征得本小程序的同意,否则,会员名和密码不得以任何方式转让、赠与或继承(与账户相关的财产权益除外)。</view>
|
||||
<view class="text2">3.4用户不得将在本站注册获得的账户借给他人使用,否则用户应承担由此产生的全部责任,并与实际使用人承担连带责任。</view>
|
||||
<view class="text2">3.5如果发现任何非法使用等可能危及您的账户安全的情形时,您应当立即以有效方式通知本小程序要求暂停相关服务,并向公安机关报案。您理解本小程序对您的请求采取行动需要合理时间,本小程序对在采取行动前已经产生的后果(包括但不限于您的任何损失)不承担任何责任。</view>
|
||||
</view>
|
||||
<view>四、用户信息的合理使用</view>
|
||||
<view>
|
||||
<view class="text2">4.1您同意本小程序平台拥有通过短信、电话、微信消息提醒等形式,向在本站注册用户发送信息等告知信息的权利。</view>
|
||||
<view class="text2">4.2您了解并同意,本小程序有权应国家司法、行政等主管部门的要求,向其提供您在本小程序平台填写的注册信息和交易记录等必要信息。如您涉嫌侵犯他人知识产权,则本小程序亦有权在初步判断涉嫌侵权行为存在的情况下,向权利人提供您必要的身份信息。</view>
|
||||
<view class="text2">4.3用户同意本小程序有权使用用户的注册信息、用户名、密码等信息,登陆进入用户的注册账户,进行证据保全,包括但不限于公证、见证等。</view>
|
||||
</view>
|
||||
<view>五、免责条款</view>
|
||||
<view class="text2">5.1 本平台仅提供信息对接,发生一切纠纷问题皆与本平台无关,请通过仲裁部门维护各自权益。</view>
|
||||
</view>
|
||||
</status-container>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
data(){
|
||||
data() {
|
||||
return {
|
||||
|
||||
richText:'',
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
statusHeight() {
|
||||
return this.$store.state.statusHeight
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
// this.$toolAll.tools.escape2Html(this.content)
|
||||
methods: {
|
||||
// 查询关于我们信息
|
||||
checkAboutUs(){
|
||||
this.$requst.post('/api/index/about').then(res=>{
|
||||
if(res.code==0){
|
||||
this.lat = res.data.lat;
|
||||
this.lng = res.data.lon;
|
||||
this.richText = this.$toolAll.tools.escape2Html(res.data.content);
|
||||
this.address = res.data.address;
|
||||
} else {
|
||||
this.$toolAll.tools.showToast(res.msg);
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue