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.

323 regels
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. console.log(res.code);
  154. wx.showToast({
  155. title: "提交成功!",
  156. icon: 'success',
  157. duration: 1500,
  158. })
  159. this.getResumeDetail()
  160. }).catch(err => {
  161. wx.showToast({
  162. title: err.message,
  163. icon: 'none',
  164. duration: 2000,
  165. })
  166. })
  167. },
  168. getUserPhone() {
  169. const that = this
  170. Http.get({
  171. url: config.api.getScore,
  172. data: {}
  173. }).then(res => {
  174. console.log(res.data);
  175. if (res.data.phone) {
  176. that.setData({
  177. phone: res.data.phone
  178. })
  179. }
  180. })
  181. .catch(err => {
  182. wx.showModal({
  183. title: '提示',
  184. content: err.errMsg,
  185. showCancel: false
  186. })
  187. })
  188. },
  189. getResumeDetail() {
  190. const that = this
  191. Http.get({
  192. url: config.api.resumeDetail,
  193. }).then(res => {
  194. const data = res.data
  195. that.setData({
  196. userName: data.userName,
  197. sexFlag: 2,
  198. gender: data.sex - 1,
  199. dateFlag: 2,
  200. date: data.birthDayStr,
  201. })
  202. if (data.content) {
  203. that.setData({
  204. content: data.content,
  205. isTextleft: true
  206. })
  207. }
  208. if (data.id) {
  209. that.setData({
  210. currentID: data.id
  211. })
  212. }
  213. if (data.fileName) {
  214. that.setData({
  215. fileName: data.fileName
  216. })
  217. }
  218. if (data.filePath) {
  219. that.setData({
  220. filePath: data.filePath
  221. })
  222. }
  223. }).catch(err => {
  224. })
  225. },
  226. getPhoneStatus() {
  227. Http.get({
  228. url: config.api.checkPhoneStatus,
  229. }).then(res => {
  230. }).catch(err => {
  231. app.globalData.skip = "redirectTo"
  232. const skipUrl = "/pages3/resume/resume"
  233. app.globalData.skipUrl = skipUrl
  234. wx.redirectTo({
  235. url: `/pages/getphoneInfo/index?skipUrl=1`
  236. });
  237. })
  238. },
  239. /**
  240. * 生命周期函数--监听页面加载
  241. */
  242. onLoad(options) {
  243. this.getPhoneStatus()
  244. this.getUserPhone()
  245. this.getResumeDetail()
  246. },
  247. /**
  248. * 生命周期函数--监听页面初次渲染完成
  249. */
  250. onReady() {
  251. },
  252. /**
  253. * 生命周期函数--监听页面显示
  254. */
  255. onShow() {
  256. },
  257. /**
  258. * 生命周期函数--监听页面隐藏
  259. */
  260. onHide() {
  261. },
  262. /**
  263. * 生命周期函数--监听页面卸载
  264. */
  265. onUnload() {
  266. },
  267. /**
  268. * 页面相关事件处理函数--监听用户下拉动作
  269. */
  270. onPullDownRefresh() {
  271. },
  272. /**
  273. * 页面上拉触底事件的处理函数
  274. */
  275. onReachBottom() {
  276. },
  277. /**
  278. * 用户点击右上角分享
  279. */
  280. // onShareAppMessage() {
  281. // },
  282. })