Переглянути джерело

消息和黑洞矿场 完善

x 4 роки тому
батько
коміт
2514de67cf

+ 27 - 0
view/xcx/api/message.js

@@ -0,0 +1,27 @@
+import request from "./../utils/request.js";
+/**
+ * 消息相关接口
+ * 
+*/
+
+
+/**
+ * 获取列表
+*/
+export function getMessages(page, limit = 20) {
+  return request.get("user/messages", {page: page, limit: limit});
+}
+
+/**
+ * 已读/未读 标记 0 未读 1已读
+*/
+export function readMessage(ids, state) {
+  return request.post("user/messages", {ids: ids, read: state});
+}
+
+/**
+ * 删除
+*/
+export function delMessage(ids) {
+  return request.delete("user/messages", {ids: ids});
+}

+ 2 - 1
view/xcx/app.json

@@ -63,7 +63,8 @@
     "components/write-off/index",
     "components/price-change/index",
     "components/general-window/index",
-    "pages/message/index"
+    "pages/message/index",
+    "pages/mine_rule/index"
   ],
   "subPackages": [
     {

+ 87 - 2
view/xcx/components/mine/index.js

@@ -1,23 +1,108 @@
 // components/mine/index.js
+import { bootCoin } from "../../api/mine"
+import { getNotifications } from "../../api/api"
+import { formatTime } from "../../utils/util"
+
 Component({
   /**
    * 组件的属性列表
    */
   properties: {
-
   },
 
   /**
    * 组件的初始数据
    */
   data: {
-
+    symbol: "BTC",
+    icon: "/images/one.png",
+    btnTxt: "开始挖矿",
+    history: [{
+      "symbol": "doge",
+      "icon": "/images/one.png",
+      "amount": 12.00034,
+      "ts": "2021/05/10 15:50:03",
+      "from": "abcde034345dd",
+      "to": "aabde2343df34",
+      "out": 0,
+    },{
+      "symbol": "doge",
+      "icon": "/images/one.png",
+      "amount": 12.00034,
+      "ts": "2021/05/10 17:12:42",
+      "from": "abcde034345dd",
+      "to": "aabde2343df34",
+      "out": -1,
+    }],
+    totals: 9999.9999,
+    progress: 99.999,
+    timer: null,
+    coinTimer: null
   },
 
   /**
    * 组件的方法列表
    */
   methods: {
+    tabIn: function() {
+      this.getNotification();
+      this.starTimer();
+
+      console.log(formatTime(new Date(1620633003000)));
+      this.setData({history: []});
+    },
+
+    tabOut: function() {
+      clearInterval(this.data.timer);
+      clearTimeout(this.data.coinTimer);
+    },
+
+    getNotification: function() {
+      var that = this;
+      getNotifications().then(res=>{
+        console.log(res);
+        that.setData({
+
+        });
+      }, err=>{
+        console.log(err);
+        that.setData({
+          totals: 0,
+          progress: 0
+        });
+      });
+
+      that.data.coinTimer = setTimeout(()=>{
+        that.getNotification();
+      }, 30000);
+    },
+
+    starTimer: function() {
+      var that = this;
+      that.data.timer = setInterval(function(){
+        var current = parseFloat(that.data.progress);
+        that.setData({
+          progress: (current + parseFloat(Math.random() * 0.001)).toFixed(4)
+        });
+      }, 1000);
+    },
+
+    drawClick: function() {
+      let that = this;
+      that.setData({
+        btnTxt: "挖矿中"
+      });
+    },
+
+    goRule: function() {
+      wx.navigateTo({
+        url: '/pages/mine_rule/index',
+      })
+    },
 
+    dateTime: function(time) {
+      console.log(time);
+      return formatTime(new Date(parseInt(time)));
+    }
   }
 })

+ 44 - 2
view/xcx/components/mine/index.wxml

@@ -1,2 +1,44 @@
-<!--components/mine/index.wxml-->
-<text>components/mine/index.wxml</text>
+<view class="mine">
+  <view class="banner">
+    <view>
+      
+    </view>
+  </view>
+  <view class="content">
+    <button class="btn" bindtap="drawClick">{{btnTxt}}</button>
+    <view class="bottom">
+      <view class="space"></view>
+      <button class="rule" bindtap="goRule">活动规则</button>
+    </view>
+  </view>
+  <view class="details">
+    <view class="totals">
+      <image src="{{icon}}"></image>
+      <view class="text">
+        <view class="title">当前总数</view>
+        <view class="value">{{totals}}<text class="bit">{{symbol}}</text></view>
+      </view>
+    </view>
+    <view class="progress">
+        <view class="title">当前进度</view>
+        <view class="value">{{progress}}<text class="bit">{{symbol}}</text></view>
+    </view>
+  </view>
+  <view class="history">
+    <view class="title">
+      <image src="/images/historyTitle.png"></image>
+    </view>
+    <view class="noRecord" wx:if="{{history.length < 1}}">暂时没有记录</view>
+    <view wx:else>
+      <view wx:for="{{history}}" wx:key="index" class="item">
+      <view>
+        {{ item.ts }}
+        {{ item.out >=0 ? "挖矿" : "导出" }}
+        <text class="{{item.out >= 0 ? 'out' : 'in'}}">{{item.amount}}</text>
+        <text class="symbol">{{item.symbol}}</text>
+        <image class="icon" src="{{item.icon}}"></image>
+      </view>
+    </view>
+    </view>
+  </view>
+</view>

+ 29 - 1
view/xcx/components/mine/index.wxss

@@ -1 +1,29 @@
-/* components/mine/index.wxss */
+.mine { text-align: center; margin: auto; background-color: #f5f5f5; }
+.mine .banner { width: 100%; height: 360rpx;  margin: 20rpx auto; background-color: #fff; }
+.mine .content { width: 100%; height: 200rpx; background-color: #fff; margin-top: 20rpx; padding-top: 20rpx; }
+.mine .content .btn { width: 300rpx; height: 100rpx; line-height: 100rpx; margin: auto; background-color: #e93323!important;  color: #fff; border-radius: 45rpx; }
+.mine .content .bottom { display: flex; }
+.mine .content .bottom .space { width: 100%; flex-shrink: 2; }
+.mine .content .bottom .rule { font-size: 32rpx; text-decoration: underline; width: 156rpx; margin-right: 46rpx; }
+
+.mine .details { width: 100%; background-color: #fff; margin-top: 20rpx; display: flex; height: 120rpx; padding-top: 10rpx; padding-bottom: 10rpx;}
+.mine .details .totals { flex-shrink: 2; margin-left: 32rpx;  width: 50%; text-align: left; display: flex; }
+.mine .details .totals image { width: 86rpx; height: 86rpx; }
+.mine .details .totals .text { margin-left: 20rpx; }
+.mine .details .totals .title { font-size: 28rpx; }
+.mine .details .totals .value { font-size: 40rpx; }
+.mine .details .totals .value .bit { font-weight: bold; margin-left: 8rpx; }
+.mine .details .progress { text-align: left; }
+.mine .details .progress .title { font-size: 28rpx; }
+.mine .details .progress .value { font-size: 40rpx; }
+.mine .details .progress .value .bit { font-weight: bold; margin-left: 8rpx; }
+
+.mine .history { width: 100%; background-color: #fff; margin-top: 20rpx; }
+.mine .history .title { height: 88rpx; width: 431rpx; margin: auto; margin-bottom: 20rpx; }
+.mine .history .title image { width: 100%; height: 100%; }
+.mine .history .noRecord { margin-top: 42rpx; color: gray; }
+.mine .history .item { height: 64rpx; line-height: 64rpx; margin-top: 10rpx; text-align: left; margin-left: 64rpx; }
+.mine .history .item .out { color: red; }
+.mine .history .item .in { color: green; }
+.mine .history .item .symbol { margin-left: 12rpx; }
+.mine .history .item .icon { width: 48rpx; height: 48rpx; margin-left: 12rpx; margin-right: 12rpx; }

BIN
view/xcx/images/historyTitle.png


BIN
view/xcx/images/noMessage.png


+ 10 - 7
view/xcx/pages/goods_details/index.wxml

@@ -28,10 +28,10 @@
       <view class='money font-color'>
         <text class='num'>{{storeInfo.price}}</text>
-        <text class='vip-money' wx:if="{{storeInfo.vip_price && storeInfo.vip_price > 0}}">¥{{storeInfo.vip_price}}</text>
-        <image wx:if="{{storeInfo.vip_price && storeInfo.vip_price > 0}}" src="/images/vip.png"></image>
+        <!-- <text class='vip-money' wx:if="{{storeInfo.vip_price && storeInfo.vip_price > 0}}">¥{{storeInfo.vip_price}}</text> -->
+        <!-- <image wx:if="{{storeInfo.vip_price && storeInfo.vip_price > 0}}" src="/images/vip.png"></image> -->
       </view>
-      <view class='iconfont icon-fenxiang' bindtap='listenerActionSheet'></view>
+      <!-- <view class='iconfont icon-fenxiang' bindtap='listenerActionSheet'></view> -->
     </view>
     <view class='introduce'>{{storeInfo.store_name}}</view>
     <view class='label acea-row row-between-wrapper'>
@@ -45,13 +45,13 @@
         <view class='activity'>赠送 {{storeInfo.give_integral}} 积分</view>
       </view>
     </view>
-    <view class='coupon acea-row row-between-wrapper' bindtap='coupon' style="{{ storeInfo.give_integral > 0 ? 'margin-top:0;':''}}">
+    <!-- <view class='coupon acea-row row-between-wrapper' bindtap='coupon' style="{{ storeInfo.give_integral > 0 ? 'margin-top:0;':''}}">
       <view class='hide line1 acea-row'>
         优惠券:
         <view class='activity' wx:for="{{couponList}}" wx:key='index'>满{{item.use_min_price}}减{{item.coupon_price}}</view>
       </view>
       <view class='iconfont icon-jiantou'></view>
-    </view>
+    </view> -->
     <view class="coupon acea-row row-between-wrapper"  wx:if="{{activity.length}}">
         <view class="line1 acea-row">
           <text decode="{{true}}" space="{{true}}">活&nbsp;&nbsp;&nbsp;动:</text>
@@ -176,9 +176,12 @@
       <form wx:else>
         <button class='buy bnts bg-color-hui'>已售罄</button>
       </form>
+      <form bindsubmit="listenerActionSheet">
+        <button class='share bnts' formType="submit">分享</button>
+      </form>
     </view>
   </view>
-  <shareRedPackets sharePacket="{{sharePacket}}" bind:listenerActionSheet="listenerActionSheet"></shareRedPackets>
+  <!-- <shareRedPackets sharePacket="{{sharePacket}}" bind:listenerActionSheet="listenerActionSheet"></shareRedPackets> -->
 </view>
 <!-- 分享按钮 -->
 <action-sheet hidden="{{actionSheetHidden}}" bindchange="listenerActionSheet" class='pro-wrapper' hover-class='none'>
@@ -207,4 +210,4 @@
 <authorize bind:onLoadFun="onLoadFun" isAuto="{{isAuto}}" iShidden="{{iShidden}}"></authorize>
 <!-- html转wxml -->
 <import src="/wxParse/wxParse.wxml" />
-<home></home>
+<!-- <home></home> -->

+ 2 - 1
view/xcx/pages/goods_details/index.wxss

@@ -16,9 +16,10 @@
 .product-con .footer .item .iconfont.icon-gouwuche1 .num{color:#fff;position:absolute;font-size:18rpx;
 padding:2rpx 8rpx 3rpx;border-radius:200rpx;top:-10rpx;right:-10rpx;}
 .product-con .footer .bnt{width:444rpx;height:76rpx;}
-.product-con .footer .bnt .bnts{width:222rpx;text-align:center;line-height:76rpx;color:#fff;font-size:28rpx;}
+.product-con .footer .bnt .bnts{width:142rpx;text-align:center;line-height:76rpx;color:#fff;font-size:25rpx;}
 .product-con .footer .bnt .joinCart{border-radius:50rpx 0 0 50rpx;background-image: linear-gradient(to right,#fea10f 0%,#fa8013 100%);}
 .product-con .footer .bnt .buy{border-radius:0 50rpx 50rpx 0;background-image: linear-gradient(to right,#fa6514 0%,#e93323 100%);}
+.product-con .footer .bnt .share{border-radius:50rpx 50rpx 50rpx 50rpx;background-image: linear-gradient(to right,#fa6514 0%,#e93323 100%); margin-left: 6rpx;}
 .product-con .store-info {margin-top:20rpx;background-color: #fff;}
 .product-con .store-info .title {font-size: 28rpx;color: #282828;
   height: 80rpx;line-height: 80rpx;}

+ 31 - 1
view/xcx/pages/index/index.js

@@ -82,7 +82,8 @@ Page({
     interval:null,
     newGoodsBananr: '',
     liveList: [],
-    liveInfo: {}
+    liveInfo: {},
+    activities: {}
   },
   closeTip:function(){
     wx.setStorageSync('msg_key',true);
@@ -126,6 +127,11 @@ Page({
   },
   onColse:function(){
     this.setData({ window: false});
+
+    console.log(this.data.activities);
+    this.data.activities.forEach(item => {
+      item.tabOut();
+    });
   },
   /**
    * 生命周期函数--监听页面初次渲染完成
@@ -144,6 +150,11 @@ Page({
     // this.getCoupon();
     this.getIndexConfig();
     // this.getSeckillTime();
+
+    var activity = this.data.activities[this.data.tapActive];
+    if(activity) {
+      activity.tabIn();
+    }
   },
   getIndexConfig:function(){
     var that = this;
@@ -244,6 +255,21 @@ Page({
       })
       that.get_product_list(true);
     }
+
+    let mine = that.selectComponent('#mine');
+    if(event.detail.title === "黑洞矿场"){
+      if(mine && that.data.activities[tapActive] == null) {
+        var activities = {};
+        activities[tapActive] = mine;
+        that.setData({
+          activities: activities
+        });
+      }
+
+       mine.tabIn();
+    } else {
+      mine.tabOut();
+    }
   },
   productTap: function (e) {
     let that = this,index = e.currentTarget.dataset.indexn;
@@ -389,6 +415,10 @@ Page({
   onHide: function () {
     this.setData({ window:false});
     this.data.interval !== null && clearInterval(this.data.interval);
+
+    for(var item in this.data.activities){
+      this.data.activities[item].tabOut();
+    };
   },
   /**
    * 生命周期函数--监听页面卸载

+ 1 - 1
view/xcx/pages/index/index.wxml

@@ -373,7 +373,7 @@
         </view>
       </Tab>
       <Tab wx:for="{{categoryOne}}" title="{{item.cate_name}}" wx:key='index'>
-        <view wx:if="{{item.cate_name === '黑洞矿场'}}"><Mine></Mine></view>
+        <view wx:if="{{item.cate_name === '黑洞矿场'}}"><Mine id="mine"></Mine></view>
         <view wx:else class="wrapper">
           <image wx:if="{{item.pic !== ''}}" src="{{item.pic}}" style="width: 100%"></image>
           <view class="scroll acea-row row-middle">

+ 69 - 11
view/xcx/pages/message/index.js

@@ -1,6 +1,8 @@
 // pages/message/index.js
 
-import { getNotifications } from "../../api/api"
+import { getProductHot } from '../../api/store.js';
+import { getMessages } from "../../api/message"
+import { SplitArray } from "../../utils/util"
 
 const app = getApp();
 
@@ -15,60 +17,105 @@ Page({
       'navbar': '1',
       'return': '1',
       'color': false,
-    }
+    },
+    host_product:[],
+    iShidden: false,
+    page: 0,
+    messages: []
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    wx.showTabBarRedDot({
+    wx.setTabBarBadge({
       index: 2,
+      text: '9'
     });
-    console.log("load")
+    console.log("load");
+    if (app.globalData.token) this.setData({ iShidden:true});
   },
 
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {
-    console.log("ready");
+  },
+
+  onLoadFun: function() {
+    this.get_host_product();
+    this.refreshNotifications();
   },
 
   /**
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-    console.log("show");
-    // getNotifications()
+    if (app.globalData.isLog) {
+      this.data.page = 1;
+      this.get_host_product();
+      this.pullMessageList();
+      this.setData({
+        iShidden: true
+      });
+    }
+  },
+
+  refreshNotifications: function() {
+    var that = this;
+    getNotifications().then(res=>{
+      console.log(res);
+    }, err=> {
+      console.log(err);
+      // that.setData({
+      //   messages: [ 1 ]
+      // });
+    });
   },
 
+  /**
+   * 获取我的推荐
+  */
+ get_host_product:function(){
+  var that=this;
+  getProductHot().then(res=>{
+    that.setData({ host_product: res.data });
+  })
+},
+
   /**
    * 生命周期函数--监听页面隐藏
    */
   onHide: function () {
-    console.log("hide")
   },
 
   /**
    * 生命周期函数--监听页面卸载
    */
   onUnload: function () {
-    console.log("unload")
+    console.log("unload");
   },
 
   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function () {
-
+    setTimeout(function() {
+      wx.stopPullDownRefresh({
+        success: (res) => {
+          console.log("success stop")
+        },
+      });
+    }, 300);
   },
 
   /**
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
-
+    console.log("load more");
+    this.data.page ++;
+    this.pullMessageList();
   },
 
   /**
@@ -76,5 +123,16 @@ Page({
    */
   onShareAppMessage: function () {
 
+  },
+
+  pullMessageList() {
+    var that = this;
+    getMessages(that.data.page).then(res=>{
+      that.setData({
+        messages: SplitArray(that.data.messages, res.messages)
+      });
+    }, err=> {
+
+    });
   }
 })

+ 4 - 1
view/xcx/pages/message/index.json

@@ -1,5 +1,8 @@
 {
+  "enablePullDownRefresh": true,
   "usingComponents": {
-    "navbar": "/components/navbar/index"
+    "navbar": "/components/navbar/index",
+    "recommend": "/components/recommend/index",
+    "authorize": "/components/authorize/authorize"
   }
 }

+ 13 - 2
view/xcx/pages/message/index.wxml

@@ -1,4 +1,15 @@
 <navbar parameter='{{parameter}}'></navbar>
 <view class="message">
-我的消息列表
-</view>
+  <view wx:if="{{messages.length == 0}}" class="noMessage" style="flex-direction:column;">
+    <view class="picture">
+      <image src="/images/noMessage.png" mode="heightFix"></image>
+    </view>
+    <recommend host_product="{{host_product}}"></recommend>
+  </view>
+  <view class="list" wx:else>
+    <view class="item" wx:for="{{messages}}" wx:key="index">
+      {{ item }}
+    </view>
+  </view>
+</view>
+<authorize bind:onLoadFun='onLoadFun' iShidden="{{iShidden}}"></authorize>

+ 6 - 2
view/xcx/pages/message/index.wxss

@@ -1,2 +1,6 @@
-.message { text-align: center; }
-.message .item .bg { background-color: red;}
+.message { text-align: center; align-self: start; }
+.message .noMessage { background-color: #fff; }
+.message .noMessage .picture {width:414rpx; height:336rpx; margin:20rpx auto; }
+.message .noMessage .picture image{width:100%;height:100%; }
+.message .list { margin: auto; }
+.message .list .item { background-color: red; height: 168rpx; margin-bottom: 12rpx; }

+ 73 - 0
view/xcx/pages/mine_rule/index.js

@@ -0,0 +1,73 @@
+// pages/mine_rule/index.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    parameter: {
+      'navbar': '1',
+      'return': '1',
+      'title': '活动规则',
+      'color': true,
+      'class':'0'
+    },
+    html: "<p style='color: red;text-align: center'>html text<p>"
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 5 - 0
view/xcx/pages/mine_rule/index.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "navbar": "/components/navbar/index"
+  }
+}

+ 4 - 0
view/xcx/pages/mine_rule/index.wxml

@@ -0,0 +1,4 @@
+<navbar parameter='{{parameter}}'></navbar>
+<view>
+  <rich-text nodes="{{html}}"></rich-text>
+</view>

+ 1 - 0
view/xcx/pages/mine_rule/index.wxss

@@ -0,0 +1 @@
+/* pages/mine_rule/index.wxss */

+ 5 - 1
view/xcx/pages/user_money/index.js

@@ -18,6 +18,7 @@ Page({
       'title': '我的账户',
       'color': false,
     },
+    iShidden: false,
     userInfo:{},
     host_product:[],
     isClose:false,
@@ -36,7 +37,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    if (app.globalData.token) this.setData({ iShidden:true});
   },
 
   openSubscribe:function(e){
@@ -93,6 +94,9 @@ Page({
       this.getUserInfo();
       this.get_host_product();
       this.get_activity();
+      this.setData({
+        iShidden: true
+      });
     }
   },
 

+ 1 - 1
view/xcx/pages/user_money/index.wxml

@@ -94,4 +94,4 @@
    </view>
    <recommend host_product="{{host_product}}"></recommend>
 </view>
-<authorize bind:onLoadFun='onLoadFun'></authorize>
+<authorize bind:onLoadFun='onLoadFun' iShidden="{{iShidden}}"></authorize>