activity.vue 15 KB

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