mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 16:03:25 +08:00
【新增】增加微信小程序私域直播功能。增加后台开关
This commit is contained in:
@@ -889,6 +889,12 @@ namespace CoreCms.Net.Configuration
|
||||
public static readonly string ContinuousCheckInPeriodType = "continuousCheckInPeriodType";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 显示直播入口
|
||||
/// </summary>
|
||||
public static readonly string ShowLiveBroadCast = "showLiveBroadCast";
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -256,6 +256,11 @@ namespace CoreCms.Net.Configuration
|
||||
di.Add(SystemSettingConstVars.CheckInCommonType, new DictionaryKeyValues() { sKey = "签到赠送类型", sValue = GlobalEnumVars.CheckInCommonType.积分.ToString() });
|
||||
di.Add(SystemSettingConstVars.ContinuousCheckInPeriodType, new DictionaryKeyValues() { sKey = "连续签到周期", sValue = GlobalEnumVars.ContinuousCheckInPeriodType.不限.ToString() });
|
||||
|
||||
//小程序直播
|
||||
di.Add(SystemSettingConstVars.ShowLiveBroadCast, new DictionaryKeyValues() { sKey = "显示小程序直播入口", sValue = "2" });
|
||||
|
||||
|
||||
|
||||
return di;
|
||||
}
|
||||
|
||||
|
||||
@@ -405,6 +405,10 @@ const install = (Vue, vm) => {
|
||||
let getSolitaireDetail = (params, config = {}) => http.post('/Api/Solitaire/GetDetail', params, { custom: { methodName: 'solitaire.getDetail', needToken: false } });
|
||||
|
||||
|
||||
//直播
|
||||
let getLiveInfo = (params, config = {}) => http.post('/Api/LiveBroadCast/GetLiveInfo', params, { custom: { methodName: 'liveBroadCast.getLiveInfo', needToken: false } });
|
||||
|
||||
|
||||
// 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下
|
||||
vm.$u.api = {
|
||||
shopConfigV2,
|
||||
@@ -596,7 +600,9 @@ const install = (Vue, vm) => {
|
||||
serviceVerificationTicket,
|
||||
|
||||
getSolitairePageList,
|
||||
getSolitaireDetail
|
||||
getSolitaireDetail,
|
||||
|
||||
getLiveInfo
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -51,6 +51,25 @@
|
||||
}
|
||||
],
|
||||
"subpackages": [
|
||||
{
|
||||
"root": "pages/livebroadcast",
|
||||
"name": "livebroadcast",
|
||||
"pages": [
|
||||
{
|
||||
"path": "index/index",
|
||||
"style": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "直播间"
|
||||
}
|
||||
}
|
||||
],
|
||||
"plugins": {
|
||||
"live-player-plugin": {
|
||||
"version": "1.3.5", // 注意该直播组件最新版本号
|
||||
"provider": "wx2b03c6e691cd7370" // 必须填该直播组件appid,不是小程序的appid
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"root": "pages/article",
|
||||
"name": "article",
|
||||
|
||||
@@ -367,6 +367,12 @@
|
||||
router: '/pages/form/list/list',
|
||||
showItem: false
|
||||
},
|
||||
livebroadcast: {
|
||||
name: '直播',
|
||||
icon: 'play-circle',
|
||||
router: '/pages/livebroadcast/index/index',
|
||||
showItem: false
|
||||
},
|
||||
},
|
||||
other: {
|
||||
invite: {
|
||||
@@ -510,6 +516,8 @@
|
||||
_this.vas.calendar.showItem = _this.config.showCalendar == 1;
|
||||
//自定义表单
|
||||
_this.vas.customForm.showItem = _this.config.showCustomForm == 1;
|
||||
//是否显示直播
|
||||
_this.vas.livebroadcast.showItem = _this.config.showLiveBroadCast == 1;
|
||||
//显示我的发票
|
||||
_this.utilityMenus.myInvoice.showItem = _this.config.invoiceSwitch == 1;
|
||||
//获取用户信息
|
||||
|
||||
165
CoreCms.Net.Uni-App/CoreShop/pages/livebroadcast/index/index.vue
Normal file
165
CoreCms.Net.Uni-App/CoreShop/pages/livebroadcast/index/index.vue
Normal file
@@ -0,0 +1,165 @@
|
||||
<template>
|
||||
<view>
|
||||
<u-toast ref="uToast" /><u-no-network></u-no-network>
|
||||
<u-navbar title="直播间" safeAreaInsetTop fixed placeholder>
|
||||
<view class="coreshop-navbar-left-slot" slot="left">
|
||||
<u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
|
||||
<u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
|
||||
<u-icon name="home" size="22" @click="goHome"></u-icon>
|
||||
</view>
|
||||
<view slot="right">
|
||||
</view>
|
||||
</u-navbar>
|
||||
|
||||
<view class="coreshop-margin-top-10" v-if="list.length > 0">
|
||||
<view class="coreshop-bg-white coreshop-border-radius-9 coreshop-margin-10" v-for="item in list" :key="item.roomid" @click="goRoom(item.roomid)">
|
||||
<view class="coreshop-flex coreshop-position-relative coreshop-border-radius-9" >
|
||||
<view style="border-top-right-radius: 10px; border-top-left-radius: 10px ">
|
||||
<u--image :src="item.share_img" mode="widthFix" width="716rpx" height="170px" ></u--image>
|
||||
</view>
|
||||
<view class="coreshop-position-absolute" v-if="item.live_status==101">
|
||||
<u-tag text="直播中" size="mini" type="success"></u-tag>
|
||||
</view>
|
||||
<view class="coreshop-position-absolute" v-if="item.live_status==102">
|
||||
<u-tag text="未开始" size="mini"></u-tag>
|
||||
</view>
|
||||
<view class="coreshop-position-absolute" v-if="item.live_status==103">
|
||||
<u-tag text="已结束" size="mini" type="warning"></u-tag>
|
||||
</view>
|
||||
<view class="coreshop-position-absolute" v-if="item.live_status==104">
|
||||
<u-tag text="禁播" size="mini" type="warning"></u-tag>
|
||||
</view>
|
||||
<view class="coreshop-position-absolute" v-if="item.live_status==105">
|
||||
<u-tag text="暂停" size="mini" type="error"></u-tag>
|
||||
</view>
|
||||
<view class="coreshop-position-absolute" v-if="item.live_status==106">
|
||||
<u-tag text="异常" size="mini" type="error"></u-tag>
|
||||
</view>
|
||||
<view class="coreshop-position-absolute" v-if="item.live_status==107">
|
||||
<u-tag text="已过期" size="mini" type="error"></u-tag>
|
||||
</view>
|
||||
<view class="coreshop-position-absolute coreshop-padding-8" style="bottom: 0rpx; ">
|
||||
<view class="coreshop-font-14 coreshop-text-white">{{ item.name }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="coreshop-flex coreshop-flex-wrap coreshop-justify-start coreshop-font-sm coreshop-flex-direction-row coreshop-align-center coreshop-padding-top-10 coreshop-padding-left-8 coreshop-padding-right-8 coreshop-padding-bottom-5">
|
||||
<view class="coreshop-font-14 coreshop-text-black">
|
||||
主播:
|
||||
</view>
|
||||
<view class="coreshop-font-14 coreshop-text-black">{{ item.anchor_name }}</view>
|
||||
<view class="coreshop-font-12 coreshop-text-black coreshop-padding-left-4 coreshop-padding-right-4 "> | </view>
|
||||
<view class="coreshop-font-12 coreshop-text-black">直播商品:{{ item.goods.length }}件</view>
|
||||
</view>
|
||||
<view class="coreshop-flex coreshop-flex-wrap coreshop-font-sm coreshop-flex-direction-row coreshop-font-12 coreshop-padding-left-8 coreshop-padding-right-8 coreshop-padding-bottom-8 coreshop-text-grey">
|
||||
直播时间:{{$u.timeFormat(item.start_time, 'yyyy-mm-dd hh:MM:ss')}} 至 {{$u.timeFormat(item.end_time, 'yyyy-mm-dd hh:MM:ss')}}
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" margin-top="0" margin-bottom="20" class="coreshop-padding-top-10" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 无数据时默认显示 -->
|
||||
<view class="coreshop-emptybox" v-else>
|
||||
<u-empty :icon="$globalConstVars.apiFilesUrl+'/static/images/empty/data.png'" icon-size="150" text="当前列表为空" mode="list"></u-empty>
|
||||
</view>
|
||||
|
||||
<!-- 登录提示 -->
|
||||
<coreshop-login-modal></coreshop-login-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
page: 1,
|
||||
limit: 10,
|
||||
list: [],
|
||||
status: 'loadmore',
|
||||
iconType: 'flower',
|
||||
loadText: {
|
||||
loadmore: '轻轻上拉',
|
||||
loading: '努力加载中',
|
||||
nomore: '实在没有了'
|
||||
},
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.getList();
|
||||
console.log(this.userInfo);
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.status === 'loadmore') {
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
hasLogin: state => state.hasLogin,
|
||||
userInfo: state => state.userInfo,
|
||||
}),
|
||||
hasLogin: {
|
||||
get() {
|
||||
return this.$store.state.hasLogin;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit('hasLogin', val);
|
||||
}
|
||||
},
|
||||
userInfo: {
|
||||
get() {
|
||||
return this.$store.state.userInfo;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit('userInfo', val);
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getList() {
|
||||
let data = {
|
||||
page: this.page,
|
||||
limit: this.limit,
|
||||
};
|
||||
this.status = 'loading';
|
||||
this.$u.api.getLiveInfo(data).then(res => {
|
||||
if (res.status) {
|
||||
const _list = res.data.room_info;
|
||||
this.list = [...this.list, ..._list];
|
||||
if (res.data.total > this.list.length) {
|
||||
this.status = 'loadmore';
|
||||
this.page++;
|
||||
} else {
|
||||
// 数据已加载完毕
|
||||
this.status = 'nomore';
|
||||
}
|
||||
} else {
|
||||
// 接口请求出错了
|
||||
this.$u.toast(res.msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
goRoom(roomid) {
|
||||
console.log(roomid);
|
||||
if (!this.hasLogin) {
|
||||
uni.hideLoading();
|
||||
this.$store.commit('showLoginTip', true);
|
||||
return false;
|
||||
} else {
|
||||
let customParams = encodeURIComponent(JSON.stringify({ path: 'pages/livebroadcast/index/index', userId: this.userInfo.id })) // 开发者在直播间页面路径上携带自定义参数(如示例中的 path 和pid参数)
|
||||
console.log(customParams);
|
||||
wx.navigateTo({
|
||||
url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${roomid}&custom_params=${customParams}`
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
@@ -0,0 +1,71 @@
|
||||
using CoreCms.Net.Caching.AccressToken;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.WeChat.Service.HttpClients;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api.Models;
|
||||
using System.Threading.Tasks;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api;
|
||||
|
||||
namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 小程序内置直播功能
|
||||
/// </summary>
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class LiveBroadCastController : ControllerBase
|
||||
{
|
||||
private readonly IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="weChatApiHttpClientFactory"></param>
|
||||
public LiveBroadCastController(IWeChatApiHttpClientFactory weChatApiHttpClientFactory)
|
||||
{
|
||||
_weChatApiHttpClientFactory = weChatApiHttpClientFactory;
|
||||
}
|
||||
|
||||
|
||||
#region 获取直播间列表和回放
|
||||
/// <summary>
|
||||
/// 获取直播间列表和回放
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<WebApiCallBack> GetLiveInfo([FromBody] FMPageByIntId entity)
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
|
||||
var request = new WxaBusinessGetLiveInfoRequest
|
||||
{
|
||||
AccessToken = accessToken,
|
||||
Limit = entity.limit,
|
||||
};
|
||||
|
||||
var response = await client.ExecuteWxaBusinessGetLiveInfoAsync(request);
|
||||
if (response.IsSuccessful())
|
||||
{
|
||||
jm.status = true;
|
||||
jm.data = response;
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.status = false;
|
||||
jm.msg = response.ErrorCode == 9410000 ? "直播间列表为空" : response.ErrorMessage;
|
||||
jm.otherData = response;
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user