enrolledForm.vue 16 KB

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