coursePublish.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. // pages/coursePublish/coursePublish.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. courseOption: '', //课程类别
  8. showCourseOptions: false, //课程类别选项是否展示
  9. courseOptionIndex:'', //选中课程的索引
  10. teachPosition: '', //辅导方式
  11. chosedTeachPosition: false, //辅导方式选项是否展示
  12. teachTimeAM: [], //上午授课时间
  13. teachTimePM: [], //下午授课时间
  14. teachTimeEvening: [], //晚上授课时间
  15. teachTime: [], //合并后的授课时间
  16. successExperience: '', //成功经验
  17. selfIntroduction: '', //自我介绍
  18. // 课程类别
  19. courseOptions: [{
  20. name: "小学",
  21. choesd: false
  22. },
  23. {
  24. name: "初中",
  25. choesd: false
  26. },
  27. {
  28. name: "高中",
  29. choesd: false
  30. },
  31. {
  32. name: "大学",
  33. choesd: false
  34. },
  35. {
  36. name: "音乐",
  37. choesd: false
  38. },
  39. {
  40. name: "舞蹈",
  41. choesd: false
  42. },
  43. {
  44. name: "语言",
  45. choesd: false
  46. },
  47. {
  48. name: "体育",
  49. choesd: false
  50. },
  51. {
  52. name: "美术",
  53. choesd: false
  54. },
  55. {
  56. name: "书法",
  57. choesd: false
  58. },
  59. {
  60. name: "少儿编程",
  61. choesd: false
  62. },
  63. {
  64. name: "计算机",
  65. choesd: false
  66. },
  67. {
  68. name: "其他",
  69. choesd: false
  70. }
  71. ],
  72. // 辅导方式
  73. teachPositions: [{
  74. opType: '老师上门',
  75. choesd: false
  76. },
  77. {
  78. opType: '学员上门',
  79. choesd: false
  80. }, {
  81. opType: '线上辅导',
  82. choesd: false
  83. }, {
  84. opType: '老师住家',
  85. choesd: false
  86. },
  87. {
  88. opType: '学员住家',
  89. choesd: false
  90. }
  91. ],
  92. // 授课时间
  93. // 上午
  94. timeAM: [{
  95. name: '1',
  96. value: 'A1'
  97. },
  98. {
  99. name: '2',
  100. value: 'A2'
  101. },
  102. {
  103. name: '3',
  104. value: 'A3'
  105. },
  106. {
  107. name: '4',
  108. value: 'A4'
  109. },
  110. {
  111. name: '5',
  112. value: 'A5'
  113. },
  114. {
  115. name: '6',
  116. value: 'A6'
  117. },
  118. {
  119. name: '7',
  120. value: 'A7'
  121. }
  122. ],
  123. // 下午
  124. timePM: [{
  125. name: '1',
  126. value: 'P1'
  127. },
  128. {
  129. name: '2',
  130. value: 'P2'
  131. },
  132. {
  133. name: '3',
  134. value: 'P3'
  135. },
  136. {
  137. name: '4',
  138. value: 'P4'
  139. },
  140. {
  141. name: '5',
  142. value: 'P5'
  143. },
  144. {
  145. name: '6',
  146. value: 'P6'
  147. },
  148. {
  149. name: '7',
  150. value: 'P7'
  151. }
  152. ],
  153. // 晚上
  154. timeEvening: [{
  155. name: '1',
  156. value: 'E1'
  157. },
  158. {
  159. name: '2',
  160. value: 'E2'
  161. },
  162. {
  163. name: '3',
  164. value: 'E3'
  165. },
  166. {
  167. name: '4',
  168. value: 'E4'
  169. },
  170. {
  171. name: '5',
  172. value: 'E5'
  173. },
  174. {
  175. name: '6',
  176. value: 'E6'
  177. },
  178. {
  179. name: '7',
  180. value: 'E7'
  181. }
  182. ]
  183. },
  184. /**
  185. * 生命周期函数--监听页面加载
  186. */
  187. onLoad(options) {
  188. },
  189. // 选择课程类别
  190. // 打开课程类别(大类)选项区
  191. toChooseCourseOptions() {
  192. this.setData({
  193. showCourseOptions: true
  194. })
  195. },
  196. // 定义退出下拉选区的方法
  197. hiddenCourseOptions() {
  198. this.setData({
  199. showCourseOptions: false
  200. })
  201. },
  202. // 从下拉区选择课程类别内容
  203. onChooseCourseOptions(e) {
  204. let index = e.currentTarget.dataset.index
  205. let courseOptions = this.data.courseOptions
  206. for (let i = 0; i < courseOptions.length; i++) {
  207. if (i == index) {
  208. courseOptions[i].chosed = !courseOptions[i].chosed
  209. } else {
  210. courseOptions[i].chosed = false
  211. }
  212. }
  213. this.setData({
  214. courseOptions
  215. })
  216. },
  217. // 课程类别(大类)确定按钮的点击事件
  218. confirmCourseOptions() {
  219. let courseOptions = this.data.courseOptions
  220. let index
  221. for (let i = 0; i < courseOptions.length; i++) {
  222. if (courseOptions[i].chosed) {
  223. index = i
  224. }
  225. }
  226. let courseOption = courseOptions[index]?.name || ''
  227. let courseOptionIndex = index
  228. this.setData({
  229. courseOption,
  230. courseOptionIndex
  231. })
  232. this.hiddenCourseOptions()
  233. },
  234. // 辅导方式
  235. // 打开辅导方式选项区
  236. toChosedTeachPosition() {
  237. this.setData({
  238. chosedTeachPosition: true
  239. })
  240. },
  241. // 关闭辅导方式选项区的方法
  242. hiddenTeachPosition() {
  243. this.setData({
  244. chosedTeachPosition: false
  245. })
  246. },
  247. // 从下拉选区选择辅导方式内容
  248. onTeachPosition(e) {
  249. let index = e.currentTarget.dataset.index
  250. let teachPositions = this.data.teachPositions
  251. for (let i = 0; i < teachPositions.length; i++) {
  252. if (i == index) {
  253. teachPositions[i].chosed = !teachPositions[i].chosed
  254. } else {
  255. teachPositions[i].chosed = false
  256. }
  257. }
  258. this.setData({
  259. teachPositions
  260. })
  261. },
  262. // 辅导方式确定按钮点击事件
  263. confirmTeachPosition() {
  264. let teachPositions = this.data.teachPositions
  265. let index
  266. for (let i = 0; i < teachPositions.length; i++) {
  267. if (teachPositions[i].chosed) {
  268. index = i
  269. }
  270. }
  271. let teachPosition = teachPositions[index]?.opType || ''
  272. this.setData({
  273. teachPosition
  274. })
  275. this.hiddenTeachPosition()
  276. },
  277. // 选择授课时间
  278. // 上午
  279. chechboxChangeAM(e) {
  280. // console.log(e)
  281. let teachTimeAM = this.data.teachTimeAM
  282. teachTimeAM = e.detail.value
  283. this.setData({
  284. teachTimeAM
  285. })
  286. // console.log(teachTimeAM)
  287. },
  288. // 下午
  289. chechboxChangePM(e) {
  290. // console.log(e)
  291. let teachTimePM = this.data.teachTimePM
  292. teachTimePM = e.detail.value
  293. this.setData({
  294. teachTimePM
  295. })
  296. // console.log(teachTimePM)
  297. },
  298. // 晚上
  299. chechboxChangeEvening(e) {
  300. // console.log(e)
  301. let teachTimeEvening = this.data.teachTimeEvening
  302. teachTimeEvening = e.detail.value
  303. this.setData({
  304. teachTimeEvening
  305. })
  306. // console.log(teachTimeEvening)
  307. },
  308. // 合并授课时间的函数
  309. joinTime() {
  310. let teachTimeAM = this.data.teachTimeAM
  311. let teachTimePM = this.data.teachTimePM
  312. let teachTimeEvening = this.data.teachTimeEvening
  313. let teachTime = this.data.teachTime
  314. teachTime = teachTimeAM.concat(teachTimePM, teachTimeEvening)
  315. this.setData({
  316. teachTime
  317. })
  318. // console.log("授课时间为:" + teachTime)
  319. },
  320. // 获取成功经验
  321. getSuccess(e) {
  322. console.log(e.detail.value)
  323. this.setData({
  324. successExperience: e.detail.value
  325. })
  326. },
  327. // 获取自我介绍
  328. getSelfIntroduction(e) {
  329. this.setData({
  330. selfIntroduction: e.detail.value
  331. })
  332. },
  333. // 发布课程按钮的点击事件
  334. toPublisCourse() {
  335. this.joinTime()
  336. wx.setStorageSync('course', {
  337. teachPosition: this.data.teachPosition,
  338. teachTime: this.data.teachTime,
  339. successExperience: this.data.successExperience,
  340. selfIntroduction: this.data.selfIntroduction
  341. })
  342. },
  343. /**
  344. * 生命周期函数--监听页面初次渲染完成
  345. */
  346. onReady() {
  347. },
  348. /**
  349. * 生命周期函数--监听页面显示
  350. */
  351. onShow() {
  352. },
  353. /**
  354. * 生命周期函数--监听页面隐藏
  355. */
  356. onHide() {
  357. },
  358. /**
  359. * 生命周期函数--监听页面卸载
  360. */
  361. onUnload() {
  362. },
  363. /**
  364. * 页面相关事件处理函数--监听用户下拉动作
  365. */
  366. onPullDownRefresh() {
  367. },
  368. /**
  369. * 页面上拉触底事件的处理函数
  370. */
  371. onReachBottom() {
  372. },
  373. /**
  374. * 用户点击右上角分享
  375. */
  376. onShareAppMessage() {
  377. }
  378. })