phone.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import Toast from '@vant/weapp/toast/toast';
  2. Page({
  3. data: {
  4. isAgree: false,
  5. disabled: true, //是否禁用
  6. loading: false, //登陆中
  7. languages: [],
  8. },
  9. async onLoad() {
  10. if (wx.getStorageSync('isAgree')) this.setData({
  11. isAgree: wx.getStorageSync('isAgree')
  12. })
  13. this.setData({
  14. devCount: 0,
  15. })
  16. getApp().globalData.http.base({
  17. id: "10026401",
  18. content: {}
  19. }).then(res => {
  20. console.log("语言包列表", res)
  21. if (res.msg == '成功') {
  22. let item = res.data.find(v => v.languagecode == (wx.getStorageSync('languagecode')))
  23. console.log("item", item)
  24. this.setData({
  25. languages: res.data,
  26. languagename: item.languagename || '简体中文',
  27. rowIndex: item.rowindex - 1
  28. })
  29. this.changeTitle();
  30. }
  31. })
  32. getApp().globalData.Language.getLanguagePackage(this);
  33. },
  34. changeLanguages(e) {
  35. let item = this.data.languages[e.detail.value];
  36. getApp().globalData.Language.getLanguages(item.languagecode).then(res => {
  37. this.setData({
  38. language: res,
  39. languagename: item.languagename || '简体中文',
  40. rowIndex: item.rowindex - 1
  41. })
  42. this.changeTitle();
  43. })
  44. },
  45. changeTitle() {
  46. getApp().globalData.Language.setNavBarTitle('账户登录')
  47. },
  48. /* 微信登录 */
  49. wechatLogin() {
  50. if (!this.data.isAgree) return Toast({
  51. message: getApp().globalData.Language.getMapText("确认用户协议") || '请阅读并勾选用户协议',
  52. position: 'bottom'
  53. });
  54. wx.login({
  55. success(res) {
  56. if (res.code) {
  57. getApp().globalData.http.loginbywechat({
  58. wechat_code: res.code,
  59. "systemclient": "wechatsaletool"
  60. }).then(res => {
  61. console.log("微信快捷登录", res)
  62. if (res.code == 0) return wx.showToast({
  63. title: res.msg,
  64. icon: "none"
  65. })
  66. require("./modules/login").loginMsg(res);
  67. getApp().globalData.remindchangepassword = res.remindchangepassword == 1;
  68. })
  69. } else {
  70. console.log('登录失败!' + res.errMsg)
  71. }
  72. }
  73. })
  74. },
  75. /* 用户登录 */
  76. userLogin() {
  77. if (this.data.loading || this.data.disabled) return;
  78. if (!this.data.isAgree) return Toast({
  79. message: getApp().globalData.Language.getMapText("确认用户协议") || '请阅读并勾选用户协议',
  80. position: 'bottom'
  81. });
  82. this.setData({
  83. loading: true
  84. })
  85. this.selectComponent('#login').handleLogin();
  86. },
  87. /* 授权 */
  88. agreementChange({
  89. detail
  90. }) {
  91. this.setData({
  92. isAgree: detail
  93. })
  94. },
  95. todev() {
  96. if (this.data.devCount == 5) {
  97. wx.navigateTo({
  98. url: '/pages/login/developerTools',
  99. })
  100. this.data.devCount = 0;
  101. } else {
  102. this.data.devCount += 1;
  103. }
  104. },
  105. onShareAppMessage() {}
  106. })