C端小程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

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