businessNew.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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'></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">
  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. isSHowReleaseAlert: null,
  121. canReset: false,
  122. selectPlace: '',
  123. mescroll: null,
  124. isShowAlert: false,
  125. contentStyle: {
  126. "font-weight": 700
  127. },
  128. isShowSearch: false,
  129. selectItem: {},
  130. show: false,
  131. keyword: '',
  132. inputStyle: {
  133. // "padding-left": '30rpx'
  134. },
  135. content: '',
  136. upOption: {
  137. // page: {
  138. // num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  139. // size: 10 // 每页数据的数量
  140. // },
  141. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  142. empty: {
  143. icon: '/static/empty.png',
  144. tip: '暂无内容', // 提示
  145. // btnText: '去看看'
  146. }
  147. },
  148. goods: [], //列表数据
  149. tabs: [{
  150. name: '全部',
  151. type: 'xx'
  152. }, {
  153. name: '采购',
  154. type: 'xx'
  155. }, {
  156. name: '销售',
  157. type: 'xx'
  158. }, {
  159. name: '关注',
  160. type: 'xx'
  161. }],
  162. tabIndex: 0 // tab下标
  163. }
  164. },
  165. computed: {
  166. ...mapState(['hasLogin', 'userInfo', 'clientId']),
  167. },
  168. onShow() {
  169. this.isSHowReleaseAlert = getApp().globalData.userRelease
  170. console.log("this.isSHowReleaseAlert", this.isSHowReleaseAlert)
  171. uni.showTabBar()
  172. uni.hideKeyboard()
  173. var userInfo = uni.getStorageSync("userInfo")
  174. var that = this
  175. console.log("userInfo", userInfo)
  176. // setTimeout(function() {
  177. // that.$api.doRequest('get', '/appVersion/test', {
  178. // userId: "7e83070d05fc4d50aaa46e00a3ee03d8"
  179. // }).then(res => {
  180. // })
  181. // }, 500);
  182. uni.removeTabBarBadge({
  183. index: 4
  184. })
  185. this.$api.doRequest('get', '/newNoticeTask/query/noticeTasks').then(res => {
  186. if (res.data.data) {
  187. let name = 'myTip';
  188. let value = res.data.data.total;
  189. that.$store.commit('$uStore', {
  190. name,
  191. value
  192. });
  193. if (value != 0 && value) {
  194. uni.setTabBarBadge({
  195. index: 4,
  196. text: value + ""
  197. })
  198. }
  199. name = 'taskTip';
  200. value = res.data.data.total;
  201. that.$store.commit('$uStore', {
  202. name,
  203. value
  204. });
  205. }
  206. })
  207. this.$nextTick(function() {
  208. this.canReset && this.mescroll.resetUpScroll() // 重置列表数据为第一页
  209. this.canReset && this.mescroll.scrollTo(0, 0) // 重置列表数据为第一页时,建议把滚动条也重置到顶部,避免无法再次翻页的问题
  210. this.canReset = true // 过滤第一次的onShow事件,避免初始化界面时重复触发upCallback, 无需配置auto:false
  211. });
  212. },
  213. onLoad(options) {},
  214. onNavigationBarButtonTap(e) {
  215. console.log(e)
  216. if (!this.hasLogin) {
  217. this.isShowAlert = true;
  218. } else {
  219. uni.navigateTo({
  220. url: 'myAttention'
  221. })
  222. }
  223. },
  224. methods: {
  225. releaseAlertbtn() {
  226. getApp().globalData.userRelease = false
  227. this.isSHowReleaseAlert = false
  228. },
  229. cancelFollow() {
  230. let _obj = {
  231. id: this.selectItem.followInformation.id
  232. }
  233. console.log()
  234. this.$api.doRequest('post', '/followInformation/api/deleteInfo', _obj).then(res => {
  235. if (res.data.code == 200) {
  236. this.$refs.uToast.show({
  237. title: '取关成功',
  238. type: 'success',
  239. })
  240. this.mescroll.resetUpScroll()
  241. }
  242. uni.hideLoading()
  243. })
  244. },
  245. mescrollInit(mescroll) {
  246. console.log("mescroll", mescroll)
  247. this.mescroll = mescroll;
  248. },
  249. cancelClick() {
  250. this.isShowAlert = false
  251. },
  252. alertBtn() {
  253. uni.navigateTo({
  254. url: '/pages/public/login'
  255. })
  256. },
  257. searchVal(e) {
  258. console.log(e)
  259. this.isShowSearch = false
  260. this.keyword = e
  261. },
  262. toSearch() {
  263. this.isShowSearch = true
  264. },
  265. follow(val, type) {
  266. // 2关注
  267. if (!this.hasLogin) {
  268. this.isShowAlert = true;
  269. } else {
  270. this.selectItem = val
  271. if (type == 1) {
  272. this.show = true
  273. } else {
  274. let _obj = {
  275. userId: this.userInfo.id,
  276. followedId: val.userId
  277. }
  278. uni.showLoading({
  279. title: '数据加载中',
  280. mask: true
  281. })
  282. this.$api.doRequest('post', '/followInformation/api/addInfo', _obj).then(res => {
  283. if (res.data.code == 200) {
  284. this.$refs.uToast.show({
  285. title: '关注成功',
  286. type: 'success',
  287. })
  288. this.mescroll.resetUpScroll()
  289. }
  290. uni.hideLoading()
  291. })
  292. }
  293. }
  294. },
  295. selectAddress(val) {
  296. this.selectPlace = val
  297. this.mescroll.resetUpScroll() // 再刷新列表数据
  298. console.log(val)
  299. },
  300. release() {
  301. if (!this.hasLogin) {
  302. this.isShowAlert = true;
  303. } else {
  304. uni.navigateTo({
  305. url: 'release'
  306. })
  307. }
  308. },
  309. downCallback() {
  310. this.mescroll.resetUpScroll();
  311. },
  312. upCallback(page) {
  313. uni.showLoading({
  314. title: '数据加载中',
  315. mask: true
  316. })
  317. console.log("this.selectPlace", this.selectPlace)
  318. console.log("this.selectType", this.selectType)
  319. let _obj = {
  320. }
  321. if (this.selectType == '关注') {
  322. _obj = {
  323. pageSize: page.size,
  324. currentPage: page.num,
  325. placeDelivery: this.selectPlace,
  326. tranType: this.selectType,
  327. userIdFollow: this.userInfo.id,
  328. nowUserId: this.userInfo.id
  329. }
  330. } else {
  331. _obj = {
  332. pageSize: page.size,
  333. currentPage: page.num,
  334. placeDelivery: this.selectPlace,
  335. tranType: this.selectType,
  336. nowUserId: this.userInfo.id,
  337. searchKeyWord: this.keyword
  338. }
  339. }
  340. this.$api.doRequest('get', '/transactionExchangeInfo/selectTransactionExchangeInfo', _obj).then(res => {
  341. console.log(res.data.data.records)
  342. if (res.data.code == 200) {
  343. let curPageData = res.data.data.records;
  344. let curPageLen = curPageData.length;
  345. let totalPage = res.data.data.total;
  346. if (page.num == 1) this.goods = [];
  347. this.goods = this.goods.concat(curPageData);
  348. console.log(curPageLen, totalPage)
  349. this.mescroll.endByPage(curPageLen, totalPage);
  350. for (let i = 0; i < this.goods.length; i++) {
  351. this.goods[i].imgList = this.goods[i].urlImg.split(',')
  352. }
  353. }
  354. uni.hideLoading()
  355. })
  356. },
  357. //点击空布局按钮的回调
  358. emptyClick() {
  359. uni.showToast({
  360. title: '点击了按钮,具体逻辑自行实现'
  361. })
  362. },
  363. // 切换菜单
  364. tabChange(e) {
  365. this.goods = [] // 先置空列表,显示加载进度
  366. if (this.tabs[e].name == '全部') {
  367. this.selectType = ''
  368. } else {
  369. this.selectType = this.tabs[e].name
  370. }
  371. console.log(this.selectType)
  372. this.mescroll.resetUpScroll() // 再刷新列表数据
  373. }
  374. }
  375. }
  376. </script>
  377. <style lang='scss'>
  378. page,
  379. .content {
  380. background: #F5F6FA;
  381. }
  382. .flex {
  383. display: flex;
  384. }
  385. .alc {
  386. align-items: center;
  387. }
  388. .jcse {
  389. justify-content: space-evenly;
  390. }
  391. .jcsb {
  392. justify-content: space-between;
  393. }
  394. .top-warp {
  395. z-index: 998;
  396. position: fixed;
  397. top: --window-top;
  398. /* css变量 */
  399. left: 0;
  400. width: 100%;
  401. /* height: 120upx; */
  402. background-color: white;
  403. }
  404. .top-warp .tip {
  405. font-size: 28upx;
  406. height: 60upx;
  407. line-height: 60upx;
  408. text-align: center;
  409. }
  410. .slot-wrap {
  411. margin-right: 45rpx;
  412. font-size: 32rpx;
  413. }
  414. .list {
  415. margin: 0 20rpx;
  416. .list-item {
  417. padding: 26rpx 17rpx;
  418. background: #fff;
  419. margin-bottom: 20rpx;
  420. border-radius: 20rpx;
  421. .row1 {
  422. .head-img {
  423. width: 72rpx;
  424. border-radius: 8rpx;
  425. margin-right: 22rpx;
  426. }
  427. .left {
  428. .title {
  429. font-weight: 700;
  430. color: #333333;
  431. }
  432. .bottom {
  433. .color1 {
  434. font-size: 24rpx;
  435. padding: 4rpx 10rpx;
  436. color: #fff;
  437. display: inline-block;
  438. background: linear-gradient(180deg, #607AE0 0%, #516CDC 100%);
  439. border-radius: 4rpx;
  440. }
  441. .color2 {
  442. font-size: 24rpx;
  443. padding: 4rpx 10rpx;
  444. color: #fff;
  445. display: inline-block;
  446. background: linear-gradient(180deg, #FD714F 0%, #FD613C 100%);
  447. border-radius: 4rpx;
  448. }
  449. .color3 {
  450. font-size: 24rpx;
  451. color: #AFB3BF;
  452. margin-left: 14rpx;
  453. }
  454. }
  455. }
  456. .right {
  457. padding: 10rpx 20rpx;
  458. border: 1px solid #CDCDCD;
  459. border-radius: 50rpx;
  460. }
  461. }
  462. .row2 {
  463. margin-top: 20rpx;
  464. /* overflow: hidden;
  465. text-overflow: ellipsis;
  466. width: 100%;
  467. display: -webkit-box;
  468. -webkit-box-orient: vertical;
  469. -webkit-line-clamp: 3;
  470. word-break: break-all; */
  471. }
  472. .row3 {
  473. /* padding: 30rpx 30rpx 0 30rpx; */
  474. margin-top: 18rpx;
  475. display: flex;
  476. align-items: center;
  477. /* justify-content: space-between; */
  478. flex-wrap: wrap;
  479. /* background: #bbb; */
  480. .img {
  481. display: flex;
  482. align-items: center;
  483. justify-content: center;
  484. width: 214rpx;
  485. height: 214rpx;
  486. margin-bottom: 20rpx;
  487. background: lightblue;
  488. list-style: none;
  489. border-radius: 10rpx;
  490. margin-right: 16rpx;
  491. }
  492. .img:nth-of-type(3),
  493. .img:nth-of-type(6),
  494. .img:nth-of-type(9) {
  495. margin-right: 0;
  496. }
  497. }
  498. .row4 {
  499. margin-top: 4rpx;
  500. .text {
  501. color: #878C9C;
  502. font-size: 24rpx;
  503. }
  504. }
  505. }
  506. .case {
  507. font-weight: 700;
  508. margin-left: 6rpx;
  509. }
  510. }
  511. .add {
  512. position: fixed;
  513. bottom: 250rpx;
  514. right: 32rpx;
  515. background: #22C572;
  516. z-index: 999;
  517. width: 84rpx;
  518. height: 84rpx;
  519. border-radius: 50%;
  520. display: flex;
  521. align-items: center;
  522. justify-content: center;
  523. }
  524. .search {
  525. display: flex;
  526. align-items: center;
  527. position: relative;
  528. margin: 20rpx 28rpx 20rpx 28rpx;
  529. .text {
  530. width: 90rpx;
  531. overflow: hidden;
  532. white-space: nowrap;
  533. text-overflow: ellipsis;
  534. }
  535. }
  536. /deep/.u-content {
  537. padding-left: 170rpx;
  538. }
  539. .place {
  540. display: flex;
  541. align-items: center;
  542. left: 28rpx;
  543. position: absolute;
  544. font-weight: 700;
  545. }
  546. </style>