condition-screening.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. // components/condition-screening/condition-screening.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. // 默认城市名
  8. cityName: {
  9. type: String,
  10. value: '',
  11. observer(city_name) {
  12. this.setData({
  13. city_name
  14. })
  15. }
  16. },
  17. //地区编码
  18. countryCode: {
  19. type: String,
  20. value: ''
  21. },
  22. // 默认地区列表
  23. areaList: {
  24. type: Array,
  25. value: wx.getStorageSync('areaList')
  26. },
  27. // 是否展示地区
  28. show_area: {
  29. type: Boolean,
  30. value: true
  31. },
  32. // 是否展示薪资
  33. show_salay: {
  34. type: Boolean,
  35. value: true
  36. },
  37. // 是否展示距离
  38. show_distince: {
  39. type: Boolean,
  40. value: true
  41. },
  42. // 是否展示结算方式
  43. show_settlement: {
  44. type: Boolean,
  45. value: true
  46. }
  47. },
  48. /**
  49. * 组件的初始数据
  50. */
  51. data: {
  52. // 结算方式
  53. settlementMethod: [
  54. {
  55. index: '',
  56. name: '不限'
  57. },
  58. {
  59. index: 2,
  60. name: '日结'
  61. },
  62. {
  63. index: 1,
  64. name: '周结'
  65. },
  66. {
  67. index: 0,
  68. name: '月结'
  69. },
  70. {
  71. index: 3,
  72. name: '完工结'
  73. },
  74. {
  75. index: 4,
  76. name: '其他'
  77. },
  78. ],
  79. showAreaList: false, // 显示地区选择开关
  80. showSettlement: false, // 显示地区选择开关
  81. totalSalary: '', //薪资待遇排序(1:正序;2:倒序)
  82. sort: '', //距离排序(1:正序;2:倒序)
  83. settle: '', //结算方式索引
  84. selectId: -1, //选中筛选的条件
  85. city_name: '' //实际显示的地区变量
  86. },
  87. /**
  88. * 组件的方法列表
  89. */
  90. methods: {
  91. // 显示地区选择
  92. showArea() {
  93. this.setData({
  94. selectId: -1,
  95. showSettlement: false,
  96. showAreaList: !this.data.showAreaList
  97. })
  98. },
  99. // 显示结算方式
  100. showSettlementMethod() {
  101. this.setData({
  102. selectId: 0,
  103. showSettlement: !this.data.showSettlement,
  104. showAreaList: false
  105. })
  106. },
  107. // 选择地区
  108. chooseArea(e) {
  109. const { cityname, countrycode } = e.currentTarget.dataset;
  110. this.setData({
  111. city_name: countrycode ? cityname : this.data.cityName,
  112. countryCode: countrycode,
  113. showAreaList: false,
  114. }, () => {
  115. const { countryCode, totalSalary, sort, settle } = this.data;
  116. this.triggerEvent('area', { countryCode, totalSalary, sort, settle })
  117. })
  118. },
  119. // 选择结算方式
  120. doSettlemethod(e) {
  121. const { settle } = e.currentTarget.dataset;
  122. this.setData({
  123. showSettlement: false,
  124. settle
  125. }, () => {
  126. const { countryCode, totalSalary, sort, settle } = this.data;
  127. this.triggerEvent('settlemethod', { countryCode, totalSalary, sort, settle })
  128. })
  129. },
  130. // 按照薪资排序
  131. doSalay() {
  132. let totalSalary = null;
  133. if (this.data.totalSalary == 1) {
  134. totalSalary = 2;
  135. } else {
  136. totalSalary = 1;
  137. }
  138. this.setData({
  139. selectId: 1,
  140. totalSalary,
  141. sort: '',
  142. showSettlement: false,
  143. showAreaList: false
  144. }, () => {
  145. const { countryCode, totalSalary, sort, settle } = this.data;
  146. this.triggerEvent('salay', { countryCode, totalSalary, sort, settle })
  147. })
  148. },
  149. // 按照地区排序
  150. doDistince() {
  151. let sort = null;
  152. if (this.data.sort == 1) {
  153. sort = 2;
  154. } else {
  155. sort = 1;
  156. }
  157. this.setData({
  158. selectId: 2,
  159. sort,
  160. totalSalary: '', //重置
  161. showAreaList: false,
  162. showSettlement: false,
  163. }, () => {
  164. const { countryCode, totalSalary, sort, settle } = this.data;
  165. this.triggerEvent('distince', { countryCode, totalSalary, sort, settle })
  166. })
  167. }
  168. }
  169. })