C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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