cargoTerminal.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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.native.stop="shelvesBtnClick(1,item)" v-if="item.status=='已下架'">
  48. 上架
  49. </view>
  50. <view class="btn" @click.native.stop="shelvesBtnClick(2,item)" v-if="item.status=='已上架'">
  51. 下架
  52. </view>
  53. <view class="btn" @click.native.stop="copyToNewPage(item,1)" v-if="tabIndex==1">
  54. 复制
  55. </view>
  56. <view class="btn" @click.native.stop="often(item)" v-if="tabIndex==1&&item.oftenFlag!=1">
  57. 常发
  58. </view>
  59. <view class="btn often" v-if="tabIndex==1&&item.oftenFlag==1">
  60. 常发
  61. </view>
  62. <view class="btn" @click.native.stop="deleteTask(item)">
  63. 删除
  64. </view>
  65. <view class="btn" @click.native.stop="editTask(item)">
  66. 编辑
  67. </view>
  68. <view class="btn" @click.native.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. },
  116. goodsList: [],
  117. customStyleButton: {
  118. position: "fixed",
  119. bottom: "140rpx",
  120. margin: "0 20rpx",
  121. width: "calc(100vw - 40rpx)"
  122. },
  123. scrollTop: 0,
  124. tabIndex: 0,
  125. tabList: [{
  126. name: '发布中'
  127. }, {
  128. name: '发布记录'
  129. }, {
  130. name: '常发货源'
  131. }, ],
  132. };
  133. },
  134. onLoad() {
  135. that = this
  136. },
  137. computed: {
  138. ...mapState(['hasLogin', 'userInfo']),
  139. },
  140. methods: {
  141. toDetail(id) {
  142. uni.navigateTo({
  143. url: "/pages/cargoTerminal/cargoTerminalDetail?id=" + id
  144. })
  145. },
  146. toPublishSource() {
  147. uni.navigateTo({
  148. url: "/pages/cargoTerminal/publishSource"
  149. })
  150. },
  151. copyToNewPage(val, type) {
  152. uni.setStorageSync("selectGoodObj", val)
  153. uni.navigateTo({
  154. url: "/pages/cargoTerminal/publishSource?type=1"
  155. })
  156. },
  157. deleteTask(val) {
  158. this.selectObj = val
  159. this.show2 = true
  160. },
  161. editTask(val) {
  162. uni.setStorageSync("selectGoodObj", val)
  163. uni.navigateTo({
  164. url: "/pages/cargoTerminal/publishSource?type=2"
  165. })
  166. },
  167. removeOften(val) {
  168. this.selectObj = val
  169. this.show = true
  170. },
  171. confirmRemove2() {
  172. uni.showLoading({
  173. title: "加载中"
  174. })
  175. this.$request.baseRequest('post', '/hyReleaseGoodsInfo/deleteTask', this.selectObj).then(res => {
  176. uni.hideLoading()
  177. uni.showToast({
  178. title: "货源删除成功!",
  179. icon:'none'
  180. })
  181. this.show2 = true
  182. this.mescroll.resetUpScroll()
  183. })
  184. .catch(res => {});
  185. },
  186. confirmRemove1() {
  187. uni.showLoading({
  188. title: "加载中"
  189. })
  190. this.selectObj.status = '已下架'
  191. this.$request.baseRequest('post', '/hyReleaseGoodsInfo/api/editTask', this.selectObj).then(res => {
  192. uni.showToast({
  193. title: "货源已下架",
  194. icon:'none'
  195. })
  196. this.show1 = false
  197. that.mescroll.resetUpScroll()
  198. })
  199. .catch(res => {
  200. uni.hideLoading()
  201. uni.$u.toast(res.message);
  202. });
  203. },
  204. confirmRemove() {
  205. uni.showLoading({
  206. title: "加载中",
  207. icon:'none'
  208. })
  209. this.selectObj.oftenFlag = 0
  210. this.$request.baseRequest('post', '/hyReleaseGoodsInfo/api/editTask', this.selectObj).then(res => {
  211. uni.hideLoading()
  212. this.show = false
  213. uni.showToast({
  214. title: "成功移除常发货源!",
  215. icon:'none'
  216. })
  217. this.mescroll.resetUpScroll()
  218. })
  219. .catch(res => {});
  220. },
  221. often(val) {
  222. uni.showLoading({
  223. title: "加载中"
  224. })
  225. this.$request.baseRequest('post', '/hyReleaseGoodsInfo/api/editTask', val).then(res => {
  226. uni.hideLoading()
  227. uni.showToast({
  228. title: "已存为常发货源!",
  229. icon:'none'
  230. })
  231. this.mescroll.resetUpScroll()
  232. })
  233. .catch(res => {});
  234. },
  235. shelvesBtnClick(flag, val) {
  236. if (flag == '1') {
  237. val.status = '已上架'
  238. this.$request.baseRequest('post', '/hyReleaseGoodsInfo/api/editTask', val).then(res => {
  239. uni.showToast({
  240. title: "货源已上架",
  241. icon:'none'
  242. })
  243. that.mescroll.resetUpScroll()
  244. })
  245. .catch(res => {
  246. uni.hideLoading()
  247. uni.$u.toast(res.message);
  248. });
  249. } else {
  250. this.selectObj = val
  251. this.show1 = true
  252. }
  253. },
  254. upCallback(page) {
  255. uni.showLoading({
  256. mask: true,
  257. title: '加载中'
  258. })
  259. this.$request.baseRequest('get', '/hyReleaseGoodsInfo/selectTask', {
  260. currentPage: page.num,
  261. pageSize: page.size,
  262. searchType: this.tabIndex + 1,
  263. commonId: this.userInfo.id
  264. }).then(res => {
  265. uni.hideLoading()
  266. let curPageData = res.data.records;
  267. let totalPage = res.data.total;
  268. let curPageLen = curPageData.length;
  269. this.mescroll.endByPage(curPageLen, totalPage);
  270. console.log(res.data)
  271. if (page.num == 1) this.goodsList = [];
  272. this.goodsList = this.goodsList.concat(curPageData);
  273. for (let i = 0; i < this.goodsList.length; i++) {
  274. let _text3 = ''
  275. let _textList = this.goodsList[i].measuringMethod.split(',')
  276. for (let k = 0; k < _textList.length; k++) {
  277. if (_textList[k] == '重量(吨)') {
  278. _text3 += this.goodsList[i].weight + '吨/'
  279. } else {
  280. _text3 += this.goodsList[i].volume + '方/'
  281. }
  282. }
  283. _text3 = _text3.substring(0, _text3.length - 1)
  284. this.goodsList[i].content = this.goodsList[i].carModel.replace(',', '/') + '、' + this
  285. .goodsList[i].carLength.replace(',', '/') + '米、' + _text3 + '、' + this.goodsList[i]
  286. .expectedNum + '车、' + this.goodsList[i].goodsName + '、' + this.goodsList[i]
  287. .packageType + '、' + this.goodsList[i].cargoDistance + 'km'
  288. }
  289. })
  290. .catch(res => {
  291. uni.hideLoading()
  292. uni.$u.toast(res.message);
  293. this.mescroll.endErr();
  294. });
  295. },
  296. downCallback() {
  297. this.mescroll.resetUpScroll()
  298. },
  299. mescrollInit(mescroll) {
  300. this.mescroll = mescroll;
  301. },
  302. async clickTab(val) {
  303. console.log("val", val)
  304. this.tabIndex = val.index
  305. this.mescroll.resetUpScroll()
  306. },
  307. }
  308. }
  309. </script>
  310. <style lang="scss" scoped>
  311. .fixed,
  312. .fixed1 {
  313. background: linear-gradient(97deg, #F5BA3C 0%, #F5BA3C 100%);
  314. position: fixed;
  315. top: var(--status-bar-height);
  316. z-index: 999;
  317. // width: calc(100% - 40rpx);
  318. width: 100%;
  319. // margin:0 20rpx;
  320. }
  321. .fixed1 {
  322. top: 0;
  323. height: var(--status-bar-height);
  324. background: linear-gradient(97deg, #F5BA3C 0%, #F5BA3C 100%);
  325. }
  326. .tab-view {
  327. padding: 0 20rpx;
  328. }
  329. .list-content {
  330. margin: 20rpx;
  331. }
  332. .list-item {
  333. position: relative;
  334. background: #fff;
  335. padding: 20rpx;
  336. border-radius: 20rpx;
  337. .xj {
  338. position: absolute;
  339. right: 40rpx;
  340. top: 50rpx;
  341. color: red;
  342. font-weight: 700;
  343. border: 2px solid red;
  344. padding: 10rpx 20rpx;
  345. border-radius: 10rpx;
  346. transform: rotate(40deg);
  347. background-color: rgba(255, 255, 255, 0.6);
  348. }
  349. .row2 {
  350. .left{
  351. color:rgb(255, 134, 0);
  352. font-weight: 700;
  353. }
  354. .right {
  355. color: rgb(153, 153, 153)
  356. }
  357. }
  358. .row {
  359. margin: 10rpx 0;
  360. }
  361. .row1 {
  362. display: flex;
  363. font-size: 32rpx;
  364. font-weight: 700;
  365. }
  366. .row2 {
  367. justify-content: space-between;
  368. }
  369. .row3 {
  370. color: rgb(153, 153, 153);
  371. text-overflow: ellipsis;
  372. white-space: nowrap;
  373. overflow: hidden;
  374. }
  375. .row4 {
  376. justify-content: flex-end;
  377. margin-top: 20rpx;
  378. }
  379. }
  380. .btn {
  381. border: 1px solid rgb(255, 134, 0);
  382. padding: 10rpx;
  383. box-sizing: border-box;
  384. margin-left: 10rpx;
  385. color: rgb(255, 134, 0);
  386. border-radius: 10rpx;
  387. font-size: 28rpx;
  388. }
  389. .often {
  390. border: 1px solid rgb(187, 187, 187);
  391. color: rgb(187, 187, 187);
  392. }
  393. </style>