enrolledForm.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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. }
  246. },
  247. onShow() {
  248. if (uni.getStorageSync("defaultClass")) {
  249. this.form.classId = uni.getStorageSync("defaultClass").classId
  250. this.form.className = uni.getStorageSync("defaultClass").className
  251. }
  252. this.form.talkerId = uni.getStorageSync('userData').userId
  253. this.form.talkerName = uni.getStorageSync('userData').nickName
  254. },
  255. onReady() {
  256. this.form.coachName = uni.getStorageSync('userData').nickName
  257. this.getAllVenueData()
  258. },
  259. watch: {
  260. 'form.payTypeId' (newData,oldData) {
  261. this.payTypeReasonShow = newData.length > 1 ? true : false
  262. }
  263. },
  264. methods: {
  265. // 多选框选择
  266. checkboxChange(e) {
  267. const id = this.payTypeList.find( item => item.name == e.name).id
  268. if(e.value) {
  269. this.form.payTypeId.push(id)
  270. } else {
  271. const itemIndex = this.form.payTypeId.findIndex( item => item == id )
  272. this.form.payTypeId.splice(itemIndex, 1)
  273. }
  274. },
  275. handleInputBlur(e) {
  276. this.getQrCodeData(e)
  277. },
  278. // 扫码二维码
  279. scanQRCode() {
  280. uni.scanCode({
  281. onlyFromCamera: true,
  282. success: (res) => {
  283. this.getQrCodeData(res.result)
  284. }
  285. });
  286. },
  287. // 获取订单信息
  288. getQrCodeData(orderNo) {
  289. NET.request(API.getQrCodeInfo, {
  290. orderNo
  291. }, 'POST').then(res => {
  292. if(res.data.payState==1){
  293. this.$refs.uTips.show({
  294. title: "订单未完成支付",
  295. type: 'warning',
  296. })
  297. return false
  298. }
  299. this.form.parentsName = res.data.parentsName
  300. this.form.studentId = res.data.studentId
  301. this.form.studentName = res.data.studentName
  302. this.form.sex = res.data.sex
  303. this.form.age = res.data.age
  304. this.form.birthday = res.data.birthday
  305. this.form.phone = res.data.phone
  306. this.cardList = res.data.cards
  307. this.form.venueId = res.data.venueId
  308. this.form.venueName = res.data.venueName
  309. if(this.cardList.length) {
  310. this.form.cardId = this.cardList[0].id
  311. this.form.cardName = this.cardList[0].cardNameTypeName
  312. }
  313. if (res.data.imageFileId) {
  314. this.form.imageFileId = res.data.imageFileId
  315. this.fileList = [{
  316. url: res.data.imageFileUrl
  317. }]
  318. }
  319. if(res.data.couponList.length) {
  320. this.form.discountCouponId = res.data.couponList[0].id
  321. this.form.content = res.data.couponList[0].content
  322. } else {
  323. this.form.content = '无可用优惠券'
  324. }
  325. this.form.orderNo = res.data.orderNo
  326. }).catch(error => {
  327. this.$refs.uTips.show({
  328. title: "订单无效",
  329. type: 'warning',
  330. })
  331. })
  332. },
  333. // 文件上传成功回调
  334. uploadSuccess(res, index, lists, name) {
  335. if (name == 1) {
  336. this.form.imageFileId = res.data.id
  337. } else if (name == 2) {
  338. this.form.payFileId = res.data.id
  339. }
  340. this.$refs.uTips.show({
  341. title: '文件上传成功',
  342. type: 'success',
  343. })
  344. return true
  345. },
  346. // 文件上传失败回调
  347. uploadError(res, index, lists, name) {
  348. this.$refs.uTips.show({
  349. title: error.message,
  350. type: 'warning',
  351. })
  352. },
  353. // 移除文件回调
  354. uploadRemove(index, lists, name) {
  355. if (name == 1) {
  356. this.form.imageFileId = ''
  357. } else if (name == 2) {
  358. this.form.contractFileId = ''
  359. }
  360. },
  361. // 会员卡
  362. selectCard() {
  363. if(!this.form.orderNo) {
  364. this.$refs.uTips.show({
  365. title: '请先选择订单',
  366. type: 'warning',
  367. })
  368. return false
  369. }
  370. this.cardShow = true
  371. },
  372. // 设置性别
  373. setSex(index) {
  374. this.form.sex = this.sexList[index].text
  375. },
  376. // 设置生日
  377. setBirthday(object) {
  378. this.form.birthday = object.year + '-' + object.month + '-' + object.day
  379. },
  380. // 获取所有场馆
  381. getAllVenueData() {
  382. NET.request(API.getVenueListInfo, {
  383. ...uni.getStorageSync('locationData'),
  384. }, 'POST').then(res => {
  385. this.venueList = res.data
  386. }).catch(error => {
  387. this.$refs.uTips.show({
  388. title: error.message,
  389. type: 'warning',
  390. })
  391. })
  392. // 获取谈单人列表
  393. NET.request(API.getTalkerList, {
  394. page: 1,
  395. size: 1000,
  396. }, 'POST').then(res => {
  397. this.talkerList = res.data.row
  398. }).catch(error => {
  399. this.$refs.uTips.show({
  400. title: error.message,
  401. type: 'warning',
  402. })
  403. })
  404. },
  405. // 设置场馆
  406. setVenue(object) {
  407. this.form.classId = ''
  408. this.form.className = ''
  409. this.form.venueId = this.venueList[object[0]].id
  410. this.form.venueName = this.venueList[object[0]].name
  411. },
  412. // 设置卡片
  413. setCard(object) {
  414. this.form.cardId = this.cardList[object[0]].id
  415. this.form.cardName = this.cardList[object[0]].cardNameTypeName
  416. },
  417. // 跳转班级列表
  418. selectClass() {
  419. if(!this.form.venueId) {
  420. this.$refs.uTips.show({
  421. title: '请先选择场馆',
  422. type: 'warning',
  423. })
  424. return
  425. }
  426. uni.navigateTo({
  427. url: `/pagesEnroll/classList?venueId=${this.form.venueId}`
  428. });
  429. },
  430. // 设置报名班级
  431. setClass(object) {
  432. this.form.classId = this.classList[object[0]].id
  433. this.form.className = this.classList[object[0]].name
  434. },
  435. // 设置谈单人
  436. setTalker(object) {
  437. this.form.talkerId = this.talkerList[object[0]].id
  438. this.form.talkerName = this.talkerList[object[0]].name
  439. },
  440. // 提交表单
  441. submitForm() {
  442. console.log(this.form);
  443. let message = ''
  444. if(this.form.payTypeId.length == 0) {
  445. message = '请选择支付方式'
  446. } else if (!this.form.orderNo) {
  447. message = '请选择订单号'
  448. } else if (!this.form.cardId) {
  449. message = '请选择会员卡'
  450. } else if (!this.form.payFileId) {
  451. message = '请上传支付凭证'
  452. } else if (!this.form.imageFileId) {
  453. message = '请上传学生照片'
  454. } else if (!this.form.phone) {
  455. message = '请输入手机号'
  456. } else if (!this.form.className) {
  457. message = '请输入报名班级'
  458. } else if (!this.form.talkerName){
  459. message = '请选择谈单人'
  460. } else if (this.form.payTypeId.length > 1 && !this.form.remark){
  461. message = '请输入支付备注'
  462. }
  463. if(message) {
  464. this.$refs.uTips.show({
  465. title: message,
  466. type: 'warning',
  467. })
  468. return false
  469. }
  470. NET.request(API.joinCLass, {
  471. ...this.form,
  472. }, 'POST').then(res => {
  473. console.log(res);
  474. this.$refs.uTips.show({
  475. title: '提交成功',
  476. type: 'success',
  477. })
  478. setTimeout(() => {
  479. uni.navigateBack()
  480. }, 1000)
  481. }).catch(error => {
  482. this.$refs.uTips.show({
  483. title: error.message,
  484. type: 'warning',
  485. })
  486. })
  487. },
  488. // 设置有效期
  489. setTime(object) {
  490. this.form.time = object.year + '-' + object.month + '-' + object.day + ' ' + object.hour + ':' + object.minute + ':' + object.second
  491. },
  492. // 设置销售员
  493. setSale(object) {
  494. this.form.saleId = this.saleList[object[0]].id
  495. this.form.saleName = this.saleList[object[0]].name
  496. },
  497. // 设置支付方式
  498. setPayType(object) {
  499. this.form.payTypeId = this.payTypeList[object[0]].id
  500. this.form.payTypeName = this.payTypeList[object[0]].name
  501. this.payTypeCode = this.payTypeList[object[0]].other
  502. },
  503. // 设置总价
  504. setCoursePrice() {
  505. if (this.form.courseNumber && this.form.sumPrice) {
  506. this.form.coursePrice = (this.form.sumPrice / this.form.courseNumber).toFixed(2)
  507. }
  508. },
  509. },
  510. }
  511. </script>
  512. <style>
  513. page {
  514. width: 100%;
  515. height: 100%;
  516. position: relative;
  517. }
  518. </style>
  519. <style lang="scss" scoped>
  520. @import "@/static/css/themes.scss";
  521. .content {
  522. width: 100%;
  523. float: left;
  524. padding: 0 15px 60px 15px;
  525. box-sizing: border-box;
  526. }
  527. </style>