enrolledForm.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. <template>
  2. <view class="content">
  3. <u-form :model="form" ref="form" label-width="140">
  4. <!-- <u-form-item label="支付方式" prop="payTypeName" required right-icon="arrow-right" @click.native="payTypeShow = true"> -->
  5. <u-form-item label="支付方式" prop="payTypeName" required>
  6. <!-- <text>{{form.payTypeName}}</text> -->
  7. <u-checkbox-group>
  8. <u-checkbox v-model="item.checked" v-for="(item, index) in payTypeList" :key="index" :name="item.name" @change="checkboxChange">
  9. {{ item.name }}
  10. </u-checkbox>
  11. </u-checkbox-group>
  12. </u-form-item>
  13. <u-form-item label="训练服" prop="payTypeName">
  14. <!-- <text>{{form.payTypeName}}</text> -->
  15. <u-checkbox-group>
  16. <u-checkbox v-model="clothingChecked" name="clothingChecked" @change="clothingCheckboxChange">
  17. 100元训练服
  18. </u-checkbox>
  19. </u-checkbox-group>
  20. </u-form-item>
  21. <!-- <u-form-item v-if="payTypeReasonShow" label="备注" prop="payTypeReason" required>
  22. <u-input v-model="form.payTypeReason" placeholder="请输入支付备注" />
  23. </u-form-item> -->
  24. <u-form-item label="订单号" prop="orderNo" required>
  25. <view style="display: flex;">
  26. <u-input v-model="form.orderNo" placeholder="请选择订单号" style="flex: 1;" @blur="handleInputBlur" />
  27. <u-icon name="scan" size="60" style="margin-left: 5px;" @click="scanQRCode"></u-icon>
  28. </view>
  29. </u-form-item>
  30. <u-form-item label="会员卡" prop="cardName" required right-icon="arrow-right" @click.native="selectCard">
  31. <text>{{form.cardName}}</text>
  32. </u-form-item>
  33. <u-form-item label="优惠券" prop="content" required>
  34. <text>{{form.content}}</text>
  35. </u-form-item>
  36. <!-- <u-form-item label="有效期" prop="time" required right-icon="arrow-right" @click.native="timeShow = true" v-if="payTypeCode == 1">
  37. <text>{{form.time}}</text>
  38. </u-form-item> -->
  39. <u-form-item label="支付凭证" prop="payFileId" required label-position="top">
  40. <u-upload :max-count="1" :action="uploadUrl" :header="uploadHeader" @on-success="uploadSuccess" @on-error="uploadError"
  41. @on-remove="uploadRemove" :file-list="payFileList" index="2"></u-upload>
  42. </u-form-item>
  43. <u-form-item label="学生照片" prop="imageFileId" required label-position="top">
  44. <u-upload :max-count="1" :action="uploadUrl" :header="uploadHeader" @on-success="uploadSuccess" @on-error="uploadError"
  45. @on-remove="uploadRemove" :file-list="fileList" index="1"></u-upload>
  46. </u-form-item>
  47. <!-- <u-form-item label="上传合同" prop="contractFileId" required label-position="top" v-if="payTypeCode == 1">
  48. <u-upload :max-count="1" :action="uploadUrl" :header="uploadHeader" @on-success="uploadSuccess" @on-error="uploadError"
  49. @on-remove="uploadRemove" index="2"></u-upload>
  50. </u-form-item> -->
  51. <u-form-item label="接收人" prop="coachName" required>
  52. <u-input v-model="form.coachName" placeholder="请输入接收人" disabled />
  53. </u-form-item>
  54. <u-form-item label="家长姓名" prop="parentsName">
  55. <u-input v-model="form.parentsName" placeholder=" " disabled />
  56. </u-form-item>
  57. <u-form-item label="学员姓名" prop="studentName">
  58. <u-input v-model="form.studentName" placeholder=" " disabled />
  59. </u-form-item>
  60. <!-- <u-form-item label="学员性别" prop="sex" right-icon="arrow-right" @click.native="sexShow = true"> -->
  61. <u-form-item label="学员性别" prop="sex" placeholder=" " disabled>
  62. <!-- <text>{{form.sex}}</text> -->
  63. <u-input v-model="form.sex" placeholder=" " disabled />
  64. </u-form-item>
  65. <u-form-item label="学员年龄" prop="age">
  66. <u-input v-model="form.age" placeholder=" " disabled />
  67. </u-form-item>
  68. <u-form-item label="学生生日" prop="birthday" >
  69. <u-input v-model="form.birthday" placeholder=" " disabled @click="birthdayShow = true"/>
  70. </u-form-item>
  71. <u-form-item label="手机号码" prop="phone">
  72. <u-input v-model="form.phone" placeholder=" " disabled />
  73. </u-form-item>
  74. <!--<u-form-item label="报名场馆" prop="venueName" required right-icon="arrow-right" @click.native="venueShow = true">-->
  75. <u-form-item label="报名场馆" prop="venueName" required right-icon="arrow-right">
  76. <text>{{form.venueName}}</text>
  77. </u-form-item>
  78. <u-form-item label="报名班级" prop="className" required right-icon="arrow-right" @click.native="selectClass">
  79. <text>{{form.className}}</text>
  80. </u-form-item>
  81. <u-form-item label="销售员" prop="talkerName" required right-icon="arrow-right" @click.native="talkerShow = true">
  82. <text>{{form.talkerName}}</text>
  83. </u-form-item>
  84. <u-form-item label="备注" :required="payTypeReasonShow">
  85. <u-input v-model="form.remark" placeholder="请输入备注" />
  86. </u-form-item>
  87. </u-form>
  88. <!-- 性别 -->
  89. <u-action-sheet :list="sexList" v-model="sexShow" @click="setSex"></u-action-sheet>
  90. <!-- 有效期 -- >
  91. <u-picker v-model="timeShow" mode="time" :params="timeParams" @confirm="setTime"></u-picker>
  92. <!-- 学生生日 -->
  93. <u-picker v-model="birthdayShow" mode="time" :params="birthdayParams" @confirm="setBirthday"></u-picker>
  94. <!-- <u-picker mode="selector" v-model="classShow" :range="classList" range-key="name" @confirm="setClass"></u-picker> -->
  95. <!-- 销售员 -->
  96. <!-- <u-picker mode="selector" v-model="saleShow" :range="saleList" range-key="name" @confirm="setSale"></u-picker> -->
  97. <!-- 会员卡 -->
  98. <u-picker mode="selector" v-model="cardShow" :range="cardList" range-key="cardNameTypeName" @confirm="setCard"></u-picker>
  99. <!-- 场馆 -->
  100. <u-picker mode="selector" v-model="venueShow" :range="venueList" range-key="name" @confirm="setVenue"></u-picker>
  101. <!-- 谈单人 -->
  102. <u-picker mode="selector" v-model="talkerShow" :range="talkerList" range-key="name" @confirm="setTalker"></u-picker>
  103. <!-- 支付方式 -->
  104. <u-picker mode="selector" v-model="payTypeShow" :range="payTypeList" range-key="name" @confirm="setPayType"></u-picker>
  105. <view class="handle-fix-box">
  106. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="submitForm">提交</u-button>
  107. </view>
  108. <u-top-tips ref="uTips"></u-top-tips>
  109. </view>
  110. </template>
  111. <script>
  112. import {
  113. mapGetters
  114. } from 'vuex'
  115. const NET = require('@/utils/request')
  116. const API = require('@/config/api')
  117. export default {
  118. computed: {
  119. ...mapGetters([
  120. 'customStyle',
  121. ])
  122. },
  123. data() {
  124. return {
  125. uploadUrl: API.uploadFile,
  126. uploadHeader: {
  127. Authorization: uni.getStorageSync('token')
  128. },
  129. // payTypeCode: '',
  130. // 支付凭证
  131. payFileList: [],
  132. // 学生照片
  133. fileList: [],
  134. // 多选支付备注显示
  135. payTypeReasonShow: false,
  136. form: {
  137. saleIsMeFlag:true,
  138. isSignUp:0,
  139. // 选中的支付方式
  140. payTypeId: [],
  141. // 备注
  142. // payTypeReason: '',
  143. // 订单
  144. orderNo: '',
  145. // 支付凭证
  146. payFileId: '',
  147. // 会员卡
  148. cardId: '',
  149. cardName: '',
  150. // 优惠券
  151. discountCouponId: '',
  152. content: '',
  153. // 学生照片
  154. imageFileId: '',
  155. // 接收人
  156. coachName: '',
  157. // 家长姓名
  158. parentsName: '',
  159. // 学生姓名
  160. studentId: '',
  161. studentName: '',
  162. // 学生性别
  163. sex: '',
  164. // 学生年龄
  165. age: '',
  166. // 学生生日
  167. birthday: '',
  168. // 手机号码
  169. phone: '',
  170. // 场馆
  171. venueId: '',
  172. venueName: '',
  173. // 班级
  174. classId: '',
  175. className: '',
  176. // 谈单人
  177. talkerId: '',
  178. talkerName: '',
  179. // 备注
  180. remark: '',
  181. // contractFileId: '',
  182. // time: '',
  183. // courseNumber: '',
  184. // coursePrice: '',
  185. // sumPrice: '',
  186. // orderNo: '',
  187. // lessonsGiveNumber: '',
  188. // giftId: [],
  189. // saleId: '',
  190. // saleName: '',
  191. },
  192. sexShow: false,
  193. sexList: [{
  194. text: '男'
  195. },
  196. {
  197. text: '女'
  198. }
  199. ],
  200. timeShow: false,
  201. timeParams: {
  202. year: true,
  203. month: true,
  204. day: true,
  205. hour: true,
  206. minute: true,
  207. second: true
  208. },
  209. birthdayShow: false,
  210. birthdayParams: {
  211. year: true,
  212. month: true,
  213. day: true,
  214. hour: false,
  215. minute: false,
  216. second: false
  217. },
  218. cardShow: false,
  219. cardList: [],
  220. classShow: false,
  221. classList: [],
  222. giftList: [],
  223. saleShow: false,
  224. saleList: [],
  225. venueShow: false,
  226. venueList: [],
  227. talkerShow: false,
  228. talkerList: [],
  229. payTypeShow: false,
  230. clothingChecked: false,
  231. payTypeList: [],
  232. /*payTypeList: [
  233. {
  234. name: '小程序支付',
  235. checked: false,
  236. id: 1
  237. },
  238. {
  239. name: '拉卡拉支付',
  240. checked: false,
  241. id: 2
  242. },
  243. {
  244. name: '现金支付',
  245. checked: false,
  246. id: 3
  247. },
  248. {
  249. name: '刷卡',
  250. checked: false,
  251. id: 4
  252. },
  253. {
  254. name: '中体首款码',
  255. checked: false,
  256. id: 5
  257. },
  258. {
  259. name: '学校收费',
  260. checked: false,
  261. id: 6
  262. }
  263. ]*/
  264. }
  265. },
  266. onShow() {
  267. if (uni.getStorageSync("defaultClass")) {
  268. this.form.classId = uni.getStorageSync("defaultClass").classId
  269. this.form.className = uni.getStorageSync("defaultClass").className
  270. }
  271. NET.request(API.getPayTypeList, {
  272. }, 'POST').then(res => {
  273. res.data.forEach(function(item, index) {
  274. item.checked=false
  275. })
  276. this.payTypeList=res.data
  277. console.log(this.payTypeList)
  278. }).catch(error => {
  279. this.$refs.uTips.show({
  280. title: "无效",
  281. type: 'warning',
  282. })
  283. })
  284. this.form.talkerId = uni.getStorageSync('userData').userId
  285. this.form.talkerName = uni.getStorageSync('userData').nickName
  286. },
  287. onReady() {
  288. this.form.coachName = uni.getStorageSync('userData').nickName
  289. this.getAllVenueData()
  290. },
  291. watch: {
  292. 'form.payTypeId' (newData,oldData) {
  293. this.payTypeReasonShow = newData.length > 1 ? true : false
  294. }
  295. },
  296. methods: {
  297. // 多选框选择
  298. checkboxChange(e) {
  299. const id = this.payTypeList.find( item => item.name == e.name).id
  300. if(e.value) {
  301. this.form.payTypeId.push(id)
  302. } else {
  303. const itemIndex = this.form.payTypeId.findIndex( item => item == id )
  304. this.form.payTypeId.splice(itemIndex, 1)
  305. }
  306. },
  307. clothingCheckboxChange(data){
  308. console.log(data)
  309. },
  310. handleInputBlur(e) {
  311. this.getQrCodeData(e)
  312. },
  313. // 扫码二维码
  314. scanQRCode() {
  315. uni.scanCode({
  316. onlyFromCamera: true,
  317. success: (res) => {
  318. this.getQrCodeData(res.result)
  319. }
  320. });
  321. },
  322. // 获取订单信息
  323. getQrCodeData(orderNo) {
  324. NET.request(API.getQrCodeInfo, {
  325. orderNo
  326. }, 'POST').then(res => {
  327. if(res.data.payState==1){
  328. this.$refs.uTips.show({
  329. title: "订单未完成支付",
  330. type: 'warning',
  331. })
  332. return false
  333. }
  334. this.form.parentsName = res.data.parentsName
  335. this.form.studentId = res.data.studentId
  336. this.form.studentName = res.data.studentName
  337. this.form.sex = res.data.sex
  338. this.form.age = res.data.age
  339. this.form.birthday = res.data.birthday
  340. this.form.phone = res.data.phone
  341. this.cardList = res.data.cards
  342. this.form.venueId = res.data.venueId
  343. this.form.venueName = res.data.venueName
  344. if(this.cardList.length) {
  345. this.form.cardId = this.cardList[0].id
  346. this.form.cardName = this.cardList[0].cardNameTypeName
  347. }
  348. if (res.data.imageFileId) {
  349. this.form.imageFileId = res.data.imageFileId
  350. this.fileList = [{
  351. url: res.data.imageFileUrl
  352. }]
  353. }
  354. if(res.data.couponList.length) {
  355. this.form.discountCouponId = res.data.couponList[0].id
  356. this.form.content = res.data.couponList[0].content
  357. } else {
  358. this.form.discountCouponId = ""
  359. this.form.content = '无可用优惠券'
  360. }
  361. this.form.orderNo = res.data.orderNo
  362. }).catch(error => {
  363. this.$refs.uTips.show({
  364. title: "订单无效",
  365. type: 'warning',
  366. })
  367. })
  368. },
  369. // 文件上传成功回调
  370. uploadSuccess(res, index, lists, name) {
  371. if (name == 1) {
  372. this.form.imageFileId = res.data.id
  373. } else if (name == 2) {
  374. this.form.payFileId = res.data.id
  375. }
  376. this.$refs.uTips.show({
  377. title: '文件上传成功',
  378. type: 'success',
  379. })
  380. return true
  381. },
  382. // 文件上传失败回调
  383. uploadError(res, index, lists, name) {
  384. this.$refs.uTips.show({
  385. title: error.message,
  386. type: 'warning',
  387. })
  388. },
  389. // 移除文件回调
  390. uploadRemove(index, lists, name) {
  391. if (name == 1) {
  392. this.form.imageFileId = ''
  393. } else if (name == 2) {
  394. this.form.contractFileId = ''
  395. }
  396. },
  397. // 会员卡
  398. selectCard() {
  399. if(!this.form.orderNo) {
  400. this.$refs.uTips.show({
  401. title: '请先选择订单',
  402. type: 'warning',
  403. })
  404. return false
  405. }
  406. this.cardShow = true
  407. },
  408. // 设置性别
  409. setSex(index) {
  410. this.form.sex = this.sexList[index].text
  411. },
  412. // 设置生日
  413. setBirthday(object) {
  414. this.form.birthday = object.year + '-' + object.month + '-' + object.day
  415. },
  416. // 获取所有场馆
  417. getAllVenueData() {
  418. NET.request(API.getVenueListInfo, {
  419. ...uni.getStorageSync('locationData'),
  420. }, 'POST').then(res => {
  421. console.log(res.data)
  422. this.venueList = res.data
  423. }).catch(error => {
  424. this.$refs.uTips.show({
  425. title: error.message,
  426. type: 'warning',
  427. })
  428. })
  429. // 获取谈单人列表
  430. NET.request(API.getTalkerList, {
  431. page: 1,
  432. size: 1000,
  433. }, 'POST').then(res => {
  434. this.talkerList = res.data.row
  435. }).catch(error => {
  436. this.$refs.uTips.show({
  437. title: error.message,
  438. type: 'warning',
  439. })
  440. })
  441. },
  442. // 设置场馆
  443. setVenue(object) {
  444. this.form.classId = ''
  445. this.form.className = ''
  446. this.form.venueId = this.venueList[object[0]].id
  447. this.form.venueName = this.venueList[object[0]].name
  448. },
  449. // 设置卡片
  450. setCard(object) {
  451. this.form.cardId = this.cardList[object[0]].id
  452. this.form.cardName = this.cardList[object[0]].cardNameTypeName
  453. },
  454. // 跳转班级列表
  455. selectClass() {
  456. if(!this.form.venueId) {
  457. this.$refs.uTips.show({
  458. title: '请先选择场馆',
  459. type: 'warning',
  460. })
  461. return
  462. }
  463. uni.navigateTo({
  464. url: `/pagesEnroll/classList?venueId=${this.form.venueId}`
  465. });
  466. },
  467. // 设置报名班级
  468. setClass(object) {
  469. this.form.classId = this.classList[object[0]].id
  470. this.form.className = this.classList[object[0]].name
  471. },
  472. // 设置谈单人
  473. setTalker(object) {
  474. this.form.talkerId = this.talkerList[object[0]].id
  475. this.form.talkerName = this.talkerList[object[0]].name
  476. },
  477. // 提交表单
  478. submitForm() {
  479. this.form.suitFee = this.clothingChecked
  480. console.log(this.form);
  481. let message = ''
  482. if(this.form.payTypeId.length == 0) {
  483. message = '请选择支付方式'
  484. } else if (!this.form.orderNo) {
  485. message = '请选择订单号'
  486. } else if (!this.form.cardId) {
  487. message = '请选择会员卡'
  488. } else if (!this.form.payFileId) {
  489. message = '请上传支付凭证'
  490. } else if (!this.form.imageFileId) {
  491. message = '请上传学生照片'
  492. } else if (!this.form.phone) {
  493. message = '请输入手机号'
  494. } else if (!this.form.className) {
  495. message = '请输入报名班级'
  496. } else if (!this.form.talkerName){
  497. message = '请选择谈单人'
  498. } else if (this.form.payTypeId.length > 1 && !this.form.remark){
  499. message = '请输入支付备注'
  500. }
  501. if(message) {
  502. this.$refs.uTips.show({
  503. title: message,
  504. type: 'warning',
  505. })
  506. return false
  507. }
  508. NET.request(API.joinCLass, {
  509. ...this.form,
  510. }, 'POST').then(res => {
  511. console.log(res);
  512. this.$refs.uTips.show({
  513. title: '提交成功',
  514. type: 'success',
  515. })
  516. setTimeout(() => {
  517. uni.navigateBack()
  518. }, 1000)
  519. }).catch(error => {
  520. this.$refs.uTips.show({
  521. title: error.message,
  522. type: 'warning',
  523. })
  524. })
  525. },
  526. // 设置有效期
  527. setTime(object) {
  528. this.form.time = object.year + '-' + object.month + '-' + object.day + ' ' + object.hour + ':' + object.minute + ':' + object.second
  529. },
  530. // 设置销售员
  531. setSale(object) {
  532. this.form.saleId = this.saleList[object[0]].id
  533. this.form.saleName = this.saleList[object[0]].name
  534. },
  535. // 设置支付方式
  536. setPayType(object) {
  537. this.form.payTypeId = this.payTypeList[object[0]].id
  538. this.form.payTypeName = this.payTypeList[object[0]].name
  539. this.payTypeCode = this.payTypeList[object[0]].other
  540. },
  541. // 设置总价
  542. setCoursePrice() {
  543. if (this.form.courseNumber && this.form.sumPrice) {
  544. this.form.coursePrice = (this.form.sumPrice / this.form.courseNumber).toFixed(2)
  545. }
  546. },
  547. },
  548. }
  549. </script>
  550. <style>
  551. page {
  552. width: 100%;
  553. height: 100%;
  554. position: relative;
  555. }
  556. </style>
  557. <style lang="scss" scoped>
  558. @import "@/static/css/themes.scss";
  559. .content {
  560. width: 100%;
  561. float: left;
  562. padding: 0 15px 60px 15px;
  563. box-sizing: border-box;
  564. }
  565. </style>