xq-csg-weapp_uni-ts
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

496 lines
12KB

  1. <template>
  2. <view>
  3. <custom-nav-bar :left-text="options.name" left-arrow />
  4. <image class="custom-swiper-img" mode="aspectFill"
  5. :src="InfoObj.image ? InfoObj.image : '/static/packages/people/images/icon10.png'"></image>
  6. <view class="area" v-if="options.type === '1' || options.type === '2'">
  7. <view class="tabs-list flex flex-center">
  8. <view :class="'tabs-item ' + (index === ruralActive ? 'tabs-active' : '')" :data-index="index" @tap="tabsSwitch"
  9. v-for="(item, index) in ruralTabs" :key="index">
  10. {{ item.name }}
  11. </view>
  12. </view>
  13. <view class="area-list flex" v-if="ruralActive">
  14. <view class="area-item" :data-item="item" @tap="toArea" v-for="(item, index) in deptList" :key="index">
  15. {{ item.name }}
  16. </view>
  17. </view>
  18. <view class="rich" v-else>
  19. <rich-text :nodes="InfoObj.content"></rich-text>
  20. </view>
  21. </view>
  22. <view class="page-content" v-if="options.type === '3'">
  23. <view class="title flex">
  24. <text class="title-name">村务公开详情</text>
  25. </view>
  26. <view class="cell-list" v-if="villageAffairsPageList.length">
  27. <view class="cell" :data-item="item" @tap="headleDetails" v-for="(item, index) in villageAffairsPageList"
  28. :key="index">
  29. <view class="cell-left flex flex-v-center flex1">{{ item.title }}</view>
  30. <view class="cell-right">
  31. <view class="cell-right-number"></view>
  32. <view class="arrow">
  33. <van-icon name="arrow" color="#e1e1e1" size="32rpx" />
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <view v-else>
  39. <van-empty description="暂无数据" />
  40. </view>
  41. </view>
  42. <view class="party" v-if="options.type === '12101'">
  43. <view class="rich">
  44. <rich-text :nodes="InfoObj.content"></rich-text>
  45. </view>
  46. <view class="tabs-list flex flex-center">
  47. <view :class="'tabs-item ' + (index === ruralActive ? 'tabs-active' : '')" :data-index="index" @tap="tabsSwitch"
  48. v-for="(item, index) in ruralTabs" :key="index">
  49. {{ item.name }}
  50. </view>
  51. </view>
  52. <view class="party-list flex flex-col" v-if="ruralActive">
  53. <view class="section-item flex flex-between" :data-item="item" @tap="headleDetails"
  54. v-for="(item, index) in partyEventPageList" :key="index" >
  55. <image class="section-item-right" :src="item.image" mode="aspectFill"></image>
  56. <view class="section-item-left flex1 flex flex-col">
  57. <view class="consult-content-title text-line-2">{{ item.title }}</view>
  58. <view class="consult-content-block">{{ item.createTime }}</view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="rich2" v-else>
  63. <rich-text v-if="partyEventPageList.length !== 0" :nodes="partyEventPageList[0].content"></rich-text>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <!-- <script module="util" lang="wxs" src="@/wxs/util.wxs"></script> -->
  69. <script>
  70. // const app = getApp();
  71. // const { peopleApi } = app.globalData.api;
  72. import * as peopleApi from '@/api/peopleApi';
  73. export default {
  74. components: {},
  75. data() {
  76. return {
  77. options: {
  78. name: '',
  79. type: ''
  80. },
  81. InfoObj: {
  82. image: false,
  83. content: ''
  84. },
  85. // 富文本渲染
  86. ruralActive: 0,
  87. // tabs下标
  88. ruralTabs: [],
  89. deptList: [],
  90. villageAffairsPageList: [],
  91. partyEventPageList: [],
  92. content: ''
  93. };
  94. },
  95. /**
  96. * 生命周期函数--监听页面加载
  97. */
  98. onLoad(options) {
  99. console.log('options', options);
  100. this.options = options
  101. if (options.type === '1' || options.type === '2') {
  102. const typeTbas = {
  103. 1: [{
  104. name: '乡镇农业产业'
  105. },
  106. {
  107. name: '村列表'
  108. }
  109. ],
  110. 2: [{
  111. name: '街道简介'
  112. },
  113. {
  114. name: '社区列表'
  115. }
  116. ]
  117. };
  118. this.ruralTabs = typeTbas[Number(options.type)] || []
  119. this.tabsSwitch();
  120. }
  121. if (options.type === '3') {
  122. this.villageAffairsPageApi();
  123. this.getVillageAffairsGetApi();
  124. }
  125. if (options.type === '12101') {
  126. this.ruralTabs = [{
  127. name: '优秀事迹'
  128. },
  129. {
  130. name: '党建活动'
  131. }
  132. ]
  133. this.partyBranchGetApi();
  134. this.tabsSwitch();
  135. }
  136. },
  137. methods: {
  138. // 切换tabs
  139. tabsSwitch(event) {
  140. if (event) {
  141. const {
  142. index
  143. } = event.currentTarget.dataset;
  144. this.ruralActive = index || 0
  145. }
  146. if (['1', '2'].includes(this.options.type)) {
  147. if (this.ruralActive) {
  148. this.deptListApi();
  149. } else {
  150. this.agencyContentGetApi();
  151. }
  152. }
  153. if (['12101'].includes(this.options.type)) {
  154. if (this.ruralActive) {
  155. this.partyEventPageApi(2);
  156. } else {
  157. this.partyEventPageApi(1);
  158. }
  159. }
  160. },
  161. // 获取简介
  162. // TODO:10月13日之前读的是 agencyContentGetOrgIdApi 这个接口
  163. async agencyContentGetApi() {
  164. const res = await peopleApi.agencyGetApi({
  165. id: this.options.id,
  166. orgId: this.options.orgId
  167. });
  168. this.InfoObj = this.generalFunction(res)
  169. },
  170. // 获取党支部详情
  171. async partyBranchGetApi() {
  172. const res = await peopleApi.partyBranchGetApi({
  173. id: this.options.id
  174. });
  175. res.data.title = res.data.name || '';
  176. res.data.content = res.data.descInfo || '';
  177. this.InfoObj = this.generalFunction(res)
  178. },
  179. // 获取村务公开详情
  180. async getVillageAffairsGetApi() {
  181. const res = await peopleApi.agencyGetApi({
  182. id: this.options.id
  183. });
  184. res.data.title = res.data.name || '';
  185. res.data.content = res.data.descInfo || '';
  186. this.InfoObj = this.generalFunction(res)
  187. },
  188. // 获取列表
  189. async deptListApi() {
  190. const res = await peopleApi.deptListApi({
  191. parentId: this.options.orgId
  192. });
  193. this.deptList = res.data
  194. },
  195. // 获取村务公开详情列表
  196. async villageAffairsPageApi() {
  197. const params = {
  198. pageNo: 1,
  199. pageSize: 99,
  200. agencyId: this.options.id
  201. };
  202. const res = await peopleApi.villageAffairsPageApi(params);
  203. if (res.data) {
  204. const {
  205. list = []
  206. } = res.data;
  207. this.villageAffairsPageList = list
  208. }
  209. },
  210. // 获得党活动事件分页
  211. async partyEventPageApi(eventType) {
  212. const params = {
  213. pageNo: 1,
  214. pageSize: 99,
  215. eventType,
  216. // 字典
  217. partyBranchId: this.options.id
  218. };
  219. const res = await peopleApi.partyEventPageApi(params);
  220. if (res.data) {
  221. let list = res.data.list
  222. if (eventType === 1) {
  223. let setList = list.map((item) => {
  224. const e = item;
  225. // e.createTime = app.globalData.util.timeFormat(e.createTime);
  226. e.content = e.content
  227. .replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block" ')
  228. .replace(/&lt;/g, '<')
  229. .replace(/&gt;/g, '>')
  230. .replace(/&amp;nbsp;/g, ' ')
  231. .replace(/&quot;/g, '"');
  232. return e;
  233. });
  234. console.log(setList)
  235. this.partyEventPageList = setList
  236. return;
  237. }
  238. this.partyEventPageList = list
  239. }
  240. },
  241. // 通用函数
  242. generalFunction(res) {
  243. if (res.data && res.data.createTime) {
  244. // res.data.createTime = app.globalData.util.timeFormat(res.data.createTime);
  245. if (res.data.introduce) {
  246. res.data.content = res.data.introduce;
  247. }
  248. if (res.data.content) {
  249. res.data.content = res.data.content
  250. .replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block" ')
  251. .replace(/&lt;/g, '<')
  252. .replace(/&gt;/g, '>')
  253. .replace(/&amp;nbsp;/g, ' ')
  254. .replace(/&quot;/g, '"');
  255. }
  256. return res.data;
  257. }
  258. return {};
  259. },
  260. toArea(event) {
  261. const {
  262. item
  263. } = event.currentTarget.dataset;
  264. uni.navigateTo({
  265. url: `/packages/people/pages/area-detail/area-detail?orgId=${item.id}&name=${item.name}`
  266. });
  267. },
  268. headleDetails(event) {
  269. const {
  270. item
  271. } = event.currentTarget.dataset;
  272. uni.navigateTo({
  273. url: `/packages/public/pages/details/details-no-ops?name=村务公开详情&referId=${item.id}`
  274. });
  275. }
  276. }
  277. };
  278. </script>
  279. <style lang="less">
  280. .custom-swiper-img {
  281. width: 100%;
  282. height: 400rpx;
  283. display: block;
  284. }
  285. .rich {
  286. padding: 45rpx;
  287. font-size: 30rpx;
  288. font-weight: 400;
  289. color: #222222;
  290. line-height: 60rpx;
  291. }
  292. .tabs-list {
  293. .tabs-item {
  294. font-size: 32rpx;
  295. font-weight: 500;
  296. color: #000000;
  297. line-height: 32rpx;
  298. position: relative;
  299. &:not(:last-child) {
  300. margin-right: 55rpx;
  301. }
  302. }
  303. .tabs-active {
  304. color: #f5001c;
  305. &::after {
  306. content: '';
  307. position: absolute;
  308. left: 4rpx;
  309. bottom: 0;
  310. z-index: -1;
  311. // width: 175rpx;
  312. width: 95%;
  313. height: 10rpx;
  314. background: var(--title-guides-color);
  315. border-radius: 2rpx;
  316. }
  317. }
  318. }
  319. .area {
  320. margin-top: 60rpx;
  321. .area-list {
  322. padding: 46rpx 40rpx;
  323. flex-wrap: wrap;
  324. .area-item {
  325. // flex: 1 0 0;
  326. flex-shrink: 0;
  327. width: 326rpx;
  328. height: 80rpx;
  329. background: #fff6f7;
  330. border-radius: 8rpx;
  331. font-size: 32rpx;
  332. font-weight: 500;
  333. color: #333333;
  334. line-height: 80rpx;
  335. text-align: center;
  336. &:nth-child(2n) {
  337. margin-left: 16rpx;
  338. }
  339. &:nth-child(n + 3) {
  340. margin-top: 16rpx;
  341. }
  342. }
  343. }
  344. }
  345. .page-content {
  346. margin-top: 70rpx;
  347. padding: 0 40rpx;
  348. .title {
  349. font-size: 36rpx;
  350. font-weight: 500;
  351. color: #000000;
  352. line-height: 36rpx;
  353. padding-left: 6rpx;
  354. .title-name {
  355. position: relative;
  356. &::after {
  357. content: '';
  358. position: absolute;
  359. left: -6rpx;
  360. bottom: 0;
  361. z-index: -1;
  362. // width: 175rpx;
  363. width: 115%;
  364. height: 10rpx;
  365. background: var(--title-guides-color);
  366. border-radius: 2rpx;
  367. }
  368. }
  369. }
  370. .cell-list {
  371. margin-top: 20rpx;
  372. .cell {
  373. width: 100%;
  374. padding: 24rpx 0;
  375. background: #ffffff;
  376. border-bottom: 1px solid #efefef;
  377. display: flex;
  378. justify-content: space-between;
  379. .cell-left {
  380. height: 100%;
  381. font-size: 30rpx;
  382. font-weight: 400;
  383. color: #007bd7;
  384. line-height: 30rpx;
  385. }
  386. .cell-right {
  387. height: 100%;
  388. width: 40rpx;
  389. display: flex;
  390. align-items: center;
  391. justify-content: flex-end;
  392. .cell-right-number {
  393. font-size: 32rpx;
  394. font-weight: 400;
  395. color: #666666;
  396. margin-right: 28rpx;
  397. }
  398. }
  399. }
  400. }
  401. }
  402. .party {
  403. .rich {
  404. padding: 60rpx 45rpx;
  405. }
  406. .party-list {
  407. margin-top: 55rpx;
  408. padding: 0 40rpx 0;
  409. .section-item {
  410. padding: 20rpx 0;
  411. border-bottom: 1px solid #e1e1e1;
  412. &:first-child {
  413. padding-top: 0;
  414. }
  415. .section-item-left {
  416. margin-left: 24rpx;
  417. .consult-content-title {
  418. font-size: 32rpx;
  419. font-weight: 400;
  420. color: #333333;
  421. line-height: 40rpx;
  422. margin-bottom: 24rpx;
  423. }
  424. .consult-content-block {
  425. font-size: 28rpx;
  426. font-weight: 400;
  427. color: #666666;
  428. line-height: 28rpx;
  429. }
  430. }
  431. .section-item-right {
  432. width: 214rpx;
  433. height: 140rpx;
  434. border-radius: 8rpx;
  435. }
  436. }
  437. }
  438. .rich2 {
  439. padding: 44rpx 45rpx;
  440. font-size: 30rpx;
  441. font-weight: 400;
  442. color: #222222;
  443. line-height: 60rpx;
  444. }
  445. }
  446. </style>