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.

190 lines
4.1 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 44) + '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. let app = getApp();
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. chenghr: imgurl.chenghr.url,
  13. navigationBarHeight,
  14. date: '1988-03-12',
  15. flag: 1,
  16. flagsex: 0,
  17. items: [
  18. { name: 1, value: '男', checked: false },
  19. { name: 2, value: '女', checked: false },
  20. ],
  21. username: "",
  22. array: ['上班族', '学生', '企业高管', '个体户', '自由职业', '其他'],
  23. array1: ['附近住户', '距离2km', '距离3km', '更远'],
  24. index: 0,
  25. index1: 0,
  26. showPage: false,
  27. credit: "",
  28. goHomeUrl: "",
  29. },
  30. gotomyAc() {
  31. wx.navigateTo({
  32. url: '/pages/user/myactivity/index',
  33. })
  34. },
  35. /**
  36. * 获得生日
  37. */
  38. bindDateChange: function (e) {
  39. this.setData({
  40. date: e.detail.value,
  41. flag: 2
  42. })
  43. },
  44. goback: function () {
  45. let this_ = this
  46. wx.switchTab({
  47. url: this_.data.goHomeUrl,
  48. })
  49. },
  50. /**
  51. * 职业
  52. */
  53. bindPickerChange: function (e) {
  54. this.setData({
  55. index: e.detail.value
  56. })
  57. },
  58. /**
  59. * 生活半径
  60. */
  61. bindPickerChange1: function (e) {
  62. this.setData({
  63. index1: e.detail.value
  64. })
  65. },
  66. address: function () {
  67. return
  68. let that = this;
  69. // wx.chooseL
  70. // ocation({
  71. // success: function (res) {
  72. // that.setData({
  73. // address: res.name + '(' + res.address + ')',
  74. // addressStr: JSON.stringify(res)
  75. // })
  76. // },
  77. // fail: function (error) {
  78. // console.log(error)
  79. // },
  80. // complete: function (data) {
  81. // }
  82. // })
  83. },
  84. formSubmit: function (e) {
  85. let that = this;
  86. /**
  87. * sex
  88. * 0 保密
  89. * 1 男
  90. * 2 女
  91. */
  92. if (that.data.flagsex == 0) {
  93. var sex = 0;
  94. } else {
  95. var sex = that.data.sex;
  96. }
  97. if (that.data.addressStr) {
  98. var address = that.data.addressStr;
  99. }
  100. else {
  101. var address = null;
  102. }
  103. if (e.detail.value.username) {
  104. var username = e.detail.value.username;
  105. }
  106. else if (that.data.username) {
  107. var username = that.data.username;
  108. }
  109. else {
  110. var username = null;
  111. }
  112. if (that.data.flag == 2 && that.data.date) {
  113. var birthdate = new Date(that.data.date).getTime();
  114. } else {
  115. var birthdate = null;
  116. }
  117. if (username == null || address == null || sex == 0 || birthdate == null) {
  118. wx.showToast({
  119. title: '请输入完整的用户信息',
  120. icon: "none"
  121. })
  122. } else {
  123. Http.post({
  124. url: config.api.activityJoin,
  125. data: {
  126. sex: sex,
  127. address: address,
  128. name: username,
  129. birthdate: birthdate,
  130. activityId: that.data.activityId
  131. }
  132. })
  133. .then(res => {
  134. wx.showToast({
  135. title: "修改成功",
  136. icon: 'none',
  137. duration: 2000,
  138. mask: false
  139. })
  140. })
  141. .catch(err => {
  142. wx.showToast({
  143. title: err.message,
  144. icon: 'none',
  145. duration: 2000,
  146. mask: false
  147. })
  148. })
  149. }
  150. },
  151. radioChange: function (e) {
  152. this.setData({
  153. sex: e.detail.value,
  154. flagsex: 1
  155. })
  156. },
  157. /**
  158. * 生命周期函数--监听页面加载
  159. */
  160. onLoad: function (options) {
  161. let that = this;
  162. that.setData({
  163. goHomeUrl: app.globalData.goHomeUrl,
  164. })
  165. console.log(options)
  166. if (options && options.activityId) {
  167. that.setData({
  168. activityId: options.activityId
  169. })
  170. that.findById(options.activityId);
  171. }
  172. },
  173. findById(id) {
  174. let that = this;
  175. Http.get({
  176. url: config.api.acfindById,
  177. data: {
  178. id: id
  179. }
  180. }).then(res => {
  181. if (res && res.data && res.data.activity) {
  182. if (res.data.activity.useCredit === 1) {
  183. that.setData({
  184. credit: res.data.activity.credit
  185. })
  186. }
  187. }
  188. })
  189. }
  190. })