C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

151 linhas
3.2 KiB

  1. const util = require("../../../utils/util.js");
  2. const Http = require("../../../utils/HttpBasics");
  3. const config = require("../../../config/config");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. date: '1988-03-12',
  10. flag: 1,
  11. flagsex: 0,
  12. items: [
  13. { name: 1, value: '男', checked: false },
  14. { name: 2, value: '女', checked: false },
  15. ],
  16. username: "",
  17. array: ['上班族', '学生', '企业高管', '个体户', '自由职业', '其他'],
  18. array1: ['附近住户', '距离2km', '距离3km', '更远'],
  19. index: 0,
  20. index1: 0,
  21. showPage:false
  22. },
  23. /**
  24. * 获得生日
  25. */
  26. bindDateChange: function (e) {
  27. this.setData({
  28. date: e.detail.value,
  29. flag: 2
  30. })
  31. },
  32. /**
  33. * 职业
  34. */
  35. bindPickerChange: function (e) {
  36. this.setData({
  37. index: e.detail.value
  38. })
  39. },
  40. /**
  41. * 生活半径
  42. */
  43. bindPickerChange1: function (e) {
  44. this.setData({
  45. index1: e.detail.value
  46. })
  47. },
  48. address: function () {
  49. let that = this;
  50. wx.chooseLocation({
  51. success: function (res) {
  52. that.setData({
  53. address: res.name + '(' + res.address + ')',
  54. addressStr: JSON.stringify(res)
  55. })
  56. },
  57. fail: function (error) {
  58. console.log(error)
  59. },
  60. complete: function (data) {
  61. }
  62. })
  63. },
  64. formSubmit: function (e) {
  65. let that = this;
  66. /**
  67. * sex
  68. * 0 保密
  69. * 1 男
  70. * 2 女
  71. */
  72. if (that.data.flagsex == 0) {
  73. var sex = 0;
  74. } else {
  75. var sex = that.data.sex;
  76. }
  77. if (that.data.addressStr) {
  78. var address = that.data.addressStr;
  79. }
  80. else {
  81. var address = null;
  82. }
  83. if (e.detail.value.username) {
  84. var username = e.detail.value.username;
  85. }
  86. else if (that.data.username) {
  87. var username = that.data.username;
  88. }
  89. else {
  90. var username = null;
  91. }
  92. if (that.data.flag == 2 && that.data.date) {
  93. var birthday = new Date(that.data.date).getTime();
  94. } else {
  95. var birthday = null;
  96. }
  97. if (username == null || address == null || sex == 0 || birthday == null) {
  98. wx.showToast({
  99. title: '请输入完整的用户信息',
  100. icon:"none"
  101. })
  102. } else {
  103. Http.post({
  104. url: config.api.activityJoin,
  105. data: {
  106. sex: sex,
  107. address: address,
  108. name: username,
  109. birthday: birthday,
  110. activityId: that.data.activityId
  111. }
  112. })
  113. .then(res => {
  114. wx.showToast({
  115. title: "提交成功",
  116. icon: 'none',
  117. duration: 2000,
  118. mask: false
  119. })
  120. wx.navigateTo({
  121. url: '/pages/radetail/success/index',
  122. })
  123. })
  124. .catch(err => {
  125. wx.showToast({
  126. title: err.message,
  127. icon: 'none',
  128. duration: 2000,
  129. mask: false
  130. })
  131. })
  132. }
  133. },
  134. radioChange: function (e) {
  135. this.setData({
  136. sex: e.detail.value,
  137. flagsex: 1
  138. })
  139. },
  140. /**
  141. * 生命周期函数--监听页面加载
  142. */
  143. onLoad: function (options) {
  144. let that = this;
  145. if (options && options.activityId){
  146. that.setData({
  147. activityId: options.activityId
  148. })
  149. }
  150. }
  151. })