activity.vue 15 KB

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