Browse Source

feat(login): 微信小程序登录功能

- 新增获取微信小程序 openid 的功能
- 修改登录接口,增加 mini_wx_openid 参数
- 更新微信登录逻辑,使用新的接口获取 openid
- 更改小程序 appid
master
liutong 10 months ago
parent
commit
592f365128
  1. 8
      api/apiRoute.js
  2. 2
      manifest.json
  3. 75
      pages/student/login/login.vue
  4. BIN
      static/images/common/black_arrow_right.png
  5. BIN
      static/images/common/closex.png
  6. BIN
      static/images/common/clousex-big.png
  7. BIN
      static/images/common/common_icon_jump_gold.png
  8. BIN
      static/images/common/delete.png
  9. BIN
      static/images/common/edit.png
  10. BIN
      static/images/common/fa_song.png
  11. BIN
      static/images/common/gift_icon_close_new.png
  12. BIN
      static/images/common/gouxuankuang.png
  13. BIN
      static/images/common/gray_arrow_down.png
  14. BIN
      static/images/common/icon-close.png
  15. BIN
      static/images/common/icon-drop-down.png
  16. BIN
      static/images/common/icon_about.png
  17. BIN
      static/images/common/icon_black_back.png
  18. BIN
      static/images/common/icon_jump_black3.png
  19. BIN
      static/images/common/image-delete.png
  20. BIN
      static/images/common/jia_hao.png
  21. BIN
      static/images/common/jump-r-arrow.png
  22. BIN
      static/images/common/menu_icon_empty.png
  23. BIN
      static/images/common/more-arrow-right.png
  24. BIN
      static/images/common/round-black-selected.png
  25. BIN
      static/images/common/round_add_disabled.png
  26. BIN
      static/images/common/round_add_normal.png
  27. BIN
      static/images/common/round_minus.png
  28. BIN
      static/images/common/search-icon.png
  29. BIN
      static/images/common/star_normal.png
  30. BIN
      static/images/common/xi_tong_xiao_xi.png
  31. BIN
      static/images/common/yong_hu.png
  32. BIN
      static/images/home/chaungjian.png
  33. BIN
      static/images/home/tixing.png
  34. BIN
      static/images/home/wang.png
  35. BIN
      static/images/home/yong.png
  36. BIN
      static/images/index/addto.png
  37. BIN
      static/images/index/check_mark.png
  38. BIN
      static/images/index/danlan.png
  39. BIN
      static/images/index/danlv.png
  40. BIN
      static/images/index/dian.png
  41. BIN
      static/images/index/hong.png
  42. BIN
      static/images/index/huang.png
  43. BIN
      static/images/index/icon_shopping_bag.png
  44. BIN
      static/images/index/img.jpg
  45. BIN
      static/images/index/intention1.png
  46. BIN
      static/images/index/intention2.png
  47. BIN
      static/images/index/intention3.png
  48. BIN
      static/images/index/lan.png
  49. BIN
      static/images/index/lv.png
  50. BIN
      static/images/index/lvs.png
  51. BIN
      static/images/index/manjian.png
  52. BIN
      static/images/index/me_icon_notification.png
  53. BIN
      static/images/index/menu_btn_close.png
  54. BIN
      static/images/index/menu_icon_popup_triangle_normal.png
  55. BIN
      static/images/index/menupopup_btn_share_normal.png
  56. BIN
      static/images/index/menupopup_btn_share_quanzi.png
  57. BIN
      static/images/index/menupopup_btn_share_wechat.png
  58. BIN
      static/images/index/message.png
  59. BIN
      static/images/index/myk.png
  60. BIN
      static/images/index/phone.png
  61. BIN
      static/images/index/rexiao.png
  62. BIN
      static/images/index/round-cancel.png
  63. BIN
      static/images/index/round.png
  64. BIN
      static/images/index/round_close_btn.png
  65. BIN
      static/images/index/score.png
  66. BIN
      static/images/index/score1.png
  67. BIN
      static/images/index/setup.png
  68. BIN
      static/images/index/shadow_yellow_star.png
  69. BIN
      static/images/index/shenlan.png
  70. BIN
      static/images/index/star.png
  71. BIN
      static/images/index/task.png
  72. BIN
      static/images/index/tuijian.png
  73. BIN
      static/images/index/work_details.png
  74. BIN
      static/images/index/writing.png
  75. BIN
      static/images/index/xinpin.png
  76. BIN
      static/images/index/yellow_star.png
  77. BIN
      static/images/index/zan_wu.png
  78. BIN
      static/images/login/login1.png
  79. BIN
      static/images/login/login2.png
  80. BIN
      static/images/login/wechat1.png
  81. BIN
      static/images/mall/b3d3a98e3c7f450aaa32fbec6aecdfaf.png
  82. BIN
      static/images/mall/img_pointmall_star.png
  83. BIN
      static/images/mall/me_img_banner_mall.png
  84. BIN
      static/images/mall/me_pointmall_img_nogift.png
  85. BIN
      static/images/mall/store_brh_home_page_normal.png
  86. BIN
      static/images/mall/store_brh_service_normal.png
  87. BIN
      static/images/member/me_club_task_img_done.png
  88. BIN
      static/images/my/b3d3a98e3c7f450aaa32fbec6aecdfaf.png
  89. BIN
      static/images/my/coupons-empty.png
  90. BIN
      static/images/my/icon_arrow.png
  91. BIN
      static/images/my/icon_attention.png
  92. BIN
      static/images/my/icon_giftcard.png
  93. BIN
      static/images/my/icon_rules.png
  94. BIN
      static/images/my/img_giftcard_empty.png
  95. BIN
      static/images/my/jf.png
  96. BIN
      static/images/my/me_icon_gift_card.png
  97. BIN
      static/images/my/me_icon_points.png
  98. BIN
      static/images/my/me_icon_quan.png
  99. BIN
      static/images/my/me_icon_wallet.png
  100. BIN
      static/images/my/member_benefits/me_rights_icon_1jia1.png

