honor.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. <template>
  2. <view class="content">
  3. <view>
  4. <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text" activeColor="#1c9bdc"></uni-segmented-control>
  5. <view class="content">
  6. <view v-show="current == 0">
  7. <view class="active-title-box">
  8. <picker :range="arrayYear" :value="dateYear" @change="bindDateChange" class="picker-class" style="margin-left: 2%; width:20%;">
  9. <view class="uni-input display-between items-center">
  10. <view>{{dateYear}}<text v-if="dateYear!=='全部'">年</text></view>
  11. <image src="/static/calendar_icon.svg" mode="aspectFit" style="top: 18rpx;"></image>
  12. </view>
  13. </picker>
  14. <picker :range="arrayMonth" :value="dateMonth" @change="bindDateMonthChange" class="picker-class" style="margin-left: 2%; width:15%;">
  15. <view class="uni-input display-between items-center" style="color: #707070;">
  16. <view>{{dateMonth}}<text v-if="dateMonth!=='全部'">月</text></view>
  17. <image src="/static/calendar_icon.svg" mode="aspectFit" style="top: 18rpx;"></image>
  18. </view>
  19. </picker>
  20. <picker @change="bindPickerChange" :value="index" :range="array">
  21. <view class="uni-input">{{array[index]}}</view>
  22. <image src="/static/arrow_down.svg" mode="aspectFit"></image>
  23. </picker>
  24. <button @click="goRecord()">+获奖记录</button>
  25. </view>
  26. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  27. <view class="honor-box" v-for="(item,index) in honorList" :key="index" style="position: relative;">
  28. <view class="honor-name">{{item.name}}</view>
  29. <view class="honor-img-box">
  30. <image :src="item.pic_url_resize" mode="aspectFit" @click="showLarge(item.pic_url)"></image>
  31. </view>
  32. <view style="display: flex;">
  33. <view class="honor-award" style="width:120rpx;">获奖人:</view>
  34. <view class="honor-award">{{item.for_branch}} {{item.for_names}}</view>
  35. </view>
  36. <view class="honor-info-box">
  37. <text>{{item.year}}年{{item.month}}月</text>
  38. <text>|</text>
  39. <text>{{item.level_str}}</text>
  40. <text>|</text>
  41. <text>{{item.from_str}}</text>
  42. <text>|</text>
  43. <text>{{item.for_str}}</text>
  44. </view>
  45. <view class="edit-icon-box">
  46. <image src="/static/edit-icon.png" mode="aspectFit" v-show="item.edit_auth" @click="goRecord(item.id)"></image>
  47. <image src="/static/del-icon.png" mode="aspectFit" v-show="item.del_auth" @click="delRecord(item.id)"></image>
  48. </view>
  49. </view>
  50. </mescroll-body>
  51. <!-- <view v-if="!honorList.length" class="no-data-box">
  52. <image src="/static/nodata.svg" mode="aspectFit" style="width: 300rpx;height: 300rpx;"></image>
  53. </view> -->
  54. </view>
  55. <view v-if="current == 1">
  56. <view class="active-title-box">
  57. <!-- <picker mode="date" fields="year" @change="bindDateChangeSelf" class="picker-class">
  58. <view class="uni-input display-between items-center">{{dateYearSelf}}年<image src="/static/calendar_icon.svg" mode="aspectFit" style="top: 18rpx;"></image></view>
  59. </picker> -->
  60. <!-- <picker :range="arrayMonth" :value="dateMonthSelf" @change="bindDateMonthChangeSelf" class="picker-class" style="margin-left: 2%;">
  61. <view class="uni-input display-between items-center" style="color: #707070;">{{dateMonthSelf}}月<image src="/static/calendar_icon.svg" mode="aspectFit" style="top: 18rpx;"></image></view>
  62. </picker> -->
  63. <!-- <picker @change="bindPickerChangeSelf" :value="indexSelf" :range="arraySelf">
  64. <view class="uni-input">{{arraySelf[index]}}</view>
  65. <image src="/static/arrow_down.svg" mode="aspectFit"></image>
  66. </picker> -->
  67. <picker :range="arrayYear" :value="dateYearSelf" @change="bindDateChangeSelf" class="picker-class" style="margin-left: 2%; width:20%;">
  68. <view class="uni-input display-between items-center">
  69. <view>{{dateYearSelf}}<text v-if="dateYearSelf!=='全部'">年</text></view>
  70. <image src="/static/calendar_icon.svg" mode="aspectFit" style="top: 18rpx;"></image>
  71. </view>
  72. </picker>
  73. <picker :range="arrayMonth" :value="dateMonthSelf" @change="bindDateMonthChangeSelf" class="picker-class" style="margin-left: 2%; width:15%;">
  74. <view class="uni-input display-between items-center" style="color: #707070;">
  75. <view>{{dateMonthSelf}}<text v-if="dateMonthSelf!=='全部'">月</text></view>
  76. <image src="/static/calendar_icon.svg" mode="aspectFit" style="top: 18rpx;"></image>
  77. </view>
  78. </picker>
  79. <button @click="goRecord()" style="margin-left: 20%;">+获奖记录</button>
  80. </view>
  81. <view class="honor-box" v-for="(item,index) in myHonorList" :key="index" style="position: relative;">
  82. <view class="honor-name">{{item.name}}</view>
  83. <image :src="item.pic_url_resize" mode="aspectFit" @click="showLarge(item.pic_url)"></image>
  84. <view style="display: flex;">
  85. <view class="honor-award" style="width:120rpx;">获奖人:</view>
  86. <view class="honor-award">{{item.for_branch}} {{item.for_names}}</view>
  87. </view>
  88. <view class="honor-info-box">
  89. <text>{{item.year}}年{{item.month}}月</text>
  90. <text>|</text>
  91. <text>{{item.level_str}}</text>
  92. <text>|</text>
  93. <text>{{item.from_str}}</text>
  94. <text>|</text>
  95. <text>{{item.for_str}}</text>
  96. </view>
  97. <view class="edit-icon-box">
  98. <image src="/static/edit-icon.png" mode="aspectFit" v-show="item.edit_auth" @click="goRecord(item.id)"></image>
  99. <image src="/static/del-icon.png" mode="aspectFit" v-show="item.del_auth" @click="delRecord(item.id)"></image>
  100. </view>
  101. </view>
  102. <!-- <view v-if="!honorList.length" class="no-data-box">
  103. <image src="/static/nodata.svg" mode="aspectFit" style="width: 300rpx;height: 300rpx;"></image>
  104. </view> -->
  105. </view>
  106. </view>
  107. </view>
  108. <!-- <share-modal @closeShare="closeShare" :isShowShare="isShowShareModal" :isFirstPage="isFirstPage" :class="{ shareParent: isShowShareModal}"></share-modal> -->
  109. </view>
  110. </template>
  111. <script>
  112. import md5 from "@/common/md5.js";
  113. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  114. // import shareModal from '@/components/share-modal/share-modal.vue'
  115. export default {
  116. components: {
  117. //"share-modal": shareModal,
  118. },
  119. mixins: [MescrollMixin], // 使用mixin
  120. data() {
  121. return {
  122. id: "",
  123. details: "",
  124. items:['支部/组织荣誉','我的荣誉'],
  125. current:0,
  126. shareUrl:getApp().globalData.shareUrl,
  127. array:['全部','中央','省级','市级','区级','单位'],
  128. index:0,
  129. indexSelf:0,
  130. dateYear:'全部',
  131. arrayYear:[],
  132. dateMonth:'全部',
  133. arrayMonth:['全部',"1","2","3","4","5","6","7","8","9","10","11","12"],
  134. dateYearSelf:'全部',
  135. dateMonthSelf:'全部',
  136. arraySelf:['全部','中央','省级','市级','区级','单位'],
  137. imageList: [],
  138. time: "",
  139. globalUrl:getApp().globalData.shareUrl,
  140. honorList:[],
  141. myHonorList:[],
  142. page:1,
  143. pageSize:10,
  144. // isShowShareModal:false,
  145. // isFirstPage:false
  146. };
  147. },
  148. onLoad() {
  149. this.makeYearArr()
  150. // this.getHonorList(this.dateYear,this.dateMonth,this.index)
  151. },
  152. onShow(){
  153. //this.getHonorList(this.dateYear,this.dateMonth,this.index)
  154. },
  155. onShareAppMessage() {
  156. return {
  157. title: '农工笔记',
  158. path:'/pages/index/activity/activity'
  159. }
  160. },
  161. methods: {
  162. makeYearArr(){
  163. let nowYear = new Date().getFullYear(),yearList = ['全部'];
  164. for(let i = 0; i < 10 ; i ++){
  165. yearList.push(nowYear--)
  166. }
  167. this.arrayYear = yearList;
  168. },
  169. // pageShowShare(obj){
  170. // this.isShowShareModal = true;
  171. // this.isFirstPage = true;
  172. // },
  173. // closeShare(e){
  174. // this.isShowShareModal = false;
  175. // },
  176. pageRefreshHonor(object) {
  177. if (object === 'add') {
  178. if(this.current){
  179. this.getMyHonor(this.dateYearSelf,this.dateMonthSelf)
  180. }else {
  181. this.getHonorList(this.dateYear,this.dateMonth,this.index)
  182. }
  183. }else if (object === 'edit'){
  184. if(this.current){
  185. this.getMyHonor(this.dateYearSelf,this.dateMonthSelf)
  186. }else {
  187. return
  188. //this.getHonorList(this.dateYear,this.dateMonth,this.index)
  189. }
  190. }
  191. else {
  192. return
  193. }
  194. },
  195. onClickItem(e){
  196. this.current = e.currentIndex
  197. this.current ?
  198. this.getMyHonor(this.dateYearSelf,this.dateMonthSelf) :
  199. this.getHonorList(this.dateYear,this.dateMonth,this.index)
  200. },
  201. bindDateChange(e){
  202. this.dateYear = this.arrayYear[e.target.value];
  203. this.getHonorList(this.dateYear,this.dateMonth,this.index)
  204. },
  205. bindDateMonthChange(e){
  206. this.dateMonth = this.arrayMonth[e.target.value];
  207. this.getHonorList(this.dateYear,this.dateMonth,this.index)
  208. },
  209. bindPickerChange(e){
  210. this.index = e.detail.value
  211. this.getHonorList(this.dateYear,this.dateMonth,e.detail.value)
  212. },
  213. bindDateChangeSelf(e){
  214. this.dateYearSelf = this.arrayYear[e.target.value];
  215. this.getMyHonor(this.dateYearSelf,this.dateMonthSelf,this.indexSelf)
  216. },
  217. bindDateMonthChangeSelf(e){
  218. this.dateMonthSelf = this.arrayMonth[e.target.value];
  219. this.getMyHonor(this.dateYearSelf,this.dateMonthSelf,this.indexSelf)
  220. },
  221. // bindPickerChangeSelf(e){
  222. // this.indexSelf = e.detail.value
  223. // this.getMyHonor(this.dateYearSelf,this.dateMonthSelf,e.detail.value)
  224. // },
  225. upCallback(page) {
  226. let pageNum = page.num; // 页码, 默认从1开始
  227. let pageSize = page.size; // 页长, 默认每页10条
  228. let md5Sign = md5(
  229. "method=" +"glory" + "&timestamp=" + getApp().globalData.globalTimestamp +
  230. "&secret=" + getApp().globalData.secret
  231. );
  232. let url = getApp().globalData.shareUrl +"api/api.php" +
  233. "?method=glory&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. level:this.index,
  248. page:pageNum,
  249. page_size:pageSize
  250. },
  251. success: (res) => {
  252. if (res.data.code === 200) {
  253. // 接口返回的当前页数据列表 (数组)
  254. let curPageData = res.data.data.list;
  255. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  256. let curPageLen = curPageData.length;
  257. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  258. let totalPage = res.data.data.page_count;
  259. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  260. let totalSize = res.data.data.count;
  261. // // 接口返回的是否有下一页 (true/false)
  262. // let hasNext = data.xxx;
  263. if(page.num == 1) this.honorList = []; //如果是第一页需手动制空列表
  264. let list = res.data.data.list;
  265. list.forEach((item)=>{
  266. item.pic_url = this.shareUrl + item.pic_url;
  267. item.pic_url_resize = this.shareUrl + item.pic_url_resize;
  268. })
  269. this.honorList=this.honorList.concat(res.data.data.list); //追加新数据
  270. this.mescroll.endByPage(curPageLen || 0, totalPage);
  271. }
  272. },
  273. fail: () => {
  274. console.log("连接失败");
  275. this.mescroll.endErr();
  276. },
  277. });
  278. },
  279. goRecord(id){
  280. if(id){
  281. uni.navigateTo({
  282. url:'./record?id=' + id
  283. })
  284. }else {
  285. uni.navigateTo({
  286. url:'./record'
  287. })
  288. }
  289. },
  290. delRecordRequest(delId){
  291. let md5Sign = md5(
  292. "method=" +"glory" + "&timestamp=" + getApp().globalData.globalTimestamp +
  293. "&secret=" + getApp().globalData.secret
  294. );
  295. let url = getApp().globalData.shareUrl +"api/api.php" +
  296. "?method=glory&action=del&timestamp=" +
  297. getApp().globalData.globalTimestamp +
  298. "&sign=" +
  299. md5Sign;
  300. uni.request({
  301. url: url,
  302. method: "POST",
  303. header: {
  304. "content-type": "application/x-www-form-urlencoded",
  305. },
  306. data: {
  307. openid: getApp().globalData.open_id,
  308. id:delId
  309. },
  310. success: (res) => {
  311. if (res.data.code === 200) {
  312. uni.showToast({
  313. title: "删除成功",
  314. icon: "none",
  315. duration: 2500,
  316. success:()=>{
  317. if(this.current){
  318. this.getMyHonor(this.dateYearSelf,this.dateMonthSelf)
  319. }else {
  320. this.getHonorList(this.dateYear,this.dateMonth,this.index)
  321. }
  322. }
  323. });
  324. }
  325. },
  326. fail: () => {
  327. console.log("连接失败");
  328. },
  329. });
  330. },
  331. delRecord(id){
  332. let that = this;
  333. uni.showModal({
  334. title: "确定删除此荣誉吗?",
  335. success(res) {
  336. if (res.confirm) {
  337. that.delRecordRequest(id);
  338. } else if (res.cancel) {
  339. console.log("用户点击取消");
  340. }
  341. },
  342. });
  343. },
  344. showLarge(src) {
  345. uni.previewImage({
  346. urls: [src],
  347. longPressActions: {
  348. itemList: ["发送给朋友", "保存图片"],
  349. success: function (data) {},
  350. fail: function (err) {
  351. console.log(err.errMsg);
  352. },
  353. },
  354. });
  355. },
  356. getHonorList(y,m,level) {
  357. let md5Sign = md5(
  358. "method=" +"glory" + "&timestamp=" + getApp().globalData.globalTimestamp +
  359. "&secret=" + getApp().globalData.secret
  360. );
  361. let url = getApp().globalData.shareUrl +"api/api.php" +
  362. "?method=glory&action=list&timestamp=" +
  363. getApp().globalData.globalTimestamp +
  364. "&sign=" +
  365. md5Sign;
  366. uni.request({
  367. url: url,
  368. method: "POST",
  369. header: {
  370. "content-type": "application/x-www-form-urlencoded",
  371. },
  372. data: {
  373. openid: getApp().globalData.open_id,
  374. year:y,
  375. month:m,
  376. level:level,
  377. page:this.page,
  378. page_size:this.pageSize
  379. },
  380. success: (res) => {
  381. if (res.data.code === 200) {
  382. let list = res.data.data.list;
  383. list.forEach((item)=>{
  384. item.pic_url = this.shareUrl + item.pic_url;
  385. item.pic_url_resize = this.shareUrl + item.pic_url_resize;
  386. })
  387. this.honorList = list;
  388. }
  389. },
  390. fail: () => {
  391. console.log("连接失败");
  392. },
  393. });
  394. },
  395. getMyHonor(y,m) {
  396. let md5Sign = md5(
  397. "method=" +"glory" + "&timestamp=" + getApp().globalData.globalTimestamp +
  398. "&secret=" + getApp().globalData.secret
  399. );
  400. let url = getApp().globalData.shareUrl +"api/api.php" +
  401. "?method=glory&action=my_list&timestamp=" +
  402. getApp().globalData.globalTimestamp +
  403. "&sign=" +
  404. md5Sign;
  405. uni.request({
  406. url: url,
  407. method: "POST",
  408. header: {
  409. "content-type": "application/x-www-form-urlencoded",
  410. },
  411. data: {
  412. openid: getApp().globalData.open_id,
  413. year:y,
  414. month:m,
  415. // level:level,
  416. // page:1,
  417. // page_size:10
  418. },
  419. success: (res) => {
  420. if (res.data.code === 200) {
  421. let list = res.data.data.list;
  422. list.forEach((item)=>{
  423. item.pic_url = this.shareUrl + item.pic_url;
  424. item.pic_url_resize = this.shareUrl + item.pic_url_resize;
  425. })
  426. this.myHonorList = list;
  427. }
  428. },
  429. fail: () => {
  430. console.log("连接失败");
  431. },
  432. });
  433. },
  434. },
  435. };
  436. </script>
  437. <style lang="scss" scoped>
  438. .content {
  439. .active-title-box {
  440. display: flex;
  441. align-items: center;
  442. margin-top: 10rpx;
  443. font-size: 26rpx;
  444. height: 100rpx;
  445. border-bottom: 1px solid #d7d7d7;
  446. margin-top: 10rpx;
  447. .time-select-box {
  448. width: 32%;
  449. margin-left: 5%;
  450. }
  451. picker {
  452. width: 20%;
  453. border: 1px solid #d7d7d7;
  454. height: 60rpx;
  455. line-height: 60rpx;
  456. border-radius: 10rpx;
  457. margin-left: 20rpx;
  458. padding: 0 10rpx;
  459. position: relative;
  460. image {
  461. width: 20rpx;
  462. height: 20rpx;
  463. position: absolute;
  464. top: 11px;
  465. right: 5px;
  466. }
  467. }
  468. button {
  469. width: 25%;
  470. font-size: 25rpx;
  471. background: #4988fd;
  472. color: #fff;
  473. margin-left: 20rpx;
  474. margin-right: 20rpx;
  475. }
  476. }
  477. .honor-box {
  478. // display: flex;
  479. // flex-direction: column;
  480. // padding: 20rpx 40rpx 20rpx 40rpx;
  481. // border-bottom: 1px solid #d7d7d7;
  482. display: flex;
  483. flex-direction: column;
  484. padding: 3%;
  485. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  486. margin: 2% 0 2% 2%;
  487. width: 90%;
  488. border-radius: 10rpx;
  489. .honor-img-box{
  490. margin-top: 30rpx;
  491. border-radius: 10rpx
  492. image {
  493. width: 100%;
  494. height: 450rpx;
  495. margin: 20rpx auto;
  496. }
  497. }
  498. .honor-award {
  499. width: 80%;
  500. color: #ccc;
  501. font-size: 28rpx;
  502. margin: 20rpx 0 10rpx 0;
  503. }
  504. .honor-info-box {
  505. display: flex;
  506. align-items: center;
  507. font-size: 26rpx;
  508. color: #ccc;
  509. text {
  510. margin-right: 20rpx;
  511. }
  512. }
  513. .edit-icon-box {
  514. position: absolute;
  515. right: 10px;
  516. top: 10px;
  517. image {
  518. width: 35rpx;
  519. height: 35rpx;
  520. margin-right: 10rpx;
  521. }
  522. }
  523. }
  524. .no-data-box {
  525. position: fixed;
  526. top: 100px;
  527. left: 30%;
  528. }
  529. }
  530. </style>