procurement.vue 9.1 KB

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