procurement.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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="procurementList.length === 0" />
  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. }
  130. },
  131. computed: {
  132. // 是否登录
  133. ...mapState(['hasLogin'])
  134. },
  135. onShow() {
  136. if (this.hasLogin) {
  137. this.userInfo = uni.getStorageSync('userInfo')
  138. this.pageInfo.userId = this.userInfo.userId
  139. this.participate.userId = this.userInfo.userId
  140. this.procurementAllList()
  141. } else {
  142. this.$api.redirectTo('/pages/login/login')
  143. }
  144. },
  145. onLoad() {
  146. uni.$on('refreshAddData', () => {
  147. this.procurementAllAddList()
  148. })
  149. },
  150. onReachBottom() {
  151. if (!this.isLastPage) {
  152. this.loadding = true
  153. this.pullUpOn = true
  154. this.pageInfo.pageNo += 1
  155. this.procurementAllList()
  156. }
  157. },
  158. onPullDownRefresh() {
  159. this.isLastPage = false
  160. this.procurementList = []
  161. this.procurementAllList()
  162. uni.stopPullDownRefresh()
  163. },
  164. methods: {
  165. // tab 切换
  166. handlerTabs($event) {
  167. this.isLastPage = false
  168. this.procurementList = []
  169. this.currentTab = $event.index
  170. this.loadding = true
  171. this.pullUpOn = true
  172. this.pageInfo.pageNo = 1
  173. this.pageInfo.status = $event.index
  174. this.procurementAllList()
  175. },
  176. // 弹窗确认或取消
  177. handleClick($event) {
  178. if ($event.index === 1) {
  179. if (this.procurement.isInvolved === 1) {
  180. // 退出参与
  181. this.procurementUpdate(1, () => this.procurementAllAddList())
  182. } else {
  183. // 删除
  184. this.procurementUpdate(0, () => this.procurementAllAddList())
  185. }
  186. }
  187. this.modal = false
  188. },
  189. hideMobel($event) {},
  190. // 组件传递商品详情 退出
  191. modelData(proData) {
  192. this.contentModalText = '确定退出参与该需求吗?'
  193. this.modal = true
  194. this.proDataInfo = proData
  195. },
  196. // 关闭底部
  197. handlerPopupClose($event) {
  198. this.popupShow = $event
  199. },
  200. // 我要参与
  201. popupAdd($event) {
  202. this.joinData = $event
  203. this.popupShow = true
  204. },
  205. // 修改
  206. popupChange($event) {
  207. this.procurement = $event
  208. if (this.procurement.isInvolved === 1) {
  209. this.procurementEditData()
  210. } else {
  211. uni.navigateTo({
  212. url: '/pages/goods/procurementAdd?id=' + $event.id
  213. })
  214. }
  215. },
  216. // 发布
  217. procurementAdd() {
  218. uni.navigateTo({
  219. url: `/pages/goods/procurementAdd?currentTab=${this.currentTab}`
  220. })
  221. },
  222. // 删除
  223. proDelete($event) {
  224. this.contentModalText = '确定删除该需求吗?'
  225. this.modal = true
  226. this.procurement = $event
  227. },
  228. // 详情
  229. procureDetail($event) {
  230. uni.navigateTo({
  231. url: `/pages/goods/procurement_info?id=${$event.id}&proTabId=${this.currentTab}`
  232. })
  233. },
  234. proListCallback() {
  235. this.procurementAllAddList()
  236. },
  237. /**
  238. * 网络请求
  239. */
  240. // 全部集采
  241. async procurementAllList() {
  242. if (!this.isLastPage) {
  243. try {
  244. const { data } = await this.ProcurementService.procurementAllList(this.pageInfo)
  245. this.procurementList = [...this.procurementList, ...data.list]
  246. this.isLastPage = data.total === this.procurementList.length
  247. this.loadding = !this.isLastPage
  248. this.pullUpOn = !this.isLastPage
  249. this.skeletonShow = false
  250. } catch (error) {
  251. console.log(error)
  252. }
  253. }
  254. },
  255. }
  256. }
  257. </script>
  258. <style lang="scss">
  259. page {
  260. background-color: #f7f7f7;
  261. }
  262. ::v-deep .tui-tabs-view {
  263. padding: 0 64rpx !important;
  264. }
  265. .proInit {
  266. background-color: #f7f7f7;
  267. }
  268. .proInit .tab {
  269. position: fixed;
  270. left: 0;
  271. top: 0;
  272. z-index: 9;
  273. }
  274. ::v-deep .tui-tabs-slider.data-v-9311a734 {
  275. background: #f3b574 !important;
  276. }
  277. ::v-deep .tui-tabs-title.tui-tabs-active {
  278. color: #f3b574 !important;
  279. }
  280. .tabsContent {
  281. background-color: #f7f7f7;
  282. padding: 16rpx 32rpx;
  283. }
  284. .add_btn {
  285. width: 100rpx;
  286. height: 100rpx;
  287. position: fixed;
  288. bottom: 129rpx;
  289. right: 34rpx;
  290. }
  291. </style>