123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710 |
- var app = getApp();
- var util = require("../../utils/util.js");
- let pageid = "";
- let timer = null;
- let endTotal = 0
- let num = 0
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- appAssetsUrl2: app.appAssetsUrl2,
- // 行家id
- id: null,
- // 主题id
- topicId: null,
- topicList: [],
- content: null,
- price: null,
- groupList: [],
- groupList3: [],
- bottomLeft: app.bottomLeft,
- onePer: true, // 单人请教
- addressIndex: 0,
- addressArray: [],
- tuanList: [
- {
- endtime: "2022-10-12 21:25:06",
- },
- {
- endtime: "2022-10-15 21:25:06",
- },
- {
- endtime: "2022-10-15 21:25:06",
- },
- {
- endtime: "2022-10-13 21:25:06",
- },
- ],
- time: "07:00",
- timelist: [
- [
- "07",
- "08",
- "09",
- "10",
- "11",
- "12",
- "13",
- "14",
- "15",
- "16",
- "17",
- "18",
- "19",
- "20",
- "21",
- "22",
- "23",
- ],
- ["00", "15", "30", "45"],
- ],
- hourIndex: 0,
- minuteIndex: 0,
- date: "",
- startDate: "",
- addressPopup: false,
- pickMove: false,
- groupWay: 0, // 拼团方式
- groupNumberPeople: 0, //拼团人数
- storeId: null, // 门店id
- contents: "", //预约内容
- topicPrice: 0,
- payPrice: 0,
- timeList: [], //空余时间
- isGroup: false, // 是否有拼团
- aa: [],
- },
- showTime() {
- this.popup.showPopup();
- },
- // 场地
- showAddress() {
- this.setData({
- addressPopup: true,
- });
- },
- //场地change
- bindChange(e) {
- console.log(e);
- this.setData({
- addressIndex: e.detail.value,
- });
- },
- pickstart() {
- this.setData({
- pickMove: true,
- });
- },
- pickend() {
- this.setData({
- pickMove: false,
- });
- },
- confirmAddress() {
- if (this.data.pickMove) {
- return;
- }
- this.setData({
- addressPopup: false,
- storeId: this.data.addressArray[this.data.addressIndex].id,
- });
- },
- toStoreDetail(e) {
- console.log(e, 111);
- wx.navigateTo({
- url: "/expert/storedetail/storedetail?id=" + e.currentTarget.dataset.id,
- });
- },
- putblur(e) {
- this.setData({
- contents: e.detail.value,
- });
- },
- submit() {
- if (this.data.topicId === null) {
- return app.showError("请选择话题!");
- }
- if (this.data.groupNumberPeople == 0 && !this.data.onePer) {
- return app.showError("请选择拼团人数!");
- }
- if (this.data.contents == "") {
- return app.showError("请输入预约内容!");
- }
- if (!util.getUserId()) {
- wx.reLaunch({
- url: "/pages/login",
- });
- return;
- }
- wx.requestSubscribeMessage({
- tmplIds: [
- "7W7QGAJiJ5xzYZtzzG3vaiVrGGtUYklkqKGCFpMP2wU",
- "LyWMllU4dWpy1Y8tS39EhOBLUSQWmUb_yDFKoJojKq8",
- ],
- success: (success) => {},
- fail: (fail) => {},
- complete: (complete) => {
- app._post_form(
- "meet/consult",
- "",
- {
- content: this.data.contents,
- expertId: this.data.id,
- groupNumberPeople: this.data.groupNumberPeople,
- groupWay: this.data.groupWay,
- meetPrice: this.data.payPrice,
- meetTime: this.data.date + " " + this.data.time + ":00",
- storeId: this.data.storeId,
- topicId: this.data.topicId,
- type: 0,
- id: util.getUserId(),
- },
- (res) => {
- if (res.code == 0) {
- wx.showActionSheet({
- itemList: ["微信支付"],
- success: (response) => {
- if (response.tapIndex === 0) {
- wx.showLoading({
- title: "正在处理...",
- mask: true,
- });
- wx.requestPayment({
- timeStamp: res.map.timestamp,
- nonceStr: res.map.nonce_str,
- package: "prepay_id=" + res.map.prepay_id,
- signType: "MD5",
- paySign: res.map.sign,
- success: (result) => {
- if (result.errMsg == "requestPayment:ok") {
- wx.showLoading({
- title: "正在处理...",
- mask: true,
- });
- console.log(result, 11111111);
- wx.hideLoading();
- // wx.showModal({
- // title: "温馨提示",
- // content: "支付成功!",
- // showCancel: false,
- // });
- wx.showToast({
- title: "支付成功!",
- icon: "none",
- duration: 1500,
- });
- setTimeout(() => {
- wx.navigateTo({
- url:
- "/expert/success/success?expertId=" +
- this.data.id +
- "&meetId=" +
- res.map.businessId +
- "&onePer=" +
- this.data.onePer,
- });
- },2000)
-
- } else {
- wx.hideLoading();
- wx.showToast({
- title: "支付失败!",
- icon: "none",
- duration: 1500,
- });
- }
- },
- fail: (error) => {
- wx.hideLoading();
- wx.showToast({
- title: "支付失败!",
- icon: "none",
- duration: 1500,
- });
- },
- });
- }
- },
- fail(errors) {},
- });
- } else {
- wx.showModal({
- title: "温馨提示",
- content: res.msg,
- showCancel: false,
- });
- }
- },
- function (res) {}
- );
- },
- });
- console.log(util.getUserId());
- // wx.navigateTo({
- // url: '/expert/success/success'
- // })
- },
- hiddenAddress() {
- this.setData({
- addressPopup: false,
- });
- },
- know() {
- this.popup.hidePopup();
- },
- //话题选择change
- msgChange(e) {
- let that = this;
- let temp;
- if (e && e.hasOwnProperty("detail")) {
- temp = e.detail.value;
- } else {
- temp = e;
- }
- console.log(e,'20')
- for (let item of this.data.topicList) {
- if (item.id == temp) {
- this.setData({
- topicId: temp,
- content: item.topicDescribe,
- price: item.topicPrice,
- payPrice: that.data.onePer
- ? item.topicPrice
- : that.data.groupNumberPeople == 0
- ? item.topicPrice
- : item.topicPrice / that.data.groupNumberPeople,
- });
- this.getGroupList();
- }
- }
- },
- //日期change
- bindDateChange(e) {
- this.setData({
- date: e.detail.value,
- });
- },
- //时间change
- timeChange(e) {
- this.setData({
- time: e.detail.value,
- });
- },
- bindMultiPickerChange(e) {
- console.log(e, 11111111);
- let hourIndex = e.detail.value[0];
- let minuteIndex = e.detail.value[1];
- this.setData({
- hourIndex: hourIndex,
- minuteIndex: minuteIndex,
- time:
- this.data.timelist[0][[hourIndex]] +
- ":" +
- this.data.timelist[1][minuteIndex],
- });
- },
- //拼团方式change
- pinChange(e) {
- let that = this;
- if (e.detail.value == "1") {
- this.setData({
- onePer: false,
- payPrice: that.data.price,
- });
- } else {
- this.setData({
- onePer: true,
- payPrice: that.data.price,
- groupNumberPeople: 0,
- });
- }
- this.setData({
- groupWay: e.detail.value,
- });
- },
- //拼团人数
- perChange(e) {
- let that = this;
- this.setData({
- groupNumberPeople: e.detail.value,
- payPrice: that.data.price / e.detail.value,
- });
- },
- //更多拼团
- more() {
- this.getGroupList();
- this.popup1.showPopup();
- },
- // 参与拼团
- joinGroup(e) {
- // console.log(e.currentTarget.dataset.meetid);
- // console.log(e.currentTarget.dataset.expertId);
- if (!util.getUserId()) {
- wx.reLaunch({
- url: "/pages/login",
- });
- return;
- }
- wx.navigateTo({
- url:
- "/meet/meet/addmeet?expertId=" +
- e.currentTarget.dataset.expertid +
- "&meetId=" +
- e.currentTarget.dataset.meetid +
- "&memberId=" +
- e.currentTarget.dataset.memberid
- });
- // console.log('expertId',e.currentTarget.dataset.expertid)
- // console.log('expertId1',this.data.id)
- // console.log(e)
- // console.log(this.data.onePer,'111222')
-
- // app._put_form(
- // "meet/joinTheGroup",
- // "",
- // {
- // id: util.getUserId(),
- // meetId: e.currentTarget.dataset.meetid,
- // },
- // (res) => {
- // if (res.code === 0) {
- // wx.showActionSheet({
- // itemList: ["微信支付"],
- // success: (response) => {
- // if (response.tapIndex === 0) {
- // wx.showLoading({
- // title: "正在处理...",
- // mask: true,
- // });
- // wx.requestPayment({
- // timeStamp: res.map.timestamp,
- // nonceStr: res.map.nonce_str,
- // package: "prepay_id=" + res.map.prepay_id,
- // signType: "MD5",
- // paySign: res.map.sign,
- // success: (result) => {
- // if (result.errMsg == "requestPayment:ok") {
- // wx.showLoading({
- // title: "正在处理...",
- // mask: true,
- // });
- // console.log(result, 11111111);
- // wx.hideLoading();
- // wx.showToast({
- // title: "拼团成功",
- // icon: "success",
- // });
- // wx.navigateTo({
- // url:
- // "/expert/success/success?expertId=" +
- // this.data.id +
- // "&meetId=" +
- // res.map.businessId +
- // "&onePer=" +
- // false,
- // });
- // } else {
- // wx.hideLoading();
- // wx.showToast({
- // title: "支付失败!",
- // icon: "none",
- // duration: 1500,
- // });
- // }
- // },
- // fail: (error) => {
- // wx.hideLoading();
- // wx.showToast({
- // title: "支付失败!",
- // icon: "none",
- // duration: 1500,
- // });
- // },
- // });
- // }
- // },
- // });
- // // this.getGroupList();
- // }
- // }
- // );
- },
- freeTime(id) {
- app._get(`expert/info/${id}`, {}, (res) => {
- if (res.code === 0) {
- this.setData({
- timeList: res.expert.periodBOList,
- });
- }
- });
- },
- //场地change
- // addressChange(e) {
- // this.setData({
- // addressIndex: e.detail.value,
- // })
- // },
- //取消事件
- _error(e) {
- this[e.currentTarget.dataset.name].hidePopup();
- clearInterval(timer);
- endTotal = 0
- num = 0
- // this.setData({
- // maskShow: false,
- // isDjs: false,
- // time: 5
- // })
- },
- //倒计时
- nowTime(res) {
- //时间函数
- num++
- let that = this;
- // var endTotal = 0
- let len = res.length; //时间数据长度
- if(endTotal == len) {
- clearInterval(timer);
- return;
- }
- for (let i = 0; i < len; i++) {
- if(res[i].difftime == '已结束!') {
- continue
- }
- let localDate = new Date();
- var intDiff = res[i].groupWayEndTime; //获取数据中的时间
- let endTime = new Date(intDiff);
- let stratTime = (new Date(res[i].currentTime)).getTime() + num*1000
- // console.log(endTime.getTime(),localDate.getTime(),'ooooooooooppppp111')
- //计算秒数,取数据只取当月的,所以从天开始
- // let s = (endTime.getTime() - localDate.getTime()) / 1000;
-
- let s = (endTime.getTime() - stratTime) / 1000;
- // let s = (endTime.getTime() - stratTime.getTime()) / 1000;
- // console.log(intDiff)
- var day = 0,
- hour = 0,
- minute = 0,
- second = 0,
- msg = "";
- if (s > 0) {
- //转换时间
- day = Math.floor(s / 86400);
- // hour =
- // Math.floor((s % 86400) / 3600) < 10
- // ? "0" + Math.floor((s % 86400) / 3600)
- // : Math.floor((s % 86400) / 3600);
- hour =Math.floor(s / 60 / 60) < 10 ? '0' + Math.floor(s / 60 / 60) : Math.floor(s / 60 / 60);
- minute =
- Math.floor((s % 3600) / 60) < 10
- ? "0" + Math.floor((s % 3600) / 60)
- : Math.floor((s % 3600) / 60);
- second =
- Math.floor(s % 60) < 10
- ? "0" + Math.floor(s % 60)
- : Math.floor(s % 60);
- msg = hour + ":" + minute + ":" + second;
- } else {
- msg = "已结束!";
- endTotal++
- // res[i].difftime = msg;
- // clearInterval(timer);
- }
- // console.log(str);
- res[i].difftime = msg; //在数据中添加difftime参数名,把时间放进去
- }
- that.setData({
- // wearList: res
- groupList: res.slice(0, 10),
- groupList3: res.slice(0, 3),
- });
- // this.setData({
- // groupList: res.list.slice(0, 10),
- // groupList3: res.list.slice(0, 3),
- // });
- // console.log(that.data.groupList3)
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- console.log(options);
- if (options.topicId) {
- this.setData({
- topicId: options.topicId,
- });
- }
-
- console.log(options,'options.topicId')
- this.setData({
- id: options.id,
- topicPrice: options.price,
- payPrice: options.price,
- });
- this.getTopic(options.id);
- this.getMeetAddressList(options.id);
- this.freeTime(options.id);
- var currentDate = new Date()
- var preDate = new Date(currentDate.getTime() + (2*24*3600*1000))
- let year = preDate.getFullYear()
- let mon = preDate.getMonth() + 1
- let day = preDate.getDate()
- let s = year + '-' + (mon<10?('0'+mon):mon) + '-' + (day<10?('0'+day):day)
- this.setData({
- date: s,
- startDate: s
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- //获得popup组件
- this.popup = this.selectComponent("#popup");
- this.popup1 = this.selectComponent("#popup1");
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {},
- // 获取擅长话题
- getTopic(id) {
- let that = this
- app._get(
- "experttopic/list",
- {
- expertId: id,
- },
- (res) => {
- if (res.code === 0) {
- this.setData({
- topicList: res.list,
- });
- if (this.data.topicId) {
- this.data.topicList.forEach((v, i) => {
- if (v.id == this.data.topicId) {
- v.checked = true;
- } else {
- v.checked = false;
- }
- });
- this.setData({
- topicList: this.data.topicList,
- });
- this.msgChange(this.data.topicId);
- }else {
- this.setData({
- topicId: res.list[0].id,
- 'topicList[0].checked': true,
- content: res.list[0].topicDescribe,
- price: res.list[0].topicPrice,
- payPrice: that.data.onePer
- ? res.list[0].topicPrice
- : that.data.groupNumberPeople == 0
- ? res.list[0].topicPrice
- : res.list[0].topicPrice / that.data.groupNumberPeople,
- });
- // this.setData({
- // topicId: temp,
- // content: item.topicDescribe,
- // price: item.topicPrice,
- // payPrice: that.data.onePer
- // ? item.topicPrice
- // : that.data.groupNumberPeople == 0
- // ? item.topicPrice
- // : item.topicPrice / that.data.groupNumberPeople,
- // });
- }
- this.getGroupList()
- console.log(this.data.topicId,'topicId2222')
- }
- }
- );
- },
- // 拼团列表
- getGroupList() {
- clearInterval(timer);
- this.setData({
- groupList: [],
- groupList3: [],
- });
- app._get(
- "meet/groupList",
- {
- expertId: this.data.id,
- topicId: this.data.topicId,
- },
- (res) => {
- if (res.code === 0) {
- // this.setData({
- // groupList: res.list.slice(0, 10), res.list
- // groupList3: res.list.slice(0, 3),
- // });
- // this.nowTime(this.data.tuanList);
- if (res.list.length > 0) {
- timer = setInterval(this.nowTime, 990, res.list);
- }
- }
- }
- );
- },
- // 约见场地列表
- getMeetAddressList(expertId) {
- let that = this;
- app._get(`expert/meetingVenueList/${expertId}`, {}, (res) => {
- if (res.code === 0) {
- this.setData({
- addressArray: res.list,
- storeId: res.list[0].id,
- });
- }
- });
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {},
- onUnload: function () {
- clearInterval(timer);
- endTotal = 0
- num = 0
- // this.data.groupList.forEach((v, k) => {
- // clearInterval(v.timer);
- // });
- // this.data.groupList.forEach((v, k) => {
- // clearInterval(v.timer);
- // // clearTimeout(v.timer)
- // // var index = "groupList[" + k + "].timer"; //这里必须这样拼接
- // // this.setData({
- // // [index]: null,
- // // });
- // console.log(this.data.aa)
- // });
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {},
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {},
- showShareMenu: function () {
- wx.showShareMenu();
- },
- hideShareMenu() {
- wx.hideShareMenu();
- },
- });
|