list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <template>
  2. <view class="content">
  3. <!-- <view>
  4. </view> -->
  5. <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text" activeColor="#1c9bdc"></uni-segmented-control>
  6. <view v-show="current == 0">
  7. <view class="active-title-box">
  8. <view class="header-title">{{activeDesc.name}}</view>
  9. <view style="color: gray;">{{activeDesc.start_time}}</view>
  10. </view>
  11. <view class="active-box" v-for="(item,index) in activiList" :key="index" style="flex-direction: column;" :class="index===activiList.length-1?'marginB40':''">
  12. <view class="active-header">
  13. <!-- <view class="active-type">
  14. <text style="margin: 0 auto;">头像</text>
  15. </view> -->
  16. <view class="active-content-box">
  17. <view class="active-content margin-top-3">
  18. <view class="active-name">{{item.author}}</view>
  19. <!-- <view class="active-date">{{item.addtime}}</view> -->
  20. </view>
  21. <view class="active-content">
  22. <view class="active-date">{{item.addtime}}</view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="active-content-box">
  27. <view class="active-content">
  28. <view class="active-title">{{item.content}}</view>
  29. </view>
  30. </view>
  31. <view class="active-content-box-img margin-top-3">
  32. <view v-for="(img,indexImg) in item.pic_list" :key="indexImg" class="marginR5">
  33. <image :src="img.pic_url_resize" mode="aspectFill" @click="showLarge(item.pic_list,indexImg)"></image>
  34. </view>
  35. </view>
  36. <view class="margin-top-3" style="color: #007AFF;" @click="tonewurl(item.web_url)" v-if="item.web_url">
  37. {{item.web_url}}
  38. </view>
  39. <view v-if="item.web_url" style="font-size: 24rpx;color: #ccc;">
  40. 点击链接可进行复制,前往浏览器查看。
  41. </view>
  42. <view class="edit-icon-box">
  43. <image src="/static/edit-icon.png" mode="aspectFit" v-if="item.edit_auth" @click="goEditPage(item.id)"></image>
  44. <image src="/static/del-icon.png" mode="aspectFit" v-if="item.del_auth" @click="delProcess(item.id)"></image>
  45. </view>
  46. </view>
  47. <button class="footer-box-record" @click="goRecord()">上传记录</button>
  48. </view>
  49. <view v-if="current == 1">
  50. <!-- <view class="active-box" v-for="(item,index) in activiList" :key="index" style="flex-direction: column;" :class="index===activiList.length-1?'marginB40':''">
  51. <view class="active-content-box-img margin-top-3">
  52. <view v-for="(img,indexImg) in item.pic_list" :key="indexImg" class="marginR5">
  53. <image :src="img.pic_url_resize" mode="aspectFill" @click="showLarge(item.pic_list,indexImg)"></image>
  54. </view>
  55. </view>
  56. <view class="edit-icon-box">
  57. <image src="/static/edit-icon.png" mode="aspectFit" v-if="item.edit_auth" @click="goEditPage(item.id)"></image>
  58. <image src="/static/del-icon.png" mode="aspectFit" v-if="item.del_auth" @click="delProcess(item.id)"></image>
  59. </view>
  60. </view> -->
  61. <button class="footer-box-record" @click="goFiles()">上传文件</button>
  62. </view>
  63. <view v-if="current == 2">
  64. <button class="footer-box-record" @click="goComment()">上传评论</button>
  65. </view>
  66. <share-modal @closeShare="closeShare" :isShowShare="isShowShareModal" :class="{ shareParent: isShowShareModal}"></share-modal>
  67. </view>
  68. </template>
  69. <script>
  70. import md5 from "@/common/md5.js";
  71. import shareModal from '@/components/share-modal/share-modal.vue'
  72. export default {
  73. components: {
  74. "share-modal": shareModal,
  75. },
  76. data() {
  77. return {
  78. isAuth:getApp().globalData.globalAuth,
  79. userHeadImg: getApp().globalData.user_headUrl,
  80. userNickName:getApp().globalData.user_name,
  81. globalUrl:getApp().globalData.shareUrl,
  82. activeId:'',
  83. branchId:'',
  84. recordId:'',
  85. activeDesc:{},
  86. activiList:[],
  87. fileObj:{},
  88. isShowShareModal:false,
  89. items:['记录','文件','评论'],
  90. current:0,
  91. };
  92. },
  93. onLoad(option) {
  94. this.recordId = option.id;
  95. this.readDesc(this.recordId);
  96. this.readActive(this.recordId);
  97. },
  98. onShow() {
  99. // this.readActive(this.recordId);
  100. //this.getFileList(this.recordId);
  101. },
  102. onShareAppMessage() {
  103. return {
  104. title: '农工笔记',
  105. path:'/pages/index/activity/activity'
  106. }
  107. },
  108. methods: {
  109. goEditPage(id){
  110. uni.navigateTo({
  111. url:'./record?id='+ id + '&bId=' + this.branchId + '&aId=' + this.activeId + '&types=edit'
  112. })
  113. },
  114. pageShowShare(obj,tabs){
  115. switch (tabs){
  116. case 'record':
  117. this.readActive(this.recordId)
  118. break;
  119. case 'files':
  120. this.getFileList(this.recordId)
  121. break;
  122. case 'comment':
  123. this.getCommentList(this.recordId)
  124. break;
  125. }
  126. this.isShowShareModal = true;
  127. },
  128. closeShare(e){
  129. this.isShowShareModal = false;
  130. },
  131. onClickItem(e){
  132. this.current = e.currentIndex;
  133. if(e.currentIndex == '0'){
  134. this.readActive(this.recordId)
  135. }
  136. if(e.currentIndex == '1'){
  137. this.getFileList(this.recordId)
  138. }
  139. if(e.currentIndex == '2'){
  140. this.getCommentList(this.recordId)
  141. }
  142. },
  143. //打开文件
  144. openFile(files){
  145. console.log(files)
  146. uni.downloadFile({
  147. url: files,
  148. success: function(res) {
  149. var filePath = res.tempFilePath;
  150. //打开文件有效值 doc, xls, ppt, pdf, docx, xlsx, pptx
  151. uni.openDocument({
  152. filePath:filePath,
  153. success: function(res) {
  154. console.log(res)
  155. //that.downloadFile_onoff = true;
  156. },
  157. fail(res) {
  158. console.log(res)
  159. uni.showToast({
  160. title: '暂不支持此类型',
  161. icon:'none',
  162. duration: 2000
  163. });
  164. //uni.hideLoading();
  165. //that.downloadFile_onoff = true;
  166. }
  167. });
  168. }
  169. });
  170. },
  171. showLarge(urlList,index) {
  172. let imgList = urlList,imgArr = [];
  173. imgList.forEach((item,index)=>{
  174. imgArr.push(item.pic_url)
  175. })
  176. uni.previewImage({
  177. urls:imgArr,
  178. current:imgArr[index],
  179. longPressActions: {
  180. itemList: ["发送给朋友", "保存图片"],
  181. success: function (data) {},
  182. fail: function (err) {
  183. console.log(err.errMsg);
  184. },
  185. },
  186. });
  187. },
  188. delProcessRequeset(delId){
  189. let md5Sign = md5(
  190. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  191. "&secret=" + getApp().globalData.secret
  192. );
  193. let url = getApp().globalData.shareUrl +"api/api.php" +
  194. "?method=activity&action=process_del&timestamp=" +
  195. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  196. uni.request({
  197. url: url,
  198. method: "POST",
  199. header: {
  200. "content-type": "application/x-www-form-urlencoded",
  201. },
  202. data: {
  203. openid: getApp().globalData.open_id,
  204. id:delId
  205. },
  206. success: (res) => {
  207. if (res.data.code === 200) {
  208. uni.showToast({
  209. title: "删除成功",
  210. icon: "none",
  211. duration: 2500,
  212. success:()=>{
  213. this.readActive(this.activeId)
  214. }
  215. });
  216. }
  217. },
  218. fail: () => {
  219. console.log("连接失败");
  220. },
  221. });
  222. },
  223. delProcess(id){
  224. let that = this;
  225. uni.showModal({
  226. title: "确定删除此记录吗?",
  227. success(res) {
  228. if (res.confirm) {
  229. that.delProcessRequeset(id);
  230. } else if (res.cancel) {
  231. console.log("用户点击取消");
  232. }
  233. },
  234. });
  235. },
  236. readDesc(id){
  237. let md5Sign = md5(
  238. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  239. "&secret=" + getApp().globalData.secret
  240. );
  241. let url = getApp().globalData.shareUrl +"api/api.php" +
  242. "?method=activity&action=info_by_id&timestamp=" +
  243. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  244. uni.request({
  245. url: url,
  246. method: "POST",
  247. header: {
  248. "content-type": "application/x-www-form-urlencoded",
  249. },
  250. data: {
  251. openid:getApp().globalData.open_id,
  252. id:id
  253. },
  254. success: (res) => {
  255. if (res.data.code === 200) {
  256. this.activeDesc = res.data.data;
  257. this.branchId = res.data.data.branch_id;
  258. this.activeId = res.data.data.id;
  259. }
  260. },
  261. fail: () => {
  262. console.log("连接失败");
  263. },
  264. });
  265. },
  266. getCommentList(id){
  267. let md5Sign = md5(
  268. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  269. "&secret=" + getApp().globalData.secret
  270. );
  271. let url = getApp().globalData.shareUrl +"api/api.php" +
  272. "?method=activity&action=comment_list&timestamp=" +
  273. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  274. uni.request({
  275. url: url,
  276. method: "POST",
  277. header: {
  278. "content-type": "application/x-www-form-urlencoded",
  279. },
  280. data: {
  281. openid:getApp().globalData.open_id,
  282. activity_id : id
  283. },
  284. success: (res) => {
  285. if (res.data.code === 200) {
  286. console.log(res.data.data)
  287. }
  288. },
  289. fail: () => {
  290. console.log("连接失败");
  291. },
  292. });
  293. },
  294. getFileList(id){
  295. let md5Sign = md5(
  296. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  297. "&secret=" + getApp().globalData.secret
  298. );
  299. let url = getApp().globalData.shareUrl +"api/api.php" +
  300. "?method=activity&action=files_list&timestamp=" +
  301. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  302. uni.request({
  303. url: url,
  304. method: "POST",
  305. header: {
  306. "content-type": "application/x-www-form-urlencoded",
  307. },
  308. data: {
  309. openid:getApp().globalData.open_id,
  310. activity_id : id
  311. },
  312. success: (res) => {
  313. if (res.data.code === 200) {
  314. console.log(res.data.data)
  315. }
  316. },
  317. fail: () => {
  318. console.log("连接失败");
  319. },
  320. });
  321. },
  322. readActive(id){
  323. let md5Sign = md5(
  324. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  325. "&secret=" + getApp().globalData.secret
  326. );
  327. let url = getApp().globalData.shareUrl +"api/api.php" +
  328. "?method=activity&action=process_list&timestamp=" +
  329. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  330. uni.request({
  331. url: url,
  332. method: "POST",
  333. header: {
  334. "content-type": "application/x-www-form-urlencoded",
  335. },
  336. data: {
  337. openid:getApp().globalData.open_id,
  338. activity_id:id
  339. },
  340. success: (res) => {
  341. if (res.data.code === 200) {
  342. let listArr = res.data.data.list;
  343. listArr.forEach((item)=>{
  344. item.pic_list.forEach((child)=>{
  345. child.pic_url = this.globalUrl + child.pic_url;
  346. child.pic_url_resize = this.globalUrl + child.pic_url_resize;
  347. })
  348. })
  349. this.activiList = listArr;
  350. }
  351. },
  352. fail: () => {
  353. console.log("连接失败");
  354. },
  355. });
  356. },
  357. tonewurl(urls) {
  358. uni.setClipboardData({
  359. data: urls,
  360. success: function (res) {
  361. uni.showToast({
  362. title: '复制成功,请在手机浏览器中打开',
  363. icon:"none"
  364. });
  365. }
  366. })
  367. // uni.navigateTo({
  368. // url:'/pages/index/webview/web-view?url=' + urls
  369. // });
  370. },
  371. goRecord(){
  372. uni.navigateTo({
  373. url:'./record?bId=' + this.branchId + '&aId=' + this.activeId + '&types=add'
  374. })
  375. },
  376. goFiles(){
  377. uni.navigateTo({
  378. url:'./files?bId=' + this.branchId + '&aId=' + this.activeId + '&types=add'
  379. })
  380. },
  381. goComment(){
  382. uni.navigateTo({
  383. url:'./comment?bId=' + this.branchId + '&aId=' + this.activeId + '&types=add'
  384. })
  385. },
  386. },
  387. };
  388. </script>
  389. <style lang="scss" scoped>
  390. .content {
  391. display: flex;
  392. flex-direction: column;
  393. .self-inf {
  394. // border-radius: 0rpx 0rpx 100% 100%;
  395. .img-name-box {
  396. height: 150rpx;
  397. margin-top: 20rpx;
  398. margin-bottom: 20rpx;
  399. display: flex;
  400. align-items: center;
  401. width: 85%;
  402. .auth-btn {
  403. margin-left: 30rpx;
  404. margin-top: 20rpx;
  405. font-size: 28rpx;
  406. background-color: #02a7f0;
  407. color: #fff;
  408. }
  409. .heade-img {
  410. z-index: 1;
  411. width: 100rpx;
  412. height: 100rpx;
  413. border-radius: 50%;
  414. // margin-left: 80rpx;
  415. }
  416. }
  417. .nickname {
  418. font-weight: 600;
  419. font-size: 28rpx;
  420. margin-left: 30rpx;
  421. margin-top: 20rpx;
  422. color: #555;
  423. letter-spacing: 1rpx;
  424. }
  425. }
  426. }
  427. .org-info-box {
  428. display: flex;
  429. justify-content: space-evenly;
  430. height: 80rpx;
  431. align-items: center;
  432. width: 100%;
  433. border-top: 1px solid #d4d4d4;
  434. color: #555;
  435. font-size: 28rpx;
  436. background: #fff;
  437. }
  438. .org-line {
  439. width: 1px;
  440. height: 82rpx;
  441. background: #d4d4d4;
  442. }
  443. .header-title {
  444. margin-top: 3%;
  445. margin-bottom: 1%;
  446. font-size: 32rpx;
  447. font-weight: bold
  448. }
  449. .active-title-box {
  450. padding-left: 3%;
  451. font-size: 26rpx;
  452. height: 100rpx;
  453. border-bottom: 4px solid #eeeeee;
  454. .time-select-box {
  455. width: 32%;
  456. margin-left: 5%;
  457. }
  458. picker {
  459. width: 25%;
  460. border: 1px solid #d7d7d7;
  461. height: 60rpx;
  462. line-height: 60rpx;
  463. border-radius: 10rpx;
  464. margin-left: 20rpx;
  465. padding: 0 10rpx;
  466. position: relative;
  467. image {
  468. width: 20rpx;
  469. height: 20rpx;
  470. position: absolute;
  471. top: 11px;
  472. right: 5px;
  473. }
  474. }
  475. button {
  476. width: 24%;
  477. font-size: 25rpx;
  478. background: #4988fd;
  479. color: #fff;
  480. margin-left: 25rpx;
  481. }
  482. }
  483. .margin-top-3 {
  484. margin-top: 3%;
  485. }
  486. .active-box {
  487. display: flex;
  488. position: relative;
  489. font-size: 28rpx;
  490. padding: 20rpx;
  491. width: 92%;
  492. margin-left: 1.5%;
  493. margin-bottom: 1%;
  494. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  495. .active-header {
  496. display: flex;
  497. width: 100%;
  498. }
  499. .active-type {
  500. width: 100rpx;
  501. height: 100rpx;
  502. border-radius: 50%;
  503. background-color: #ccc;
  504. text-align: center;
  505. display: flex;
  506. align-items: center;
  507. font-size: 26rpx;
  508. color: #fff;
  509. }
  510. .active-content-box{
  511. display: flex;
  512. flex-direction: column;
  513. // margin-left: 20rpx;
  514. }
  515. .active-content-box-img {
  516. display: flex;
  517. justify-content: flex-start;
  518. flex-wrap: wrap;
  519. image {
  520. width: 220rpx;
  521. height: 300rpx;
  522. }
  523. }
  524. .active-content {
  525. display: flex;
  526. align-items: center;
  527. // height: 45rpx;
  528. font-size: 26rpx;
  529. .active-title {
  530. font-size: 28rpx;
  531. margin-right: 10rpx;
  532. font-weight: bold;
  533. }
  534. .active-name {
  535. font-size: 26rpx;
  536. margin-right: 10rpx;
  537. }
  538. .active-date {
  539. color: #ccc;
  540. }
  541. }
  542. .edit-icon-box {
  543. position: absolute;
  544. right: 10px;
  545. top: 10px;
  546. image {
  547. width: 35rpx;
  548. height: 35rpx;
  549. margin-right: 10rpx;
  550. }
  551. }
  552. .bg-yellow {
  553. background-color: #ffdd40;
  554. }
  555. .bg-red {
  556. background-color: #ec808d;
  557. }
  558. .bg-blue {
  559. background-color: #81d3f8;
  560. }
  561. }
  562. .marginB40 {
  563. margin-bottom: 80rpx;
  564. }
  565. .marginR5{
  566. margin-right: 5rpx;
  567. }
  568. .footer-box-record{
  569. position: fixed;
  570. bottom: 0;
  571. background-color:#f59a23;
  572. width: 100%;
  573. border-radius: 0;
  574. color: #fff;
  575. font-size: 32rpx;
  576. }
  577. .img-container{
  578. display: flex;
  579. flex-direction: column;
  580. width: 90%;
  581. margin: 3% auto;
  582. font-size: 26rpx;
  583. label {
  584. width: 20%;
  585. margin-left: 2%;
  586. margin-bottom: 2%;
  587. }
  588. .note-image-box{
  589. width: 75%;
  590. display: flex;
  591. flex-wrap: wrap;
  592. .note-image-item{
  593. position: relative;
  594. //这两个百分比很关键
  595. width: 33.33%;
  596. height: 0;
  597. padding-top: 33.33%;
  598. box-sizing: border-box;
  599. .close-icon{
  600. display: flex;
  601. justify-content: center;
  602. align-items: center;
  603. position: absolute;
  604. right: 0;
  605. top: 0;
  606. width: 22px;
  607. height: 22px;
  608. border-radius: 50%;
  609. background-color: #d5d5d5;
  610. z-index: 2;
  611. }
  612. .image-box{
  613. display: flex;
  614. justify-content: center;
  615. align-items: center;
  616. position: absolute;
  617. top: 5px;
  618. right: 5px;
  619. bottom: 5px;
  620. left: 5px;
  621. border: 1px #eee solid;
  622. border-radius: 5px;
  623. overflow: hidden;
  624. image{
  625. width: 100%;
  626. height: 100%;
  627. }
  628. }
  629. }
  630. }
  631. }
  632. </style>