找回密码
 立即注册

扫一扫,访问微社区

查看: 4919|回复: 6

微信小程序学习用插件:T沙龙;分享,简单布局

  [复制链接]

76

主题

28

回帖

10万

金钱

管理员

积分
0

优秀版主

发表于 2017-1-16 14:15:38 | 显示全部楼层 |阅读模式


代码示例:
[mw_shl_code=applescript,true]// 获取全局应用程序实例对象
const app = getApp();
// 获得 AV 的引用
const AV = require('../../libs/av-weapp-min.js');

// 创建页面实例对象
Page({
  // 页面名称
  name: "detail",
  // 页面的初始数据
  data: {
    objectId: '',
    salon: { },
    orators: [],
  },

  // 生命周期函数--监听页面加载
  onLoad: function(option) {
    this.setData({
      objectId: option.objectId
    });
    wx.setNavigationBarTitle({
      title: '<T> 沙龙详情',
    });
  },
  // 生命周期函数--监听页面初次渲染完成
  onReady () {
    var params = {
      'objectId': this.data.objectId,
    }
    var that = this;
    AV.Cloud.run('getSalonWithObjectId', params).then(salon => {
      var speeches = salon.salon_speeches;
      this.setData({ orators: [] });
      speeches.forEach(function (speech, i, a) {
        var id = speech.speech_orator_id;
        var query = new AV.Query('TGuest');
        query.get(id).then(function (orator) {
          console.log(orator);
          var newOrators = that.data.orators;
          newOrators.push(orator);
          that.setData({ orators: newOrators });
        }).catch(console.error);
      })
      this.setData({ salon: salon });
    }).catch(error => {
      app.showError(error);
    });
  },

  // 自定义事件
  toggleEnroll: function(e) {
    // 首先检查是否需要完善信息
    var that = this;
    var userid = app.globalData.user.objectId;
    var params = {
      'userid': userid,
    }
    AV.Cloud.run('checkShouldFullInfo', params).then(result => {
      if (result == null) {
        // 需要,则跳转至报名界面
        wx.showModal({
          title: '报名',
          content: '我们需要您完善个人信息才能完成报名,是否前往完善信息?',
          success: function(res) {
            if (res.confirm) {
              var objectId = that.data.objectId;
              console.log(objectId);
              // 跳转到报名页面
              wx.redirectTo({ url: '../enroll/enroll?objectId=' + objectId });
            }
          }
        });
      } else {
        // 不需要,则直接调用报名接口
        wx.showModal({
          title: '报名',
          content: '是否确认报名?确认后暂不支持主动取消,如果需要取消报名请联系沙龙主办方',
          success: function(res) {
            if (res.confirm) {
              var enrollParams = {
                'salon_id': that.data.objectId,
                'guest_id': result.objectId,
              };
              AV.Cloud.run('enrollSalon', enrollParams).then(result => {
                console.log(result);
                if (result) {
                  // 报名成功,跳转报名成功页面
                  wx.navigateTo({ url: '../success/success' });
                } else {
                  var error = '报名失败!';
                  app.showError(error);
                }
              }).catch(error => {
                app.showError(error);
              });
            }
          }
        });
      }
    }).catch(error => {
      app.showError(error);
    });
  },
  onShareAppMessage: function() {
    var title = this.data.salon.salon_title;
    return {
      title: title,
      desc: title + '<T> 沙龙即将召开,感兴趣的朋友快来报名参加吧~',
      path: '/page/detail/detail',
    };
  },

  toggleGuests: function(e) {
    var objectId = this.data.objectId;
    // 跳转到用户详情页面
    wx.navigateTo({ url: '../users/users?objectId=' + objectId });
  },
})[/mw_shl_code]

附件下载
游客,如果您要查看本帖隐藏内容请回复

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

0

主题

5

回帖

47

金钱

新人求带

积分
0
发表于 2017-3-16 18:19:07 | 显示全部楼层
看看用什么工具做

0

主题

8

回帖

218

金钱

新人求带

积分
0
QQ
发表于 2017-7-15 16:22:32 | 显示全部楼层
正需要,支持楼主大人了!

0

主题

245

回帖

63

金钱

新人求带

积分
0
发表于 2017-8-15 17:27:33 | 显示全部楼层
感谢分享
回复

使用道具 举报

0

主题

3

回帖

22

金钱

新人求带

积分
0
发表于 2017-8-27 23:37:09 | 显示全部楼层
看看怎么做?

0

主题

3

回帖

314

金钱

新人求带

积分
0
发表于 2018-2-26 15:37:55 | 显示全部楼层
学习学习
回复

使用道具 举报

0

主题

222

回帖

509

金钱

新人求带

积分
0
发表于 2020-4-11 16:54:52 | 显示全部楼层
我有流量,寻求个人游戏开发者合作,有意者联系微信号jim20180688
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|微信小程序开发|教程|文档|资源汇总_即速论坛 ( 粤ICP备14097199号-1  

GMT+8, 2024-3-29 05:26 , Processed in 0.130375 second(s), 36 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表