From e5364b725e4bb39a3de2bad02ca9f5e4423fce87 Mon Sep 17 00:00:00 2001 From: "JIANWEIE-WORKPC\\Administrator" Date: Wed, 1 Mar 2023 16:22:06 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=A7=81?= =?UTF-8?q?=E5=9F=9F=E7=9B=B4=E6=92=AD=E5=8A=9F=E8=83=BD=E3=80=82=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=90=8E=E5=8F=B0=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SystemSettingConstVars.cs | 6 + .../SystemSettingDictionary.cs | 5 + .../CoreShop/common/request/http.api.js | 8 +- CoreCms.Net.Uni-App/CoreShop/pages.json | 19 ++ .../CoreShop/pages/index/member/member.vue | 8 + .../pages/livebroadcast/index/index.vue | 165 ++++++++++++++++++ .../Controllers/LiveBroadCastController.cs | 71 ++++++++ 7 files changed, 281 insertions(+), 1 deletion(-) create mode 100644 CoreCms.Net.Uni-App/CoreShop/pages/livebroadcast/index/index.vue create mode 100644 CoreCms.Net.Web.WebApi/Controllers/LiveBroadCastController.cs diff --git a/CoreCms.Net.Configuration/SystemSettingConstVars.cs b/CoreCms.Net.Configuration/SystemSettingConstVars.cs index fa4f80e0..2beebdf1 100644 --- a/CoreCms.Net.Configuration/SystemSettingConstVars.cs +++ b/CoreCms.Net.Configuration/SystemSettingConstVars.cs @@ -889,6 +889,12 @@ namespace CoreCms.Net.Configuration public static readonly string ContinuousCheckInPeriodType = "continuousCheckInPeriodType"; + /// + /// 显示直播入口 + /// + public static readonly string ShowLiveBroadCast = "showLiveBroadCast"; + + } } \ No newline at end of file diff --git a/CoreCms.Net.Configuration/SystemSettingDictionary.cs b/CoreCms.Net.Configuration/SystemSettingDictionary.cs index 2ce86472..6c18139d 100644 --- a/CoreCms.Net.Configuration/SystemSettingDictionary.cs +++ b/CoreCms.Net.Configuration/SystemSettingDictionary.cs @@ -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; } diff --git a/CoreCms.Net.Uni-App/CoreShop/common/request/http.api.js b/CoreCms.Net.Uni-App/CoreShop/common/request/http.api.js index f7186b31..558a9a85 100644 --- a/CoreCms.Net.Uni-App/CoreShop/common/request/http.api.js +++ b/CoreCms.Net.Uni-App/CoreShop/common/request/http.api.js @@ -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 }; } diff --git a/CoreCms.Net.Uni-App/CoreShop/pages.json b/CoreCms.Net.Uni-App/CoreShop/pages.json index 78eb5461..8ccbf2a7 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages.json +++ b/CoreCms.Net.Uni-App/CoreShop/pages.json @@ -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", diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/index/member/member.vue b/CoreCms.Net.Uni-App/CoreShop/pages/index/member/member.vue index a3d0ead0..128d4eb2 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/index/member/member.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/index/member/member.vue @@ -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; //获取用户信息 diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/livebroadcast/index/index.vue b/CoreCms.Net.Uni-App/CoreShop/pages/livebroadcast/index/index.vue new file mode 100644 index 00000000..f84a5c0e --- /dev/null +++ b/CoreCms.Net.Uni-App/CoreShop/pages/livebroadcast/index/index.vue @@ -0,0 +1,165 @@ + + + + + diff --git a/CoreCms.Net.Web.WebApi/Controllers/LiveBroadCastController.cs b/CoreCms.Net.Web.WebApi/Controllers/LiveBroadCastController.cs new file mode 100644 index 00000000..545782fe --- /dev/null +++ b/CoreCms.Net.Web.WebApi/Controllers/LiveBroadCastController.cs @@ -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 +{ + /// + /// 小程序内置直播功能 + /// + [Route("api/[controller]/[action]")] + [ApiController] + public class LiveBroadCastController : ControllerBase + { + private readonly IWeChatApiHttpClientFactory _weChatApiHttpClientFactory; + + /// + /// 构造函数 + /// + /// + public LiveBroadCastController(IWeChatApiHttpClientFactory weChatApiHttpClientFactory) + { + _weChatApiHttpClientFactory = weChatApiHttpClientFactory; + } + + + #region 获取直播间列表和回放 + /// + /// 获取直播间列表和回放 + /// + /// + [HttpPost] + public async Task 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 + + + + + } +}