From 12931ae7d578438e414d25d049906721dfd74011 Mon Sep 17 00:00:00 2001 From: shijing Date: Wed, 20 Oct 2021 09:30:42 +0800 Subject: [PATCH] wechartRegister --- common/http.api.js | 4 +- pages/login/register.vue | 125 ++++++++++++++++++++++++++++++++- pages/order/confirmation.vue | 2 +- pages/tabBar/home/home.vue | 4 +- pages/user/setting/setting.vue | 7 +- static/img/share/wechart.png | Bin 0 -> 1567 bytes 6 files changed, 136 insertions(+), 6 deletions(-) create mode 100644 static/img/share/wechart.png diff --git a/common/http.api.js b/common/http.api.js index 1f734be..7485bf8 100644 --- a/common/http.api.js +++ b/common/http.api.js @@ -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 { diff --git a/pages/login/register.vue b/pages/login/register.vue index c2dbc28..b909859 100644 --- a/pages/login/register.vue +++ b/pages/login/register.vue @@ -24,8 +24,14 @@ 已有账号立即登录 + + + + 微信一键注册 + - @@ -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; + } diff --git a/pages/order/confirmation.vue b/pages/order/confirmation.vue index 7ee93f5..833c824 100644 --- a/pages/order/confirmation.vue +++ b/pages/order/confirmation.vue @@ -152,7 +152,7 @@ int: 1200, //抵扣积分 deduction: 0, //抵扣价格 recinfo:{ - id:0, + // id:0, }, if_invoice:2, freights:{}, diff --git a/pages/tabBar/home/home.vue b/pages/tabBar/home/home.vue index eeb90c6..0207f25 100644 --- a/pages/tabBar/home/home.vue +++ b/pages/tabBar/home/home.vue @@ -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' }); }, diff --git a/pages/user/setting/setting.vue b/pages/user/setting/setting.vue index 7d4ebe9..fc13f53 100644 --- a/pages/user/setting/setting.vue +++ b/pages/user/setting/setting.vue @@ -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' }) } } diff --git a/static/img/share/wechart.png b/static/img/share/wechart.png new file mode 100644 index 0000000000000000000000000000000000000000..3a33cc4b493fc7f0f7dd6d65d50fd28148d0b399 GIT binary patch literal 1567 zcmdUw_dDAO0LG(c5u*s@TI-^EH6B4ILc|^oB27iBP0!wnnnBXi)}}b2T)$dso)PPi zs?~~_JVEVE)jFf7QRno}xc7P9_w(!f)BDETqRqg(lDr@g2y9_)j5#Oir+L`Vb8jyF z=p5y?)>xBsp8ZcWP*sw1UROI9gSH1zt&e+#NLm&uJMMsVJwcCmbB40?q3lt!Hxicf z__mzTN>yrJq}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