C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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