C端小程序
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

153 рядки
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. goback: function () {
  33. wx.switchTab({
  34. url: '/pages/main/index',
  35. })
  36. },
  37. /**
  38. * 职业
  39. */
  40. bindPickerChange: function (e) {
  41. this.setData({
  42. index: e.detail.value
  43. })
  44. },
  45. /**
  46. * 生活半径
  47. */
  48. bindPickerChange1: function (e) {
  49. this.setData({
  50. index1: e.detail.value
  51. })
  52. },
  53. address: function () {
  54. let that = this;
  55. wx.chooseLocation({
  56. success: function (res) {
  57. that.setData({
  58. address: res.name + '(' + res.address + ')',
  59. addressStr: JSON.stringify(res)
  60. })
  61. },
  62. fail: function (error) {
  63. console.log(error)
  64. },
  65. complete: function (data) {
  66. }
  67. })
  68. },
  69. formSubmit: function (e) {
  70. let that = this;
  71. /**
  72. * sex
  73. * 0 保密
  74. * 1 男
  75. * 2 女
  76. */
  77. if (that.data.flagsex == 0) {
  78. var sex = 0;
  79. } else {
  80. var sex = that.data.sex;
  81. }
  82. if (that.data.addressStr) {
  83. var address = that.data.addressStr;
  84. }
  85. else {
  86. var address = null;
  87. }
  88. if (e.detail.value.username) {
  89. var username = e.detail.value.username;
  90. }
  91. else if (that.data.username) {
  92. var username = that.data.username;
  93. }
  94. else {
  95. var username = null;
  96. }
  97. if (that.data.flag == 2 && that.data.date) {
  98. var birthdate = new Date(that.data.date).getTime();
  99. } else {
  100. var birthdate = null;
  101. }
  102. if (username == null || address == null || sex == 0 || birthdate == null) {
  103. wx.showToast({
  104. title: '请输入完整的用户信息',
  105. icon:"none"
  106. })
  107. } else {
  108. Http.post({
  109. url: config.api.activityJoin,
  110. data: {
  111. sex: sex,
  112. address: address,
  113. name: username,
  114. birthdate: birthdate,
  115. activityId: that.data.activityId
  116. }
  117. })
  118. .then(res => {
  119. wx.showToast({
  120. title: "修改成功",
  121. icon: 'none',
  122. duration: 2000,
  123. mask: false
  124. })
  125. })
  126. .catch(err => {
  127. wx.showToast({
  128. title: err.message,
  129. icon: 'none',
  130. duration: 2000,
  131. mask: false
  132. })
  133. })
  134. }
  135. },
  136. radioChange: function (e) {
  137. this.setData({
  138. sex: e.detail.value,
  139. flagsex: 1
  140. })
  141. },
  142. /**
  143. * 生命周期函数--监听页面加载
  144. */
  145. onLoad: function (options) {
  146. let that = this;
  147. if (options && options.activityId){
  148. that.setData({
  149. activityId: options.activityId
  150. })
  151. }
  152. }
  153. })