|
- // pages/spellDetail/index.js
- var config = require("../../config/config.js");
- const Http = require("../../utils/HttpBasics");
- const imgurl = require("../../utils/imgurl");
- const {spellStatus} = require("../../utils/spell");
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- tuanzhang: imgurl.tuanzhang.url,
- spellBg: imgurl.spellBg.url,
- position: imgurl.position.url,
- paramData:null,
- data:null,
- clock: "00",
- day: "00",
- hour: "00",
- min: "00",
- sec: "00",
- spellStatusList: spellStatus
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- console.log(this.data.spellStatusList,7777777)
- this.setData({
- paramData:options
- })
- this.getDetail(options);
- // 关闭来自于左上角的分享
- wx.hideShareMenu()
- },
- /**
- * 拼团状态字段转换
- */
- changeSatus(status){
- console.log(spellStatus,8888888)
- return spellStatus.filter(item=>item.value==status)[0].name;
- },
- // 时间格式化输出,如11:03 25:19 每1s都会调用一次
- dateformat(micro_second) {
- // 总秒数
- var second = Math.floor(micro_second / 1000);
- // 天数
- var day = Math.floor(second / 3600 / 24) < 10 ? "0" + Math.floor(second / 3600 / 24) : Math.floor(second / 3600 / 24);
- // 小时
- var hr = Math.floor(second / 3600 % 24) < 10 ? "0" + Math.floor(second / 3600 % 24) : Math.floor(second / 3600 % 24);
- // 分钟
- var min = Math.floor(second / 60 % 60) < 10 ? "0" + Math.floor(second / 60 % 60) : Math.floor(second / 60 % 60);
- // 秒
- var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60) : Math.floor(second % 60);
-
- // return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
- return {
- a1: day,
- b1: hr,
- c1: min,
- d1: sec
- }
- },
- countdown(end_time) {
- let that = this;
- var EndTime = end_time;
- var NowTime = new Date().getTime();
- var total_micro_second = EndTime - NowTime || [];
- // 渲染倒计时时钟
- let obj = that.dateformat(total_micro_second);
- if (total_micro_second > 0) {
- that.setData({
- clock: obj,
- day: obj.a1,
- hour: obj.b1,
- min: obj.c1,
- sec: obj.d1,
- })
- } else {
- that.setData({
- clock: "00",
- day: "00",
- hour: "00",
- min: "00",
- sec: "00",
- })
- }
- setTimeout(function () {
- total_micro_second -= 1000;
- that.countdown(end_time);
- }, 1000)
- },
- getDetail(){
- let that = this;
- Http.get({
- url: config.api.queryOrderGroupStatus,
- data: {
- orderId: this.data.paramData.orderId,
- couponId: this.data.paramData.couponId,
- id: this.data.paramData.orderGroupId
- }
- }).then(res => {
- console.log(res,555555555)
- let data=res.data;
- data.statustext=that.changeSatus(data.status);
- that.countdown(data.expiredDate);
- data.salePrice = (data.salePrice/100).toFixed(2)
- for (let i = 0; i < data.remainPeople;i++){
- let a={};
- data.userList.push(a)
- }
- that.setData({
- data:res.data
- })
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- // paramData
- onShareAppMessage: function (res) {
- if (res.from === 'button') {
- console.log(res, 3333333333333333333333)
- // 来自页面内转发按钮
- let _this = this;
- return {
- title: '拼团',
- path: `/pages/index/index?couponId=${this.data.couponId}&orderGroupId=${this.data.orderGroupId}&couponChannelId=${this.data.couponChannelId}`,
- imageUrl: this.data.data.coverImg,
- success: function (res) {
- // 转发成功
- },
- fail: function (res) {
- // 转发失败
- }
- }
- } else {
- console.log(res, 444444444444444444)
- }
- }
- })
|