info-hope.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. // pages/edit-info/info-hope/info-hope.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. isModify: false,
  8. r1: "1",
  9. r2: "1",
  10. //页面数据
  11. data:{
  12. expectedJobType: "不限",
  13. shortJobTime: "不限",
  14. ableWorkDay: "均可",
  15. isFullTime: 1,
  16. userId: "",
  17. },
  18. // checkbox数据
  19. isExpectedJobType: true,
  20. isShortJobTime: true,
  21. position: 'left',
  22. items1: [{
  23. id: 1,
  24. name: '短期兼职',
  25. checked: false
  26. }, {
  27. id: 2,
  28. name: '长期兼职',
  29. checked: false
  30. }, {
  31. id: 3,
  32. name: '周末兼职',
  33. checked: false
  34. },{
  35. id: 4,
  36. name: '实习',
  37. checked: false
  38. }
  39. ],
  40. items2: [{
  41. id: 1,
  42. name: '工作日',
  43. checked: false
  44. }, {
  45. id: 2,
  46. name: '周末',
  47. checked: false
  48. }, {
  49. id: 3,
  50. name: '节假日',
  51. checked: false
  52. }, {
  53. id: 4,
  54. name: '寒暑假',
  55. checked: false
  56. }
  57. ],
  58. },
  59. //点击选择可上班时间
  60. workday(){
  61. var _this = this
  62. wx.showActionSheet({
  63. itemList: ['均可', '每周1天', '每周2天', '每周3天', '每周4天', '每周5天'],
  64. success(res) {
  65. if (res.tapIndex==0){
  66. _this.setData({
  67. 'data.ableWorkDay': '均可'
  68. });
  69. }else{
  70. _this.setData({
  71. 'data.ableWorkDay': '每周' + res.tapIndex + '天'
  72. });
  73. }
  74. console.log(_this.data)
  75. },
  76. fail(res) {
  77. console.log(res.errMsg)
  78. }
  79. })
  80. },
  81. // 点击重置
  82. reset(e){
  83. },
  84. // 点击提交
  85. submit(e){
  86. var _this = this
  87. wx.request({
  88. url: getApp().globalData.baseURL + '/resume/modify',
  89. method: 'POST',
  90. data: {
  91. "id": _this.data.data.userId,
  92. "type": 3,
  93. "data": _this.data.data
  94. },
  95. success(res) {
  96. if (res.statusCode == 200) {
  97. wx.showToast({
  98. title: '提交成功',
  99. icon: 'none',
  100. })
  101. } else {
  102. wx.showToast({
  103. title: '提交失败,请联系管理员',
  104. icon: 'none',
  105. })
  106. }
  107. }
  108. })
  109. },
  110. // 期望的工作类型checkbox监听事件
  111. checkboxChange(e){
  112. console.log(e.detail)
  113. let index = e.currentTarget.dataset['index'];
  114. let items = this.data[`items${index}`];
  115. items.forEach(item => {
  116. if (item.id == e.detail.key) {
  117. item.checked = e.detail.checked;
  118. }
  119. });
  120. this.setData({
  121. [`items${index}`]: items
  122. });
  123. items.forEach(item => {
  124. if (item.checked) {
  125. if (index == '1') {
  126. this.setData({
  127. 'data.expectedJobType': item.name
  128. });
  129. } else if (index == '2'){
  130. this.setData({
  131. 'data.shortJobTime': item.name
  132. });
  133. }
  134. }
  135. });
  136. },
  137. // 短期工作时间checkbox监听事件
  138. checkboxChange2(e){
  139. },
  140. // 选择短期工作时间
  141. workTimeChange(e){
  142. if(e.detail.currentKey=="2"){
  143. this.setData({
  144. isShortJobTime: false
  145. });
  146. }else{
  147. this.setData({
  148. isShortJobTime: true,
  149. shortJobTime: "不限"
  150. });
  151. }
  152. },
  153. // 选择是否支持全职上班
  154. fullTimeChange(e){
  155. if (e.detail.currentKey == "2") {
  156. this.setData({
  157. isFullTime: 2
  158. });
  159. } else {
  160. this.setData({
  161. isFullTime: 1
  162. });
  163. }
  164. },
  165. // 选择期望工作类型
  166. workTypeChange(e){
  167. if (e.detail.currentKey == "2") {
  168. this.setData({
  169. isExpectedJobType: false
  170. });
  171. } else {
  172. this.setData({
  173. isExpectedJobType: true,
  174. expectedJobType: "不限"
  175. });
  176. }
  177. },
  178. /**
  179. * 生命周期函数--监听页面加载
  180. */
  181. onLoad: function (options) {
  182. // 获取uid
  183. try {
  184. var value = wx.getStorageSync('uid')
  185. if (value) {
  186. this.setData({
  187. 'data.userId': value
  188. });
  189. }
  190. } catch (e) {
  191. console.log(e)
  192. }
  193. },
  194. /**
  195. * 生命周期函数--监听页面初次渲染完成
  196. */
  197. onReady: function () {
  198. },
  199. /**
  200. * 生命周期函数--监听页面显示
  201. */
  202. onShow: function () {
  203. var _this = this
  204. wx.request({
  205. url: getApp().globalData.baseURL + '/resume/id',
  206. method: 'GET',
  207. data: {
  208. "id": _this.data.data.userId,
  209. "type": 3
  210. },
  211. success(res) {
  212. var mydata = _this.data.data
  213. // 如果请求有数据, 就赋值
  214. if (res.data.data){
  215. mydata = res.data.data
  216. }
  217. console.log(mydata)
  218. // 给短期工作选择
  219. if(mydata.shortJobTime != '不限'){
  220. _this.setData({
  221. r1: '2',
  222. });
  223. }
  224. for (var j = 0; j < _this.data.items2.length; j++) {
  225. if (_this.data.items2[j].name === mydata.shortJobTime){
  226. _this.setData({
  227. isShortJobTime: false,
  228. ['items2[' + j + '].checked']: true
  229. });
  230. }
  231. }
  232. // 给期望工作选择
  233. if (mydata.expectedJobType != '不限') {
  234. _this.setData({
  235. r2: '2',
  236. });
  237. }
  238. for (var j = 0; j < _this.data.items1.length; j++) {
  239. if (_this.data.items1[j].name === mydata.expectedJobType) {
  240. _this.setData({
  241. isExpectedJobType: false,
  242. ['items1[' + j + '].checked']: true
  243. });
  244. }
  245. }
  246. _this.setData({
  247. data: mydata,
  248. });
  249. console.log(_this.data)
  250. }
  251. })
  252. },
  253. /**
  254. * 生命周期函数--监听页面隐藏
  255. */
  256. onHide: function () {
  257. },
  258. /**
  259. * 生命周期函数--监听页面卸载
  260. */
  261. onUnload: function () {
  262. },
  263. /**
  264. * 页面相关事件处理函数--监听用户下拉动作
  265. */
  266. onPullDownRefresh: function () {
  267. },
  268. /**
  269. * 页面上拉触底事件的处理函数
  270. */
  271. onReachBottom: function () {
  272. },
  273. /**
  274. * 用户点击右上角分享
  275. */
  276. onShareAppMessage: function () {
  277. }
  278. })