businessNew.vue 15 KB

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