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.

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