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.

188 rivejä
4.0 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. let that = this;
  68. wx.chooseLocation({
  69. success: function (res) {
  70. that.setData({
  71. address: res.name + '(' + res.address + ')',
  72. addressStr: JSON.stringify(res)
  73. })
  74. },
  75. fail: function (error) {
  76. console.log(error)
  77. },
  78. complete: function (data) {
  79. }
  80. })
  81. },
  82. formSubmit: function (e) {
  83. let that = this;
  84. /**
  85. * sex
  86. * 0 保密
  87. * 1 男
  88. * 2 女
  89. */
  90. if (that.data.flagsex == 0) {
  91. var sex = 0;
  92. } else {
  93. var sex = that.data.sex;
  94. }
  95. if (that.data.addressStr) {
  96. var address = that.data.addressStr;
  97. }
  98. else {
  99. var address = null;
  100. }
  101. if (e.detail.value.username) {
  102. var username = e.detail.value.username;
  103. }
  104. else if (that.data.username) {
  105. var username = that.data.username;
  106. }
  107. else {
  108. var username = null;
  109. }
  110. if (that.data.flag == 2 && that.data.date) {
  111. var birthdate = new Date(that.data.date).getTime();
  112. } else {
  113. var birthdate = null;
  114. }
  115. if (username == null || address == null || sex == 0 || birthdate == null) {
  116. wx.showToast({
  117. title: '请输入完整的用户信息',
  118. icon:"none"
  119. })
  120. } else {
  121. Http.post({
  122. url: config.api.activityJoin,
  123. data: {
  124. sex: sex,
  125. address: address,
  126. name: username,
  127. birthdate: birthdate,
  128. activityId: that.data.activityId
  129. }
  130. })
  131. .then(res => {
  132. wx.showToast({
  133. title: "修改成功",
  134. icon: 'none',
  135. duration: 2000,
  136. mask: false
  137. })
  138. })
  139. .catch(err => {
  140. wx.showToast({
  141. title: err.message,
  142. icon: 'none',
  143. duration: 2000,
  144. mask: false
  145. })
  146. })
  147. }
  148. },
  149. radioChange: function (e) {
  150. this.setData({
  151. sex: e.detail.value,
  152. flagsex: 1
  153. })
  154. },
  155. /**
  156. * 生命周期函数--监听页面加载
  157. */
  158. onLoad: function (options) {
  159. let that = this;
  160. that.setData({
  161. goHomeUrl: app.globalData.goHomeUrl,
  162. })
  163. console.log(options)
  164. if (options && options.activityId){
  165. that.setData({
  166. activityId: options.activityId
  167. })
  168. that.findById(options.activityId);
  169. }
  170. },
  171. findById(id) {
  172. let that = this;
  173. Http.get({
  174. url: config.api.acfindById,
  175. data: {
  176. id: id
  177. }
  178. }).then(res => {
  179. if (res && res.data && res.data.activity) {
  180. if (res.data.activity.useCredit===1){
  181. that.setData({
  182. credit: res.data.activity.credit
  183. })
  184. }
  185. }
  186. })
  187. }
  188. })