cargoTerminal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <view class="content">
  3. <view class="img">
  4. <u-image width="100%" height="300rpx" src="@/static/banner.jpg"></u-image>
  5. </view>
  6. <view class="tab-view">
  7. <u-tabs :list="tabList" @click="clickTab" :lineColor="scrollTop>1200?'white':'#000000'" :current='tabIndex'
  8. :inactiveStyle="{color: scrollTop>1200?'white':'',}" :activeStyle="{
  9. color: scrollTop>1200?'':'#000000',
  10. fontWeight: 'bold',
  11. transform: 'scale(1.25)',
  12. }" :class="scrollTop>1200?'fixed':''"></u-tabs>
  13. </view>
  14. <mescroll-body ref="mescrollRef" :up="upOption" @init="mescrollInit" @down="downCallback" @up="upCallback"
  15. class="mescroll">
  16. <view class="list-content" @click="toDetail(item.id)" v-for="item in goodsList">
  17. <view class="list-item">
  18. <view class="xj" v-if="item.status=='已下架'">
  19. 已下架
  20. </view>
  21. <view class="row1 row">
  22. <view class="left">
  23. {{item.sendCity}} {{item.sendArea}}
  24. </view>
  25. <view class="">
  26. </view>
  27. <view class="right">
  28. {{item.unloadCity}} {{item.unloadArea}}
  29. </view>
  30. </view>
  31. <view class="row2 flex row">
  32. <view class="left">
  33. <text>¥{{item.freightPrice}}</text>
  34. <text v-if="item.billingMethod==0">元/吨</text>
  35. <text v-if="item.billingMethod==1">元/车</text>
  36. <text v-if="item.billingMethod==2">元/方</text>
  37. </view>
  38. <view class="right">
  39. {{item.updateDate}}
  40. </view>
  41. </view>
  42. <view class="row3 row">
  43. {{item.content}}
  44. <!-- {{item.carModel?item.carModel.replace(',','/'):''}}、{{item.carLength?item.carLength.replace(',','/'):''}}米、10吨/10方、10车... -->
  45. </view>
  46. <view class="row4 flex row">
  47. <view class="btn" @click.stop="shelvesBtnClick(1,item)" v-if="item.status=='已下架'&&tabIndex!=2">
  48. 上架
  49. </view>
  50. <view class="btn" @click.stop="shelvesBtnClick(2,item)" v-if="item.status=='已上架'&&tabIndex!=2">
  51. 下架
  52. </view>
  53. <view class="btn" @click.stop="copyToNewPage(item,1)" v-if="tabIndex==1||tabIndex==2">
  54. 复制
  55. </view>
  56. <view class="btn" @click.stop="often(item)" v-if="tabIndex==1&&item.oftenFlag1!=1">
  57. 常发
  58. </view>
  59. <view class="btn often" v-if="tabIndex==1&&item.oftenFlag1==1">
  60. 常发
  61. </view>
  62. <view class="btn" @click.stop="deleteTask(item)" v-if="tabIndex!=2">
  63. 删除
  64. </view>
  65. <view class="btn" @click.stop="editTask(item)" v-if="tabIndex!=2">
  66. 编辑
  67. </view>
  68. <view class="btn" @click.stop="removeOften(item)" v-if="tabIndex==2">
  69. 移除
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- <view class="" v-for="(item,index) in goodsList" :key="index">
  75. {{item}}
  76. </view> -->
  77. </mescroll-body>
  78. <u-button type="warning" :custom-style="customStyleButton" @click="toPublishSource">发货找车</u-button>
  79. <u-toast ref="uToast"></u-toast>
  80. <u-modal :show="show" :content='content' @confirm="confirmRemove" @cancel="show=false"
  81. showCancelButton></u-modal>
  82. <u-modal :show="show1" :content='content1' @confirm="confirmRemove1" @cancel="show1=false"
  83. showCancelButton></u-modal>
  84. <u-modal :show="show2" :content='content2' @confirm="confirmRemove2" @cancel="show2=false"
  85. showCancelButton></u-modal>
  86. </view>
  87. </template>
  88. <script>
  89. var that;
  90. import {
  91. mapState
  92. } from 'vuex';
  93. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  94. export default {
  95. mixins: [MescrollMixin],
  96. data() {
  97. return {
  98. show: false,
  99. content: '确认移出常发货源?',
  100. show1: false,
  101. content1: '确认下架该货源?',
  102. show2: false,
  103. content2: '确认删除该货源?',
  104. upOption: {
  105. page: {
  106. size: 10 // 每页数据的数量,默认10
  107. },
  108. noMoreSize: 0, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  109. empty: {
  110. tip: '暂无记录!'
  111. },
  112. toTop: {
  113. src: ''
  114. },
  115. auto: false,
  116. },
  117. goodsList: [],
  118. customStyleButton: {
  119. position: "fixed",
  120. bottom: "60rpx",
  121. margin: "0 20rpx",
  122. width: "calc(100vw - 40rpx)"
  123. },
  124. scrollTop: 0,
  125. tabIndex: 0,
  126. tabList: [{
  127. name: '发布中'
  128. }, {
  129. name: '发布记录'
  130. }, {
  131. name: '常发货源'
  132. }, ],
  133. };
  134. },
  135. onShow() {
  136. this.$nextTick(function() {
  137. that.mescroll.resetUpScroll()
  138. });
  139. },
  140. onLoad() {
  141. that = this
  142. },
  143. computed: {
  144. ...mapState(['hasLogin', 'userInfo']),
  145. },
  146. methods: {
  147. toDetail(id) {
  148. uni.navigateTo({
  149. url: "/pages/cargoTerminal/cargoTerminalDetail?id=" + id
  150. })
  151. },
  152. toPublishSource() {
  153. uni.navigateTo({
  154. url: "/pages/cargoTerminal/publishSource"
  155. })
  156. },
  157. copyToNewPage(val, type) {
  158. uni.setStorageSync("selectGoodObj", val)
  159. uni.navigateTo({
  160. url: "/pages/cargoTerminal/publishSource?type=1"
  161. })
  162. },
  163. deleteTask(val) {
  164. this.selectObj = val
  165. this.show2 = true
  166. },
  167. editTask(val) {
  168. uni.setStorageSync("selectGoodObj", val)
  169. uni.navigateTo({
  170. url: "/pages/cargoTerminal/publishSource?type=2"
  171. })
  172. },
  173. removeOften(val) {
  174. this.selectObj = val
  175. this.show = true
  176. },
  177. confirmRemove2() {
  178. this.$request.baseRequest('post', '/hyReleaseGoodsInfo/deleteTask', this.selectObj).then(res => {
  179. uni.hideLoading()
  180. this.show2 = false
  181. uni.showToast({
  182. title: "货源删除成功!",
  183. icon: 'none'
  184. })
  185. setTimeout(() => {
  186. that.mescroll.resetUpScroll()
  187. }, 1000)
  188. })
  189. .catch(res => {});
  190. },
  191. confirmRemove1() {
  192. this.selectObj.status = '已下架'
  193. this.$request.baseRequest('post', '/hyReleaseGoodsInfo/api/editTask', this.selectObj).then(res => {
  194. this.show1 = false
  195. uni.showToast({
  196. title: "货源已下架",
  197. icon: 'none'
  198. })
  199. setTimeout(() => {
  200. that.mescroll.resetUpScroll()
  201. }, 1000)
  202. })
  203. .catch(res => {
  204. uni.hideLoading()
  205. uni.$u.toast(res.message);
  206. });
  207. },
  208. confirmRemove() {
  209. this.$request.baseRequest('post', '/hyReleaseGoodsInfo/deleteTask', this.selectObj).then(res => {
  210. uni.hideLoading()
  211. this.show = false
  212. uni.showToast({
  213. title: "成功移除常发货源!",
  214. icon: 'none'
  215. })
  216. setTimeout(() => {
  217. that.mescroll.resetUpScroll()
  218. }, 1000)
  219. })
  220. .catch(res => {});
  221. },
  222. often(val) {
  223. uni.showLoading({
  224. title: "加载中"
  225. })
  226. val.oftenFlag = val.id
  227. delete val.id
  228. this.$request.baseRequest('post', '/hyReleaseGoodsInfo/api/addTask', val).then(res => {
  229. uni.hideLoading()
  230. uni.showToast({
  231. title: "已存为常发货源!",
  232. icon: 'none'
  233. })
  234. setTimeout(() => {
  235. that.mescroll.resetUpScroll()
  236. }, 1000)
  237. })
  238. .catch(res => {});
  239. // this.$request.baseRequest('post', '/hyReleaseGoodsInfo/api/editTask', val).then(res => {
  240. // uni.hideLoading()
  241. // uni.showToast({
  242. // title: "已存为常发货源!",
  243. // icon: 'none'
  244. // })
  245. // setTimeout(() => {
  246. // that.mescroll.resetUpScroll()
  247. // }, 1000)
  248. // })
  249. // .catch(res => {});
  250. },
  251. shelvesBtnClick(flag, val) {
  252. if (flag == '1') {
  253. val.status = '已上架'
  254. this.$request.baseRequest('post', '/hyReleaseGoodsInfo/api/editTask', val).then(res => {
  255. uni.showToast({
  256. title: "货源已上架",
  257. icon: 'none'
  258. })
  259. setTimeout(() => {
  260. that.mescroll.resetUpScroll()
  261. }, 1000)
  262. })
  263. .catch(res => {
  264. uni.hideLoading()
  265. uni.$u.toast(res.message);
  266. });
  267. } else {
  268. this.selectObj = val
  269. this.show1 = true
  270. }
  271. },
  272. upCallback(page) {
  273. uni.showLoading({
  274. mask: true,
  275. title: '加载中'
  276. })
  277. this.$request.baseRequest('get', '/hyReleaseGoodsInfo/selectTask', {
  278. currentPage: page.num,
  279. pageSize: page.size,
  280. searchType: this.tabIndex + 1,
  281. commonId: this.userInfo.id
  282. }).then(res => {
  283. uni.hideLoading()
  284. let curPageData = res.data.records;
  285. let totalPage = res.data.total;
  286. let curPageLen = curPageData.length;
  287. this.mescroll.endByPage(curPageLen, totalPage);
  288. console.log(res.data)
  289. if (page.num == 1) this.goodsList = [];
  290. this.goodsList = this.goodsList.concat(curPageData);
  291. for (let i = 0; i < this.goodsList.length; i++) {
  292. let _text3 = ''
  293. let _textList = this.goodsList[i].measuringMethod.split(',')
  294. for (let k = 0; k < _textList.length; k++) {
  295. if (_textList[k] == '重量(吨)') {
  296. _text3 += this.goodsList[i].weight + '吨/'
  297. } else {
  298. _text3 += this.goodsList[i].volume + '方/'
  299. }
  300. }
  301. _text3 = _text3.substring(0, _text3.length - 1)
  302. this.goodsList[i].content = this.goodsList[i].carModel.replace(',', '/') + '、' + this
  303. .goodsList[i].carLength.replace(',', '/') + '米、' + _text3 + '、' + this.goodsList[i]
  304. .expectedNum + '车、' + this.goodsList[i].goodsName + '、' + this.goodsList[i]
  305. .packageType + '、' + this.goodsList[i].cargoDistance + 'km'
  306. }
  307. })
  308. .catch(res => {
  309. uni.hideLoading()
  310. uni.$u.toast(res.message);
  311. this.mescroll.endErr();
  312. });
  313. },
  314. downCallback() {
  315. this.mescroll.resetUpScroll()
  316. },
  317. mescrollInit(mescroll) {
  318. this.mescroll = mescroll;
  319. },
  320. async clickTab(val) {
  321. console.log("val", val)
  322. this.tabIndex = val.index
  323. this.mescroll.resetUpScroll()
  324. },
  325. }
  326. }
  327. </script>
  328. <style lang="scss" scoped>
  329. .fixed,
  330. .fixed1 {
  331. background: linear-gradient(97deg, #F5BA3C 0%, #F5BA3C 100%);
  332. position: fixed;
  333. top: var(--status-bar-height);
  334. z-index: 999;
  335. // width: calc(100% - 40rpx);
  336. width: 100%;
  337. // margin:0 20rpx;
  338. }
  339. .fixed1 {
  340. top: 0;
  341. height: var(--status-bar-height);
  342. background: linear-gradient(97deg, #F5BA3C 0%, #F5BA3C 100%);
  343. }
  344. .tab-view {
  345. padding: 0 20rpx;
  346. }
  347. .list-content {
  348. margin: 20rpx;
  349. }
  350. .list-item {
  351. position: relative;
  352. background: #fff;
  353. padding: 20rpx;
  354. border-radius: 20rpx;
  355. .xj {
  356. position: absolute;
  357. right: 40rpx;
  358. top: 50rpx;
  359. color: red;
  360. font-weight: 700;
  361. border: 2px solid red;
  362. padding: 10rpx 20rpx;
  363. border-radius: 10rpx;
  364. transform: rotate(40deg);
  365. background-color: rgba(255, 255, 255, 0.6);
  366. }
  367. .row2 {
  368. .left {
  369. color: rgb(255, 134, 0);
  370. font-weight: 700;
  371. }
  372. .right {
  373. color: rgb(153, 153, 153)
  374. }
  375. }
  376. .row {
  377. margin: 10rpx 0;
  378. }
  379. .row1 {
  380. display: flex;
  381. font-size: 32rpx;
  382. font-weight: 700;
  383. }
  384. .row2 {
  385. justify-content: space-between;
  386. }
  387. .row3 {
  388. color: rgb(153, 153, 153);
  389. text-overflow: ellipsis;
  390. white-space: nowrap;
  391. overflow: hidden;
  392. }
  393. .row4 {
  394. justify-content: flex-end;
  395. margin-top: 20rpx;
  396. }
  397. }
  398. .btn {
  399. border: 1px solid rgb(255, 134, 0);
  400. padding: 10rpx 20rpx;
  401. box-sizing: border-box;
  402. margin-left: 10rpx;
  403. color: rgb(255, 134, 0);
  404. border-radius: 10rpx;
  405. font-size: 28rpx;
  406. }
  407. .often {
  408. border: 1px solid rgb(187, 187, 187);
  409. color: rgb(187, 187, 187);
  410. }
  411. </style>