123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- // pages/groupPage/collage-details/collage-details.js
- import httpRequestApi from '../../../utils/APIClient';
- import util from '../../../utils/util';
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- groupPurchaseInfo: {},
- organizer: {},
- surplusNum: '',
- joinUserList: [],
- surplusList: [],
- timeList: [],
- productId: '',
- orderId: '',
- groupId: '',
- content: [{
- text: "转发给自己的朋友们",
- color: "#000"
- },
- {
- text: " 分享好课,追随您一起学习进步",
- color: "#000"
- },
- {
- text: " 您的魅力不是吹的",
- color: "#000"
- },
- {
- text: "在限定时间内成功拼团,您将得到奖学金。",
- color: "#FF4600"
- }
- ],
- read: false,
- organizerUid: '',
- colonelName: '',
- rewardMoney: '',
- goBackHome: false,
- dataLoading: true
- },
- //显示分享页
- openShare: function () {
- if (this.data.read) {
- const productId = this.data.productId;
- const id = this.data.orderId;
- const groupId = this.data.groupId;
- wx.navigateTo({
- url: `/pages/groupPage/grade-details/grade-details?productId=${productId}&id=${id}&groupId=${groupId}&share=true`
- })
- } else {
- this.shareDialog = this.selectComponent("#share-dialog");
- const data = {
- avatar: this.data.organizer.avatar,
- author: this.data.organizer.wechatName,
- iconImg: this.data.groupPurchaseInfo.bgImg,
- title: this.data.groupPurchaseInfo.productTitle,
- path: `pages/groupPage/group-details/group-details`,
- scene: `QR${this.data.orderId}`,
- groupPurchaseInfo: this.data.groupPurchaseInfo,
- groupType: this.data.groupOsType
- }
- this.shareDialog.share(data);
- }
- },
- // 下拉刷新
- onPullDownRefresh: function () {
- this.setData({
- surplusList: []
- }, () => {
- this.getInfo();
- })
- wx.showNavigationBarLoading() //在标题栏中显示加载
- //模拟加载
- setTimeout(function () {
- wx.hideNavigationBarLoading() //完成停止加载
- wx.stopPullDownRefresh() //停止下拉刷新
- }, 1500);
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- // if (app.globalData.isIOS) {
- // wx.redirectTo({
- // url: '../../index/index'
- // })
- // return
- // }
- if (options.read) {
- this.setData({
- read: options.read
- })
- }
- if (options.goBackHome == 'true') {
- this.setData({
- goBackHome: true
- })
- }
- // options.scene = 'QR1541862338777268';
- wx.setNavigationBarTitle({
- title: '拼团详情'
- })
- console.log(options);
- console.log(options.orderId);
- const orderId = options.orderId ? options.orderId : options.scene.replace('QR', '');
- // if (options.orderId) {
- // return false;
- // }
- console.log(orderId)
- this.setData({
- orderId
- }, () => {
- this.getInfo()
- })
- },
- getInfo: function () {
- httpRequestApi.getMygroupInfo(this.data.orderId).success(res => {
- console.log(res);
- const groupOrder = res.data.data.groupPurchaseOrder;
- const surplusNum = groupOrder.headcount - groupOrder.joinCount;
- this.setData({
- organizerUid: groupOrder.organizer,
- read: groupOrder.status === 'SUCCESSED' ? true : false
- })
- for (var i = 0; i < surplusNum; i++) {
- this.data.surplusList.push(1);
- }
- //console.log(res.data.data.groupPurchaseOrder.closeTime - res.data.data.groupPurchaseOrder.gmtModified)
- //时间转换
- let timeList = [];
- const stillGoing = groupOrder.closeTime - Date.parse(new Date()) <= 0 ? false : true
- if (stillGoing) {
- timeList = util.lastHoursInGroup(groupOrder.closeTime - Date.parse(new Date()));
- }
- // const timeList = util.formatTime(groupOrder.closeTime - Date.parse(new Date()));
- // console.log(timeList)
- //res.data.data.joinUserList.unshift(res.data.data.organizer);
- this.setData({
- groupPurchaseInfo: res.data.data.groupPurchaseInfo,
- organizer: res.data.data.organizer,
- surplusNum,
- joinUserList: res.data.data.joinUserList,
- surplusList: this.data.surplusList,
- timeList,
- stillGoing,
- productId: groupOrder.productId,
- groupId: groupOrder.groupId,
- rewardMoney: res.data.data.groupPurchaseInfo.organizerPrice / 100,
- dataLoading: false,
- groupOsType: groupOrder.os
- })
- if (groupOrder.groupType === 'PROMOTION') {
- //this.data.joinUserList.unshift(res.data.data.organizer);
- this.setData({
- colonelName: res.data.data.organizer.wechatName
- })
- this.setData({
- joinUserList: this.data.joinUserList,
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- this.shareDialog = this.selectComponent("#share-dialog");
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function (ops) {
- if (ops.from === 'button') {
- console.log(ops.target)
- }
- const id = this.data.orderId;
- const data = {
- shareTypeEnum: 'LINK',
- shareContentEnum: 'GROUP',
- productId: this.data.productId
- }
- httpRequestApi.shareRecord(data).success((res) => {
- console.log(res)
- })
- return {
- title: '老师同学都在玩的配音show,你还在等什么?',
- path: `pages/groupPage/group-details/group-details?share=true&shareId=${id}`,
- imageUrl: `https://efunbox.lingjiao.cn/reader/resource/share/group_${this.data.productId}.jpg`,
- }
- }
- })
|