student_require.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view>
  3. <uni-swipe-action>
  4. <view v-for="(item, index) in requirement" :key="item.requireId">
  5. <uni-swipe-action-item :threshold="0" :right-options="item.options" @click="bindClick(item)">
  6. <view class="requires" @click="requireDetail(item)">
  7. <uni-row class="demo-uni-row">
  8. <uni-col offset="1">
  9. <view class="requires-col1">需求号:{{item.requireId}}</view>
  10. </uni-col>
  11. </uni-row>
  12. <uni-row class="demo-uni-row">
  13. <uni-col offset="1">
  14. <view class="requires-col2">需求科目:{{item.subjectSmall}}</view>
  15. </uni-col>
  16. </uni-row>
  17. <view class="requires-col3">
  18. <uni-row class="demo-uni-row">
  19. <uni-col :span="11" offset="1">
  20. <view>需求金额:{{item.salary}}</view>
  21. </uni-col>
  22. <uni-col :span="4" >
  23. <view style="color: red;">{{item.verifyStatus}}</view>
  24. </uni-col>
  25. <uni-col :span="4" >
  26. <view style="color: red;">{{item.deal}}</view>
  27. </uni-col>
  28. <uni-col :span="4" >
  29. <view style="color: red;">{{item.locked}}</view>
  30. </uni-col>
  31. </uni-row>
  32. </view>
  33. </view>
  34. </uni-swipe-action-item>
  35. </view>
  36. </uni-swipe-action>
  37. <uni-fab :pattern="pattern" horizontal="left" vertical="bottom"
  38. :direction="direction" @fabClick="fabClick" />
  39. </view>
  40. </template>
  41. <script>
  42. import { mapState, mapMutations } from 'vuex'
  43. export default {
  44. data() {
  45. return {
  46. // 分页对象
  47. queryObj: {
  48. pageNum: 1,
  49. pageSize: 8
  50. },
  51. isloading: false,
  52. requirement: [], // 需求列表
  53. count: 0, // 总数量
  54. publishCount: 0, // 上架数量
  55. pattern: {
  56. color: '#7A7E83',
  57. backgroundColor: '#000000',
  58. selectedColor: '#E2F0D9',
  59. buttonColor: '#E2F0D9',
  60. iconColor: '#000000'
  61. }
  62. };
  63. },
  64. created() {
  65. this.getPublishCounts()
  66. },
  67. methods: {
  68. ...mapMutations('m_user', ['updateRequireDetail']),
  69. fabClick() {
  70. uni.navigateTo({
  71. url: '/subpkg/add_stu_require/add_stu_require'
  72. })
  73. },
  74. // 查询个人上架了多少课程
  75. async getPublishCounts(cb) {
  76. // 打开节流阀
  77. this.isloading = true
  78. const { data: result } = await uni.$http.get('/education/student-requirements/getPublishCounts', this.queryObj)
  79. this.isloading = false
  80. cb && cb()
  81. // console.log(result.data.list)
  82. this.publishCount = result.data.publishCounts
  83. this.count = result.data.count
  84. let courses = []
  85. courses = result.data.list
  86. for (let i = 0; i < courses.length; i++) {
  87. if (courses[i].display === '上架') {
  88. courses[i].display = '下架'
  89. courses[i].options = [{text: '下架', style: {backgroundColor: '#E2F0D9', color: 'black'}}]
  90. } else {
  91. courses[i].display = '上架'
  92. courses[i].options = [{text: '上架', style: {backgroundColor: '#E2F0D9', color: 'black'}}]
  93. }
  94. }
  95. this.requirement = [...this.requirement ,...courses]
  96. console.log(this.requirement)
  97. },
  98. // 下拉刷新的事件
  99. onPullDownRefresh() {
  100. if (this.isloading) return
  101. // 1.重置数据
  102. this.queryObj.pageNum = 1
  103. this.publishCount = 0
  104. this.requirement = []
  105. this.isloading = false
  106. // 2.重新发请求
  107. this.getPublishCounts(() => uni.stopPullDownRefresh())
  108. },
  109. // 触底的事件
  110. onReachBottom() {
  111. // 判断是否有下一页的数据
  112. if (this.queryObj.pageNum * this.queryObj.pageSize >= this.count)
  113. return uni.$showMsg('数据加载完毕!')
  114. // 是否有其他正在请求数据
  115. if (this.isloading) return
  116. // 页码自增
  117. this.queryObj.pageNum += 1
  118. this.getPublishCounts()
  119. },
  120. async bindClick(item) {
  121. console.log(item)
  122. if (item.display === '上架') {
  123. if (this.publishCount >= 4) return uni.$showMsg('最多发布4个需求')
  124. if (item.verifyStatus !== '已通过') return uni.$showMsg('审核通过才能上架')
  125. if (item.deal === '已成交') return uni.$showMsg('已成交的需求不能上架')
  126. }
  127. const queryObj = {
  128. display: item.display,
  129. requireId: item.requireId
  130. }
  131. const { data: result } = await uni.$http.get('/education/student-requirements/updatePersonDisplay', queryObj)
  132. const that = this
  133. if (result.code === 20000) {
  134. uni.$showMsg(item.display + '成功')
  135. this.queryObj.pageNum = 1
  136. this.publishCount = 0
  137. this.requirement = []
  138. const { data: result } = await uni.$http.get('/education/student-requirements/getPublishCounts', this.queryObj)
  139. this.publishCount = result.data.publishCounts
  140. this.count = result.data.count
  141. this.requirement = result.data.list
  142. for (let i = 0; i < this.requirement.length; i++) {
  143. if (this.requirement[i].display === '上架') {
  144. this.requirement[i].display = '下架'
  145. this.requirement[i].options = [{text: '下架', style: {backgroundColor: '#E2F0D9', color: 'black'}}]
  146. } else {
  147. this.requirement[i].display = '上架'
  148. this.requirement[i].options = [{text: '上架', style: {backgroundColor: '#E2F0D9', color: 'black'}}]
  149. }
  150. }
  151. }
  152. },
  153. requireDetail(item) {
  154. let stu_require = JSON.stringify(item)
  155. this.updateRequireDetail(stu_require)
  156. uni.navigateTo({
  157. url: '/subpkg/stu_require_detail/stu_require_detail'
  158. })
  159. }
  160. }
  161. }
  162. </script>
  163. <style lang="scss">
  164. .requires {
  165. background-color: #FFF2CC;
  166. border: 1px solid #41719C;
  167. .requires-col1 {
  168. margin-top: 15rpx;
  169. }
  170. .requires-col2 {
  171. margin: 15rpx 0;
  172. }
  173. .requires-col3 {
  174. padding-bottom: 15rpx;
  175. }
  176. }
  177. </style>