change_information.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. // pages/kids_information/kids_information.js
  2. import { routers, viewImage, sharePage, isFn, getGlobalVal, formatDateTime, formateNumber,curatorName,formatEncrypt } from '../../utils/util.js'
  3. import { StudentDetail,ModifyStudentInfo,BindLibAudit} from '../../utils/api.js'
  4. const { navigateTo, redirectTo, navigateBack } = routers()
  5. const { globalData, saveUserInfo, getWxloginCode, checkStatus } = getApp()
  6. const { baseImgUrl, thumbnail } = globalData
  7. const app = getApp()
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. options: {},
  14. baseImgUrl,
  15. isShowPickerModel: false,
  16. phone:'',
  17. patriarchName:'',
  18. homeAddress:'',
  19. studyPlanName:'',
  20. isAddChild:0,
  21. studentImg:'',
  22. isAdd:false,
  23. imgUrl:'',
  24. school: '',
  25. childName: '',
  26. parentName: '',
  27. sex: 0,
  28. grade: '',
  29. parentRole:'',
  30. isReview:0,
  31. refuseModel:false,
  32. pickerData: [
  33. {
  34. actIndex: 0,
  35. list: ['一年级', '二年级', '三年级', '四年级', '五年级', '六年级']
  36. },
  37. {
  38. actIndex: 0,
  39. list: ['语文', '数学', '英文']
  40. },
  41. {
  42. actIndex: 0,
  43. list: ['男', '女']
  44. }
  45. ],
  46. pickerIndex: null
  47. },
  48. /**
  49. * 生命周期函数--监听页面加载
  50. */
  51. onLoad: function (options) {
  52. this.setData(options)
  53. if (options.isReview==1){
  54. wx.setNavigationBarTitle({
  55. title: '详情',
  56. })
  57. }
  58. const {isReview}=this.data
  59. if(isReview==0){
  60. this.getInformation()
  61. }
  62. },
  63. /**
  64. * 生命周期函数--监听页面初次渲染完成
  65. */
  66. onReady: function () {
  67. const obj = { navigateTo, redirectTo, navigateBack, viewImage }
  68. for (const i in obj) {
  69. this[i] = obj[i]
  70. }
  71. },
  72. /**
  73. * 生命周期函数--监听页面显示
  74. */
  75. onShow: function () {
  76. },
  77. /**
  78. * 生命周期函数--监听页面隐藏
  79. */
  80. onHide: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面卸载
  84. */
  85. onUnload: function () {
  86. },
  87. /**
  88. * 页面相关事件处理函数--监听用户下拉动作
  89. */
  90. onPullDownRefresh: function () {
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom: function () {
  96. },
  97. /**
  98. * 用户点击右上角分享
  99. */
  100. onShareAppMessage: function () {
  101. },
  102. /**
  103. * 路由跳转
  104. */
  105. redirectCtl: app.redirectCtl,
  106. /**
  107. * 路由跳转
  108. */
  109. navigateCtl: app.navigateCtl,
  110. /**
  111. * 提示框隐藏
  112. */
  113. allShowModel: function () {
  114. this.setData({refuseModel:false })
  115. },
  116. /**
  117. * 拒绝审核弹框
  118. */
  119. refuseShow: function (e) {
  120. const { type } = e.currentTarget.dataset;
  121. this.setData({ refuseType: Number(type)})
  122. if(type==2){
  123. this.setData({ refuseModel: true})
  124. }else{
  125. this.selectRefuse()
  126. }
  127. },
  128. /**
  129. * 通过拒绝审核
  130. */
  131. selectRefuse: function (cb) {
  132. const continuousFn = { fn: this.selectRefuse, param: { ...arguments } }
  133. const { vipId,refuseType} = this.data;
  134. BindLibAudit({ data:{vipId,type:refuseType}, continuousFn }).then(res => {
  135. if(refuseType==1){
  136. wx.showToast({
  137. title: '通过审核',
  138. icon: 'none'
  139. })
  140. }else{
  141. wx.showToast({
  142. title: '拒绝成功',
  143. icon: 'none'
  144. })
  145. }
  146. this.allShowModel()
  147. setTimeout(function(){
  148. wx.navigateBack({})
  149. },1500)
  150. if (isFn(cb)) cb()
  151. }).catch(res => {
  152. if (isFn(cb)) cb()
  153. })
  154. },
  155. /**
  156. * 上传头像
  157. */
  158. uploadHeadIconCtl: function () {
  159. wx.chooseImage({
  160. count: 1,
  161. success: res => {
  162. this.uploadImage(res.tempFilePaths[0])
  163. },
  164. fail: res => {
  165. // wx.showToast({
  166. // title: '选择拍照或者相册失败',
  167. // icon: 'none'
  168. // })
  169. }
  170. })
  171. },
  172. /**
  173. * 上传头像接口
  174. */
  175. uploadImage: function (file) {
  176. app.uploadFile('/api/common/common/uploadForm', file, {}).then(res => {
  177. let { filePath } = JSON.parse(res).data.pics[0];
  178. console.log(filePath);
  179. this.setData({ imgUrl: filePath})
  180. // this.updateInfor({
  181. // imageKey: filePath
  182. // }, 1)
  183. })
  184. },
  185. /**
  186. * input
  187. */
  188. inputCtl: function (e) {
  189. const mobileExp = /^1[0-9]{10}$/;
  190. const { temp = {}, type } = e.currentTarget.dataset
  191. const { value } = e.detail
  192. temp[type] = value;
  193. const { parentName, family,phone,childName } = temp;
  194. // console.log(parentName)
  195. if (type == 'phone') {
  196. if (value != '') {
  197. if (!mobileExp.test(value)) {
  198. wx.showToast({
  199. title: '手机号码位数不对',
  200. icon: 'none',
  201. duration: 2000
  202. })
  203. return this.setData({ phone})
  204. } else {
  205. return this.setData({ phone })
  206. }
  207. }
  208. } else if (type == 'childName') {
  209. return this.setData({ childName })
  210. }
  211. },
  212. /**
  213. * picker
  214. */
  215. pickerCtl: function (e) {
  216. const { temp = {}, type, index } = e.currentTarget.dataset
  217. console.log(index)
  218. this.setData({
  219. pickerIndex: index,
  220. isShowPickerModel: true
  221. })
  222. },
  223. /**
  224. * 取消
  225. */
  226. cancel:function(){
  227. wx.navigateBack({})
  228. },
  229. /**
  230. * picker选择列
  231. */
  232. checkPickerModel: function (e) {
  233. const { index } = e.currentTarget.dataset
  234. let { temp = {}, pickerIndex, pickerData } = this.data
  235. let { actIndex, list } = pickerData[pickerIndex]
  236. let str = `pickerData[${pickerIndex}].actIndex`;
  237. console.log(index, pickerIndex)
  238. // if (index < 0) {
  239. if (pickerIndex == 0) {
  240. // if (this.data['grade'] != list[actIndex]) {
  241. temp['grade'] = list[index]
  242. // }
  243. } else if (pickerIndex == 1) {
  244. if (this.data['courseName'] != list[actIndex]) {
  245. temp['courseName'] = list[index]
  246. }
  247. } else if (pickerIndex == 2) {
  248. temp['sex'] = Number(index) + 1
  249. } else if (pickerIndex == 3) {
  250. if (this.data['studyPlan'] != list[actIndex]) {
  251. temp['studyPlan'] = list[index]
  252. }
  253. } else if (pickerIndex == 4) {
  254. if (this.data['parentRole'] != list[actIndex]) {
  255. temp['parentRole'] = list[index]
  256. }
  257. }
  258. temp['isShowPickerModel'] = false
  259. this.setData(temp)
  260. },
  261. /**
  262. * 获取个人信息
  263. */
  264. getInformation: function (cb) {
  265. const continuousFn = { fn: this.getInformation, param: { ...arguments } }
  266. const { vipId, school } = this.data
  267. StudentDetail({ data: {vipId}, continuousFn }).then(res => {
  268. const listTemp = (res => {
  269. if(res.school.length>10){
  270. res.school=res.school.slice(0,10)+'...'
  271. }
  272. return res
  273. })(res.data)
  274. this.setData({ ...res.data })
  275. if (school && school != '' && res.data.school != school) {
  276. this.setData({ school:school })
  277. }
  278. if (isFn(cb)) cb()
  279. }).catch(res => {
  280. if (isFn(cb)) cb()
  281. })
  282. },
  283. /**
  284. * 修改信息
  285. */
  286. amendChildren:function(cb){
  287. const continuousFn = { fn: this.amendChildren, param: { ...arguments } }
  288. var that = this;
  289. const { childName,grade, school, imgUrl, sex,vipId } = this.data;
  290. // console.log(childName,grade, school, imgUrl, sex,vipId);
  291. if (!childName) {
  292. wx.showToast({
  293. title: '请输入学生姓名',
  294. icon: 'none'
  295. })
  296. return
  297. }
  298. if (!grade) {
  299. wx.showToast({
  300. title: '请输入年级',
  301. icon: 'none'
  302. })
  303. return
  304. }
  305. if (!school) {
  306. wx.showToast({
  307. title: '请输入在读学校',
  308. icon: 'none'
  309. })
  310. return
  311. }
  312. ModifyStudentInfo({ data: {
  313. childName:formatEncrypt(childName),
  314. grade,
  315. school:formatEncrypt(school),
  316. imgUrl,
  317. sex:Number(sex),
  318. vipId
  319. }, continuousFn }).then(res => {
  320. wx.showToast({
  321. title: '修改成功',
  322. duration: 1000
  323. })
  324. this.getInformation()
  325. // setTimeout((function callback() {
  326. // wx.navigateBack({
  327. // delta: 2
  328. // })
  329. // }).bind(this), 1000);
  330. if (isFn(cb)) cb()
  331. }).catch(res => {
  332. if (isFn(cb)) cb()
  333. })
  334. },
  335. })