C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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