activity.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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. <!-- <uni-datetime-picker
  24. class="time-select-box"
  25. type="date"
  26. :value="single"
  27. @change="change"
  28. :clear-icon="false"
  29. /> -->
  30. <picker mode="date" fields="year" @change="bindDateChange" class="picker-class" style="margin-left: 2%; width: 15%;">
  31. <view class="uni-input display-between items-center">{{dateYear}}年<image src="/static/calendar_icon.svg" mode="aspectFit" style="top: 18rpx;"></image></view>
  32. </picker>
  33. <picker :range="arrayMonth" :value="dateMonth" @change="bindDateMonthChange" class="picker-class" style="margin-left: 2%; width: 10%;">
  34. <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>
  35. </picker>
  36. <picker @change="bindPickerChange" :value="branchValue" :range="branchArray" :range-key="'name'">
  37. <view class="uni-input">{{branchValue}}</view>
  38. <image src="/static/arrow_down.svg" mode="aspectFit"></image>
  39. </picker>
  40. <button @click="publish()">+发布活动</button>
  41. </view>
  42. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  43. <view class="active-box" v-for="(item,index) in activiList" :key="index" @click="goList(item.id)">
  44. <view class="active-type" :class="{'bg-yellow':item.type == '组织建设' ,'bg-red':item.type == '学习培训','bg-blue':item.type == '参政议政',}" >
  45. {{item.type}}
  46. </view>
  47. <view class="active-content-box">
  48. <view class="active-content">
  49. <view class="active-name">{{item.name}}</view>
  50. <view class="active-date">{{item.start_time}}</view>
  51. </view>
  52. <view class="active-content">
  53. <view style="margin-right:10rpx;">{{item.branch}}</view>
  54. <view class="author-box">{{item.author}}</view>
  55. <view style="margin-left:10rpx;">记录数:({{item.process_count}}/<text style="color:red;">{{item.process_unread_count}}</text>)</view>
  56. </view>
  57. </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: 20rpx;"></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. </mescroll-body>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import md5 from "@/common/md5.js";
  69. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  70. export default {
  71. components: {
  72. },
  73. mixins: [MescrollMixin], // 使用mixin
  74. data() {
  75. return {
  76. dateYear:new Date().getFullYear(),
  77. dateMonth:new Date().getMonth() + 1,
  78. arrayMonth:["1", "2","3", "4","5", "6","7", "8","9", "10","11", "12"],
  79. userHeadImg: getApp().globalData.user_headUrl,
  80. userNickName:getApp().globalData.user_name,
  81. userPhone:getApp().globalData.user_phone.substr(0, 3) + '****' + getApp().globalData.user_phone.substr(7),
  82. userPosList:[],
  83. branchArray: [],
  84. branchValue:'全部',
  85. branchId:'0',
  86. page:1,
  87. pageSize:10,
  88. activiList:[]
  89. };
  90. },
  91. onShow() {
  92. this.getActiveList(this.branchId)
  93. },
  94. onLoad() {
  95. this.getUserInfoBranch()
  96. this.getActiveInfoBranch()
  97. },
  98. methods: {
  99. getUserInfoBranch() {
  100. let md5Sign = md5(
  101. "method=" + "member" +"&timestamp=" + getApp().globalData.globalTimestamp +"&secret=" +getApp().globalData.secret
  102. );
  103. let url =
  104. getApp().globalData.shareUrl + "api/api.php" + "?method=member&action=my_branch&timestamp=" + getApp().globalData.globalTimestamp +
  105. "&sign=" + md5Sign;
  106. uni.request({
  107. url: url,
  108. method: "POST",
  109. header: {
  110. "content-type": "application/x-www-form-urlencoded",
  111. },
  112. data: {
  113. openid:getApp().globalData.open_id,
  114. },
  115. success: (res) => {
  116. if (res.data.code === 200) {
  117. this.userPosList = res.data.data;
  118. }
  119. },
  120. fail: () => {
  121. console.log("连接失败");
  122. },
  123. });
  124. },
  125. goEditPage(id){
  126. uni.navigateTo({
  127. url:'edit_page?id=' + id
  128. })
  129. },
  130. delActiveRequeset(delId){
  131. let md5Sign = md5(
  132. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  133. "&secret=" + getApp().globalData.secret
  134. );
  135. let url = getApp().globalData.shareUrl +"api/api.php" +
  136. "?method=activity&action=del&timestamp=" +
  137. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  138. uni.request({
  139. url: url,
  140. method: "POST",
  141. header: {
  142. "content-type": "application/x-www-form-urlencoded",
  143. },
  144. data: {
  145. openid: getApp().globalData.open_id,
  146. id:delId
  147. },
  148. success: (res) => {
  149. if (res.data.code === 200) {
  150. uni.showToast({
  151. title: "删除成功",
  152. icon: "none",
  153. duration: 2500,
  154. success:()=>{
  155. this.getActiveList(this.branchId)
  156. }
  157. });
  158. }
  159. },
  160. fail: () => {
  161. console.log("连接失败");
  162. },
  163. });
  164. },
  165. delActive(id){
  166. let that = this;
  167. uni.showModal({
  168. title: "确定删除此活动吗?",
  169. success(res) {
  170. if (res.confirm) {
  171. that.delActiveRequeset(id);
  172. } else if (res.cancel) {
  173. console.log("用户点击取消");
  174. }
  175. },
  176. });
  177. },
  178. getActiveInfoBranch() {
  179. let md5Sign = md5("method=" + "activity" +"&timestamp=" + getApp().globalData.globalTimestamp +"&secret=" +getApp().globalData.secret);
  180. let url =
  181. getApp().globalData.shareUrl + "api/api.php" + "?method=activity&action=list_branch&timestamp=" + getApp().globalData.globalTimestamp +
  182. "&sign=" + md5Sign;
  183. uni.request({
  184. url: url,
  185. method: "POST",
  186. header: {
  187. "content-type": "application/x-www-form-urlencoded",
  188. },
  189. data: {
  190. openid:getApp().globalData.open_id,
  191. },
  192. success: (res) => {
  193. if (res.data.code === 200) {
  194. let obj = {
  195. name:'全部',
  196. id:'0'
  197. }
  198. let arr = res.data.data;
  199. arr.unshift(obj);
  200. this.branchArray = arr;
  201. }
  202. },
  203. fail: () => {
  204. console.log("连接失败");
  205. },
  206. });
  207. },
  208. bindDateChange(e){
  209. this.dateYear = e.target.value;
  210. },
  211. bindDateMonthChange(e){
  212. this.dateMonth = this.arrayMonth[e.target.value];
  213. },
  214. bindPickerChange: function(e) {
  215. console.log('picker发送选择改变,携带值为', e.target.value)
  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-line {
  419. width: 1px;
  420. height: 82rpx;
  421. background: #d4d4d4;
  422. }
  423. .active-title-box {
  424. display: flex;
  425. align-items: center;
  426. margin-top: 10rpx;
  427. font-size: 26rpx;
  428. height: 100rpx;
  429. border-bottom: 1px solid #d7d7d7;
  430. margin-top: 10rpx;
  431. .time-select-box {
  432. width: 32%;
  433. margin-left: 5%;
  434. }
  435. picker {
  436. width: 29%;
  437. border: 1px solid #d7d7d7;
  438. height: 60rpx;
  439. line-height: 60rpx;
  440. border-radius: 10rpx;
  441. margin-left: 20rpx;
  442. padding: 0 10rpx;
  443. position: relative;
  444. image {
  445. width: 20rpx;
  446. height: 20rpx;
  447. position: absolute;
  448. top: 11px;
  449. right: 5px;
  450. }
  451. }
  452. button {
  453. width: 25%;
  454. font-size: 25rpx;
  455. background: #4988fd;
  456. color: #fff;
  457. margin-left: 20rpx;
  458. margin-right: 20rpx;
  459. }
  460. }
  461. .active-box {
  462. display: flex;
  463. align-items: center;
  464. position: relative;
  465. font-size: 28rpx;
  466. padding: 30rpx;
  467. border-bottom: 1px solid #d7d7d7;
  468. .active-type {
  469. width: 100rpx;
  470. height: 100rpx;
  471. border-radius: 50%;
  472. background-color: yellow;
  473. text-align: center;
  474. display: flex;
  475. align-items: center;
  476. font-size: 26rpx;
  477. color: #fff;
  478. justify-content: center;
  479. }
  480. .active-content-box {
  481. height: 120rpx;
  482. display: flex;
  483. flex-direction: column;
  484. margin-left: 20rpx;
  485. justify-content: space-around;
  486. }
  487. .active-content {
  488. display: flex;
  489. align-items: center;
  490. height: 45rpx;
  491. font-size: 26rpx;
  492. .author-box {
  493. border-left: 1px solid #d7d7d7;
  494. border-right: 1px solid #d7d7d7;
  495. padding: 0 30rpx 0 30rpx;
  496. margin: 0 20rpx 0 20rpx;
  497. }
  498. .active-name {
  499. font-size: 30rpx;
  500. margin-right: 10rpx;
  501. }
  502. .active-date {
  503. font-size: 24rpx;
  504. color: #ccc;
  505. }
  506. }
  507. .edit-icon-box {
  508. position: absolute;
  509. right: 10px;
  510. top: 10px;
  511. image {
  512. width: 35rpx;
  513. height: 35rpx;
  514. }
  515. }
  516. .bg-yellow {
  517. background-color: #ffdd40;
  518. }
  519. .bg-red {
  520. background-color: #ec808d;
  521. }
  522. .bg-blue {
  523. background-color: #81d3f8;
  524. }
  525. }
  526. </style>