recordOne.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. var app = getApp();
  2. var that;
  3. var animation;
  4. Page({
  5. data: {
  6. defaultVal: '',
  7. process: {
  8. recorder_id: app.globalData.userData.id,
  9. recorder: app.globalData.userData.name,
  10. remark: '',
  11. point: 0,
  12. img_url: app.globalData.userData.img_url,
  13. time: app.globalData.allDate
  14. },
  15. items:[],
  16. id:'',
  17. isArrindex:true,//正还是负
  18. },
  19. onLoad(e) {
  20. that = this;
  21. dd.setNavigationBar({ title: "任务过程" });
  22. if(e.id){
  23. this.setData({
  24. id:e.id,
  25. items:JSON.parse(e.item),
  26. process: {
  27. recorder_id: app.globalData.userData.id,
  28. recorder: app.globalData.userData.name,
  29. remark: '',
  30. point: 0,
  31. img_url: app.globalData.userData.img_url,
  32. time: app.globalData.allDate
  33. },
  34. })
  35. }
  36. },
  37. //备注输入
  38. bindTextAreaBlur: function (e) {
  39. this.setData({
  40. [`process.remark`]: e.detail.value,
  41. });
  42. },
  43. bindKeyInput(e) {
  44. this.setData({
  45. [`process.point`]: e.detail.value,
  46. });
  47. },
  48. formSubmit() {
  49. var page1 = getCurrentPages()[getCurrentPages().length - 2]//上一个页面的数据
  50. if(this.data.process.point==0||!this.data.process.point){
  51. app.globalData.showToast("请输入记分");
  52. return;
  53. }
  54. var data={
  55. work_id:this.data.id,
  56. process:[]
  57. }
  58. var items=this.data.items;
  59. var process=this.data.process;
  60. this.data.isArrindex === false ? process.point = process.point * -1 : process.point = process.point * 1
  61. items.unshift(process)
  62. data.process=JSON.stringify(items);
  63. app.$post("api/integral/work", data).then((res) => {
  64. page1.getDetail(this.data.id,function(){
  65. app.globalData.showToast(res.data.msg);
  66. setTimeout(() => {
  67. dd.navigateBack({ delta: 1 })
  68. }, 1000);
  69. })
  70. })
  71. console.log(page1)
  72. },
  73. //选择奖还是扣(细则)
  74. bindPickerChange() {
  75. this.setData({
  76. isArrindex: !this.data.isArrindex,
  77. });
  78. },
  79. });