|
- const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
- const util = require("../../../utils/util.js");
- const Http = require("../../../utils/HttpBasics");
- const config = require("../../../config/config");
- const imgurl = require("../../../utils/imgurl");
- let app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- chenghr: imgurl.chenghr.url,
- navigationBarHeight,
- date: '1988-03-12',
- flag: 1,
- flagsex: 0,
- items: [
- { name: 1, value: '男', checked: false },
- { name: 2, value: '女', checked: false },
- ],
- username: "",
- array: ['上班族', '学生', '企业高管', '个体户', '自由职业', '其他'],
- array1: ['附近住户', '距离2km', '距离3km', '更远'],
- index: 0,
- index1: 0,
- showPage:false,
- credit:"",
- goHomeUrl:"",
- },
- gotomyAc(){
- wx.navigateTo({
- url: '/pages/user/myactivity/index',
- })
- },
- /**
- * 获得生日
- */
- bindDateChange: function (e) {
- this.setData({
- date: e.detail.value,
- flag: 2
- })
- },
- goback: function () {
- let this_ = this
- wx.switchTab({
- url: this_.data.goHomeUrl,
- })
- },
- /**
- * 职业
- */
- bindPickerChange: function (e) {
- this.setData({
- index: e.detail.value
- })
- },
- /**
- * 生活半径
- */
- bindPickerChange1: function (e) {
- this.setData({
- index1: e.detail.value
- })
- },
- address: function () {
- let that = this;
- wx.chooseLocation({
- success: function (res) {
- that.setData({
- address: res.name + '(' + res.address + ')',
- addressStr: JSON.stringify(res)
- })
- },
- fail: function (error) {
- console.log(error)
- },
- complete: function (data) {
- }
- })
- },
- formSubmit: function (e) {
- let that = this;
- /**
- * sex
- * 0 保密
- * 1 男
- * 2 女
- */
- if (that.data.flagsex == 0) {
- var sex = 0;
- } else {
- var sex = that.data.sex;
- }
- if (that.data.addressStr) {
- var address = that.data.addressStr;
- }
- else {
- var address = null;
- }
- if (e.detail.value.username) {
- var username = e.detail.value.username;
- }
- else if (that.data.username) {
- var username = that.data.username;
- }
- else {
- var username = null;
- }
- if (that.data.flag == 2 && that.data.date) {
- var birthdate = new Date(that.data.date).getTime();
- } else {
- var birthdate = null;
- }
- if (username == null || address == null || sex == 0 || birthdate == null) {
- wx.showToast({
- title: '请输入完整的用户信息',
- icon:"none"
- })
- } else {
- Http.post({
- url: config.api.activityJoin,
- data: {
- sex: sex,
- address: address,
- name: username,
- birthdate: birthdate,
- activityId: that.data.activityId
- }
- })
- .then(res => {
- wx.showToast({
- title: "修改成功",
- icon: 'none',
- duration: 2000,
- mask: false
- })
- })
- .catch(err => {
- wx.showToast({
- title: err.message,
- icon: 'none',
- duration: 2000,
- mask: false
- })
- })
- }
- },
- radioChange: function (e) {
- this.setData({
- sex: e.detail.value,
- flagsex: 1
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let that = this;
- that.setData({
- goHomeUrl: app.globalData.goHomeUrl,
- })
- console.log(options)
- if (options && options.activityId){
- that.setData({
- activityId: options.activityId
- })
- that.findById(options.activityId);
- }
- },
- findById(id) {
- let that = this;
- Http.get({
- url: config.api.acfindById,
- data: {
- id: id
- }
- }).then(res => {
- if (res && res.data && res.data.activity) {
- if (res.data.activity.useCredit===1){
- that.setData({
- credit: res.data.activity.credit
- })
- }
- }
- })
- }
- })
|