activity.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <template>
  2. <view class="content">
  3. <view class="self-inf">
  4. <view class="antu-box">
  5. <view class="img-name-box">
  6. <image :src="userHeadImg" class="heade-img" mode="aspectFill"></image>
  7. <p class="nickname">{{userNickName}}</p>
  8. <p class="nickname">{{userPhone}}</p>
  9. </view>
  10. <view class="org-info-box" v-for="(item,index) in userPosList" :key="index">
  11. <view class="org-info">{{item.name || '-'}}</view>
  12. <!-- <view class="org-line"></view> -->
  13. <view class="org-info">{{item.position}}</view>
  14. </view>
  15. </view>
  16. <!-- <view class="img-name-box" v-if="!isAuth" style="height: 180rpx;">
  17. <image src="/static/auth-icon.png" class="heade-img" mode="aspectFill" style="margin-left: 80rpx;"></image>
  18. <button @click="goAuthPage()" class="auth-btn">授权登录</button>
  19. </view> -->
  20. </view>
  21. <view>
  22. <view class="active-title-box">
  23. <picker :range="arrayYear" :value="dateYear" @change="bindDateChange" class="picker-class" style="margin-left: 2%; width: 15%;">
  24. <view class="uni-input display-between items-center">
  25. <view>{{dateYear}}<text v-if="dateYear!=='全部'">年</text></view>
  26. <image src="/static/calendar_icon.svg" mode="aspectFit" style="top: 18rpx;"></image>
  27. </view>
  28. </picker>
  29. <picker :range="arrayMonth" :value="dateMonth" @change="bindDateMonthChange" class="picker-class" style="margin-left: 2%; width: 10%;">
  30. <view class="uni-input display-between items-center" style="color: #707070;">
  31. <view>{{dateMonth}}<text v-if="dateMonth!=='全部'">月</text></view>
  32. <image src="/static/calendar_icon.svg" mode="aspectFit" style="top: 18rpx;"></image>
  33. </view>
  34. </picker>
  35. <picker @change="bindPickerChange" :value="branchValue" :range="branchArray" :range-key="'name'">
  36. <view class="uni-input">{{branchValue}}</view>
  37. <image src="/static/arrow_down.svg" mode="aspectFit"></image>
  38. </picker>
  39. <button @click="publish()">+发布活动</button>
  40. </view>
  41. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  42. <view class="active-box" v-for="(item,index) in activiList" :key="index" @click="goList(item.id)">
  43. <view class="active-type" :class="{'bg-yellow':item.type == '组织建设' ,'bg-red':item.type == '学习培训','bg-blue':item.type == '参政议政','bg-gray':item.type == '社会活动'}" >
  44. <view style="width: 55%;">{{item.type}}</view>
  45. </view>
  46. <view class="active-content-box">
  47. <view class="active-content">
  48. <view class="active-name">{{item.name}}</view>
  49. </view>
  50. <view class="active-content" >
  51. <view style="margin-right:10rpx;">{{item.branch}}</view>
  52. <view class="author-box">{{item.author}}</view>
  53. <view style="margin-left:10rpx;">记录数:({{item.process_count}}/<text style="color:red;">{{item.process_unread_count}}</text>)</view>
  54. </view>
  55. <view class="active-content" style="justify-content: space-between;">
  56. <view class="active-date">{{item.start_time}}</view>
  57. <view class="edit-icon-box">
  58. <image src="/static/edit-icon.png" mode="aspectFit" v-show="item.edit_auth" @click.stop="goEditPage(item.id)" style="margin-right: 10rpx;"></image>
  59. <image src="/static/del-icon.png" mode="aspectFit" v-show="item.del_auth" @click.stop="delActive(item.id)"></image>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- <view class="edit-icon-box">
  64. <image src="/static/edit-icon.png" mode="aspectFit" v-show="item.edit_auth" @click.stop="goEditPage(item.id)" style="margin-right: 20rpx;"></image>
  65. <image src="/static/del-icon.png" mode="aspectFit" v-show="item.del_auth" @click.stop="delActive(item.id)"></image>
  66. </view> -->
  67. </view>
  68. </mescroll-body>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import md5 from "@/common/md5.js";
  74. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  75. export default {
  76. components: {
  77. },
  78. mixins: [MescrollMixin], // 使用mixin
  79. data() {
  80. return {
  81. dateYear:'全部',
  82. arrayYear:[],
  83. dateMonth:'全部',
  84. arrayMonth:['全部',"1","2","3","4","5","6","7","8","9","10","11","12"],
  85. userHeadImg: getApp().globalData.user_headUrl,
  86. userNickName:getApp().globalData.user_name,
  87. userPhone:getApp().globalData.user_phone.substr(0, 3) + '****' + getApp().globalData.user_phone.substr(7),
  88. userPosList:[],
  89. branchArray: [],
  90. branchValue:'全部',
  91. branchId:'0',
  92. page:1,
  93. pageSize:10,
  94. activiList:[]
  95. };
  96. },
  97. onShow() {
  98. // this.getActiveList(this.branchId)
  99. },
  100. onLoad(option) {
  101. this.getUserInfoBranch()
  102. this.getActiveInfoBranch()
  103. this.makeYearArr()
  104. },
  105. methods: {
  106. makeYearArr(){
  107. let nowYear = new Date().getFullYear(),yearList = ['全部'];
  108. for(let i = 0; i < 10 ; i ++){
  109. yearList.push(nowYear--)
  110. }
  111. this.arrayYear = yearList;
  112. },
  113. pageRefresh(object) {
  114. if (object) {
  115. this.getActiveList(this.branchId)
  116. } else {
  117. return
  118. }
  119. },
  120. getUserInfoBranch() {
  121. let md5Sign = md5(
  122. "method=" + "member" +"&timestamp=" + getApp().globalData.globalTimestamp +"&secret=" +getApp().globalData.secret
  123. );
  124. let url =
  125. getApp().globalData.shareUrl + "api/api.php" + "?method=member&action=my_branch&timestamp=" + getApp().globalData.globalTimestamp +
  126. "&sign=" + md5Sign;
  127. uni.request({
  128. url: url,
  129. method: "POST",
  130. header: {
  131. "content-type": "application/x-www-form-urlencoded",
  132. },
  133. data: {
  134. openid:getApp().globalData.open_id,
  135. },
  136. success: (res) => {
  137. if (res.data.code === 200) {
  138. this.userPosList = res.data.data;
  139. }
  140. },
  141. fail: () => {
  142. console.log("连接失败");
  143. },
  144. });
  145. },
  146. goEditPage(id){
  147. uni.navigateTo({
  148. url:'edit_page?id=' + id
  149. })
  150. },
  151. delActiveRequeset(delId){
  152. let md5Sign = md5(
  153. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  154. "&secret=" + getApp().globalData.secret
  155. );
  156. let url = getApp().globalData.shareUrl +"api/api.php" +
  157. "?method=activity&action=del&timestamp=" +
  158. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  159. uni.request({
  160. url: url,
  161. method: "POST",
  162. header: {
  163. "content-type": "application/x-www-form-urlencoded",
  164. },
  165. data: {
  166. openid: getApp().globalData.open_id,
  167. id:delId
  168. },
  169. success: (res) => {
  170. if (res.data.code === 200) {
  171. uni.showToast({
  172. title: "删除成功",
  173. icon: "none",
  174. duration: 2500,
  175. success:()=>{
  176. this.getActiveList(this.branchId)
  177. }
  178. });
  179. }
  180. },
  181. fail: () => {
  182. console.log("连接失败");
  183. },
  184. });
  185. },
  186. delActive(id){
  187. let that = this;
  188. uni.showModal({
  189. title: "确定删除此活动吗?",
  190. success(res) {
  191. if (res.confirm) {
  192. that.delActiveRequeset(id);
  193. } else if (res.cancel) {
  194. console.log("用户点击取消");
  195. }
  196. },
  197. });
  198. },
  199. getActiveInfoBranch() {
  200. let md5Sign = md5("method=" + "activity" +"&timestamp=" + getApp().globalData.globalTimestamp +"&secret=" +getApp().globalData.secret);
  201. let url =
  202. getApp().globalData.shareUrl + "api/api.php" + "?method=activity&action=list_branch&timestamp=" + getApp().globalData.globalTimestamp +
  203. "&sign=" + md5Sign;
  204. uni.request({
  205. url: url,
  206. method: "POST",
  207. header: {
  208. "content-type": "application/x-www-form-urlencoded",
  209. },
  210. data: {
  211. openid:getApp().globalData.open_id,
  212. },
  213. success: (res) => {
  214. if (res.data.code === 200) {
  215. let obj = {
  216. name:'全部',
  217. id:'0'
  218. }
  219. let arr = res.data.data;
  220. arr.unshift(obj);
  221. this.branchArray = arr;
  222. }
  223. },
  224. fail: () => {
  225. console.log("连接失败");
  226. },
  227. });
  228. },
  229. bindDateChange(e){
  230. this.dateYear = this.arrayYear[e.target.value];
  231. this.getActiveList(this.branchId)
  232. },
  233. bindDateMonthChange(e){
  234. this.dateMonth = this.arrayMonth[e.target.value];
  235. this.getActiveList(this.branchId)
  236. },
  237. bindPickerChange: function(e) {
  238. this.branchValue = this.branchArray[e.target.value].name;
  239. this.branchId = this.branchArray[e.target.value].id;
  240. this.getActiveList(this.branchId)
  241. },
  242. getActiveList(bId){
  243. let md5Sign = md5(
  244. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  245. "&secret=" + getApp().globalData.secret
  246. );
  247. let url = getApp().globalData.shareUrl +"api/api.php" +
  248. "?method=activity&action=list&timestamp=" +
  249. getApp().globalData.globalTimestamp +
  250. "&sign=" +
  251. md5Sign;
  252. uni.request({
  253. url: url,
  254. method: "POST",
  255. header: {
  256. "content-type": "application/x-www-form-urlencoded",
  257. },
  258. data: {
  259. openid: getApp().globalData.open_id,
  260. year:this.dateYear,
  261. month:this.dateMonth,
  262. s:'',
  263. branch_id:bId,
  264. page:this.page,
  265. page_size:this.pageSize
  266. },
  267. success: (res) => {
  268. if (res.data.code === 200) {
  269. this.activiList=res.data.data.list;
  270. }
  271. },
  272. fail: () => {
  273. console.log("连接失败");
  274. },
  275. });
  276. },
  277. upCallback(page) {
  278. console.log(666)
  279. let pageNum = page.num; // 页码, 默认从1开始
  280. let pageSize = page.size; // 页长, 默认每页10条
  281. let md5Sign = md5(
  282. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  283. "&secret=" + getApp().globalData.secret
  284. );
  285. let url = getApp().globalData.shareUrl +"api/api.php" +
  286. "?method=activity&action=list&timestamp=" +
  287. getApp().globalData.globalTimestamp +
  288. "&sign=" +
  289. md5Sign;
  290. uni.request({
  291. url: url,
  292. method: "POST",
  293. header: {
  294. "content-type": "application/x-www-form-urlencoded",
  295. },
  296. data: {
  297. openid: getApp().globalData.open_id,
  298. year:this.dateYear,
  299. month:this.dateMonth,
  300. s:'',
  301. branch_id:this.branchId,
  302. page:pageNum,
  303. page_size:pageSize
  304. },
  305. success: (res) => {
  306. if (res.data.code === 200) {
  307. // 接口返回的当前页数据列表 (数组)
  308. let curPageData = res.data.data.list;
  309. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  310. let curPageLen = curPageData.length;
  311. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  312. let totalPage = res.data.data.page_count;
  313. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  314. let totalSize = res.data.data.count;
  315. // // 接口返回的是否有下一页 (true/false)
  316. // let hasNext = data.xxx;
  317. if(page.num == 1) this.activiList = []; //如果是第一页需手动制空列表
  318. // let list = res.data.data.list;
  319. // list.forEach((item)=>{
  320. // item.pic_url = this.shareUrl + item.pic_url;
  321. // item.pic_url_resize = this.shareUrl + item.pic_url_resize;
  322. // })
  323. this.activiList=this.activiList.concat(res.data.data.list); //追加新数据
  324. this.mescroll.endByPage(curPageLen || 0, totalPage);
  325. }
  326. },
  327. fail: () => {
  328. console.log("连接失败");
  329. this.mescroll.endErr();
  330. },
  331. });
  332. },
  333. getPublishBranch() {
  334. let md5Sign = md5(
  335. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  336. "&secret=" +getApp().globalData.secret
  337. );
  338. let url = getApp().globalData.shareUrl +"api/api.php" +
  339. "?method=activity&action=activity_branch&timestamp=" +
  340. getApp().globalData.globalTimestamp +"&sign=" + md5Sign;
  341. uni.request({
  342. url: url,
  343. method: "POST",
  344. header: {
  345. "content-type": "application/x-www-form-urlencoded",
  346. },
  347. data: {
  348. openid:getApp().globalData.open_id,
  349. },
  350. success: (res) => {
  351. if (res.data.code === 200) {
  352. let publishList = res.data.data;
  353. if(publishList.length >= 2){
  354. uni.navigateTo({
  355. url:'./create1?list=' + JSON.stringify(publishList)
  356. })
  357. }else {
  358. uni.navigateTo({
  359. url:'./create2?list=' + JSON.stringify(publishList)
  360. })
  361. }
  362. }
  363. },
  364. fail: () => {
  365. console.log("连接失败");
  366. },
  367. });
  368. },
  369. publish(){
  370. this.getPublishBranch()
  371. },
  372. goList(ids){
  373. uni.navigateTo({
  374. url:'./list?id='+ ids
  375. })
  376. }
  377. },
  378. };
  379. </script>
  380. <style lang="scss" scoped>
  381. .content {
  382. display: flex;
  383. flex-direction: column;
  384. .self-inf {
  385. // border-radius: 0rpx 0rpx 100% 100%;
  386. .img-name-box {
  387. height: 150rpx;
  388. margin-top: 20rpx;
  389. margin-bottom: 20rpx;
  390. display: flex;
  391. align-items: center;
  392. width: 85%;
  393. .auth-btn {
  394. margin-left: 30rpx;
  395. margin-top: 20rpx;
  396. font-size: 28rpx;
  397. background-color: #02a7f0;
  398. color: #fff;
  399. }
  400. .heade-img {
  401. z-index: 1;
  402. width: 100rpx;
  403. height: 100rpx;
  404. border-radius: 50%;
  405. // margin-left: 80rpx;
  406. }
  407. }
  408. .nickname {
  409. font-weight: 600;
  410. font-size: 28rpx;
  411. margin-left: 30rpx;
  412. margin-top: 20rpx;
  413. color: #555;
  414. letter-spacing: 1rpx;
  415. }
  416. }
  417. }
  418. .antu-box {
  419. display: flex;
  420. flex-direction: column;
  421. align-items: center;
  422. background: #fff;
  423. margin-left: 5%;
  424. margin-top: 50rpx;
  425. border-radius: 10rpx;
  426. width: 90%;
  427. color: #555;
  428. box-shadow: 0px 2px 16px rgba(0, 0, 0, 0.2);
  429. }
  430. .org-info-box {
  431. display: flex;
  432. justify-content: space-evenly;
  433. height: 80rpx;
  434. align-items: center;
  435. width: 100%;
  436. border-top: 1px solid #d4d4d4;
  437. color: #555;
  438. font-size: 28rpx;
  439. background: #fff;
  440. }
  441. .org-info {
  442. width: 50%;
  443. padding-left: 10%;
  444. }
  445. .org-line {
  446. width: 1px;
  447. height: 82rpx;
  448. background: #d4d4d4;
  449. }
  450. .active-title-box {
  451. display: flex;
  452. align-items: center;
  453. margin-top: 10rpx;
  454. font-size: 26rpx;
  455. height: 100rpx;
  456. border-bottom: 1px solid #d7d7d7;
  457. margin-top: 10rpx;
  458. .time-select-box {
  459. width: 32%;
  460. margin-left: 5%;
  461. }
  462. picker {
  463. width: 29%;
  464. border: 1px solid #d7d7d7;
  465. height: 60rpx;
  466. line-height: 60rpx;
  467. border-radius: 10rpx;
  468. margin-left: 20rpx;
  469. padding: 0 10rpx;
  470. position: relative;
  471. image {
  472. width: 20rpx;
  473. height: 20rpx;
  474. position: absolute;
  475. top: 11px;
  476. right: 5px;
  477. }
  478. }
  479. button {
  480. width: 25%;
  481. font-size: 25rpx;
  482. background: #4988fd;
  483. color: #fff;
  484. margin-left: 20rpx;
  485. margin-right: 20rpx;
  486. }
  487. }
  488. .active-box {
  489. display: flex;
  490. align-items: flex-start;
  491. position: relative;
  492. font-size: 28rpx;
  493. padding: 20rpx;
  494. border-bottom: 1px solid #d7d7d7;
  495. .active-type {
  496. width: 100rpx;
  497. height: 100rpx;
  498. border-radius: 50%;
  499. background-color: aquamarine;
  500. text-align: center;
  501. display: flex;
  502. align-items: center;
  503. font-size: 26rpx;
  504. color: #fff;
  505. justify-content: center;
  506. }
  507. .active-content-box {
  508. width:83%;
  509. // height: 120rpx;
  510. display: flex;
  511. flex-direction: column;
  512. margin-left: 20rpx;
  513. justify-content: space-around;
  514. }
  515. .active-content {
  516. display: flex;
  517. align-items: center;
  518. // height: 45rpx;
  519. font-size: 26rpx;
  520. .author-box {
  521. border-left: 1px solid #d7d7d7;
  522. border-right: 1px solid #d7d7d7;
  523. padding: 0 30rpx 0 30rpx;
  524. margin: 0 20rpx 0 20rpx;
  525. }
  526. .active-name {
  527. font-size: 30rpx;
  528. margin-right: 10rpx;
  529. }
  530. .active-date {
  531. font-size: 24rpx;
  532. color: #ccc;
  533. }
  534. }
  535. .edit-icon-box {
  536. // position: absolute;
  537. // right: 10px;
  538. // top: 10px;
  539. // margin-top: 10rpx;
  540. image {
  541. width: 30rpx;
  542. height: 30rpx;
  543. }
  544. }
  545. .bg-yellow {
  546. background-color: #ffdd40;
  547. }
  548. .bg-gray {
  549. background-color: darkgrey;
  550. }
  551. .bg-red {
  552. background-color: #ec808d;
  553. }
  554. .bg-blue {
  555. background-color: #81d3f8;
  556. }
  557. }
  558. </style>