need.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. <template>
  2. <view>
  3. <tn-nav-bar fixed customBack>
  4. <view slot="back" class='tn-custom-nav-bar__back' @click="goBack">
  5. <text class='icon tn-icon-left'></text>
  6. </view>
  7. <view slot="default">
  8. <text :style="{fontSize:(wxFontSize)+'px'}">我的需求</text>
  9. </view>
  10. </tn-nav-bar>
  11. <view :style="{paddingTop: vuex_custom_bar_height + 'px'}">
  12. <uv-sticky :offsetTop="vuex_custom_bar_height + 'px'" bgColor="#ffffff">
  13. <tn-tabs-swiper :list="list" :isScroll="false" :current="current" name="tab-name" @change="tabChange"
  14. style="border-bottom: 1rpx solid #f1f1f1cc;" :fontSize="(wxFontSize+12)" :barWidth="wxFontSize+50"></tn-tabs-swiper>
  15. </uv-sticky>
  16. <!-- 图文信息 -->
  17. <block v-for="(item,index) in content" :key="index">
  18. <view class="blogger__item">
  19. <view class="blogger__author tn-flex tn-flex-row-between tn-flex-col-center">
  20. <view class="justify__author__info">
  21. <view class="tn-flex tn-flex-row-center">
  22. <view class="tn-flex tn-flex-row-center tn-flex-col-center">
  23. <!-- <view class="">
  24. <tn-avatar class="" shape="circle" :src="item.userAvatar" size="lg">
  25. </tn-avatar>
  26. </view> -->
  27. <view class="tn-padding-right tn-text-ellipsis">
  28. <view class="tn-padding-right tn-text-bold tn-text-lg" :style="{fontSize:(wxFontSize)+'px'}">
  29. {{ item.company }}
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view v-if="item.status=='4'&&item.showFlag=='否'"
  36. class="blogger__author__btn justify-content-item tn-flex-col-center tn-flex-row-center">
  37. <text class="" style="background: #3F51B542;font-size: 12px;
  38. padding: 8px;
  39. color: #333333;
  40. border-radius: 24px;
  41. " :style="{fontSize:(wxFontSize-6)+'px'}">需求已结束</text>
  42. </view>
  43. <!-- 状态(1:暂存,2:待处理,3:审核中,4:已通过,9:已拒绝,10:已取消) -->
  44. <view v-if="item.status=='1'"
  45. class="blogger__author__btn justify-content-item tn-flex-col-center tn-flex-row-center">
  46. <text class="" style="background: #3F51B542;font-size: 12px;
  47. padding: 8px;
  48. color: #333333;
  49. border-radius: 24px;
  50. " :style="{fontSize:(wxFontSize-6)+'px'}">暂存</text>
  51. </view>
  52. <view v-if="item.status=='3'"
  53. class="blogger__author__btn justify-content-item tn-flex-col-center tn-flex-row-center">
  54. <text class="" style="background: #3f51b56b;font-size: 12px;
  55. padding: 8px;
  56. color: #ff0;
  57. border-radius: 24px;
  58. " :style="{fontSize:(wxFontSize-6)+'px'}">审核中</text>
  59. </view>
  60. <view v-if="item.status=='4'&&item.showFlag!='否'"
  61. class="blogger__author__btn justify-content-item tn-flex-col-center tn-flex-row-center">
  62. <text class="" style="background: #3F51B542;font-size: 12px;
  63. padding: 8px;
  64. color: #007000;
  65. border-radius: 24px;
  66. " :style="{fontSize:(wxFontSize-6)+'px'}">已通过</text>
  67. </view>
  68. <view v-if="item.status=='9'"
  69. class="blogger__author__btn justify-content-item tn-flex-col-center tn-flex-row-center">
  70. <text class="" style="background: #3F51B542;font-size: 12px;
  71. padding: 8px;
  72. color: #d23920;
  73. border-radius: 24px;
  74. " @click="showTips(item)" :style="{fontSize:(wxFontSize-6)+'px'}">已拒绝</text>
  75. </view>
  76. <view v-if="item.status=='10'"
  77. class="blogger__author__btn justify-content-item tn-flex-col-center tn-flex-row-center">
  78. <text class="" style="background: #3F51B542;font-size: 12px;
  79. padding: 8px;
  80. color: #333333;
  81. border-radius: 24px;
  82. " :style="{fontSize:(wxFontSize-6)+'px'}">已取消</text>
  83. </view>
  84. </view>
  85. <view
  86. class="blogger__desc tn-margin-top-sm tn-margin-bottom-sm tn-text-justify tn-flex-col-center tn-flex-row-left"
  87. @click="tn('')">
  88. <text
  89. class="blogger__desc__content tn-flex-1 tn-text-justify tn-text-df" :style="{fontSize:(wxFontSize-2)+'px'}">{{ item.content }}</text>
  90. </view>
  91. <block v-if="item.imgList">
  92. <view v-if="[1,2,4].indexOf(item.imgList.length) != -1" class="tn-padding-top-xs"
  93. @click="tn('')">
  94. <image v-for="(image_item,image_index) in item.imgList" :key="image_index"
  95. class="blogger__main-image" :class="{
  96. 'blogger__main-image--1 tn-margin-bottom-sm': item.imgList.length === 1,
  97. 'blogger__main-image--2 tn-margin-right-sm tn-margin-bottom-sm': item.imgList.length === 2 || item.imgList.length === 4
  98. }" :src="image_item.ftpUrl" mode="aspectFill" @click="showImg(item.imgList,image_index)"></image>
  99. </view>
  100. <view v-else class="tn-padding-top-xs">
  101. <tn-grid hoverClass="none" :col="3">
  102. <block v-for="(image_item,image_index) in item.imgList" :key="image_index">
  103. <!-- #ifndef MP-WEIXIN -->
  104. <tn-grid-item style="width: 30%;margin: 10rpx;">
  105. <image class="blogger__main-image blogger__main-image--3"
  106. @click="showImg(item.imgList,image_index)" :src="image_item.ftpUrl"
  107. mode="aspectFill"></image>
  108. </tn-grid-item>
  109. <!-- #endif-->
  110. <!-- #ifdef MP-WEIXIN -->
  111. <tn-grid-item style="width: 30%;margin: 10rpx;">
  112. <image class="blogger__main-image blogger__main-image--3"
  113. @click="showImg(item.imgList,image_index)" :src="image_item.ftpUrl"
  114. mode="aspectFill"></image>
  115. </tn-grid-item>
  116. <!-- #endif-->
  117. </block>
  118. </tn-grid>
  119. </view>
  120. </block>
  121. <view v-for="file in item.fileDetailList" :key="file.id" v-if="!isImage(file.fileName)">
  122. <view>
  123. <text class="tn-icon-link" :style="{fontSize:(wxFontSize-4)+'px'}"></text>
  124. <view style="display: inline;margin-left:8px" @click="clickLink(file.ftpUrl,file.fileName)" :style="{fontSize:(wxFontSize-3)+'px'}">
  125. {{file.fileName}}
  126. </view>
  127. </view>
  128. </view>
  129. <view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin-top-xs">
  130. <view class="justify-content-item tn-color-gray">
  131. <view class="tn-padding-right tn-padding-top-xs tn-color-gray" style="display: flex;">
  132. <view style="white-space: nowrap;">{{ item.createTime|formatDate }}</view>
  133. <view style="color: red;margin-left:8px;" v-if="item.status==9&&item.feedback" :style="{fontSize:(wxFontSize-3)+'px'}">
  134. 反馈意见:{{item.feedback||'--'}}
  135. </view>
  136. </view>
  137. </view>
  138. <view class="justify-content-item tn-flex tn-flex-col-center" v-if="item.status==4&&item.showFlag!='否'">
  139. <button type="warn" plain="true" size="mini" @click="finishItem(item)">结束需求</button>
  140. <!-- <tn-button shadow shape="round" fontColor="tn-color-white" backgroundColor="tn-bg-blue"
  141. :fontSize="24" height="auto" padding="10rpx 18rpx"
  142. @click="finishItem(item)">结束需求</tn-button> -->
  143. </view>
  144. <view class="justify-content-item tn-flex tn-flex-col-center" style="flex: none;" v-if="item.status==1||item.status==9">
  145. <button type="warn" plain="true" size="mini" @click="editItem(item)">编辑</button>
  146. <!-- <tn-button shadow shape="round" fontColor="tn-color-white" backgroundColor="tn-bg-blue"
  147. :fontSize="24" height="auto" padding="10rpx 18rpx"
  148. @click="finishItem(item)">结束需求</tn-button> -->
  149. </view>
  150. </view>
  151. </view>
  152. <!-- 边距间隔 -->
  153. <view class="tn-strip-bottom" v-if="index != content.length - 1"></view>
  154. </block>
  155. <view v-if="showEmpty" style="margin-top: 32vh;">
  156. <tn-empty mode="data"></tn-empty>
  157. </view>
  158. </view>
  159. <uni-popup ref="alertDialog" type="dialog">
  160. <uni-popup-dialog type="info" cancelText="关闭" confirmText="确定" title="结束确认" content="确定结束需求吗"
  161. @confirm="dialogConfirm"></uni-popup-dialog>
  162. </uni-popup>
  163. </view>
  164. </template>
  165. <script>
  166. import request from '../../utils/request'
  167. import {
  168. uniShowModal
  169. } from '../../utils/uni_api'
  170. export default {
  171. data() {
  172. return {
  173. list: [{
  174. 'tab-name': '已通过'
  175. }, {
  176. 'tab-name': '审核中'
  177. }, {
  178. 'tab-name': '暂存'
  179. }, {
  180. 'tab-name': '已拒绝'
  181. }],
  182. current: 0,
  183. content: [],
  184. showEmpty: false,
  185. curItem: {},
  186. wxFontSize:17
  187. }
  188. },
  189. filters: {
  190. formatDate(value) {
  191. if (!value) return '';
  192. const date = new Date(value);
  193. const today = new Date();
  194. const yesterday = new Date(today); // 昨天的日期
  195. yesterday.setDate(yesterday.getDate() - 1); // 将昨天的日期设置为前一天
  196. if (date.getFullYear() == today.getFullYear() && date.getMonth() == today.getMonth() && date.getDate() ==
  197. today.getDate()) {
  198. return '今天 ' + (date.getHours() > 9 ? '' : '0') + date.getHours() + ':' + (date
  199. .getMinutes() > 9 ? '' : '0') + date.getMinutes(); // 根据需要格式化日期
  200. }
  201. if (date.getFullYear() == yesterday.getFullYear() && date.getMonth() == yesterday.getMonth() && date
  202. .getDate() == yesterday.getDate()) {
  203. return '昨天 ' + (date.getHours() > 9 ? '' : '0') + date.getHours() + ':' + (date
  204. .getMinutes() > 9 ? '' : '0') + date.getMinutes(); // 根据需要格式化日期
  205. }
  206. return date.toLocaleDateString() + ' ' + (date.getHours() > 9 ? '' : '0') + date.getHours() + ':' + (date
  207. .getMinutes() > 9 ? '' : '0') + date.getMinutes(); // 根据需要格式化日期
  208. },
  209. },
  210. onLoad(props){
  211. const appBaseInfo = wx.getAppBaseInfo();
  212. this.wxFontSize = uni.getStorageSync('fontSize')||appBaseInfo.fontSizeSetting||17;
  213. if(props.tab==1){
  214. this.current= 1;
  215. }
  216. if(props.tab==2){
  217. this.current= 2;
  218. }
  219. },
  220. onShow() {
  221. this.loadData();
  222. },
  223. methods: {
  224. showTips(item){
  225. uni.showToast({
  226. title: item.feedback?item.feedback:'已拒绝',
  227. icon: 'none',
  228. })
  229. },
  230. goBack() {
  231. const pages = getCurrentPages()
  232. // 有可返回的页面则直接返回,uni.navigateBack 默认返回失败之后会自动刷新页面 ,无法继续返回
  233. if (pages.length > 1) {
  234. uni.navigateBack()
  235. return;
  236. }else{
  237. uni.navigateTo({
  238. url: '/pages/index/index'
  239. })
  240. }
  241. },
  242. tabChange(index) {
  243. this.current = index;
  244. this.loadData();
  245. },
  246. isImage(fileName) {
  247. const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'ico']
  248. const extension = fileName.split('.').pop().toLowerCase();
  249. return imageExtensions.includes(extension);
  250. },
  251. loadData() {
  252. let that = this;
  253. that.content = [];
  254. request.post('/slbResourceDemand/show/my', {
  255. userNo: uni.getStorageSync('userNo'),
  256. // 状态(1:暂存,2:待处理,3:审核中,4:已通过,9:已拒绝,10:已取消)
  257. status: that.current == 1 ? '3' : that.current == 2 ? '1' : that.current == 3 ? '9' : '4',
  258. limit: 1000,
  259. index: 1
  260. }).then(res => {
  261. if (res && res.success) {
  262. let newList = res.list || [];
  263. for (let i = 0; i < newList.length; i++) {
  264. newList[i].imgList = [];
  265. for (let j = 0; j < newList[i].fileDetailList.length; j++) {
  266. if (that.isImage(newList[i].fileDetailList[j].fileName)) {
  267. newList[i].imgList.push(newList[i].fileDetailList[j]);
  268. }
  269. }
  270. }
  271. that.content = newList;
  272. if (newList.length == 0) {
  273. that.showEmpty = true;
  274. } else {
  275. that.showEmpty = false;
  276. }
  277. }else{
  278. if(res._redirect){
  279. uni.showToast({
  280. title: '操作过期,请重试',
  281. duration: 2000,
  282. icon:'none'
  283. });
  284. that.goBack();
  285. }
  286. }
  287. console.warn(res);
  288. })
  289. },
  290. dialogConfirm() {
  291. let item = this.curItem;
  292. let that = this;
  293. request.post('/slbResourceDemand/offShelf', {
  294. id: item.id,
  295. userNo: uni.getStorageSync('userNo'),
  296. }).then(res => {
  297. if (res.success) {
  298. uni.showToast({
  299. title: '结束成功'
  300. })
  301. that.loadData();
  302. } else {
  303. uni.showToast({
  304. title: res.msg,
  305. icon: 'none'
  306. })
  307. }
  308. })
  309. },
  310. finishItem(item) {
  311. this.curItem = item;
  312. let that = this;
  313. uniShowModal('确定结束需求吗?', '', {
  314. showCancel: true,
  315. confirmText:'确定',
  316. success: (res) => {
  317. if(res.confirm){
  318. that.dialogConfirm();
  319. }
  320. }
  321. })
  322. },
  323. showImg(items, index) {
  324. let urls = [];
  325. for (let i = 0; i < items.length; i++) {
  326. urls.push(items[i].ftpUrl);
  327. }
  328. // 预览图片
  329. uni.previewImage({
  330. urls: urls,
  331. current: index,
  332. });
  333. },
  334. clickLink(url,fileName) {
  335. // uni.navigateTo({
  336. // url:'/pages/webview/web-view?url='+encodeURIComponent('https://slb-m.lx-device.com/webview?title='+fileName+'&url='+ url),
  337. // })
  338. uni.downloadFile({
  339. url: url,
  340. filePath: wx.env.USER_DATA_PATH + "/" + fileName,
  341. success: function (res) {
  342. const filePath = res.filePath
  343. uni.openDocument({
  344. filePath: filePath,
  345. showMenu: true,
  346. success: function (res) {
  347. console.log('打开文档成功')
  348. },
  349. fail: function(){
  350. uni.navigateTo({
  351. url:'/pages/webview/web-view?url='+encodeURIComponent('https://slb-m.lx-device.com/webview?title='+fileName+'&url='+ url),
  352. })
  353. }
  354. })
  355. }
  356. })
  357. },
  358. editItem(item){
  359. uni.setStorageSync(item.bisNo,JSON.stringify(item))
  360. uni.navigateTo({
  361. url: '/circlePages/circle?sid=' + item.bisNo,
  362. })
  363. }
  364. }
  365. }
  366. </script>
  367. <style lang="scss" scoped>
  368. /* 胶囊*/
  369. .tn-custom-nav-bar__back {
  370. width: 60%;
  371. height: 100%;
  372. position: relative;
  373. display: flex;
  374. justify-content: space-evenly;
  375. align-items: center;
  376. box-sizing: border-box;
  377. // background-color: rgba(0, 0, 0, 0.15);
  378. border-radius: 1000rpx;
  379. // border: 1rpx solid rgba(255, 255, 255, 0.5);
  380. // color: #FFFFFF;
  381. font-size: 18px;
  382. .icon {
  383. display: block;
  384. flex: 1;
  385. margin: auto;
  386. text-align: center;
  387. }
  388. &:before {
  389. content: " ";
  390. width: 1rpx;
  391. height: 110%;
  392. position: absolute;
  393. top: 22.5%;
  394. left: 0;
  395. right: 0;
  396. margin: auto;
  397. transform: scale(0.5);
  398. transform-origin: 0 0;
  399. pointer-events: none;
  400. box-sizing: border-box;
  401. opacity: 0.7;
  402. background-color: #FFFFFF;
  403. }
  404. }
  405. /* 文章内容 start*/
  406. .blogger {
  407. &__item {
  408. padding: 30rpx;
  409. }
  410. &__author {
  411. &__btn {
  412. margin-right: -12rpx;
  413. opacity: 0.5;
  414. }
  415. }
  416. &__desc {
  417. line-height: 30rpx;
  418. &__label {
  419. color: #1D2541;
  420. background-color: #F3F2F7;
  421. border-radius: 10rpx;
  422. font-size: 22rpx;
  423. padding: 5rpx 15rpx;
  424. margin: 5rpx 18rpx 0 0;
  425. &--prefix {
  426. font-size: 24rpx;
  427. color: #1D2541;
  428. padding-right: 10rpx;
  429. }
  430. }
  431. &__content {
  432. line-height: 50rpx;
  433. }
  434. }
  435. &__content {
  436. margin-top: 18rpx;
  437. padding-right: 18rpx;
  438. &__data {
  439. line-height: 46rpx;
  440. text-align: justify;
  441. overflow: hidden;
  442. transition: all 0.25s ease-in-out;
  443. }
  444. &__status {
  445. margin-top: 10rpx;
  446. font-size: 26rpx;
  447. color: #82B2FF;
  448. }
  449. }
  450. &__main-image {
  451. border: 1rpx solid #F8F7F8;
  452. border-radius: 16rpx;
  453. &--1 {
  454. max-width: 80%;
  455. max-height: 300rpx;
  456. }
  457. &--2 {
  458. max-width: 260rpx;
  459. max-height: 260rpx;
  460. }
  461. &--3 {
  462. height: 212rpx;
  463. width: 100%;
  464. }
  465. }
  466. &__count-icon {
  467. font-size: 40rpx;
  468. padding-right: 5rpx;
  469. }
  470. &__ad {
  471. width: 100%;
  472. height: 500rpx;
  473. transform: translate3d(0px, 0px, 0px) !important;
  474. ::v-deep .uni-swiper-slide-frame {
  475. transform: translate3d(0px, 0px, 0px) !important;
  476. }
  477. .uni-swiper-slide-frame {
  478. transform: translate3d(0px, 0px, 0px) !important;
  479. }
  480. &__item {
  481. position: absolute;
  482. width: 100%;
  483. height: 100%;
  484. transform-origin: left center;
  485. transform: translate3d(100%, 0px, 0px) scale(1) !important;
  486. transition: transform 0.25s ease-in-out;
  487. z-index: 1;
  488. &--0 {
  489. transform: translate3d(0%, 0px, 0px) scale(1) !important;
  490. z-index: 4;
  491. }
  492. &--1 {
  493. transform: translate3d(13%, 0px, 0px) scale(0.9) !important;
  494. z-index: 3;
  495. }
  496. &--2 {
  497. transform: translate3d(26%, 0px, 0px) scale(0.8) !important;
  498. z-index: 2;
  499. }
  500. }
  501. &__content {
  502. border-radius: 40rpx;
  503. width: 640rpx;
  504. height: 500rpx;
  505. overflow: hidden;
  506. }
  507. &__image {
  508. width: 100%;
  509. height: 100%;
  510. }
  511. }
  512. }
  513. /* 文章内容 end*/
  514. /* 间隔线 start*/
  515. .tn-strip-bottom {
  516. width: 100%;
  517. border-bottom: 20rpx solid rgba(241, 241, 241, 0.8);
  518. }
  519. /* 间隔线 end*/
  520. </style>