activity.vue 13 KB

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