C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

324 rivejä
6.0 KiB

  1. let app = getApp();
  2. const Http = require("../../utils/HttpBasics");
  3. const util = require("../../utils/util.js");
  4. const config = require("../../config/config");
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. userName: '',
  11. content: '',
  12. phone: '',
  13. date: '2000-01-01',
  14. dateEnd: '',
  15. dateFlag: 1,
  16. gender: '',
  17. sexArry: ['男', '女'],
  18. sexFlag: 1,
  19. fileName: '',
  20. filePath: '',
  21. currentID: '',
  22. isTextleft: false
  23. },
  24. bindDateChange(e) {
  25. this.setData({
  26. date: e.detail.value,
  27. dateFlag: 2
  28. })
  29. },
  30. bindGenderChange(e) {
  31. this.setData({
  32. gender: e.detail.value,
  33. sexFlag: 2
  34. })
  35. },
  36. showPhoneMsg() {
  37. wx.showToast({
  38. title: '手机号无法更改',
  39. icon: "error"
  40. })
  41. },
  42. textareaInput(e) {
  43. const text = e.detail.value
  44. this.setData({
  45. isTextleft: text ? true : false
  46. })
  47. console.log(text);
  48. console.log(this.data.isTextleft);
  49. },
  50. uploadFile() {
  51. wx.chooseMessageFile({
  52. count: 1, // 选择一个文件
  53. type: 'file', // 文件类型,可以是 image、video、file
  54. success: (res) => {
  55. console.log(res, 'res');
  56. wx.showLoading({
  57. title: '上传中',
  58. })
  59. const fileName = res.tempFiles[0].name;
  60. const tempFilePath = res.tempFiles[0].path;
  61. this.goUpload(fileName, tempFilePath);
  62. },
  63. });
  64. },
  65. goUpload(fileName, filePath) {
  66. const that = this
  67. wx.uploadFile({
  68. url: config.url + config.api.resumeFileUpload,
  69. filePath,
  70. name: 'file',
  71. header: {
  72. 'token': app.globalData.token
  73. },
  74. success: (res) => {
  75. const response = JSON.parse(res.data)
  76. console.log(response, 'response')
  77. wx.hideLoading()
  78. wx.showToast({
  79. title: '上传成功',
  80. icon: 'success'
  81. });
  82. that.setData({
  83. fileName,
  84. filePath: response.data.url
  85. })
  86. },
  87. fail: (err) => {
  88. wx.hideLoading()
  89. wx.showToast({
  90. title: '上传失败',
  91. icon: 'error'
  92. });
  93. console.error(err);
  94. },
  95. });
  96. },
  97. cancelUpload() {
  98. const that = this
  99. wx.showModal({
  100. title: '提示',
  101. content: '删除文件后需要重新上传',
  102. success(res) {
  103. if (res.confirm) {
  104. that.setData({
  105. fileName: "",
  106. filePath: ""
  107. })
  108. } else if (res.cancel) {
  109. }
  110. }
  111. })
  112. },
  113. formSubmit(e) {
  114. const that = this
  115. const data = {
  116. userName: e.detail.value.userName,
  117. sex: 1 * that.data.gender + 1,
  118. birthDay: that.data.date + " 00:00:00",
  119. content: e.detail.value.content,
  120. }
  121. console.log(data, 'data');
  122. if (!data.userName) {
  123. wx.showToast({
  124. title: '请输入真实姓名',
  125. icon: 'error',
  126. duration: 2000
  127. })
  128. return
  129. }
  130. if (data.sex == 0) {
  131. wx.showToast({
  132. title: '请选择性别',
  133. icon: 'error',
  134. duration: 2000
  135. })
  136. return
  137. }
  138. if (!data.content) {
  139. wx.showToast({
  140. title: '请输入求职内容',
  141. icon: 'error',
  142. duration: 2000
  143. })
  144. return
  145. }
  146. if (that.data.fileName) data.fileName = that.data.fileName
  147. if (that.data.filePath) data.filePath = that.data.filePath
  148. if (that.data.currentID) data.id = that.data.currentID
  149. Http.post({
  150. url: config.api.resumeAdd,
  151. data,
  152. }).then(res => {
  153. if (res.code == 200) {
  154. wx.showToast({
  155. title: "提交成功!",
  156. icon: 'success',
  157. duration: 1500,
  158. })
  159. } else {
  160. wx.showToast({
  161. title: "提交出错!",
  162. icon: 'error',
  163. duration: 1500,
  164. })
  165. }
  166. }).catch(err => {
  167. console.log(err);
  168. })
  169. },
  170. getUserPhone() {
  171. const that = this
  172. Http.get({
  173. url: config.api.getScore,
  174. data: {}
  175. }).then(res => {
  176. console.log(res.data);
  177. if (res.data.phone) {
  178. that.setData({
  179. phone: res.data.phone
  180. })
  181. }
  182. })
  183. .catch(err => {
  184. wx.showModal({
  185. title: '提示',
  186. content: err.errMsg,
  187. showCancel: false
  188. })
  189. })
  190. },
  191. getResumeDetail() {
  192. const that = this
  193. Http.get({
  194. url: config.api.resumeDetail,
  195. }).then(res => {
  196. const data = res.data
  197. that.setData({
  198. userName: data.userName,
  199. sexFlag: 2,
  200. gender: data.sex - 1,
  201. dateFlag: 2,
  202. date: data.birthDayStr,
  203. })
  204. if (data.content) {
  205. that.setData({
  206. content: data.content,
  207. isTextleft: true
  208. })
  209. }
  210. if (data.id) {
  211. that.setData({
  212. currentID: data.id
  213. })
  214. }
  215. if (data.fileName) {
  216. that.setData({
  217. fileName: data.fileName
  218. })
  219. }
  220. if (data.filePath) {
  221. that.setData({
  222. filePath: data.filePath
  223. })
  224. }
  225. }).catch(err => {
  226. })
  227. },
  228. getPhoneStatus() {
  229. Http.get({
  230. url: config.api.checkPhoneStatus,
  231. }).then(res => {
  232. }).catch(err => {
  233. app.globalData.skip = "redirectTo"
  234. const skipUrl = "/pages3/resume/resume"
  235. wx.redirectTo({
  236. url: `/pages/getphoneInfo/index?skipUrl=${skipUrl}`
  237. });
  238. })
  239. },
  240. /**
  241. * 生命周期函数--监听页面加载
  242. */
  243. onLoad(options) {
  244. this.getPhoneStatus()
  245. this.getUserPhone()
  246. this.getResumeDetail()
  247. },
  248. /**
  249. * 生命周期函数--监听页面初次渲染完成
  250. */
  251. onReady() {
  252. },
  253. /**
  254. * 生命周期函数--监听页面显示
  255. */
  256. onShow() {
  257. },
  258. /**
  259. * 生命周期函数--监听页面隐藏
  260. */
  261. onHide() {
  262. },
  263. /**
  264. * 生命周期函数--监听页面卸载
  265. */
  266. onUnload() {
  267. },
  268. /**
  269. * 页面相关事件处理函数--监听用户下拉动作
  270. */
  271. onPullDownRefresh() {
  272. },
  273. /**
  274. * 页面上拉触底事件的处理函数
  275. */
  276. onReachBottom() {
  277. },
  278. /**
  279. * 用户点击右上角分享
  280. */
  281. // onShareAppMessage() {
  282. // },
  283. })