8
api/apiRoute.js

@ -98,6 +98,14 @@ export default {
//公共端-获取配置项 //公共端-获取配置项
common_getConfig(data = {}) { common_getConfig(data = {}) {
let url = '/common/getConfig' let url = '/common/getConfig'
return http.get(url, data).then(res => {
return res;
})
},
//公共端-获取配置项
common_getMiniWxOpenId(data = {}) {
let url = '/common/getMiniWxOpenId'
return http.post(url, data).then(res => { return http.post(url, data).then(res => {
return res; return res;
}) })

2
manifest.json

@ -62,7 +62,7 @@
"quickapp" : {}, "quickapp" : {},
/* */ /* */
"mp-weixin" : { "mp-weixin" : {
"appid" : "wx26182c3e34af2dc5", "appid" : "wxdaf2fffe7e397c01",
"setting" : { "setting" : {
"urlCheck" : false, "urlCheck" : false,
"minified" : true, "minified" : true,

75
pages/student/login/login.vue

@ -98,7 +98,7 @@ export default {
}, },
methods: { methods: {
async init(){ async init(){
await this.getWxConfig() await this.getMiNiWxOpenId()
}, },
input(e) { input(e) {
console.log(e) console.log(e)
@ -149,6 +149,7 @@ export default {
'phone': this.user, 'phone': this.user,
'password': this.password1, 'password': this.password1,
'login_type': 1, 'login_type': 1,
'mini_wx_openid':this.mini_wx_openid,//openid
} }
res = await apiRoute.personnelLogin(params) res = await apiRoute.personnelLogin(params)
}else if(this.loginType == 2){ }else if(this.loginType == 2){
@ -158,11 +159,19 @@ export default {
'phone': this.user, 'phone': this.user,
'password': this.password1, 'password': this.password1,
'login_type': 2, 'login_type': 2,
'mini_wx_openid':this.mini_wx_openid,//openid
} }
res = await apiRoute.personnelLogin(params) res = await apiRoute.personnelLogin(params)
console.log(123123,res) console.log(123123,res)
}else if (this.loginType == 3){ }else if (this.loginType == 3){
//
let params = {
'phone': this.user,
'password': this.password1,
'login_type': 2,
'mini_wx_openid':this.mini_wx_openid,//openid
}
} }
if(!res.code){ if(!res.code){
@ -202,57 +211,35 @@ export default {
}) })
}, },
async getWxConfig(){ //openid
let params = { // code openid
config_key: 'WECHAT' async getMiNiWxOpenId() {
}
let res = await apiRoute.common_getConfig(params)
if ( res.code != 1){
uni.showToast({
title: res.msg,
icon: 'none'
})
return
}
let appid = res.data.app_id || ''
let secret = res.data.app_secret || ''
if(!appid || !secret){
uni.showToast({
title: '请配置微信小程序信息',
icon: 'none'
})
}
await this.loginWx(appid, secret)
},
async loginWx(appid,secret) {
uni.login({ uni.login({
provider: 'weixin', provider: 'weixin',
success: (res) => { success: (res) => {
console.log(res.code); // code const code = res.code;
this.fetchOpenId(code); //
// code openid
uni.request({
url: 'https://api.weixin.qq.com/sns/jscode2session',
data: {
appid: '你的AppID', // AppID
secret: '你的AppSecret', // AppSecret
js_code: res.code,
grant_type: 'authorization_code'
},
success: (wxRes) => {
console.log('获取到的 openid:', wxRes.data.openid); // openid
},
fail: () => {
console.error('请求失败');
}
});
}, },
fail: () => { fail: () => {
console.error('uni.login 失败'); uni.showToast({ title: '微信登录失败', icon: 'none' });
} }
}); });
}, },
// code openid
async fetchOpenId(code){
let params = {
code: code,
}
let res = await apiRoute.common_getMiniWxOpenId(params)
if (res.code != 1){
uni.showToast({
title: res.msg,
icon: 'none'
})
return
}
this.mini_wx_openid = res.data.openid
},
// //
changePicker_loginType(e){ changePicker_loginType(e){

BIN
static/images/common/black_arrow_right.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 B

BIN
static/images/common/closex.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 801 B

BIN
static/images/common/clousex-big.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 642 B

BIN
static/images/common/common_icon_jump_gold.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 475 B

BIN
static/images/common/delete.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

BIN
static/images/common/edit.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

BIN
static/images/common/fa_song.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 B

BIN
static/images/common/gift_icon_close_new.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 427 B

BIN
static/images/common/gouxuankuang.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

BIN
static/images/common/gray_arrow_down.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

BIN
static/images/common/icon-close.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 B

BIN
static/images/common/icon-drop-down.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 652 B

BIN
static/images/common/icon_about.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

BIN
static/images/common/icon_black_back.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

BIN
static/images/common/icon_jump_black3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 B

BIN
static/images/common/image-delete.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 561 B

BIN
static/images/common/jia_hao.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 817 B

BIN
static/images/common/jump-r-arrow.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 370 B

BIN
static/images/common/menu_icon_empty.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 570 B

BIN
static/images/common/more-arrow-right.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

BIN
static/images/common/round-black-selected.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

BIN
static/images/common/round_add_disabled.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

BIN
static/images/common/round_add_normal.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

BIN
static/images/common/round_minus.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 860 B

BIN
static/images/common/search-icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

BIN
static/images/common/star_normal.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

BIN
static/images/common/xi_tong_xiao_xi.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 729 B

BIN
static/images/common/yong_hu.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

BIN
static/images/home/chaungjian.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

BIN
static/images/home/tixing.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1003 B

BIN
static/images/home/wang.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

BIN
static/images/home/yong.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

BIN
static/images/index/addto.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

BIN
static/images/index/check_mark.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

BIN
static/images/index/danlan.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

BIN
static/images/index/danlv.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

BIN
static/images/index/dian.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

BIN
static/images/index/hong.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

BIN
static/images/index/huang.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

BIN
static/images/index/icon_shopping_bag.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 930 B

BIN
static/images/index/img.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

BIN
static/images/index/intention1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

BIN
static/images/index/intention2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

BIN
static/images/index/intention3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

BIN
static/images/index/lan.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

BIN
static/images/index/lv.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

BIN
static/images/index/lvs.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

BIN
static/images/index/manjian.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

BIN
static/images/index/me_icon_notification.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

BIN
static/images/index/menu_btn_close.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

BIN
static/images/index/menu_icon_popup_triangle_normal.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 563 B

BIN
static/images/index/menupopup_btn_share_normal.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

BIN
static/images/index/menupopup_btn_share_quanzi.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

BIN
static/images/index/menupopup_btn_share_wechat.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

BIN
static/images/index/message.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

BIN
static/images/index/myk.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

BIN
static/images/index/phone.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

BIN
static/images/index/rexiao.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

BIN
static/images/index/round-cancel.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 456 B

BIN
static/images/index/round.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

BIN
static/images/index/round_close_btn.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

BIN
static/images/index/score.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

BIN
static/images/index/score1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

BIN
static/images/index/setup.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 B

BIN
static/images/index/shadow_yellow_star.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 595 B

BIN
static/images/index/shenlan.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

BIN
static/images/index/star.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

BIN
static/images/index/task.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

BIN
static/images/index/tuijian.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

BIN
static/images/index/work_details.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

BIN
static/images/index/writing.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

BIN
static/images/index/xinpin.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

BIN
static/images/index/yellow_star.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 647 B

BIN
static/images/index/zan_wu.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 872 B

BIN
static/images/login/login1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 631 B

BIN
static/images/login/login2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 B

BIN
static/images/login/wechat1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

BIN
static/images/mall/b3d3a98e3c7f450aaa32fbec6aecdfaf.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

BIN
static/images/mall/img_pointmall_star.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

BIN
static/images/mall/me_img_banner_mall.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

BIN
static/images/mall/me_pointmall_img_nogift.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

BIN
static/images/mall/store_brh_home_page_normal.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 415 B

BIN
static/images/mall/store_brh_service_normal.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 807 B

BIN
static/images/member/me_club_task_img_done.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

BIN
static/images/my/b3d3a98e3c7f450aaa32fbec6aecdfaf.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

BIN
static/images/my/coupons-empty.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

BIN
static/images/my/icon_arrow.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 B

BIN
static/images/my/icon_attention.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 918 B

BIN
static/images/my/icon_giftcard.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

BIN
static/images/my/icon_rules.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 B

BIN
static/images/my/img_giftcard_empty.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

BIN
static/images/my/jf.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

BIN
static/images/my/me_icon_gift_card.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

BIN
static/images/my/me_icon_points.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

BIN
static/images/my/me_icon_quan.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

BIN
static/images/my/me_icon_wallet.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

BIN
static/images/my/member_benefits/me_rights_icon_1jia1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 688 B

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save