businessNew.vue 14 KB

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