list.vue 14 KB

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