activity.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <view class="container activity-content">
  3. <view class="top-content-box">
  4. <search-bar @goSearch="goSearch" :searchTitle="searchPlaceholderList.SummarySearch" :width="52">
  5. <template slot="content-left">
  6. <view class="content">
  7. <view class="activity-back" @click="activityPlayBack" v-if="isUserBindingPhoneNumber">
  8. <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/new_cygx/at_back.png"></image>
  9. 回放
  10. </view>
  11. </view>
  12. </template>
  13. </search-bar>
  14. <view class="screen-item">
  15. <text v-if="isUserBindingPhoneNumber" :class="isShowJurisdiction ? 'active' : ''" @click="permissioActivity">有权限行业</text>
  16. <!-- 各种状态选择 -->
  17. <view class="select-conyent" ref="select-conyent">
  18. <van-dropdown-menu active-color="#333333">
  19. <van-dropdown-item id="industry" :title="chartPermissionName">
  20. <view class="menu-items">
  21. <view class="menu-items-box" v-for="item in listChartPermission" :key="item.ChartPermissionId" @click="overallClick(item)">
  22. <view class="items-box">
  23. <u-icon v-if="item.IsChoose" name="checkbox-mark" :color="isShowJurisdiction ? '#ccc' : '#376cbb'" size="24"></u-icon>
  24. </view>
  25. <text>{{ item.PermissionName }}</text>
  26. </view>
  27. </view>
  28. <view class="replacement">
  29. <text @click="replacementBtn" class="replacement-box">重置</text>
  30. <text @click="replacementConfirm">确定</text>
  31. </view>
  32. </van-dropdown-item>
  33. </van-dropdown-menu>
  34. </view>
  35. <text v-for="item in activityTimeList" :key="item.Id" :class="item.IsChoose ? 'active' : ''" @click="isActivityDate(item.Id)">{{ item.StatusName }}</text>
  36. </view>
  37. </view>
  38. <!-- 筛选状态 -->
  39. <!-- 活动列表 -->
  40. <block>
  41. <view class="collect-activity" v-if="haveData">
  42. <activityTypeList
  43. :dataList="collectTypeList"
  44. :chartPermissionIds="chartPermissionIds"
  45. :isShowJurisdiction="isShowJurisdiction"
  46. :whichDay="whichDay"
  47. containerStyle="padding: 34rpx;display: flex;"
  48. />
  49. <view class="end-activity-text" v-if="collectTypeList.length" @click="endActivity">已结束活动 >></view>
  50. </view>
  51. <view class="nodata" v-if="!haveData">
  52. <image src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/act_search.png" mode="" class="nodata_ico"></image>
  53. <text>暂时没有符合条件的活动</text>
  54. </view>
  55. <freeCharge class="free-charge" :isShowFreeBtn="isShowFree" />
  56. </block>
  57. <!-- <not-have-login v-else /> -->
  58. <Loading />
  59. </view>
  60. </template>
  61. <script>
  62. import { activity } from "@/config/api.js";
  63. import { Throttle } from "@/config/util.js";
  64. import SearchBar from "@/components/search-bar/searchBar.vue";
  65. import activityTypeList from "./components/activityTypeList.vue";
  66. import freeCharge from "@/components/freeCharge";
  67. import NotHaveLogin from "../../components/notHaveLogin.vue";
  68. let app = getApp();
  69. export default {
  70. components: {
  71. freeCharge,
  72. SearchBar,
  73. NotHaveLogin,
  74. activityTypeList,
  75. },
  76. data() {
  77. return {
  78. whichDay: "",
  79. activityTypeId: "",
  80. chartPermissionIds: "",
  81. chartPermissionName: "全行业",
  82. isGetJurisdiction: 0,
  83. isrefresh: true,
  84. isShowJurisdiction: false, //
  85. haveData: true,
  86. listChartPermission: [],
  87. listChartPermissionInit: [],
  88. collectTypeList: [],
  89. activityTimeList: [
  90. { Id: 1, IsChoose: false, StatusName: "今日活动" },
  91. { Id: 2, IsChoose: false, StatusName: "明日活动" },
  92. ],
  93. };
  94. },
  95. computed: {
  96. messageTitle() {
  97. // 计算分享时候的title
  98. let arr = this.whichDay ? this.whichDay.split(",") : [];
  99. let whichData = arr.length == 2 ? "今日活动,明日活动" : arr == "1" ? "今日活动" : arr == "2" ? "明日活动" : "";
  100. let title = whichData ? whichData + "," + this.chartPermissionName : this.chartPermissionName !== "全行业" ? this.chartPermissionName : "";
  101. return title || "近期全行业活动预告";
  102. },
  103. },
  104. methods: {
  105. // 获取权限、所有的行业
  106. async getUserSearchContent() {
  107. // IsHideResearch 行业列表是否隐藏 买方研选
  108. const res = await activity.getUserSearchContent({
  109. IsShowJurisdiction: this.isGetJurisdiction,
  110. IsHideResearch: false,
  111. });
  112. if (res.Ret === 200) {
  113. this.isShowJurisdiction = res.Data.IsShowJurisdiction;
  114. this.listChartPermission = res.Data.ListChartPermission;
  115. this.listChartPermissionInit = res.Data.ListChartPermission2;
  116. this.clickPermission();
  117. if (this.chartPermissionIds) {
  118. this.closeTheWindow();
  119. }
  120. }
  121. },
  122. // 获取列表数据
  123. async getActivityLabelTypeList() {
  124. const res = await activity.getActivityLabelTypeList({
  125. ChartPermissionIds: this.chartPermissionIds,
  126. IsShowJurisdiction: this.isGetJurisdiction,
  127. ActiveState: "1",
  128. WhichDay: this.whichDay,
  129. IsPower: this.isGetJurisdiction,
  130. });
  131. if (res.Ret === 200) {
  132. this.collectTypeList = res.Data.List || [];
  133. this.haveData = this.collectTypeList.length ? true : false;
  134. if (this.refresh) {
  135. uni.stopPullDownRefresh();
  136. this.refresh = false;
  137. }
  138. }
  139. },
  140. // 下拉的选择的关闭事件
  141. closeTheWindow() {
  142. const types = this.chartPermissionIds ? this.chartPermissionIds.split(",").map(Number) : [];
  143. if (types.length > 0) {
  144. const str = [];
  145. this.listChartPermission.forEach((item) => {
  146. if (types.includes(item.ChartPermissionId)) {
  147. item.IsChoose = true;
  148. str.push(item.PermissionName);
  149. } else {
  150. item.IsChoose = false;
  151. }
  152. });
  153. this.chartPermissionName = str.length == 6 ? "全行业" : str.join(",");
  154. }
  155. },
  156. // 下拉的选择的选中事件
  157. overallClick(item) {
  158. if (this.isShowJurisdiction) return;
  159. this.listChartPermission.forEach((key) => {
  160. if (key.ChartPermissionId == item.ChartPermissionId) {
  161. key.IsChoose = !key.IsChoose;
  162. }
  163. });
  164. },
  165. // 下拉的选择的重置事件
  166. replacementBtn() {
  167. this.listChartPermission = this.listChartPermissionInit;
  168. this.chartPermissionIds = "";
  169. this.isShowJurisdiction = false;
  170. this.listChartPermission.map((item) => (item.IsChoose = false));
  171. this.chartPermissionName = "全行业";
  172. this.getActivityLabelTypeList();
  173. },
  174. // 下拉选择的确定事件
  175. replacementConfirm() {
  176. const arr = [];
  177. const str = [];
  178. this.listChartPermission &&
  179. this.listChartPermission.forEach((key) => {
  180. if (key.IsChoose) {
  181. arr.push(key.ChartPermissionId);
  182. str.push(key.PermissionName);
  183. }
  184. });
  185. if (str.length == this.listChartPermission.length || str.length <= 0) {
  186. this.chartPermissionName = "全行业";
  187. } else {
  188. this.chartPermissionName = str.join(",");
  189. }
  190. this.chartPermissionIds = arr.join(",");
  191. this.getActivityLabelTypeList();
  192. this.selectComponent("#industry").toggle(false);
  193. },
  194. // 今日明日的点击事件
  195. isActivityDate(id) {
  196. this.selectComponent("#industry").toggle(false);
  197. this.activityTimeList.forEach((item) => {
  198. if (item.Id == id) item.IsChoose = !item.IsChoose;
  199. });
  200. const arr = [];
  201. this.activityTimeList.forEach((item) => item.IsChoose && arr.push(item.Id));
  202. this.whichDay = arr.join(",");
  203. this.getActivityLabelTypeList();
  204. },
  205. // 是否有权限的点击事件
  206. async permissioActivity() {
  207. if (!this.$store.state.isAuth && !this.$store.state.isBind) {
  208. this.selectComponent("#industry").toggle(false);
  209. this.isShowJurisdiction = !this.isShowJurisdiction;
  210. this.isGetJurisdiction = this.isShowJurisdiction ? 1 : 2;
  211. await this.getUserSearchContent();
  212. this.selectComponent("#industry").toggle(false);
  213. if (this.isShowJurisdiction) {
  214. this.getActivityLabelTypeList();
  215. } else {
  216. this.replacementBtn();
  217. }
  218. } else {
  219. //已授权未绑定
  220. this.$store.dispatch("checkHandle");
  221. }
  222. },
  223. // 点击后有权限的
  224. clickPermission() {
  225. if (this.isShowJurisdiction) {
  226. const arr = [];
  227. this.listChartPermission &&
  228. this.listChartPermission.forEach((key) => {
  229. if (key.IsChoose) {
  230. arr.push(key.ChartPermissionId);
  231. }
  232. });
  233. this.chartPermissionIds = arr.join(",");
  234. }
  235. },
  236. // 进入页面 判断是否是分享的
  237. loadShare(option) {
  238. if (option && Object.keys(option).length !== 0) {
  239. this.whichDay = option.whichDay || "";
  240. this.chartPermissionIds = option.chartPermissionIds || "";
  241. this.isGetJurisdiction = option.isGetJurisdiction;
  242. this.$nextTick(() => {
  243. let day = this.whichDay ? this.whichDay.split(",").map(Number) : [];
  244. this.activityTimeList.forEach((item) => {
  245. if (day.includes(item.Id)) {
  246. item.IsChoose = true;
  247. }
  248. });
  249. });
  250. }
  251. },
  252. //去往搜索事件
  253. goSearch() {
  254. uni.navigateTo({ url: "/pages-search/indedxSearch/indedxSearch?source=活动页面" });
  255. },
  256. //去往 活动回放activityPlayBack
  257. async activityPlayBack() {
  258. // await this.$store.dispatch("showLoginModal");
  259. uni.navigateTo({ url: "/activityPages/playBack/playBack" });
  260. },
  261. // 跳转已结束活动
  262. endActivity() {
  263. uni.navigateTo({
  264. url: "/activityPages/endActivity/endActivity",
  265. });
  266. },
  267. },
  268. //load
  269. onLoad(option) {
  270. this.loadShare(option);
  271. this.getUserSearchContent();
  272. this.getActivityLabelTypeList();
  273. },
  274. onShow() {
  275. this.$store.commit("setRouterReport", "活动");
  276. this.$store.commit("setRouterActivity", "活动");
  277. this.getRecordTracking("活动");
  278. },
  279. /** 用户点击分享 */
  280. onShareAppMessage: function (res) {
  281. return {
  282. title: this.isHorzMobile ? "好友向您推荐此内容,上传名片享查研观向免费月卡!" : this.messageTitle,
  283. path: "/pages/activity/activity?whichDay=" + this.whichDay + "&chartPermissionIds=" + this.chartPermissionIds + "&isGetJurisdiction=" + this.isGetJurisdiction,
  284. };
  285. },
  286. /* 下拉刷新 */
  287. onPullDownRefresh: Throttle(function () {
  288. this.refresh = true;
  289. this.page_no = 1;
  290. this.getActivityLabelTypeList();
  291. }),
  292. // 页面滚动事件
  293. onPageScroll() {},
  294. };
  295. </script>
  296. <style scoped lang="scss">
  297. .activity-content {
  298. background-color: $uni-bg-color;
  299. padding-bottom: 90rpx;
  300. position: relative;
  301. .top-content-box {
  302. position: sticky;
  303. top: 0;
  304. left: 0;
  305. width: 100%;
  306. z-index: 99;
  307. background-color: #fff;
  308. /deep/ .nav-bar-wrap {
  309. .content {
  310. height: 100%;
  311. display: flex;
  312. align-items: center;
  313. padding-left: 30rpx;
  314. margin-right: 20rpx;
  315. .activity-back {
  316. display: flex;
  317. flex-shrink: 0;
  318. align-items: center;
  319. color: $uni-color-new;
  320. font-size: 30rpx;
  321. image {
  322. width: 40rpx;
  323. height: 40rpx;
  324. }
  325. }
  326. }
  327. }
  328. }
  329. .screen-item {
  330. height: 100rpx;
  331. padding: 0 34rpx;
  332. font-size: 24rpx;
  333. color: #333;
  334. display: flex;
  335. justify-content: space-between;
  336. align-items: center;
  337. text {
  338. width: 150rpx;
  339. text-align: center;
  340. line-height: 51rpx;
  341. background-color: #f8f8fa;
  342. box-sizing: border-box;
  343. border-radius: 26rpx;
  344. }
  345. .active {
  346. background-color: $uni-color-new;
  347. color: #fff;
  348. }
  349. }
  350. .select-conyent {
  351. .decide {
  352. background-color: #f8f8fa;
  353. display: flex;
  354. align-items: center;
  355. margin: 0 auto;
  356. height: 110rpx;
  357. width: 100%;
  358. padding-left: 30rpx;
  359. }
  360. .items-box {
  361. width: 40rpx;
  362. }
  363. .menu-items {
  364. background-color: #f8f8fa;
  365. width: 100%;
  366. display: flex;
  367. flex-wrap: wrap;
  368. padding: 30rpx 30rpx 0;
  369. .menu-items-box {
  370. display: flex;
  371. width: 50%;
  372. font-size: 28rpx;
  373. font-weight: 400;
  374. margin-bottom: 40rpx;
  375. }
  376. text {
  377. text-align: left;
  378. }
  379. }
  380. .replacement {
  381. margin: 0rpx 30rpx 20rpx;
  382. display: flex;
  383. background-color: $uni-color-new;
  384. height: 60rpx;
  385. font-size: 28rpx;
  386. font-weight: 400;
  387. color: #ffffff;
  388. border-radius: 30rpx;
  389. box-sizing: border-box;
  390. text {
  391. flex: 1;
  392. line-height: 58rpx;
  393. background-color: $uni-color-new;
  394. }
  395. .replacement-box {
  396. border: 1rpx solid $uni-color-new;
  397. color: $uni-color-new;
  398. background: #ffffff;
  399. border-radius: 28rpx 0rpx 28rpx 28rpx;
  400. }
  401. }
  402. }
  403. .nodata_ico {
  404. width: 374rpx;
  405. height: 288rpx;
  406. }
  407. .end-activity-text {
  408. display: flex;
  409. justify-content: center;
  410. margin-top: 60rpx;
  411. color: $uni-color-new;
  412. }
  413. /deep/.not-have-login {
  414. padding-top: 200rpx !important;
  415. }
  416. }
  417. /deep/.van-dropdown-menu {
  418. background-color: #fff;
  419. box-shadow: none !important;
  420. align-items: center !important;
  421. }
  422. /deep/.van-dropdown-menu__item {
  423. box-sizing: border-box;
  424. width: 160rpx;
  425. padding-right: 20rpx;
  426. height: 51rpx;
  427. border-radius: 26rpx;
  428. background: #f8f8fa;
  429. }
  430. /deep/.van-dropdown-item {
  431. margin-top: -10rpx;
  432. }
  433. /deep/[data-index="2"] {
  434. margin-right: 0rpx;
  435. }
  436. /deep/ .van-ellipsis {
  437. font-size: 24rpx;
  438. }
  439. @import "@/components/activity/indexActivity.scss";
  440. </style>