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.

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