index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <div class="app-body-white">
  3. <div class="flex-between-center broadcast-head">
  4. <div class="flex-between-center head-search">
  5. <input
  6. @click="showResult = true"
  7. type="text"
  8. v-model="type"
  9. class="head-search-select"
  10. placeholder="请选择"
  11. readonly
  12. />
  13. <input
  14. v-model="search.activityName"
  15. placeholder="请输入关键词"
  16. type="text"
  17. class="head-search-keyword"
  18. @input="titleChange"
  19. />
  20. </div>
  21. <div class="broadcast-head-add">
  22. <van-button
  23. icon="plus"
  24. color="#3b7aff"
  25. size="small"
  26. @click="goNavigator()"
  27. >新增</van-button
  28. >
  29. </div>
  30. </div>
  31. <van-pull-refresh
  32. v-model="isDownLoading"
  33. @refresh="onDownRefresh"
  34. v-show="listData.length !== 0"
  35. >
  36. <van-list
  37. v-model="isUpLoading"
  38. :error.sync="error"
  39. :finished="upFinished"
  40. :immediate-check="false"
  41. :offset="10"
  42. finished-text="加载完成"
  43. @load="onLoadList"
  44. >
  45. <ul class="admin-exposure-list" v-if="listData.length > 0">
  46. <li class="box-shadow-gray" v-for="item in listData">
  47. <img
  48. :src="item.annexUrl"
  49. alt=""
  50. @click="goNavigator(item.id, 'view')"
  51. />
  52. <div class="exposure-main">
  53. <div class="exposure-name">{{ item.activityName }}</div>
  54. <div class="flex-between-center notice-edit-mesg">
  55. <div class="activities-text">
  56. <span>{{ item.registrationNumbers }}人报名</span>
  57. {{ item.signInNumber }}人签到
  58. </div>
  59. <div class="notice-edit-button" style="padding-top: 0">
  60. <van-button
  61. v-if="item.releaseStatus !== '1'"
  62. color="#1989fa"
  63. size="mini"
  64. plain
  65. round
  66. @click.stop="goNavigator(item.id, '')"
  67. >编辑</van-button
  68. >
  69. <van-button
  70. v-if="item.releaseStatus !== '1'"
  71. color="#1989fa"
  72. size="mini"
  73. round
  74. @click.stop="handleRecruitment(item.id, '1')"
  75. >上架</van-button
  76. >
  77. <van-button
  78. v-if="item.releaseStatus === '1'"
  79. color="#1989fa"
  80. size="mini"
  81. round
  82. @click.stop="handleRecruitment(item.id, '2')"
  83. >下架</van-button
  84. >
  85. </div>
  86. </div>
  87. </div>
  88. <div class="notice-edit-label">
  89. <div v-if="item.releaseStatus === '1'" class="label-style">
  90. 已发布
  91. </div>
  92. <div
  93. v-if="item.releaseStatus === '0'"
  94. class="label-style disable"
  95. >
  96. 未发布
  97. </div>
  98. <div
  99. v-if="item.releaseStatus === '2'"
  100. class="label-style disable"
  101. >
  102. 已下架
  103. </div>
  104. </div>
  105. </li>
  106. </ul>
  107. </van-list>
  108. </van-pull-refresh>
  109. <van-popup :show="showResult" position="bottom" class="popup-box">
  110. <van-picker
  111. show-toolbar
  112. title="请选择"
  113. :columns="columns"
  114. value-key="label"
  115. @cancel="showResult = false"
  116. @confirm="onConfirm"
  117. @change="onChange"
  118. />
  119. </van-popup>
  120. </div>
  121. </template>
  122. <script>
  123. import {
  124. editHomeCommunityActivity,
  125. listHomeCommunityActivity,
  126. } from "@/js_sdk/api_community";
  127. // import { Toast } from "vant";
  128. import { getByCodes, getUserLocalStorageInfo } from "@/js_sdk/http";
  129. import common from "../../utils/common.js";
  130. // import auth from "@/service/auth";
  131. export default {
  132. data() {
  133. return {
  134. dc_key: ["release_status", "activity_type"],
  135. registrantChange: "",
  136. listData: [],
  137. columns: [],
  138. type: "",
  139. showResult: false,
  140. search: {
  141. createdBy: getUserLocalStorageInfo().user.id,
  142. pageNum: 1,
  143. pageSize: 10,
  144. },
  145. dic_SelectList: {},
  146. // 上拉加载
  147. pageSize: 30,
  148. pageIndex: 1,
  149. isDownLoading: false,
  150. isUpLoading: false,
  151. upFinished: false,
  152. offset: 100,
  153. };
  154. },
  155. // mixins: [Base],
  156. onLoad() {
  157. this.getDictData(this.dc_key);
  158. },
  159. methods: {
  160. goNavigator(id = "", type = "") {
  161. uni.navigateTo({
  162. url: "/pages/subPackages/eventRelease/add?id=" + id + "&type=" + type,
  163. });
  164. },
  165. getData() {
  166. try {
  167. const _this = this;
  168. _this.search.pageNum = _this.pageIndex;
  169. _this.search.pageSize = _this.pageSize;
  170. listHomeCommunityActivity(_this.search)
  171. .then((res) => {
  172. const partList = res.data.rows || [];
  173. partList.forEach((item) => {
  174. console.log("aaaaaaaaa", item);
  175. console.log("JSON.parse(annex)", JSON.parse(item.annex)[0]);
  176. // const annex = JSON.parse(item.annex);
  177. if (item.annex && item.annex.length != 0) {
  178. // const annex = _this.$common.castEval(item.annex);
  179. item.annexUrl = JSON.parse(item.annex)[0].url;
  180. }
  181. item.releaseTimeStr = common.transServDate(item.releaseTime);
  182. });
  183. console.log("partList == null", partList);
  184. if (partList == null || partList.length == 0) {
  185. _this.upFinished = true;
  186. return;
  187. }
  188. console.log("_this.pageIndex", _this.pageIndex);
  189. if (partList.length < _this.pageSize) {
  190. _this.upFinished = true;
  191. }
  192. if (partList.length == res.data.total) {
  193. _this.upFinished = true;
  194. }
  195. if (_this.pageIndex == 1) {
  196. _this.listData = partList;
  197. } else {
  198. _this.listData = [..._this.listData, ...partList];
  199. }
  200. })
  201. .catch((error) => {})
  202. .finally(() => {
  203. _this.isDownLoading = false;
  204. _this.isUpLoading = false;
  205. });
  206. } catch (error) {
  207. console.log(error);
  208. }
  209. },
  210. titleChange() {
  211. const _this = this;
  212. _this.listData = [];
  213. _this.pageIndex = 1;
  214. _this.isDownLoading = false;
  215. _this.isUpLoading = false;
  216. _this.upFinished = false;
  217. this.getData();
  218. },
  219. videoDetails(val, edit) {
  220. this.$router.push({
  221. path: "/admin/activities/add",
  222. query: {
  223. id: val.id,
  224. },
  225. });
  226. },
  227. handleRecruitment(id, status) {
  228. const pos = {
  229. id: id,
  230. releaseStatus: status,
  231. };
  232. editHomeCommunityActivity(pos)
  233. .then((res) => {
  234. this.listData = [];
  235. this.getData();
  236. if (status == "1") {
  237. this.$showToast("发布成功");
  238. } else {
  239. this.$showToast("下架成功");
  240. }
  241. })
  242. .catch(() => {
  243. if (status == "1") {
  244. this.$showToast("发布失败");
  245. } else {
  246. this.$showToast("下架失败");
  247. }
  248. });
  249. },
  250. // 上拉加载
  251. onDownRefresh() {
  252. const _this = this;
  253. _this.pageIndex = 1;
  254. _this.listData = [];
  255. _this.upFinished = false;
  256. _this.getData();
  257. },
  258. onLoadList() {
  259. const _this = this;
  260. _this.pageIndex++;
  261. _this.isUpLoading = true;
  262. _this.getData();
  263. },
  264. getDictData(codes) {
  265. const _this = this;
  266. getByCodes(JSON.stringify(this.dc_key)).then((data) => {
  267. if (data) {
  268. this.dic_SelectList = common.handleDicList(data);
  269. const dat = [
  270. {
  271. values: [
  272. {
  273. id: 1,
  274. label: "发布状态",
  275. className: "column2",
  276. // children: _this.dic_SelectList.release_status,
  277. },
  278. {
  279. id: 2,
  280. label: "活动类型",
  281. className: "column2",
  282. // children: _this.dic_SelectList.release_status,
  283. },
  284. ],
  285. className: "column1",
  286. // children: _this.dic_SelectList.release_status,
  287. },
  288. {
  289. values: _this.dic_SelectList.release_status,
  290. className: "column2",
  291. // children: _this.dic_SelectList.release_status,
  292. },
  293. ];
  294. _this.columns = dat;
  295. _this.getData();
  296. }
  297. });
  298. },
  299. onChange(event) {
  300. let _this = this;
  301. console.log(event);
  302. const { picker, value, index } = event.detail;
  303. console.log("value", value);
  304. if (value[0].label == "发布状态") {
  305. picker.setColumnValues(1, _this.dic_SelectList.release_status);
  306. } else {
  307. picker.setColumnValues(1, _this.dic_SelectList.activity_type);
  308. }
  309. // picker.setColumnValues(1, citys[value[0]]);
  310. },
  311. // onConfirm: function(val) {
  312. // this.type = val.text
  313. // if (val.text == '待核实') {
  314. // this.seachFrom.status = 1
  315. // } else {
  316. // this.seachFrom.status = 0
  317. // }
  318. // this.onDownRefresh()
  319. // this.showResult = false
  320. // },
  321. onConfirm: function (event) {
  322. console.log(event);
  323. const { picker, value, index } = event.detail;
  324. this.listData = [];
  325. console.log(value);
  326. if (value[0].label == "发布状态") {
  327. this.search.releaseStatus = value[1].value;
  328. this.search.activityType = "";
  329. } else if (value[0].label == "活动类型") {
  330. this.search.activityType = value[1].value;
  331. this.search.releaseStatus = "";
  332. }
  333. this.type = value[1].label;
  334. this.showResult = false;
  335. this.getData();
  336. },
  337. },
  338. };
  339. </script>
  340. <style lang="scss" scoped>
  341. </style>
  342. <style>
  343. .flex-between-center {
  344. display: flex;
  345. justify-content: space-between;
  346. align-items: center;
  347. /*俩端居中*/
  348. }
  349. .broadcast-head {
  350. padding: 0.5rem 0.8rem 0 0.8rem;
  351. }
  352. .head-search {
  353. width: calc(100% - 4.4rem);
  354. }
  355. .app-body-white {
  356. background-color: #fff;
  357. height: 100%;
  358. overflow-y: auto;
  359. border-top: 1px solid transparent;
  360. border-bottom: 1px solid transparent;
  361. font-size: 28px;
  362. }
  363. .app-body-white .van-uploader__upload {
  364. background: #f3f7ff;
  365. }
  366. .app-body-white .tab-card-box {
  367. padding: 4vw;
  368. }
  369. .broadcast-head-add .van-button {
  370. border-radius: 0.8vw;
  371. font-size: 3.467vw;
  372. font-weight: 500;
  373. }
  374. .broadcast-head-add .van-button__icon {
  375. font-size: 0.8rem;
  376. }
  377. .head-search input.head-search-select,
  378. .head-search input.head-search-keyword {
  379. border-radius: 0.8vw;
  380. border: 1px solid #3b7aff;
  381. /* box-sizing: border-box; */
  382. font-size: 3.2vw;
  383. }
  384. input.head-search-select {
  385. padding: 5rpx;
  386. /* background: transparent url("../image/down-icon.png") no-repeat */
  387. /* calc(100% - 0.5rem) center; */
  388. background-size: auto 24%;
  389. }
  390. input.head-search-keyword {
  391. padding: 5rpx;
  392. }
  393. .head-search input.head-search-select {
  394. width: 6.5rem;
  395. }
  396. .head-search input.head-search-keyword {
  397. width: calc(100% - 6.8rem);
  398. }
  399. .admin-exposure-list {
  400. margin: 1.5rem 0.8rem;
  401. }
  402. .admin-exposure-list li {
  403. margin-bottom: 1.5rem;
  404. border-radius: 0.5rem;
  405. position: relative;
  406. padding: 0.8rem;
  407. }
  408. .admin-exposure-list .exposure-main {
  409. padding: 0.5rem 0;
  410. }
  411. .exposure-name {
  412. font-size: 32rpx;
  413. font-weight: bold;
  414. }
  415. .activities-text {
  416. font-size: 28rpx;
  417. color: #999;
  418. }
  419. .activities-text span {
  420. color: #1989fa;
  421. }
  422. .notice-edit-label {
  423. position: absolute;
  424. left: 0;
  425. top: -1.707vw;
  426. top: -0.8rem;
  427. }
  428. .label-style {
  429. font-size: 3.2vw;
  430. font-weight: 500;
  431. color: #fff;
  432. background: #3b7aff;
  433. border-radius: 0.8rem 0 0.8rem 0;
  434. width: 10.667vw;
  435. width: 5rem;
  436. text-align: center;
  437. line-height: 2;
  438. }
  439. .admin-exposure-list {
  440. margin: 1.5rem 0.8rem;
  441. }
  442. .admin-exposure-list li {
  443. margin-bottom: 1.5rem;
  444. border-radius: 0.5rem;
  445. position: relative;
  446. padding: 0.8rem;
  447. }
  448. .admin-exposure-list .exposure-main {
  449. padding: 0.5rem 0;
  450. }
  451. .admin-exposure-list li {
  452. margin-bottom: 1.5rem;
  453. border-radius: 0.5rem;
  454. position: relative;
  455. box-shadow: 0 0 0.3rem rgba(0, 0, 0, 0.15);
  456. padding: 0.8rem;
  457. }
  458. </style>