C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

143 строки
2.7 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 60) + 'px'
  2. const util = require("../../utils/util.js");
  3. const Http = require("../../utils/HttpBasics");
  4. const config = require("../../config/config");
  5. const imgurl = require("../../utils/imgurl");
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. navigationBarHeight,
  12. tabIndex: 0,
  13. pdwSwitch: 0,
  14. isChangePhone: false,
  15. code: "",
  16. name: "叶文沁",
  17. phone: "1379****591",
  18. tempPhone: '',
  19. password: '',
  20. },
  21. // 兑换
  22. exchange(e) {
  23. console.log(e, 'e');
  24. let that = this;
  25. let code = e.detail.value.code;
  26. console.log(code);
  27. },
  28. // 更改手机号
  29. changePhone() {
  30. this.setData({
  31. isChangePhone: true,
  32. tempPhone: this.data.phone
  33. })
  34. },
  35. // 输入手机号
  36. phoneInput(e) {
  37. this.setData({
  38. phone: e.detail.value
  39. })
  40. },
  41. // 输入密码
  42. pwdInput(e) {
  43. this.setData({
  44. password: e.detail.value
  45. })
  46. },
  47. // 确认手机号更改
  48. confirmPhone() {
  49. const phoneReg = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/
  50. const phoneValid = phoneReg.test(this.data.phone)
  51. if (!phoneValid) {
  52. wx.showToast({
  53. title: '请输入正确的手机号!',
  54. icon: 'none'
  55. })
  56. return
  57. }
  58. this.setData({
  59. isChangePhone: false,
  60. })
  61. },
  62. // 取消更改
  63. cancelChangePhone() {
  64. this.setData({
  65. isChangePhone: false,
  66. phone: this.data.tempPhone
  67. })
  68. },
  69. // 更改tab栏
  70. changeTabs(e) {
  71. console.log(e, 'changeTabs');
  72. this.setData({
  73. tabIndex: e.target.id,
  74. code: '',
  75. password: ''
  76. })
  77. },
  78. // 支付安全设置
  79. securityChange(e) {
  80. this.setData({
  81. pdwSwitch: e.detail.value * 1
  82. })
  83. },
  84. // 扫描二维码
  85. goScanCode() {
  86. console.log('scan!!!');
  87. const that = this
  88. wx.scanCode({
  89. success: (res) => {
  90. console.log(res, 'res');
  91. const num = res.result
  92. that.setData({
  93. code: num
  94. })
  95. that.exchange({ detail: { value: num } })
  96. },
  97. fail: (res) => {
  98. console.log(res, 'fail');
  99. }
  100. })
  101. },
  102. // 检查用户登录状态
  103. checkPhoneStatus() {
  104. let that = this;
  105. Http.get({
  106. url: config.api.checkPhoneStatus,
  107. })
  108. .then(res => {
  109. })
  110. .catch(err => {
  111. if (err.code == 11005) {
  112. // 手机号没有授权,将值传到用户手机号授权的页面
  113. wx.redirectTo({
  114. url: "/pages/getphoneInfo/index",
  115. })
  116. } else {
  117. wx.showToast({
  118. title: err.message,
  119. icon: 'none',
  120. duration: 2500
  121. })
  122. }
  123. })
  124. },
  125. onLoad() {
  126. setTimeout(() => {
  127. this.checkPhoneStatus()
  128. }, 2000);
  129. }
  130. })