Commit daf2d4418b20051f257376241392c4dc1a0d8f1d

Authored by yvan.ni
1 parent 67ee3d41

直播间的分享

packageA/pages/live_share/live_share.js
1 // packageA//pages/goods_share/goods_share.js 1 // packageA//pages/goods_share/goods_share.js
  2 +var app=getApp(),oo = app.globalData.setting,os=oo,ut = require("../../../utils/util.js");
2 Page({ 3 Page({
3 4
4 /** 5 /**
5 * 页面的初始数据 6 * 页面的初始数据
6 */ 7 */
7 - data: {  
8 - // tab  
9 - tab: ['秒杀','拼单','促销','专享礼包'],  
10 - currentIndex: 0, 8 + data: {
11 //促销页tab 9 //促销页tab
12 tab2: ['正在直播','即将开始','精彩回放'], 10 tab2: ['正在直播','即将开始','精彩回放'],
13 currentIndex2: 0, 11 currentIndex2: 0,
14 - //秒杀和拼单底部tab  
15 - currentIndex3: 0,  
16 - // 控制价格  
17 - active1: false,  
18 - // 控制佣金  
19 - active2: false,  
20 //popup 12 //popup
21 hiddenPopup: true, 13 hiddenPopup: true,
  14 +
  15 + list:[],
  16 + is_load:0, //是否正在加载
  17 + is_no_data:0, //没有数据
  18 + is_no_more:0, //没有更多数据
  19 + key_str:'',
  20 + pattern:0, //分成的方式
  21 + currentPage:1, //当前的页码
  22 +
  23 + share_hidden:1, //-- 分享的按钮隐藏 --
22 }, 24 },
23 25
24 /** 26 /**
25 * 生命周期函数--监听页面加载 27 * 生命周期函数--监听页面加载
26 */ 28 */
27 onLoad: function (options) { 29 onLoad: function (options) {
  30 + var th=this;
  31 + //接受有没有导购的参数
  32 + var first_leader=options.first_leader;
  33 + if(first_leader){
  34 + //-- user_id代过来免登陆 --
  35 + getApp().globalData.user_id=first_leader;
  36 + getApp().getUserFir();
  37 + }
  38 + this.requestGoodsList();
28 39
29 }, 40 },
30 -  
31 - /**  
32 - * 生命周期函数--监听页面初次渲染完成  
33 - */  
34 - onReady: function () {  
35 -  
36 - },  
37 -  
38 /** 41 /**
39 * 生命周期函数--监听页面显示 42 * 生命周期函数--监听页面显示
40 */ 43 */
@@ -50,13 +53,6 @@ Page({ @@ -50,13 +53,6 @@ Page({
50 }, 53 },
51 54
52 /** 55 /**
53 - * 生命周期函数--监听页面卸载  
54 - */  
55 - onUnload: function () {  
56 -  
57 - },  
58 -  
59 - /**  
60 * 页面相关事件处理函数--监听用户下拉动作 56 * 页面相关事件处理函数--监听用户下拉动作
61 */ 57 */
62 // onPullDownRefresh: function () { 58 // onPullDownRefresh: function () {
@@ -74,50 +70,36 @@ Page({ @@ -74,50 +70,36 @@ Page({
74 * 用户点击右上角分享 70 * 用户点击右上角分享
75 */ 71 */
76 onShareAppMessage: function () { 72 onShareAppMessage: function () {
77 - 73 + var th=this;
  74 + var id=th.data.hui_active.id;
  75 + var url='/packageA/pages/liveStreamDetails/liveStreamDetails?id=' + id + '&live=ing';
  76 + if(getApp().globalData.user_id){
  77 + url+="&first_leader="+getApp().globalData.user_id;
  78 + }
  79 + var title=th.data.hui_active.name;
  80 + var img=th.data.hui_active.share_img;
  81 + var ob={
  82 + title:title,
  83 + path:url,
  84 + imageUrl: img,
  85 + };
  86 + th.setData({share_hidden:1});
  87 + return ob;
78 }, 88 },
79 -  
80 - // 点击价格排序  
81 - sort1() {  
82 - if(this.data.active2) {  
83 - this.setData({  
84 - active2: !this.data.active2  
85 - });  
86 - };  
87 - this.setData({  
88 - active1: !this.data.active1  
89 - });  
90 89
91 - },  
92 - // 点击佣金排序  
93 - sort2() {  
94 - if(this.data.active1) { 90 +
  91 + // 点击tab
  92 + clickTab2(e) {
  93 + if(this.data.currentIndex2!=e.target.dataset.index){
95 this.setData({ 94 this.setData({
96 - active1: !this.data.active1 95 + currentIndex2: e.target.dataset.index,is_no_data:0,is_no_more:0,list:[],
97 }); 96 });
98 - };  
99 - this.setData({  
100 - active2: !this.data.active2  
101 - });  
102 - },  
103 - // 点击tab  
104 - clickTab(e) {  
105 - this.setData({  
106 - currentIndex: e.target.dataset.index,  
107 - });  
108 - },  
109 - // 点击促销页tab  
110 - clickTab2(e) {  
111 - this.setData({  
112 - currentIndex2: e.target.dataset.index,  
113 - });  
114 - },  
115 - // 点击秒杀和拼单底部tab  
116 - clickTab3(e) {  
117 - this.setData({  
118 - currentIndex3: e.target.dataset.index,  
119 - }); 97 + this.data.is_load=0;
  98 + this.data.currentPage=1;
  99 + this.requestGoodsList();
  100 + }
120 }, 101 },
  102 +
121 // 关闭弹出层 103 // 关闭弹出层
122 closePopup() { 104 closePopup() {
123 this.setData({ 105 this.setData({
@@ -130,4 +112,75 @@ Page({ @@ -130,4 +112,75 @@ Page({
130 hiddenPopup: false 112 hiddenPopup: false
131 }); 113 });
132 }, 114 },
  115 +
  116 + requestGoodsList:function(){
  117 + var th=this;
  118 + if(th.data.is_load) return false; //-- 正在加载
  119 + if(th.data.is_no_data) return false; //-- 没有数据
  120 + if(th.data.is_no_more) return false; //-- 没有更多
  121 + th.data.is_load=1;
  122 +
  123 + var url="/api/weshop/wx/livelist/page";
  124 + var req_data={
  125 + page:this.data.currentPage,
  126 + store_id:oo.stoid,
  127 + }
  128 + switch(th.data.currentIndex2){
  129 + case 0:
  130 + req_data.live_status=101;
  131 + break;
  132 + case 1:
  133 + req_data.live_status=102;
  134 + break;
  135 + case 2:
  136 + req_data.live_status=103;
  137 + break;
  138 + }
  139 + if(this.data.key_str && this.data.key_str.trim()){
  140 + var str=this.data.key_str.trim();
  141 + req_data.key_str=str;
  142 + }
  143 + //-- ---调用接口----
  144 + app.request.promiseGet(url,{data:req_data,isShowLoading:1}).then(res=>{
  145 + th.data.is_load=0;
  146 + if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){
  147 + th.data.currentPage++;
  148 + var data=res.data.data.pageData;
  149 + if(res.data.data.page*10>res.data.data.total){th.setData({is_no_more:1});}
  150 + var list=th.data.list;
  151 + list=list.concat(data);
  152 + th.setData({list:list});
  153 + }else{
  154 + if(th.data.currentPage==1){
  155 + th.setData({is_no_data:1});
  156 + }
  157 + }
  158 + })
  159 + },
  160 +
  161 + //---点击分享优惠活动---
  162 + share_index:function(e){
  163 +
  164 + //--先判断会员状态--
  165 + var user_info = getApp().globalData.userInfo;
  166 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  167 + //getApp().my_warnning("请先登录",0,this);
  168 + wx.navigateTo({ url: '/pages/togoin/togoin', })
  169 + return false;
  170 + }
  171 +
  172 + var index=e.currentTarget.dataset.index;
  173 + var item=this.data.list[index];
  174 + this.setData({share_hidden:0,hui_active:item});
  175 +
  176 + var com = this.selectComponent("#share_button"); //组件的id
  177 + com.set_type(1);
  178 + },
  179 + //-- ---更多加载----
  180 + refresh:function(){
  181 + this.requestGoodsList();
  182 + },
  183 +
  184 +
  185 +
133 }) 186 })
134 \ No newline at end of file 187 \ No newline at end of file
packageA/pages/live_share/live_share.json
1 { 1 {
  2 + "navigationBarTitleText": "直播间分享",
2 "usingComponents": { 3 "usingComponents": {
3 - "nodata": "/components/nodata/nodata" 4 + "nodata": "/components/nodata/nodata",
  5 + "share_button": "/components/share/share"
4 }, 6 },
5 "enablePullDownRefresh": false 7 "enablePullDownRefresh": false
6 } 8 }
7 \ No newline at end of file 9 \ No newline at end of file
packageA/pages/live_share/live_share.wxml
  1 +<wxs src="../../../utils/filter.wxs" module="filter"></wxs>
1 <view class="container"> 2 <view class="container">
2 <!-- 列表 --> 3 <!-- 列表 -->
3 <view class="list-container"> 4 <view class="list-container">
@@ -11,27 +12,31 @@ @@ -11,27 +12,31 @@
11 <scroll-view 12 <scroll-view
12 class="list" 13 class="list"
13 scroll-y="true" 14 scroll-y="true"
  15 + bindscrolltolower="refresh"
14 scroll-anchoring 16 scroll-anchoring
15 - refresher-enabled>  
16 -  
17 - <!-- 暂无数据 -->  
18 - <nodata nodataContainer="nodata">暂无数据</nodata>  
19 - 17 + refresher-enabled>
20 <!-- 专享礼包 --> 18 <!-- 专享礼包 -->
21 - <block> 19 + <block wx:for="{{list}}">
22 <view class class="list-item"> 20 <view class class="list-item">
23 - <view class="img-container {{currentIndex2 == 0?'live':currentIndex2 == 1?'coming':'playback'}}"></view> 21 + <view class="img-container {{currentIndex2 == 0?'live':currentIndex2 == 1?'coming':'playback'}}">
  22 + <image src="{{item.cover_img}}" style="width: 100%; height: 100%;"
  23 + binderror="bind_bnerr2" lazy-load="true"
  24 + data-errorimg="list[{{index}}].share_img"></image>
  25 + </view>
24 <view class="details"> 26 <view class="details">
25 - <view class="ellipsis-2 fs28 name">商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称</view>  
26 - <view class="pdt20 fs26 red">直播时间:2020-12-31 18:00</view>  
27 - <view class="fs26 red pdv10">主播:何大大</view>  
28 - <view class="t-r fs28 pdt10"><view class="btn-share">分享</view></view> 27 + <view class="ellipsis-2 fs28 name">{{item.name}}</view>
  28 + <view class="pdt20 fs26 red">直播时间:{{filter.format_time(item.start_time, 2)}} </view>
  29 + <view class="fs26 red pdv10">主播:{{item['anchor_name']}}</view>
  30 + <view bindtap="share_index" data-index="{{index}}" class="t-r fs28 pdt10"><view class="btn-share">分享</view></view>
29 </view> 31 </view>
30 </view> 32 </view>
31 - </block>  
32 -  
33 - <view class="no-more t-c">- 已全部加载 -</view> 33 + </block>
  34 + <!-- 暂无数据 -->
  35 + <nodata wx:if="{{list.length==0}}" nodataContainer="nodata">暂无数据</nodata>
  36 + <view wx:if="{{is_no_more}}" class="no-more t-c">- 已全部加载 -</view>
34 </scroll-view> 37 </scroll-view>
35 </view> 38 </view>
36 </view> 39 </view>
  40 +<!-- 分享控件,底部弹出 -->
  41 +<share_button id="share_button" bind:cancel="cancel" bind:share_img="saveImageToPhotosAlbum" wx:if="{{!share_hidden}}"></share_button>
37 42
packageA/pages/live_share/live_share.wxss
@@ -111,12 +111,7 @@ page { @@ -111,12 +111,7 @@ page {
111 justify-content: center; 111 justify-content: center;
112 position: relative; 112 position: relative;
113 } 113 }
114 -.img-container:after {  
115 - font-family: iconfont;  
116 - content: '\e8c1';  
117 - color: #bbb;  
118 - font-size: 80rpx;  
119 -} 114 +.img-container:after {}
120 115
121 116
122 .img-container.live:before { 117 .img-container.live:before {