123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427 |
- // pages/my/meet/detail.js
- const App = getApp();
- var util = require("../../utils/util.js");
- let timer = null;
- let sNum = 0
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- appAssetsUrl2: App.appAssetsUrl2,
- meetId: null,
- expertId: null,
- memberId: null, //拼主id
- detail: {},
- expertDetail: {},
- groupList: [],
- experienceDetail: {},
- h: "00",
- m: "00",
- s: "00",
- queryPage: {
- page: 1,
- limit: 10,
- },
- list: [],
- total: null,
- totalPage: null,
- currPage: null,
- user: wx.getStorageSync("USER"),
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- console.log(options);
- this.setData({
- meetId: options.meetId,
- expertId: options.expertId,
- memberId: options.memberId
- });
- this.getDetail(options.meetId);
- this.getExpert();
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- this.popup2 = this.selectComponent("#popup2");
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {},
- getDetail(meetId) {
- wx.showLoading({
- title: "努力加载中...",
- });
- App._get(
- `myMeet/myAppointmentInfo`,
- {
- meetId: meetId,
- id: this.data.memberId,
- },
- (res) => {
- if (res.code === 0) {
- this.setData({
- detail: res.data,
- groupList: res.data.meetPeopleBOList,
- });
- if (res.data.process >= 3) {
- this.getExperience(res.data.meetId);
- }
- if (
- res.data.groupWay == 1 &&
- res.data.process == 0 &&
- res.data.meetType == 0
- ) {
- sNum = 0
- timer = setInterval(this.countDown, 1000);
- }
- wx.hideLoading();
- }
- },
- (err) => {},
- (complete) => {}
- );
- },
- // 立即参团 /pages/login
- addsub() {
- if(!util.getUserId()) {
- wx.navigateTo({
- url: `/pages/login?meetId=${this.data.meetId}&expertId=${this.data.expertId}&memberId=${this.data.memberId}`,
- })
- return
- }
-
- console.log('1111111111111')
- App._put_form(
- "meet/joinTheGroup",
- "",
- {
- id: util.getUserId(),
- // id: this.data.memberId,
- meetId: this.data.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.expertId +
- "&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();
- }
- }
- );
- },
- // 获取行家详情
- getExpert() {
- App._get(`expert/info/${this.data.expertId}`, {}, (res) => {
- if (res.code === 0) {
- this.setData({
- expertDetail: res.expert,
- });
- }
- });
- },
- // 获取心得分享
- getExperience(meetId) {
- if (this.data.queryPage.page > 1) {
- if (this.data.total > 0 && this.data.currPage == this.data.totalPage) {
- wx.showToast({
- title: "没有更多了~",
- icon: "none",
- });
- return false;
- }
- }
- wx.showLoading({
- title: "努力加载中...",
- });
- App._get(
- "meetevaluation/evaluatePage",
- {
- meetId: meetId,
- ...this.data.queryPage,
- },
- (res) => {
- if (res.code === 0) {
- this.setData({
- list: [...this.data.list, ...res.page.list],
- total: res.page.totalCount,
- totalPage: res.page.totalPage,
- currPage: res.page.currPage,
- });
- }
- },
- (err) => {},
- (complete) => {
- setTimeout(() => {
- wx.hideLoading();
- }, 500);
- }
- );
- },
- // 查看更多
- lookMore() {
- wx.navigateTo({
- url: "/meet/meet/meet",
- });
- },
- // 取消预约
- closeMakeHandle() {
- this.popup2.showPopup();
- },
- // 心得分享
- experienceSharingHandle() {
- wx.navigateTo({
- url: `/meet/experience/experience?meetId=${this.data.meetId}&expertId=${this.data.expertId}&topicId=${this.data.detail.topicId}&memberId=${this.data.expertDetail.memberId}`,
- });
- },
- _error() {
- console.log("返回");
- this.popup2.hidePopup();
- },
- // 确认取消预约
- _success() {
- console.log("查看");
- wx.showLoading({
- title: "取消中...",
- });
- App._put_form(
- "myMeet/cancelAppointment",
- "",
- {
- id: this.data.user.id,
- meetId: this.data.meetId,
- },
- (res) => {
- if (res.code === 0) {
- this.popup2.hidePopup();
- wx.hideLoading();
- wx.navigateBack();
- wx.showToast({
- title: "已取消预约",
- });
- }
- },
- (err) => {
- wx.showToast({
- icon: "error",
- title: "服务端异常",
- });
- }
- );
- },
- // 完成请教
- finishHandle() {
- App._put_form(
- "myMeet/completeTheConsultation",
- "",
- {
- id: this.data.user.id,
- meetId: this.data.meetId,
- },
- (res) => {
- if (res.code === 0) {
- wx.navigateBack();
- wx.showToast({
- title: "请教成功",
- });
- }
- }
- );
- },
- contactExpert() {
- this.setData({
- isShowContact: true,
- });
- },
- cancelContact() {
- this.setData({
- isShowContact: false,
- });
- },
- contactPhone(e) {
- console.log(e, 1111);
- wx.makePhoneCall({
- phoneNumber: e.currentTarget.dataset.phone,
- });
- this.setData({
- isShowContact: false,
- });
- },
- toCustomer() {
- wx.navigateTo({
- url: "/pages/my/myCustomer/myCustomer",
- });
- },
- //统计积分(每日小程序分享)
- addScore: function () {
- if (!util.getUserId()) {
- return;
- }
- let _this = this;
- wx.showLoading({
- title: "努力加载中...",
- });
- App._post_form(
- "scoreStu/share",
- "",
- {
- stuId: util.getUserId(),
- },
- function (res) {
- if (res.code === 0) {
- wx.hideLoading();
- }
- }
- );
- },
- // 倒计时
- countDown() {
- sNum++
- let endTime = new Date(this.data.detail.groupWayEndTime).getTime();
- let nowTime = this.data.detail.currentTimeStamp;
- let times = (endTime - nowTime) / 1000 - sNum;
- if (times > 0) {
- let h = parseInt(times / 60 / 60);
- h = h < 10 ? "0" + h : h;
- let m = parseInt((times / 60) % 60);
- m = m < 10 ? "0" + m : m;
- let s = parseInt(times % 60);
- s = s < 10 ? "0" + s : s;
- this.setData({
- h: h,
- m: m,
- s: s,
- });
- if (h == "00" && m == "00" && s == "00") {
- clearInterval(timer);
- sNum = 0
- setTimeout(() => {
- wx.showToast({
- title: "时间到了",
- });
- }, 1);
- this.getDetail(this.data.meetId);
- this.getExpert();
- }
- } else {
- clearInterval(timer);
- sNum = 0
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- clearInterval(timer);
- sNum = 0
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {},
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- if (this.data.detail.process >= 3) {
- this.setData({
- queryPage: {
- page: ++this.data.queryPage.page,
- limit: 10,
- },
- });
- this.getExperience(this.meetId);
- }
- },
- /**
- * 用户点击右上角分享
- */
- // onShareAppMessage() {
-
- // },
- });
|