list.vue 16 KB

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