wechartRegister

This commit is contained in:
shijing 2021-10-20 09:30:42 +08:00
parent 732db99e9a
commit 12931ae7d5
6 changed files with 136 additions and 6 deletions

View File

@ -47,6 +47,7 @@ const install = (Vue, vm) => {
let checkUserName = (params={})=>vm.$u.get(`/index.php/api/login/check_username`, params);//注册时检查用户名是否
let getCodeRepass = (id,params)=>vm.$u.get(`/index.php/api/login/getpwdnum/type/mobphone/to/${id}`,params);//获取验证码
let changepwd = ( params)=>vm.$u.post(`/index.php/api/login/changepwd`, params);//修改密码
let wxReg = ( params)=>vm.$u.post(`/index.php/api/login/one_key_reg`, params);//微信一键注册
vm.$u.api = {
getSearch,
@ -84,7 +85,8 @@ const install = (Vue, vm) => {
getCodeRepass,
changepwd,
checkUserName,
register};
register,
wxReg};
}
export default {

View File

@ -24,8 +24,14 @@
<view class="res">
<view @tap="toLogin">已有账号立即登录</view>
</view>
</view>
<view class="wechartRegister">
<button id="wxRegister" open-type="getUserInfo" @getuserinfo="weChartReg">
<image src="../../static/img/share/wechart.png" class="wechartRegisterImg"></image>
</button>
<view class="wechartRegisterText">微信一键注册</view>
</view>
</view>
</view>
</template>
@ -42,6 +48,8 @@
getCodeBtnColor:"#ffffff",
getCodeisWaiting:false,
unique:true,
nickname:'',
code:''
}
},
onLoad() {
@ -106,6 +114,96 @@
}else{}
})
},
//
weChartReg(){
let that = this;
uni.showModal({
title: '温馨提示',
content: '亲,授权微信登录后才能正常使用小程序功能',
success(modelRes) {
//
if (modelRes.confirm) {
uni.getUserProfile({
desc: '获取你的昵称',
success: profileRes => {
that.nickName = profileRes.userInfo.nickName;
uni.login({
provider: 'weixin',
success: function (wxLoginRes) {
debugger;
console.log(wxLoginRes.code)
that.code = wxLoginRes.code;
let params = {nickname:that.nickName,code:wxLoginRes.code};
that.$u.api.wxReg(params).then(wxRegRes=>{
uni.hideLoading();
if(wxRegRes.code==0){
uni.showToast({
title: '注册成功',
icon: "success"
});
uni.login({
provider: 'weixin',
success: function (ress) {
that.$u.api.login({
code: ress.code
}).then(
res => {
that.$u.vuex('vuex_token', res.data.token)
that.$u.api.getInfo().then(res => {
that.$u.vuex('vuex_user', res.data)
if(res.data.icon===""){
that.$u.vuex('vuex_user.icon', '/static/img/face.jpg')
}else{
that.$u.vuex('vuex_user.icon', that.vuex_host + 'public/' + res.data.icon)
}
uni.reLaunch({
url:'/pages/tabBar/home/home'
})
})
uni.hideLoading()
}
).catch(res=>{
uni.redirectTo({
url:'/pages/login/login'
})
})
},
})
}else{
uni.showToast({
title: infoRes.data.msg,
icon:'none'
});
}
})
},
})
},
fail: res => {
console.log(2);
console.log(res)
//
uni.showToast({
title: '您拒绝了请求,不能正常使用小程序',
icon: 'error',
duration: 2000
});
return;
}
});
} else if (res.cancel) {
//
console.log(3);
uni.showToast({
title: '您拒绝了请求,不能正常使用小程序',
icon: 'error',
duration: 2000
});
return;
}
}
});
},
//
doReg(){
let that = this;
@ -177,6 +275,9 @@
// });
// },1000)
//
},
weChartRegister(){
},
toLogin(){
uni.hideKeyboard()
@ -195,4 +296,26 @@
color: #ff0000;
text-decoration: underline;
}
.wechartRegister{
text-align: center;
}
.wechartRegisterImg{
width: 100upx;
height: 100upx;
margin-top: 30upx;
}
.wechartRegisterText{
font-size: 22upx;
color: #ffffff;
}
#wxRegister{
background-color: #f06c7a ;
height: max-content;
padding: 0;
border: none;
// line-height: 0;
}
#wxRegister::after{
border: none;
}
</style>

View File

@ -152,7 +152,7 @@
int: 1200, //
deduction: 0, //
recinfo:{
id:0,
// id:0,
},
if_invoice:2,
freights:{},

View File

@ -307,7 +307,7 @@ export default {
res.data[i].img = this.vuex_host + '/' + res.data[i].img+"?timer="+timestamp
console.log(i)
console.log(res.data[i].img)
debugger;
// debugger;
}
this.swiperList = res.data;
console.log(this.swiperList)
@ -452,7 +452,7 @@ export default {
},
//
toSwiper(e) {
debugger;
// debugger;
console.log(e)
// uni.showToast({ title: e.src, icon: 'none' });
},

View File

@ -99,7 +99,7 @@
},
logout(){
var that = this
that.$u.api.logout().then(res=>{
/* that.$u.api.logout().then(res=>{
if(res.code==0){
that.$u.vuex('vuex_user', {nickname: '游客', icon:'/static/img/face.jpg'})
that.$u.vuex('vuex_token', '')
@ -107,6 +107,11 @@
url:'/pages/login/login'
})
}
}) */
that.$u.vuex('vuex_user', {nickname: '游客', icon:'/static/img/face.jpg'})
that.$u.vuex('vuex_token', '')
uni.reLaunch({
url:'/pages/login/login'
})
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB