activity.vue 16 KB

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