拓恒河湖长制全民护河平台WEB端
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.

index.js 3.3KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // package_mine/pages/approveId/index.js
  2. import {approveIdenty} from '../../../api/mine.js'
  3. import {isPositiveInteger} from '../../../utils/check.js'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. checkAgree: false,
  10. form: {},
  11. // 表单验证
  12. formRules: {
  13. applyName: {
  14. validator: function (value) {
  15. return value;
  16. },
  17. warning: false
  18. },
  19. applyPhone: {
  20. validator: function (value) {
  21. return value && isPositiveInteger(value);
  22. },
  23. warning: false
  24. }
  25. },
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad(options) {
  31. if(options.data) {
  32. const params = JSON.parse(options.data)
  33. const applyOpenid = wx.getStorageSync('openid')
  34. this.setData({
  35. form: {
  36. applyOpenid,
  37. ...params
  38. }
  39. })
  40. }
  41. },
  42. // 输入框输入
  43. bindValue(e) {
  44. let name = e.currentTarget.dataset.name;
  45. let form = this.data.form;
  46. form[name] = e.detail.value;
  47. this.setData({
  48. form,
  49. })
  50. this.validate(name, e.detail.value)
  51. },
  52. // 表项验证
  53. validate(name) {
  54. if(name !== 'applyRemark') {
  55. let formRules = this.data.formRules;
  56. let validator = formRules[name].validator
  57. let result = validator ? !validator(this.data.form[name]) : false;
  58. formRules[name].warning = result
  59. this.setData({formRules})
  60. return result
  61. }
  62. },
  63. // 表单验证
  64. validateForm() {
  65. return new Promise((resolve, reject) => {
  66. try {
  67. let formRules = this.data.formRules;
  68. let result = false;
  69. for (let key in formRules) {
  70. let temp = this.validate(key)
  71. if (temp) {
  72. result = temp
  73. }
  74. }
  75. resolve(!result)
  76. } catch (e) {
  77. reject(e)
  78. }
  79. })
  80. },
  81. /**
  82. * 同意用户协议
  83. */
  84. checkBoxChange() {
  85. let checkAgree = this.data.checkAgree
  86. this.setData({
  87. checkAgree: !checkAgree
  88. })
  89. },
  90. // 用户服务协议
  91. showAgree() {
  92. wx.navigateTo({
  93. url: '/package_A/pages/agree/index',
  94. })
  95. },
  96. // 隐私政策
  97. showConceal() {
  98. wx.navigateTo({
  99. url: '/package_A/pages/conceal/index',
  100. })
  101. },
  102. // 提交申请
  103. submit(){
  104. this.validateForm().then(res => {
  105. if(res) {
  106. wx.showLoading({title:"上传中",mask:true})
  107. const params = this.data.form
  108. approveIdenty(params).then(res => {
  109. if (res.code === 0) {
  110. wx.reLaunch({
  111. url: '/package_mine/pages/submitSuccess/index',
  112. })
  113. }
  114. }).finally(()=>{
  115. wx.hideLoading();
  116. })
  117. }
  118. })
  119. },
  120. // 取消
  121. returnLastPage() {
  122. wx.navigateBack({
  123. delta: 1,
  124. })
  125. }
  126. })