碧桂园
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

77 rader
1.5 KiB

  1. // index.js
  2. // 获取应用实例
  3. const app = getApp()
  4. Page({
  5. data: {
  6. ischecked: true
  7. },
  8. onLoad() {
  9. },
  10. backGame(){
  11. wx.navigateTo({
  12. url: ''
  13. })
  14. },
  15. checkFun(){
  16. this.setData({
  17. ischecked: !this.data.ischecked
  18. })
  19. },
  20. login(){
  21. if(!this.data.ischecked){
  22. wx.showToast({
  23. title: '请勾选协议',
  24. icon: 'none',
  25. duration: 2000
  26. })
  27. return;
  28. }
  29. wx.login({
  30. success (res) {
  31. console.log(res)
  32. if (res.code) {
  33. //发起网络请求
  34. // wx.request({
  35. // url: 'https://example.com/onLogin',
  36. // data: {
  37. // code: res.code
  38. // }
  39. // })
  40. } else {
  41. console.log('登录失败!' + res.errMsg)
  42. }
  43. }
  44. })
  45. },
  46. // 授权手机号
  47. getPhoneNumber(e) {
  48. console.log(e);
  49. let that = this
  50. if (e.detail.errMsg == "getPhoneNumber:ok") {
  51. // console.log(e)
  52. const {
  53. iv,
  54. encryptedData
  55. } = e.detail;
  56. // that.$u.api.bindMini({
  57. // encrypted: encryptedData,
  58. // iv
  59. // }).then((res) => { // 绑定手机号
  60. // console.log(res);
  61. // let userinfo = that.vuex_userInfo
  62. // userinfo.phone = res.data
  63. // that.$u.vuex("vuex_userInfo", userinfo);
  64. // uni.setStorageSync('userInfo', userinfo)
  65. // that.islogin = true
  66. // })
  67. } else {
  68. uni.showToast({
  69. icon: "none",
  70. title: "请授权手机号"
  71. })
  72. }
  73. }
  74. })