C端小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

308 Zeilen
5.6 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. wx.showModal({
  99. title: '提示',
  100. content: '删除文件后需要重新上传',
  101. success(res) {
  102. if (res.confirm) {
  103. this.setData({
  104. fileName: "",
  105. filePath: ""
  106. })
  107. } else if (res.cancel) {
  108. }
  109. }
  110. })
  111. },
  112. formSubmit(e) {
  113. const that = this
  114. const data = {
  115. userName: e.detail.value.userName,
  116. sex: 1 * that.data.gender + 1,
  117. birthDay: that.data.date + " 00:00:00",
  118. content: e.detail.value.content,
  119. }
  120. console.log(data, 'data');
  121. if (!data.userName) {
  122. wx.showToast({
  123. title: '请输入真实姓名',
  124. icon: 'error',
  125. duration: 2000
  126. })
  127. return
  128. }
  129. if (data.sex == 0) {
  130. wx.showToast({
  131. title: '请选择性别',
  132. icon: 'error',
  133. duration: 2000
  134. })
  135. return
  136. }
  137. if (!data.content) {
  138. wx.showToast({
  139. title: '请输入求职内容',
  140. icon: 'error',
  141. duration: 2000
  142. })
  143. return
  144. }
  145. if (that.data.fileName) data.fileName = that.data.fileName
  146. if (that.data.filePath) data.filePath = that.data.filePath
  147. if (that.data.currentID) data.id = that.data.currentID
  148. Http.post({
  149. url: config.api.resumeAdd,
  150. data,
  151. }).then(res => {
  152. if (res.code == 200) {
  153. wx.showToast({
  154. title: "提交成功!",
  155. icon: 'success',
  156. duration: 1500,
  157. })
  158. } else {
  159. wx.showToast({
  160. title: "提交出错!",
  161. icon: 'error',
  162. duration: 1500,
  163. })
  164. }
  165. }).catch(err => {
  166. console.log(err);
  167. })
  168. },
  169. getUserPhone() {
  170. const that = this
  171. Http.get({
  172. url: config.api.getScore,
  173. data: {}
  174. }).then(res => {
  175. console.log(res.data);
  176. if (res.data.phone) {
  177. that.setData({
  178. phone: res.data.phone
  179. })
  180. }
  181. })
  182. .catch(err => {
  183. wx.showModal({
  184. title: '提示',
  185. content: err.errMsg,
  186. showCancel: false
  187. })
  188. })
  189. },
  190. getResumeDetail() {
  191. const that = this
  192. Http.get({
  193. url: config.api.resumeDetail,
  194. }).then(res => {
  195. const data = res.data
  196. that.setData({
  197. userName: data.userName,
  198. sexFlag: 2,
  199. gender: data.sex - 1,
  200. dateFlag: 2,
  201. date: data.birthDayStr,
  202. })
  203. if (data.content) {
  204. that.setData({
  205. content: data.content,
  206. isTextleft: true
  207. })
  208. }
  209. if (data.id) {
  210. that.setData({
  211. currentID: data.id
  212. })
  213. }
  214. if (data.fileName) {
  215. that.setData({
  216. fileName: data.fileName
  217. })
  218. }
  219. if (data.filePath) {
  220. that.setData({
  221. filePath: data.filePath
  222. })
  223. }
  224. }).catch(err => {
  225. })
  226. },
  227. /**
  228. * 生命周期函数--监听页面加载
  229. */
  230. onLoad(options) {
  231. this.getUserPhone()
  232. this.getResumeDetail()
  233. },
  234. /**
  235. * 生命周期函数--监听页面初次渲染完成
  236. */
  237. onReady() {
  238. },
  239. /**
  240. * 生命周期函数--监听页面显示
  241. */
  242. onShow() {
  243. },
  244. /**
  245. * 生命周期函数--监听页面隐藏
  246. */
  247. onHide() {
  248. },
  249. /**
  250. * 生命周期函数--监听页面卸载
  251. */
  252. onUnload() {
  253. },
  254. /**
  255. * 页面相关事件处理函数--监听用户下拉动作
  256. */
  257. onPullDownRefresh() {
  258. },
  259. /**
  260. * 页面上拉触底事件的处理函数
  261. */
  262. onReachBottom() {
  263. },
  264. /**
  265. * 用户点击右上角分享
  266. */
  267. // onShareAppMessage() {
  268. // },
  269. })