businessNew.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. <template>
  2. <view>
  3. <!-- <input class="uni-input" focus placeholder="自动获得焦点" /> -->
  4. <view v-if="!isShowSearch">
  5. <view class="top-warp">
  6. <view class="search">
  7. <view class="place">
  8. <selectAddress @selectAddress='selectAddress' :searchPlace='searchPlace'>
  9. <u-icon :slot="'icon'" name="arrow-down" color="#333333" size="17" bold
  10. style='margin-left: 6rpx;'></u-icon>
  11. </selectAddress>
  12. <!-- <picker @change="bindPickerChange" :value="multiIndex" :range="multiArray" range-key='label'
  13. mode="multiSelector" @columnchange='columnchange'>
  14. <view class="text">{{searchPlace}}</view>
  15. </picker> -->
  16. </view>
  17. <u-search placeholder="请输入作物名称或用户名称" v-model="keyword" :input-style='inputStyle'
  18. :show-action="false" disabled @click='toSearch'>
  19. </u-search>
  20. <view class="del" @click.stop='delIcon' v-if="keyword">
  21. <u-icon name="close-circle" size="40" color="#999"></u-icon>
  22. </view>
  23. </view>
  24. <me-tabs v-model="tabIndex" :tabs="tabs" @change="tabChange"></me-tabs>
  25. </view>
  26. <mescroll-body ref="mescrollRef" @init="mescrollInit" top="180" @down="downCallback" :up="upOption"
  27. @up="upCallback" @emptyclick="emptyClick" :bottombar="false">
  28. <!-- 数据列表 -->
  29. <view class="list" v-if="goods.length!=0">
  30. <view class="list-item" v-for="(item,index) in goods">
  31. <view class="row1 flex jcsb alc">
  32. <view class="left flex alc">
  33. <image
  34. :src="item.commonUser.avatarUrl?item.commonUser.avatarUrl:'../../static/img/myimg/YongHu@3x.png'"
  35. mode="widthFix" class="head-img"></image>
  36. <view class="">
  37. <view class="title">
  38. {{item.publisher}}
  39. </view>
  40. <view class="bottom" style="margin-top: 6rpx;">
  41. <text class="color1" v-if="item.tranType=='采购'">采购</text>
  42. <text class="color2" v-if="item.tranType=='销售'">销售</text>
  43. <text class="color3">{{item.remark3?$helper.changeTime(item.remark3):''}}</text>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="right"
  48. v-if="item.followed==1&&item.commonUser&&item.commonUser.userName!=userInfo.userName"
  49. @click="follow(item,1)">
  50. <text class="case" style="color:#878C9C;">已关注</text>
  51. </view>
  52. <view class="right"
  53. v-else-if='item.followed!=1&&item.commonUser&&item.commonUser.userName!=userInfo.userName'
  54. @click="follow(item,2)">
  55. <u-icon name="plus" color="#333333" size="17" bold></u-icon><text class="case">关注</text>
  56. </view>
  57. </view>
  58. <view class="row2">
  59. <mote-lines-divide :dt="item.publishingContent" :line="8" expandText="展开" foldHint="收起" />
  60. </view>
  61. <view class="row3">
  62. <image :src="item1" mode="aspectFill" v-for="(item1,index) in item.imgList"
  63. @tap="previewImage(item,index)" class="img">
  64. </image>
  65. <image v-if='item.imgList&&item.imgList.length%3==1||item.imgList&&item.imgList.length%3==2'
  66. class="img" style='background:#fff;'></image>
  67. <image v-if='item.imgList&&item.imgList.length%3==1' class="img" style='background:#fff;'>
  68. </image>
  69. <!-- <u-row justify="space-between" gutter="10">
  70. <u-col span="4">
  71. <view class="demo-layout bg-purple">
  72. <image src="../../static/img/liangmai/bg.png" mode="aspectFill"
  73. style="width: 100%;height: 100%;"></image>
  74. </view>
  75. </u-col>
  76. <u-col span="4">
  77. <view class="demo-layout bg-purple-light">
  78. <image src="../../static/img/liangmai/bg.png" mode="aspectFill"
  79. style="width: 100%;height: 100%;"></image>
  80. </view>
  81. </u-col>
  82. <u-col span="4">
  83. <view class="demo-layout bg-purple">
  84. <image src="../../static/img/liangmai/bg.png" mode="aspectFill"
  85. style="width: 100%;height: 100%;"></image>
  86. </view>
  87. </u-col>
  88. </u-row> -->
  89. </view>
  90. <view class="row4">
  91. <u-icon name="map-fill" color="#AFB3BF" size="28" bold></u-icon>
  92. <text class="text">{{item.placeDelivery}}</text>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- <good-list :list="goods"></good-list> -->
  97. </mescroll-body>
  98. <view class="add" @click="release">
  99. <u-icon name="plus" color="#fff" size="34" bold></u-icon>
  100. </view>
  101. <u-modal v-model="show" content="确定不在关注?" :show-title='false' :show-cancel-button='true'
  102. :content-style="contentStyle" @confirm="cancelFollow" @cancel="show=false">
  103. </u-modal>
  104. </view>
  105. <!-- <search v-show="isShowSearch" @searchVal='searchVal'></search> -->
  106. <u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
  107. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='提示'
  108. content="尚未登录,是否立即登录" @confirm="alertBtn" @cancel="cancelClick"></u-modal>
  109. <!-- <u-modal v-model="isSHowReleaseAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
  110. :content-style="{fontSize: '14px',fontWeight:'400','text-align':'left'}" confirm-color='#22C572'
  111. confirm-text='我知道了' title='温馨提示' content="交易信息为用户自由发布,正式签订合同前切勿进行任何付款操作,以免给您的财产造成损失。"
  112. @confirm="releaseAlertbtn"></u-modal> -->
  113. <u-toast ref="uToast" />
  114. </view>
  115. </template>
  116. <script>
  117. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  118. import MoteLinesDivide from "@/components/text-over-flow"
  119. import selectAddress from "@/components/selectAddress.vue"
  120. import search from "@/components/search.vue"
  121. import {
  122. apiGoods
  123. } from "@/api/mock.js"
  124. import {
  125. mapState
  126. } from 'vuex';
  127. export default {
  128. components: {
  129. MoteLinesDivide,
  130. selectAddress,
  131. search
  132. },
  133. mixins: [MescrollMixin], // 使用mixin
  134. data() {
  135. return {
  136. searchPlace: '全国',
  137. selectType: '',
  138. isSHowReleaseAlert: null,
  139. canReset: false,
  140. focus:false,
  141. selectPlace: '',
  142. mescroll: null,
  143. isShowAlert: false,
  144. contentStyle: {
  145. "font-weight": 700
  146. },
  147. isShowSearch: false,
  148. selectItem: {
  149. followInformation:{
  150. id:''
  151. }
  152. },
  153. show: false,
  154. keyword: '',
  155. inputStyle: {
  156. // "padding-left": '30rpx'
  157. },
  158. content: '',
  159. upOption: {
  160. // page: {
  161. // num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  162. // size: 10 // 每页数据的数量
  163. // },
  164. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  165. empty: {
  166. // icon: '/static/empty.png',
  167. tip: '暂无内容', // 提示
  168. // btnText: '去看看'
  169. },
  170. textNoMore: '没有更多了~',
  171. textColor: '#878C9C',
  172. toTop: {
  173. src: "",
  174. },
  175. },
  176. goods: [], //列表数据
  177. tabs: [{
  178. name: '全部',
  179. type: 'xx'
  180. }, {
  181. name: '采购',
  182. type: 'xx'
  183. }, {
  184. name: '销售',
  185. type: 'xx'
  186. }, {
  187. name: '关注',
  188. type: 'xx'
  189. }],
  190. tabbar: true,
  191. windowHeight: '',
  192. tabIndex: 0 // tab下标
  193. }
  194. },
  195. computed: {
  196. ...mapState(['hasLogin', 'userInfo', 'clientId']),
  197. },
  198. onLoad() {
  199. // uni.getSystemInfo({
  200. // success: (res)=> {
  201. // this.windowHeight = res.windowHeight;
  202. // }
  203. // });
  204. // uni.onWindowResize((res) => {
  205. // if(res.size.windowHeight < this.windowHeight){
  206. // uni.hideTabBar()
  207. // }else{
  208. // uni.showTabBar()
  209. // }
  210. // })
  211. },
  212. onShow() {
  213. if(uni.getStorageSync('jiaoyikeyword')){
  214. this.keyword=uni.getStorageSync('jiaoyikeyword')
  215. }else{
  216. this.keyword=''
  217. }
  218. let _tl = uni.getStorageSync('transactionLocation')
  219. if (_tl) {
  220. this.searchPlace = _tl.showVal
  221. this.selectPlace = _tl.address
  222. } else {
  223. }
  224. this.isSHowReleaseAlert = getApp().globalData.userRelease
  225. // console.log("this.isSHowReleaseAlert", this.isSHowReleaseAlert)
  226. uni.showTabBar()
  227. uni.hideKeyboard()
  228. var userInfo = uni.getStorageSync("userInfo")
  229. var that = this
  230. console.log("userInfo", userInfo)
  231. // setTimeout(function() {
  232. // that.$api.doRequest('get', '/appVersion/test', {
  233. // userId: "7e83070d05fc4d50aaa46e00a3ee03d8"
  234. // }).then(res => {
  235. // })
  236. // }, 500);
  237. uni.removeTabBarBadge({
  238. index: 4
  239. })
  240. this.$api.doRequest('get', '/newNoticeTask/query/noticeTasks').then(res => {
  241. if (res.data.data) {
  242. let name = 'myTip';
  243. let value = res.data.data.total;
  244. that.$store.commit('$uStore', {
  245. name,
  246. value
  247. });
  248. if (value != 0 && value) {
  249. uni.setTabBarBadge({
  250. index: 4,
  251. text: value + ""
  252. })
  253. }
  254. name = 'taskTip';
  255. value = res.data.data.total;
  256. that.$store.commit('$uStore', {
  257. name,
  258. value
  259. });
  260. }
  261. })
  262. this.$nextTick(function() {
  263. this.canReset && this.mescroll.resetUpScroll() // 重置列表数据为第一页
  264. this.canReset && this.mescroll.scrollTo(0, 0) // 重置列表数据为第一页时,建议把滚动条也重置到顶部,避免无法再次翻页的问题
  265. this.canReset = true // 过滤第一次的onShow事件,避免初始化界面时重复触发upCallback, 无需配置auto:false
  266. });
  267. },
  268. onNavigationBarButtonTap(e) {
  269. console.log(e)
  270. if (!this.hasLogin) {
  271. this.isShowAlert = true;
  272. } else {
  273. uni.navigateTo({
  274. url: 'myAttention?selectType=' + '关注'
  275. })
  276. }
  277. },
  278. methods: {
  279. delIcon() {
  280. this.keyword = ''
  281. uni.setStorageSync('jiaoyikeyword','')
  282. this.mescroll.resetUpScroll()
  283. },
  284. previewImage(item, index) {
  285. var i = item.imgList; //获取当前页面的轮播图数据
  286. //uniapp预览轮播图
  287. uni.previewImage({
  288. current: index, //预览图片的下标
  289. urls: i //预览图片的地址,必须要数组形式,如果不是数组形式就转换成数组形式就可以
  290. })
  291. },
  292. releaseAlertbtn() {
  293. getApp().globalData.userRelease = false
  294. this.isSHowReleaseAlert = false
  295. },
  296. cancelFollow() {
  297. let _obj = {
  298. id: this.selectItem.followInformation.id
  299. }
  300. console.log()
  301. this.$api.doRequest('post', '/followInformation/api/deleteInfo', _obj).then(res => {
  302. if (res.data.code == 200) {
  303. this.$refs.uToast.show({
  304. title: '取关成功',
  305. type: 'success',
  306. })
  307. this.mescroll.resetUpScroll()
  308. }
  309. uni.hideLoading()
  310. })
  311. },
  312. mescrollInit(mescroll) {
  313. console.log("mescroll", mescroll)
  314. this.mescroll = mescroll;
  315. },
  316. cancelClick() {
  317. this.isShowAlert = false
  318. },
  319. alertBtn() {
  320. uni.navigateTo({
  321. url: '/pages/public/login'
  322. })
  323. },
  324. toSearch() {
  325. uni.setStorageSync('jiaoyikeyword', this.keyword)
  326. uni.setStorageSync('jiaoyifocus', true)
  327. // this.isShowSearch = true
  328. uni.navigateTo({
  329. url:'/pages/business/search'
  330. })
  331. },
  332. follow(val, type) {
  333. // 2关注
  334. if (!this.hasLogin) {
  335. this.isShowAlert = true;
  336. } else {
  337. this.selectItem = val
  338. if (type == 1) {
  339. this.show = true
  340. } else {
  341. let _obj = {
  342. userId: this.userInfo.id,
  343. followedId: val.userId
  344. }
  345. uni.showLoading({
  346. title: '数据加载中',
  347. mask: true
  348. })
  349. this.$api.doRequest('post', '/followInformation/api/addInfo', _obj).then(res => {
  350. if (res.data.code == 200) {
  351. this.$refs.uToast.show({
  352. title: '关注成功',
  353. type: 'success',
  354. })
  355. this.mescroll.resetUpScroll()
  356. }
  357. uni.hideLoading()
  358. })
  359. }
  360. }
  361. },
  362. selectAddress(val) {
  363. console.log(val)
  364. try {
  365. uni.setStorageSync('transactionLocation', val);
  366. this.selectPlace = val.address
  367. this.searchPlace = val.showVal
  368. } catch (e) {
  369. // error
  370. }
  371. this.mescroll.resetUpScroll()
  372. console.log(val)
  373. },
  374. release() {
  375. if (!this.hasLogin) {
  376. this.isShowAlert = true;
  377. } else {
  378. this.$api.doRequest('get', '/commonUser/getInfo', {id:uni.getStorageSync('userInfo').id}).then(
  379. res => {
  380. console.log(res.data)
  381. if (!res.data.data.transactionStatus || res.data.data.transactionStatus && res.data.data.transactionStatus != '禁止发布') {
  382. uni.navigateTo({
  383. url: 'release'
  384. })
  385. } else {
  386. uni.showToast({
  387. title: '暂未获得发布权限!',
  388. icon:'none'
  389. })
  390. }
  391. })
  392. }
  393. },
  394. downCallback() {
  395. this.mescroll.resetUpScroll();
  396. },
  397. async upCallback(page) {
  398. uni.showLoading({
  399. title: '数据加载中',
  400. mask: true
  401. })
  402. console.log("this.selectPlace", this.selectPlace)
  403. console.log("this.selectType", this.selectType)
  404. let _obj = {
  405. }
  406. console.log(this.selectType)
  407. if (this.selectType == '关注') {
  408. _obj = {
  409. pageSize: page.size,
  410. currentPage: page.num,
  411. placeDelivery: this.selectPlace,
  412. tranType: this.selectType,
  413. userIdFollow: this.userInfo.id,
  414. nowUserId: this.userInfo.id,
  415. pcphone: 'mobile'
  416. }
  417. } else {
  418. _obj = {
  419. pageSize: page.size,
  420. currentPage: page.num,
  421. placeDelivery: this.selectPlace,
  422. tranType: this.selectType,
  423. nowUserId: this.userInfo.id,
  424. searchKeyWord: this.keyword,
  425. pcphone: 'mobile'
  426. }
  427. }
  428. await this.$api.doRequest('get', '/transactionExchangeInfo/selectTransactionExchangeInfo', _obj).then(
  429. res => {
  430. console.log(res.data)
  431. if (res.data.code == 200) {
  432. console.log(res.data.data.records, page.num)
  433. let curPageData = res.data.data.records;
  434. let curPageLen = curPageData.length;
  435. let totalPage = res.data.data.total;
  436. if (page.num == 1) this.goods = [];
  437. this.goods = this.goods.concat(curPageData);
  438. console.log(curPageLen, totalPage)
  439. this.mescroll.endByPage(curPageLen, totalPage);
  440. }
  441. })
  442. if (this.goods.length > 0) {
  443. for (let i = 0; i < this.goods.length; i++) {
  444. await this.$api.doRequest('get', 'appendix/query/getFileList', {
  445. appendixIds: this.goods[i].urlImg
  446. }).then(res1 => {
  447. if (i == this.goods.length - 1) {
  448. uni.hideLoading()
  449. }
  450. var arr = []
  451. for (let q = 0; q < res1.data.data.length; q++) {
  452. arr.push(res1.data.data[q].appendixPath)
  453. }
  454. this.goods[i].imgList = arr
  455. this.$forceUpdate()
  456. })
  457. }
  458. }else{
  459. uni.hideLoading()
  460. }
  461. },
  462. //点击空布局按钮的回调
  463. emptyClick() {
  464. uni.showToast({
  465. title: '点击了按钮,具体逻辑自行实现'
  466. })
  467. },
  468. // 切换菜单
  469. tabChange(e) {
  470. this.goods = [] // 先置空列表,显示加载进度
  471. if (this.tabs[e].name == '全部') {
  472. this.selectType = ''
  473. } else {
  474. this.selectType = this.tabs[e].name
  475. }
  476. console.log(this.selectType)
  477. this.mescroll.resetUpScroll() // 再刷新列表数据
  478. }
  479. }
  480. }
  481. </script>
  482. <style lang='scss' scoped>
  483. page,
  484. .content {
  485. background: #F5F6FA;
  486. }
  487. /deep/.button-show {
  488. width: 80rpx;
  489. }
  490. .flex {
  491. display: flex;
  492. }
  493. .alc {
  494. align-items: center;
  495. }
  496. .jcse {
  497. justify-content: space-evenly;
  498. }
  499. .jcsb {
  500. justify-content: space-between;
  501. }
  502. .top-warp {
  503. z-index: 998;
  504. position: fixed;
  505. top: --window-top;
  506. /* css变量 */
  507. left: 0;
  508. width: 100%;
  509. /* height: 120upx; */
  510. background-color: white;
  511. }
  512. .top-warp .tip {
  513. font-size: 28upx;
  514. height: 60upx;
  515. line-height: 60upx;
  516. text-align: center;
  517. }
  518. .slot-wrap {
  519. margin-right: 45rpx;
  520. font-size: 32rpx;
  521. }
  522. .list {
  523. margin: 0 20rpx;
  524. .list-item {
  525. padding: 26rpx 17rpx;
  526. background: #fff;
  527. margin-bottom: 20rpx;
  528. border-radius: 20rpx;
  529. .row1 {
  530. .head-img {
  531. width: 72rpx;
  532. border-radius: 8rpx;
  533. margin-right: 22rpx;
  534. }
  535. .left {
  536. .title {
  537. font-weight: 700;
  538. color: #333333;
  539. }
  540. .bottom {
  541. .color1 {
  542. font-size: 24rpx;
  543. padding: 4rpx 10rpx;
  544. color: #fff;
  545. display: inline-block;
  546. background: linear-gradient(180deg, #607AE0 0%, #516CDC 100%);
  547. border-radius: 4rpx;
  548. }
  549. .color2 {
  550. font-size: 24rpx;
  551. padding: 4rpx 10rpx;
  552. color: #fff;
  553. display: inline-block;
  554. background: linear-gradient(180deg, #FD714F 0%, #FD613C 100%);
  555. border-radius: 4rpx;
  556. }
  557. .color3 {
  558. font-size: 24rpx;
  559. color: #AFB3BF;
  560. margin-left: 14rpx;
  561. }
  562. }
  563. }
  564. .right {
  565. display:flex;
  566. align-items: center;
  567. padding: 10rpx 20rpx;
  568. border: 1px solid #CDCDCD;
  569. border-radius: 50rpx;
  570. }
  571. }
  572. .row2 {
  573. margin-top: 20rpx;
  574. /* overflow: hidden;
  575. text-overflow: ellipsis;
  576. width: 100%;
  577. display: -webkit-box;
  578. -webkit-box-orient: vertical;
  579. -webkit-line-clamp: 3;
  580. word-break: break-all; */
  581. }
  582. .row3 {
  583. /* padding: 30rpx 30rpx 0 30rpx; */
  584. margin-top: 18rpx;
  585. display: flex;
  586. align-items: center;
  587. justify-content: space-between;
  588. flex-wrap: wrap;
  589. /* background: #bbb; */
  590. .img {
  591. display: flex;
  592. align-items: center;
  593. /* justify-content: space-between; */
  594. width: 210rpx;
  595. height: 210rpx;
  596. margin-bottom: 20rpx;
  597. background: lightblue;
  598. list-style: none;
  599. border-radius: 10rpx;
  600. margin-right: 16rpx;
  601. }
  602. .img:nth-of-type(3),
  603. .img:nth-of-type(6),
  604. .img:nth-of-type(9) {
  605. margin-right: 0;
  606. }
  607. }
  608. .row4 {
  609. margin-top: 4rpx;
  610. .text {
  611. color: #878C9C;
  612. font-size: 24rpx;
  613. }
  614. }
  615. }
  616. .case {
  617. font-weight: 700;
  618. margin-left: 6rpx;
  619. }
  620. }
  621. .add {
  622. position: fixed;
  623. bottom: 150rpx;
  624. right: 32rpx;
  625. background: #22C572;
  626. z-index: 999;
  627. width: 84rpx;
  628. height: 84rpx;
  629. border-radius: 50%;
  630. display: flex;
  631. align-items: center;
  632. justify-content: center;
  633. }
  634. .search {
  635. display: flex;
  636. align-items: center;
  637. position: relative;
  638. margin: 20rpx 28rpx 20rpx 28rpx;
  639. position: relative;
  640. .text {
  641. width: 90rpx;
  642. overflow: hidden;
  643. white-space: nowrap;
  644. text-overflow: ellipsis;
  645. }
  646. .del {
  647. position: absolute;
  648. right: 20rpx;
  649. }
  650. }
  651. /deep/.u-search .u-content {
  652. padding-left: 120rpx;
  653. }
  654. .place {
  655. display: flex;
  656. align-items: center;
  657. left: 28rpx;
  658. position: absolute;
  659. font-weight: 700;
  660. }
  661. .uni-page-head-ft {
  662. margin-right: 40rpx;
  663. }
  664. </style>