procurement.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <view class="proInit">
  3. <tui-skeleton
  4. v-if="skeletonShow"
  5. backgroundColor="#fafafa"
  6. borderRadius="10rpx"
  7. :isLoading="true"
  8. :loadingType="5"
  9. ></tui-skeleton>
  10. <view v-else>
  11. <tui-tabs :tabs="tabs" :currentTab="currentTab" @change="handlerTabs" class="tab"></tui-tabs>
  12. <view
  13. class="tabsContent"
  14. v-for="(item, index) in procurementList"
  15. :key="index"
  16. :style="{ marginTop: index === 0 ? '40px' : '' }"
  17. >
  18. <proCard
  19. @modelData="modelData"
  20. :proTabId="currentTab"
  21. :procuretInfo="item"
  22. @popupAdd="popupAdd"
  23. @popupChange="popupChange"
  24. @proDelete="proDelete"
  25. @procureDetail="procureDetail"
  26. />
  27. </view>
  28. </view>
  29. <!-- 弹窗提示 -->
  30. <tui-modal
  31. :show="modal"
  32. @click="handleClick"
  33. @cancel="hideMobel"
  34. :content="contentModalText"
  35. :button="modalButton"
  36. color="#333"
  37. :size="32"
  38. shape="circle"
  39. :maskClosable="false"
  40. ></tui-modal>
  41. <view class="add_btn" @click="procurementAdd">
  42. <image style="width: 100%;height: 100%;" src="@/static/procurement/add_pro.png"></image>
  43. </view>
  44. <pro-pupop
  45. :dataObj="joinData"
  46. :isShow="popupShow"
  47. @handlerPopupClose="handlerPopupClose"
  48. @procurementParticipate="procurementParticipate($event, proListCallback)"
  49. />
  50. <view v-if="procurementList.length > 2" :style="{ marginTop: procurementList.length > 0 ? '0' : '88rpx' }">
  51. <!--加载loadding-->
  52. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  53. <tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText"></tui-nomore>
  54. <!--加载loadding-->
  55. </view>
  56. <proEmpty v-if="isEmpty" />
  57. </view>
  58. </template>
  59. <script>
  60. import proCard from './components/procurement_card.vue'
  61. import { mapState } from 'vuex'
  62. import procurementMixins from './mixins/procurementMixins.js'
  63. import proEmpty from './components/procurement-empty.vue'
  64. import proPupop from './components/procurement-popup.vue'
  65. export default {
  66. components: {
  67. proCard,
  68. proEmpty,
  69. proPupop
  70. },
  71. mixins: [procurementMixins],
  72. data() {
  73. return {
  74. skeletonShow: true, // loading
  75. // tab 栏切换
  76. tabs: [
  77. {
  78. name: '全部'
  79. },
  80. {
  81. name: '我参与的'
  82. },
  83. {
  84. name: '我发起的'
  85. }
  86. ],
  87. currentTab: 0, // tab 当前所在栏
  88. modal: false, // 弹窗
  89. contentModalText: '', // 弹窗内容
  90. // 弹窗配置
  91. modalButton: [
  92. {
  93. text: '取消',
  94. type: 'gray',
  95. plain: true //是否空心
  96. },
  97. {
  98. text: '确认',
  99. customStyle: {
  100. color: '#fff',
  101. bgColor: 'linear-gradient(90deg, #F28F31 0%, #F3B574 100%)'
  102. },
  103. plain: false
  104. }
  105. ],
  106. proDataInfo: {}, // 弹窗prodata
  107. popupShow: false, // 底部上移栏
  108. loadding: true, // 下拉刷新
  109. pullUpOn: true, // 下拉刷新
  110. // 分页参数
  111. pageInfo: {
  112. pageNo: 1,
  113. pageSize: 10,
  114. userId: '',
  115. status: 0
  116. },
  117. // 我参与的数据请求
  118. participate: {
  119. userId: '',
  120. procurementType: 0
  121. },
  122. // 所有数据
  123. procurementList: [],
  124. // 下拉刷新
  125. nomoreText: '已经没有了~',
  126. isLastPage: false, // 是否是最后一页
  127. joinData: {}, // 我要参与
  128. procurement: {},
  129. isEmpty: false, // 判断是否为空
  130. }
  131. },
  132. computed: {
  133. // 是否登录
  134. ...mapState(['hasLogin'])
  135. },
  136. onShow() {
  137. if (this.hasLogin) {
  138. this.userInfo = uni.getStorageSync('userInfo')
  139. this.pageInfo.userId = this.userInfo.userId
  140. this.participate.userId = this.userInfo.userId
  141. this.procurementAllList()
  142. } else {
  143. this.$api.redirectTo('/pages/login/login')
  144. }
  145. },
  146. onLoad() {
  147. // 刷新数据
  148. uni.$on('refreshAddData', () => {
  149. this.isEmpty = false
  150. this.procurementAllAddList()
  151. })
  152. },
  153. onReachBottom() {
  154. if (!this.isLastPage) {
  155. this.loadding = true
  156. this.pullUpOn = true
  157. this.pageInfo.pageNo += 1
  158. this.procurementAllList()
  159. }
  160. },
  161. onPullDownRefresh() {
  162. this.isEmpty = false
  163. this.isLastPage = false
  164. this.procurementList = []
  165. this.procurementAllList()
  166. uni.stopPullDownRefresh()
  167. },
  168. methods: {
  169. // tab 切换
  170. handlerTabs($event) {
  171. uni.showToast({
  172. icon:'loading',
  173. duration:1000
  174. })
  175. this.isEmpty = false
  176. this.isLastPage = false
  177. this.procurementList = []
  178. this.currentTab = $event.index
  179. this.loadding = true
  180. this.pullUpOn = true
  181. this.pageInfo.pageNo = 1
  182. this.pageInfo.status = $event.index
  183. this.procurementAllList()
  184. },
  185. // 弹窗确认或取消
  186. handleClick($event) {
  187. if ($event.index === 1) {
  188. if (this.procurement.isInvolved === 1) {
  189. // 退出参与
  190. this.procurementUpdate(1, () => this.procurementAllAddList())
  191. } else {
  192. // 删除
  193. this.procurementUpdate(0, () => this.procurementAllAddList())
  194. }
  195. }
  196. this.modal = false
  197. },
  198. hideMobel($event) {},
  199. // 组件传递商品详情 退出
  200. modelData(proData) {
  201. this.contentModalText = '确定退出参与该需求吗?'
  202. this.modal = true
  203. this.procurement = proData
  204. },
  205. // 关闭底部
  206. handlerPopupClose($event) {
  207. this.popupShow = $event
  208. },
  209. // 我要参与
  210. popupAdd($event) {
  211. this.joinData = $event
  212. this.popupShow = true
  213. },
  214. // 修改
  215. popupChange($event) {
  216. this.procurement = $event
  217. if (this.procurement.isInvolved === 1) {
  218. this.procurementEditData()
  219. } else {
  220. uni.navigateTo({
  221. url: '/pages/goods/procurementAdd?id=' + $event.id
  222. })
  223. }
  224. },
  225. // 发布
  226. procurementAdd() {
  227. uni.navigateTo({
  228. url: `/pages/goods/procurementAdd?currentTab=${this.currentTab}`
  229. })
  230. },
  231. // 删除
  232. proDelete($event) {
  233. this.contentModalText = '确定删除该需求吗?'
  234. this.modal = true
  235. this.procurement = $event
  236. },
  237. // 详情
  238. procureDetail($event) {
  239. uni.navigateTo({
  240. url: `/pages/goods/procurement_info?id=${$event.id}&proTabId=${this.currentTab}`
  241. })
  242. },
  243. proListCallback() {
  244. this.procurementAllAddList()
  245. },
  246. /**
  247. * 网络请求
  248. */
  249. // 全部集采
  250. async procurementAllList() {
  251. if (!this.isLastPage) {
  252. try {
  253. const { data } = await this.ProcurementService.procurementAllList(this.pageInfo)
  254. this.procurementList = [...this.procurementList, ...data.list]
  255. this.isLastPage = data.total === this.procurementList.length
  256. this.loadding = !this.isLastPage
  257. this.pullUpOn = !this.isLastPage
  258. this.skeletonShow = false
  259. if (this.procurementList.length === 0) {
  260. this.isEmpty = true
  261. }
  262. } catch (error) {
  263. console.log(error)
  264. }
  265. }
  266. },
  267. }
  268. }
  269. </script>
  270. <style lang="scss">
  271. page {
  272. background-color: #f7f7f7;
  273. }
  274. ::v-deep .tui-tabs-view {
  275. padding: 0 64rpx !important;
  276. }
  277. .proInit {
  278. background-color: #f7f7f7;
  279. }
  280. .proInit .tab {
  281. position: fixed;
  282. left: 0;
  283. top: 0;
  284. z-index: 9;
  285. }
  286. ::v-deep .tui-tabs-slider {
  287. background: #f3b574 !important;
  288. }
  289. ::v-deep .tui-tabs-title.tui-tabs-active {
  290. color: #f3b574 !important;
  291. }
  292. .tabsContent {
  293. background-color: #f7f7f7;
  294. padding: 16rpx 32rpx;
  295. }
  296. .add_btn {
  297. width: 100rpx;
  298. height: 100rpx;
  299. position: fixed;
  300. bottom: 129rpx;
  301. right: 34rpx;
  302. }
  303. </style>