| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772 |
- // pages/my/activity/activity.js
- const App = getApp();
- const util = require("../../utils/tool");
- let CityArray0 = [];
- let CityArray1 = [];
- let CityArray2 = [];
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- appAssetsUrl2: App.appAssetsUrl2,
- user: wx.getStorageSync("USER"),
- lng: null,
- lat: null,
- activityId: null,
- detail: {},
- region: [],
- // 负责人
- staffId: null,
- // 负责人联系电话
- teacherPhone: null,
- // 活动标题
- title: null,
- // 省
- province: null,
- // 市
- city: null,
- // 区
- area: null,
- // 活动地址
- address: null,
- // 坐标
- coordinate: null,
- // 活动时间
- startTime: null,
- endTime: null,
- startTimeDate: null,
- startTimeHS: null,
- endTimeDate: null,
- endTimeHS: null,
- // 报名截止
- registrationEnd: null,
- registrationEndDate: null,
- registrationEndHS: null,
- // 集合时间
- meetingTime: null,
- // 集合日期
- meetingTimeDate: null,
- // 集合日期时间
- meetingTimeHS: null,
- // 活动费用
- isNeedVip: 0,
- money: null,
- // 是否推荐至首页
- isTop: null,
- // 报名数
- willnum: null,
- // 负责老师
- principal: null,
- // 活动封面图
- thumbnailImg: null,
- // 兼职banner图
- bannerImg: null,
- // 活动详情
- content: null,
- // 联系二维码
- qrCodePicture: null,
- contactInstructions: null,
- multiArray: [],
- multiIndex: [],
- activityjs: null,
- activityyq: null,
- activitysx: null,
- auditStatus: null,
- labelListIndex: null,
- labelList: []
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- if (options.activityId) {
- this.setData({
- activityId: options.activityId,
- });
- this.getDetail();
- } else {
- this.getProvince();
- }
- this.setData({
- staffId: this.data.user.id,
- teacherPhone: this.data.user.phone,
- });
- this.getCoord();
- this.getLabel()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {},
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {},
- // 获取经纬度
- getCoord() {
- wx.getFuzzyLocation({
- type: "gcj02",
- success: (res) => {
- const latitude = res.latitude;
- const longitude = res.longitude;
- this.setData({
- lng: Number(longitude),
- lat: Number(latitude),
- });
- },
- fail: (e) => {},
- });
- },
- // 获取省
- getProvince() {
- App._get("region/provinceList", {}, (res) => {
- let pId = "";
- let prov = "";
- if (res.code === 0) {
- let provice = res.data;
- this.data.multiArray[0] = provice;
- CityArray0 = provice;
- if (CityArray0.length) {
- for (let i = 0; i < CityArray0.length; i++) {
- if (CityArray0[i].id == this.data.province) {
- this.data.multiIndex[0] = i;
- break;
- } else {
- this.data.multiIndex[0] = 0;
- // break;
- }
- }
- }
- if (this.data.province) {
- pId = this.data.province;
- } else {
- //根据默认省,获取默认市
- if (this.data.multiArray[0].length) {
- pId = this.data.multiArray[0][0].id;
- }
- }
- this.getCity(pId);
- }
- });
- },
- //选择标签
- labelPickerChange(e){
- let labelListIndex = e.detail.value;
- this.setData({
- labelListIndex
- })
- },
- // labelList
- getLabel() {
- let that = this;
- App._post_form('bizcatelog/apiSelectBizcatelog/act_title', '', null,
- function(res) {
- if(res.code == 0){
- that.setData({
- labelList: res.dictList
- })
- }
- })
- },
- getCity(pId) {
- App._get(`region/urbanDistrictList?id=${pId}`, {}, (res) => {
- // App._get(`region/urbanDistrictList?id=420000`, {}, res => {
- if (res.code === 0) {
- let city = res.data;
- this.data.multiArray[1] = city;
- CityArray1 = city;
- if (CityArray1.length) {
- for (let i = 0; i < CityArray1.length; i++) {
- // console.log(CityArray1[i].id, pId, 222)
- if (CityArray1[i].pid === pId) {
- this.data.multiIndex[1] = i;
- break;
- }
- }
- }
- let cityId = "";
- if (this.data.city) {
- cityId = this.data.city;
- } else {
- if (this.data.multiArray[1].length) {
- cityId = this.data.multiArray[1][0].id;
- }
- }
- this.getArea(cityId);
- this.setData({
- multiArray: this.data.multiArray,
- multiIndex: this.data.multiIndex,
- });
- }
- });
- },
- // 获取区
- getArea(cityId) {
- for (let i = 0; i < this.data.multiArray[1].length; i++) {
- console.log(this.data.multiArray[1], cityId, "area");
- if (this.data.multiArray[1][i].id === cityId) {
- CityArray2 = this.data.multiArray[1][i].childRegionList;
- this.data.multiArray[2] = this.data.multiArray[1][i].childRegionList;
- this.data.multiIndex[2] = i;
- break;
- }
- }
- if (this.data.area) {
- for (let j = 0; j < this.data.multiArray[2].length; j++) {
- if (this.data.multiArray[2][j].id === this.data.area) {
- this.data.multiIndex[2] = j;
- break;
- }
- }
- }
- this.setData({
- multiArray: this.data.multiArray,
- multiIndex: this.data.multiIndex,
- });
- console.log(this.data.multiArray, this.data.multiIndex, 1111);
- },
- areaChange(e) {
- this.data.multiIndex[0] = e.detail.value[0];
- this.data.multiIndex[1] = e.detail.value[1];
- this.data.multiIndex[2] = e.detail.value[2];
- let province = CityArray0[e.detail.value[0]].id;
- let city = CityArray1[e.detail.value[1]].id;
- let area = CityArray2[e.detail.value[2]].id;
- this.setData({
- multiIndex: this.data.multiIndex,
- province: province,
- city: city,
- area: area,
- });
- },
- MultiPickerAreaChange(e) {
- if (e.detail.column == 0) {
- let pid = CityArray0[e.detail.value].id;
- this.data.multiIndex[0] = e.detail.value;
- this.getCity(pid);
- } else if (e.detail.column == 1) {
- let pid = CityArray1[e.detail.value].id;
- this.data.multiIndex[1] = e.detail.value;
- this.getArea(pid);
- } else {
- this.data.multiIndex[2] = e.detail.value;
- }
- this.setData({
- multiIndex: this.data.multiIndex,
- });
- },
- // 活动时间
- startTimeBindDateChange(e) {
- this.setData({
- startTimeDate: e.detail.value,
- });
- },
- startTimeBindTimeChange(e) {
- this.setData({
- startTimeHS: e.detail.value,
- });
- },
- endTimeBindDateChange(e) {
- this.setData({
- endTimeDate: e.detail.value,
- });
- },
- endTimeBindTimeChange(e) {
- this.setData({
- endTimeHS: e.detail.value,
- });
- },
- // 报名截止
- registrationEndBindDateChange(e) {
- this.setData({
- registrationEndDate: e.detail.value,
- });
- },
- registrationEndBindTimeChange(e) {
- this.setData({
- registrationEndHS: e.detail.value,
- });
- },
- // 集合时间
- meetingBindDateChange(e) {
- this.setData({
- meetingTimeDate: e.detail.value,
- });
- },
- meetingBindTimeChange(e) {
- this.setData({
- meetingTimeHS: e.detail.value,
- });
- },
- // 活动 免费
- freeRadioChange(e) {
- if (e.detail.value == 1) {
- this.data.money = 0;
- }
- this.setData({
- isNeedVip: e.detail.value,
- money: this.data.money,
- });
- },
- // 推荐首页
- recommendRadioChange(e) {
- this.setData({
- isTop: e.detail.value,
- });
- },
- changeAddress() {
- if (this.data.auditStatus == 1) {
- wx.showToast({
- icon: "none",
- title: "活动进行中",
- });
- return false;
- }
- wx.chooseLocation({
- success: (res) => {
- console.log(res, 1111);
- wx.showLoading({
- title: "获取位置中...",
- });
- App._get(
- "store/getDetailsAddress",
- {
- lon: res.longitude,
- lat: res.latitude,
- },
- (res2) => {
- if (res2.code === 0) {
- wx.hideLoading();
- this.setData({
- address: res2.data.street_number,
- coordinate: res.longitude + "," + res.latitude,
- });
- }
- }
- );
- },
- });
- // wx.navigateTo({
- // url: `/activity/map/map?lng=${this.data.lng}&lat=${this.data.lat}`,
- // })
- },
- uploadHandle(e) {
- if (this.data.auditStatus == 1) {
- wx.showToast({
- icon: "none",
- title: "活动进行中",
- });
- return false;
- }
- console.log(e, 11111111);
- let currentIndex = e.currentTarget.dataset.index;
- // if (this.data.list.length == 3) {
- // return false
- // }
- let _this = this;
- var tempFile;
- wx.showActionSheet({
- itemList: ["拍照上传", "从相册中选择"],
- success(res) {
- if (res.tapIndex === 0) {
- wx.chooseImage({
- count: 1,
- sizeType: ["original", "compressed"],
- sourceType: ["camera"],
- success(res) {
- const tempFilePaths = res.tempFilePaths;
- wx.uploadFile({
- url: App.apiRoot + "file/upload",
- filePath: tempFilePaths[0],
- name: "file",
- success: function (res) {
- if (res.errMsg === "uploadFile:ok") {
- wx.showToast({
- title: "上传成功",
- image: "",
- duration: 1500,
- mask: false,
- });
- let data = JSON.parse(res.data);
- if (currentIndex == 0) {
- _this.data.thumbnailImg = data.data;
- _this.setData({
- thumbnailImg: _this.data.thumbnailImg,
- });
- } else if (currentIndex == 1) {
- _this.data.bannerImg = data.data;
- _this.setData({
- bannerImg: _this.data.bannerImg,
- });
- } else {
- _this.data.qrCodePicture = data.data;
- _this.setData({
- qrCodePicture: _this.data.qrCodePicture,
- });
- }
- }
- },
- function() {
- wx.showToast({
- title: "上传失败",
- icon: "none",
- image: "",
- duration: 1500,
- mask: false,
- });
- },
- });
- },
- });
- } else if (res.tapIndex === 1) {
- wx.chooseImage({
- count: 1,
- sizeType: ["original", "compressed"],
- sourceType: ["album"],
- success(res) {
- const tempFilePaths = res.tempFilePaths;
- wx.uploadFile({
- url: App.apiRoot + "file/upload",
- filePath: tempFilePaths[0],
- name: "file",
- success: function (res) {
- if (res.errMsg === "uploadFile:ok") {
- wx.showToast({
- title: "上传成功",
- image: "",
- duration: 1500,
- mask: false,
- });
- let data = JSON.parse(res.data);
- if (currentIndex == 0) {
- _this.data.thumbnailImg = data.data;
- _this.setData({
- thumbnailImg: _this.data.thumbnailImg,
- });
- } else if (currentIndex == 1) {
- _this.data.bannerImg = data.data;
- _this.setData({
- bannerImg: _this.data.bannerImg,
- });
- } else {
- _this.data.qrCodePicture = data.data;
- _this.setData({
- qrCodePicture: _this.data.qrCodePicture,
- });
- }
- }
- },
- function() {
- wx.showToast({
- title: "上传失败",
- icon: "none",
- image: "",
- duration: 1500,
- mask: false,
- success: (result) => {},
- fail: () => {},
- complete: () => {},
- });
- },
- });
- },
- });
- }
- },
- fail(res) {},
- });
- },
- submit() {
- let startTime = this.data.startTimeDate + " " + this.data.startTimeHS;
- let endTime = this.data.endTimeDate + " " + this.data.endTimeHS;
- if (!this.data.title) {
- return util.alert("请先填写活动标题");
- }
- if (!this.data.city || !this.data.area) {
- return util.alert("请先选择所属区域");
- }
- if (!this.data.address) {
- return util.alert("请先选择活动地址");
- }
- // if (!startTime || !endTime) {
- // return util.alert("请先选择活动时间");
- // }
- if (!this.data.startTimeDate || !this.data.startTimeHS || !this.data.endTimeDate || !this.data.endTimeHS) {
- return util.alert("请先选择活动时间");
- }
- if (!this.data.registrationEndDate || !this.data.registrationEndHS) {
- return util.alert("请先选择报名截止时间");
- }
- if (!this.data.meetingTimeDate || !this.data.meetingTimeHS) {
- return util.alert("请先选择集合时间");
- }
- console.log(this.data.money,'this.data.money')
- if (this.data.money === null) {
- return util.alert("请填写活动费用");
- }
-
- if (!this.data.willnum) {
- return util.alert("请输入报名人数");
- }
- if (!this.data.thumbnailImg) {
- return util.alert("请先上传活动封面缩略图");
- }
- if (!this.data.bannerImg) {
- return util.alert("请先上传活动详情banner图");
- }
- if (!this.data.qrCodePicture) {
- return util.alert("请先上传联系二维码图");
- }
- if (!this.data.contactInstructions) {
- return util.alert("请先填写联系说明");
- }
- wx.showLoading({
- title: "提交中,请稍后",
- });
- let list = [
- this.data.activityjs,
- this.data.activityyq,
- this.data.activitysx,
- ];
- let obj = {
- address: this.data.address,
- area: this.data.area,
- bannerImg: this.data.bannerImg,
- city: this.data.city,
- activityAppletsDetailsList: list,
- coordinate: this.data.coordinate,
- // endTime: this.data.endTimeDate + ' ' + this.data.endTimeHS,
- endTime: endTime,
- isNeedVip: this.data.isNeedVip,
- isTop: this.data.isTop,
- meetingTime: this.data.meetingTimeDate + " " + this.data.meetingTimeHS,
- money: this.data.money,
- province: this.data.province,
- registrationEnd:
- this.data.registrationEndDate + " " + this.data.registrationEndHS,
- staffId: this.data.staffId,
- // startTime: this.data.startTimeDate + ' ' + this.data.startTimeHS,
- startTime: startTime,
- teacherPhone: this.data.teacherPhone,
- thumbnailImg: this.data.thumbnailImg,
- qrCodePicture: this.data.qrCodePicture,
- contactInstructions: this.data.contactInstructions,
- title: this.data.title,
- willnum: this.data.willnum,
- principal: this.data.principal,
- memberId: this.data.user.id,
- // is_applets_release 是否是小程序发布 1是 0否
- isAppletsRelease: 1,
- titleCode:this.data.labelList[this.data.labelListIndex].itemcode
- };
- wx.setStorageSync("activityDetail", obj);
- if (this.data.activityId) {
- wx.navigateTo({
- url: "/activity/detail/detail?activityId=" + this.data.activityId,
- });
- } else {
- wx.navigateTo({
- url: "/activity/detail/detail",
- });
- }
- return false;
- // if (this.data.activityId) {
- // App._put_form('activity/updateActivity', '', {
- // ...obj,
- // id: this.data.activityId
- // }, res => {
- // if (res.code === 0) {
- // wx.showToast({
- // title: '修改成功',
- // })
- // }
- // }, err => {}, complete => {
- // setTimeout(() => {
- // wx.hideLoading()
- // }, 300)
- // })
- // } else {
- // App._post_form('activity/saveActivity', '', obj, res => {
- // if (res.code === 0) {
- // wx.showToast({
- // title: '添加成功',
- // })
- // }
- // }, err => {}, complete => {
- // setTimeout(() => {
- // wx.hideLoading()
- // }, 300)
- // })
- // }
- },
- // 获取活动详情
- getDetail() {
- wx.showLoading({
- title: "努力加载中...",
- });
- App._post_form(
- "act/one",
- "",
- {
- id: this.data.activityId,
- stuId: this.data.user.id,
- },
- (res) => {
- if (res.code === 0) {
- this.setData({
- detail: res.data,
- title: res.data.title,
- province: res.data.province,
- city: res.data.city,
- area: res.data.area,
- // provincename: res.data.provincename,
- // cityname: res.data.cityname,
- // areaName: res.data.areaName,
- address: res.data.address,
- coordinate: res.data.coordinate,
- startTime: res.data.startTime,
- endTime: res.data.endTime,
- startTimeDate: res.data.startTime.split(" ")[0],
- startTimeHS: res.data.startTime.split(" ")[1],
- endTimeDate: res.data.endTime.split(" ")[0],
- endTimeHS: res.data.endTime.split(" ")[1],
- registrationEnd: res.data.registrationEnd,
- registrationEndDate: res.data.endTime.split(" ")[0],
- registrationEndHS: res.data.endTime.split(" ")[1],
- meetingTime: res.data.meetingTime,
- meetingTimeDate: res.data.endTime.split(" ")[0],
- meetingTimeHS: res.data.endTime.split(" ")[1],
- isNeedVip: res.data.isNeedVip,
- money: res.data.money,
- isTop: res.data.isTop,
- willnum: res.data.willnum,
- principal: res.data.principal,
- thumbnailImg: res.data.thumbnailImg,
- bannerImg: res.data.bannerImg,
- qrCodePicture: res.data.qrCodePicture,
- contactInstructions: res.data.contactInstructions,
- activityjs: res.data.activityAppletsDetailsList[0],
- activityyq: res.data.activityAppletsDetailsList[1],
- activitysx: res.data.activityAppletsDetailsList[2],
- auditStatus: res.data.auditStatus,
- });
- this.getProvince();
- }
- },
- (err) => {},
- (complete) => {
- setTimeout(() => {
- wx.hideLoading();
- }, 300);
- }
- );
- },
- // 取消活动
- // cancel() {
- // let parm = {
- // sid: this.data.user.id,
- // aid: this.data.activityId,
- // };
- // App._post_form(
- // "act/cancel",
- // "application/json",
- // JSON.stringify(parm),
- // (res) => {
- // if (res.code === 0) {
- // wx.showModal({
- // title: "温馨提示",
- // content: "取消成功",
- // showCancel: false,
- // });
- // wx.navigateBack();
- // }
- // }
- // );
- // },
- cancel() {
- // let parm = {
- // sid: this.data.user.id,
- // aid: this.data.activityId,
- // };
- App._put_form(
- "activity/cancelActivity/"+this.data.activityId,
- "",
- {},
- (res) => {
- if (res.code === 0) {
- wx.showModal({
- title: "温馨提示",
- content: "取消成功",
- showCancel: false,
- });
- wx.navigateBack();
- }
- },
- err => {
- wx.showToast({
- icon: 'error',
- title: '服务端异常',
- })
- }
- );
- },
- // 查看报名信息
- toApply() {
- wx.navigateTo({
- url:
- "/activity/activityInfo/activityInfo?activityId=" +
- this.data.activityId + "&willnum=" + this.data.willnum
- });
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {},
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {},
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {},
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {},
- });
|