openMember.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <template>
  2. <view class="content">
  3. <template v-if="memberCardList.length">
  4. <view class="card-list" v-for="(item,index) in memberCardList" :key="index">
  5. <view class="card-label" style="height:20rpx;">卡名: {{item.cardName}}</view>
  6. <view class="card-label" style="height:20rpx;">类型: {{item.typeValue}}</view>
  7. <view class="card-label">使用时间: {{ item.startDate }}~{{ item.endDate }}</view>
  8. <view class="card-num">¥{{ item.sellingPrice }}</view>
  9. <view class="card-icon iconfont iconzu4931"></view>
  10. </view>
  11. </template>
  12. <u-form :model="form" label-width="140" style="width: 100%; float: left;">
  13. <!-- <u-form-item label="选择场馆" :right-icon="venueEdit ? 'arrow-right' : ''" required @click.native="venueShow = venueEdit ? true : false">
  14. <text>{{venueName}}</text>
  15. </u-form-item> -->
  16. <!-- <u-form-item label="使用时间">
  17. <text>{{memberInfo.startDate + '~' + memberInfo.endDate}}</text>
  18. </u-form-item> -->
  19. <u-form-item label="学员姓名" :right-icon="studentEdit ? 'arrow-right' : ''" required @click.native="studentShow = studentEdit ? true : false">
  20. <text>{{studentName}}</text>
  21. </u-form-item>
  22. <u-form-item label="优惠金额" right-icon="arrow-right" @click.native="handleCouponClick">
  23. <!-- <text>{{couponId ? '-¥' + memberInfo.discountsAmount : ''}}</text> -->
  24. <text>{{ discountsAmount || 0 }}</text>
  25. </u-form-item>
  26. <u-form-item label="实际金额">
  27. <!-- <text>{{'¥' + (memberInfo.realPayAmount ? memberInfo.realPayAmount : 0)}}</text> -->
  28. <text> {{ '¥' + ( discountsAmount ? getRealPrice : realPayAmount ) }}</text>
  29. </u-form-item>
  30. <u-form-item label="家长名称" required>
  31. <u-input v-model="form.parentName" placeholder="请输入家长姓名" />
  32. </u-form-item>
  33. <!-- <u-form-item label="家长性别" prop="sex" required right-icon="arrow-right" @click.native="sexShow = true">
  34. <text>{{form.sex}}</text>
  35. </u-form-item> -->
  36. </u-form>
  37. <view class="handle-fix-box">
  38. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="toPay()">确定支付¥{{ discountsAmount ? getRealPrice : realPayAmount }}</u-button>
  39. </view>
  40. <!-- 学员 -->
  41. <u-popup v-model="studentShow" mode="bottom" border-radius="30">
  42. <scroll-view scroll-y class="student-box">
  43. <u-card :head-border-bottom="false" :show-foot="false"
  44. margin="10px" borderRadius="20" v-for="(item, index) in studentList" :key="index" @click="selectStudent(item)">
  45. <view slot="head" :style="cardStyle">
  46. <span style="font-size: 36rpx;">{{ item.studentName }}</span>
  47. <span v-if="item.headNum == -1" class="class-info-text" style="color:red;margin-left:10px;">资料不全</span><!-- -->
  48. </view>
  49. <view class="student-card" slot="body" style="display: flex;justify-content: space-between;">
  50. <view class="class-info-text">性别:{{item.sex}}&nbsp;&nbsp;年龄:{{item.age}}</view>
  51. <u-button type="warning" :custom-style="{background: mainColor}" size="mini" shape="circle" :ripple="true" @click="handleUpdateClassClick(item)">修改</u-button>
  52. </view>
  53. </u-card>
  54. </scroll-view>
  55. <u-button type="warning" shape="circle" :ripple="true" :custom-style="{...customStyle,margin:'15px',float: 'left',width: 'calc(100% - 30px)'}"
  56. @click="goToSubscribelForm()">新增学员</u-button>
  57. </u-popup>
  58. <!-- 优惠券 -->
  59. <u-popup v-model="couponShow" mode="bottom" border-radius="30">
  60. <scroll-view scroll-y style="height:300px;margin: 30px 0 15px 0;">
  61. <template v-if="couponList.length">
  62. <u-card :show-head="false" :show-foot="false" padding="0px" margin="0px 30px 20px 30px" borderRadius="40" v-for="(item, index) in couponList"
  63. :key="index" class="class-card" @click="selectCoupon(item)">
  64. <view class="class-content" slot="body">
  65. <view class="class-info-img">
  66. <u-image width="60px" height="60px" :src="item.url" shape="circle"></u-image>
  67. </view>
  68. <view class="class-info-content">
  69. <view class="class-info-label" v-if="item.discountType==3||item.discountType==4">{{item.name}}&nbsp;&nbsp;课时{{item.discountNum}}</view>
  70. <view class="class-info-label" v-else>{{item.name}}¥{{item.money}}</view>
  71. <view class="class-info-text">{{item.content}}</view>
  72. <view class="class-info-text">{{item.endDate}}&nbsp;&nbsp;到期</view>
  73. </view>
  74. </view>
  75. </u-card>
  76. </template>
  77. <template v-else>
  78. <u-empty mode="coupon"></u-empty>
  79. </template>
  80. </scroll-view>
  81. </u-popup>
  82. <!-- 场馆(废弃) -->
  83. <u-popup v-model="venueShow" mode="bottom" border-radius="30">
  84. <scroll-view scroll-y class="student-box">
  85. <u-card :title="item.studentName" title-size="32" :head-style="cardStyle" :head-border-bottom="false" :show-foot="false"
  86. margin="10px" borderRadius="20" v-for="(item, index) in venueList" :key="index" @click="selectVenue(item)">
  87. <view class="student-card" slot="body">
  88. <view class="class-info-text">{{item.venueName}}</view>
  89. </view>
  90. </u-card>
  91. </scroll-view>
  92. </u-popup>
  93. <u-action-sheet :list="sexList" v-model="sexShow" @click="setSex"></u-action-sheet>
  94. <u-top-tips ref="uTips" z-index="11000"></u-top-tips>
  95. </view>
  96. </template>
  97. <script>
  98. import {
  99. mapGetters
  100. } from 'vuex'
  101. const NET = require('@/utils/request')
  102. const API = require('@/config/api')
  103. export default {
  104. computed: {
  105. ...mapGetters([
  106. 'mainColor',
  107. 'customStyle',
  108. ]),
  109. getRealPrice() {
  110. if(this.discountsAmount==0){
  111. return this.realPayAmount
  112. }
  113. if(this.discountsAmount.indexOf("课时")>-1){
  114. return this.realPayAmount
  115. }else{
  116. return this.realPayAmount - Number(this.discountsAmount.replace("¥",''))
  117. }
  118. },
  119. },
  120. data() {
  121. return {
  122. cardIds: "",
  123. memberCardType: '',
  124. memberCardList: [],
  125. // 优惠金额
  126. discountsAmount: 0,
  127. // 实际金额
  128. realPayAmount: 0,
  129. memberInfo: {
  130. id: '',
  131. originalAmount: '',
  132. discountsAmount: '',
  133. realPayAmount: '',
  134. typeValue: '',
  135. endDate: '',
  136. startDate: '',
  137. },
  138. venueEdit: true,
  139. venueId: '',
  140. venueName: '',
  141. venueShow: false,
  142. venueList: [],
  143. couponId: '',
  144. couponShow: false,
  145. couponList: [],
  146. cardStyle: {
  147. fontWeight: 'bold'
  148. },
  149. studentEdit: true,
  150. // 选中的学员
  151. studentId: '',
  152. // 选中的学员名字
  153. studentName: '',
  154. studentShow: false,
  155. studentList: [],
  156. form: {
  157. parentName: '',
  158. sex: '',
  159. },
  160. sexShow: false,
  161. sexList: [{
  162. text: '男'
  163. },
  164. {
  165. text: '女'
  166. }
  167. ],
  168. }
  169. },
  170. onLoad(options) {
  171. this.memberCardList = JSON.parse(decodeURIComponent(options.cardinfo))
  172. this.cardIds = this.memberCardList.map(item => { return item.id }).join(',')
  173. console.log(this.cardIds);
  174. // 计算实际金额
  175. let price = 0
  176. this.memberCardList.map(item => { return item.sellingPrice }).forEach(item => {
  177. price += item
  178. })
  179. this.realPayAmount = price
  180. this.memberInfo.realPayAmount = price
  181. // this.getMemberInfo(1)
  182. // if (options.venueId) {
  183. // this.venueEdit = false
  184. // this.venueId = options.venueId
  185. // this.venueName = options.venueName
  186. // }
  187. // if (options.studentId) {
  188. // this.studentEdit = false
  189. // this.studentId = options.studentId
  190. // this.studentName = options.studentName
  191. // }
  192. // this.memberCardType = options.memberCardType
  193. // if (this.venueId) {
  194. // this.getMemberInfo(1)
  195. // } else {
  196. // this.memberInfo.typeValue = options.typeValue
  197. // }
  198. },
  199. onShow() {
  200. // 场馆信息
  201. // NET.request(API.getAllVenueList, uni.getStorageSync('locationData'), 'POST').then(res => {
  202. // this.venueList = res.data
  203. // }).catch(error => {
  204. // this.$refs.uTips.show({
  205. // title: error.message,
  206. // type: 'warning',
  207. // })
  208. // })
  209. NET.request(API.getAllStudentList, {}, 'POST').then(res => {
  210. this.studentList = res.data
  211. }).catch(error => {
  212. this.$refs.uTips.show({
  213. title: error.message,
  214. type: 'warning',
  215. })
  216. })
  217. // 家长信息
  218. // NET.request(API.getParentInfo, {}, 'POST').then(res => {
  219. // this.form.parentName = res.data.parentName
  220. // this.form.sex = res.data.sex
  221. // }).catch(error => {
  222. // this.$refs.uTips.show({
  223. // title: error.message,
  224. // type: 'warning',
  225. // })
  226. // })
  227. },
  228. methods: {
  229. // 获取数据
  230. getMemberInfo(type) {
  231. NET.request(API.getMemberCardInfo, {
  232. type: this.memberCardType,
  233. venueId: this.venueId,
  234. couponId: this.couponId,
  235. studentId: this.studentId
  236. }, 'POST').then(res => {
  237. this.memberInfo = res.data
  238. if (type == 1) {
  239. this.getCouponList()
  240. }
  241. }).catch(error => {
  242. this.$refs.uTips.show({
  243. title: error.message,
  244. type: 'warning',
  245. })
  246. this.venueId = ''
  247. this.venueName = ''
  248. this.memberInfo = {
  249. id: '',
  250. originalAmount: '',
  251. discountsAmount: '',
  252. realPayAmount: '',
  253. typeValue: this.memberInfo.typeValue,
  254. endDate: '',
  255. startDate: '',
  256. }
  257. })
  258. },
  259. // 获取优惠券
  260. getCouponList() {
  261. // this.couponId = ''
  262. // 仅显示能使用的优惠券
  263. const ids = this.memberCardList.map(item => { return item.id })
  264. NET.request(API.getUsableCouponList, {
  265. ids: ids,
  266. studentId: this.studentId
  267. }, 'POST').then(res => {
  268. this.couponList = res.data
  269. }).catch(error => {
  270. this.$refs.uTips.show({
  271. title: error.message,
  272. type: 'warning',
  273. })
  274. })
  275. },
  276. // 选择优惠券
  277. handleCouponClick() {
  278. // 是否选择了学生
  279. if(!this.studentId) {
  280. this.$refs.uTips.show({
  281. title: '请先选择学员~',
  282. type: 'warning',
  283. })
  284. return
  285. }
  286. // 选择一种卡,显示满减券和赠课券;多种卡,只显示满减券
  287. // discountType 1和2 满减券 3和4 赠课券
  288. if(this.memberCardList.length > 1) {
  289. this.couponList = Object.assign([],this.couponList.filter(item => item.discountType < 3))
  290. }
  291. this.couponShow = true
  292. },
  293. // 选择优惠券
  294. selectCoupon(item) {
  295. this.couponId = item.id
  296. if(item.discountType==3||item.discountType==4){
  297. this.discountsAmount = "课时"+item.discountNum
  298. }else{
  299. this.discountsAmount = "¥"+item.money
  300. }
  301. this.couponShow = false
  302. // this.getMemberInfo(2)
  303. },
  304. // 选择场馆
  305. selectVenue(item) {
  306. this.venueId = item.id
  307. this.venueName = item.venueName
  308. this.venueShow = false
  309. this.getMemberInfo(1)
  310. },
  311. // 选择学员
  312. selectStudent(item) {
  313. if(item.headNum == -1) {
  314. this.$refs.uTips.show({
  315. title: '将资料填全,才能选择',
  316. type: 'warning',
  317. })
  318. return
  319. }
  320. this.studentId = item.studentId
  321. this.studentName = item.studentName
  322. this.studentShow = false
  323. this.form.sex = item.sex
  324. // this.couponId = ''
  325. // this.getMemberInfo(1)
  326. this.getCouponList()
  327. },
  328. // 设置性别
  329. setSex(index) {
  330. this.form.sex = this.sexList[index].text
  331. },
  332. // 修改学员信息
  333. handleUpdateClassClick(item) {
  334. uni.navigateTo({
  335. url: '/pagesMember/subscribelForm?info=' + encodeURIComponent(JSON.stringify(item))
  336. });
  337. },
  338. // 支付
  339. toPay(contractId) {
  340. if (!this.studentId) {
  341. this.$refs.uTips.show({
  342. title: '请选择学员',
  343. type: 'warning',
  344. })
  345. return
  346. }
  347. if (!this.form.parentName) {
  348. this.$refs.uTips.show({
  349. title: '请输入家长姓名',
  350. type: 'warning',
  351. })
  352. return
  353. }
  354. if (!this.form.sex) {
  355. this.$refs.uTips.show({
  356. title: '请选择性别',
  357. type: 'warning',
  358. })
  359. return
  360. }
  361. uni.navigateTo({
  362. url: '/pagesMain/contractInfo?memberCardId=' + this.cardIds + '&couponId=' + this.couponId + '&studentId=' +
  363. this.studentId + '&realPayAmount=' + this.memberInfo.realPayAmount + '&parentName=' + this.form.parentName +
  364. '&sex=' + this.form.sex
  365. });
  366. },
  367. // 跳转支付结果
  368. goToPayResult(oderNo) {
  369. uni.redirectTo({
  370. url: '/pagesMain/payResult?id=' + oderNo
  371. });
  372. },
  373. // 跳转新增学员表单
  374. goToSubscribelForm() {
  375. uni.navigateTo({
  376. url: '/pagesMember/subscribelForm'
  377. });
  378. },
  379. },
  380. }
  381. </script>
  382. <style>
  383. page {
  384. width: 100%;
  385. height: 100%;
  386. }
  387. </style>
  388. <style lang="scss" scoped>
  389. @import "@/static/css/themes.scss";
  390. .content {
  391. width: 100%;
  392. float: left;
  393. // padding: 15px 15px 85px 15px;
  394. padding: 15px 15px 60px 15px;
  395. box-sizing: border-box;
  396. .card-list {
  397. width: 100%;
  398. padding: 15px 20px;
  399. margin-bottom: 15px;
  400. float: left;
  401. background-color: #FFFFFF;
  402. border-radius: 15px;
  403. box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
  404. position: relative;
  405. overflow: hidden;
  406. .card-label {
  407. width: 100%;
  408. margin-bottom: 10px;
  409. float: left;
  410. font-size: 14px;
  411. // font-weight: bold;
  412. // line-height: 20px;
  413. }
  414. .card-num {
  415. width: 100%;
  416. float: left;
  417. font-size: 28px;
  418. line-height: 28px;
  419. color: $mainColor;
  420. }
  421. .card-icon {
  422. font-size: 100px;
  423. color: $mainColor;
  424. position: absolute;
  425. right: -15px;
  426. bottom: -15x;
  427. opacity: 0.5;
  428. }
  429. }
  430. .class-card {
  431. .class-content {
  432. padding: 10px 15px;
  433. display: flex;
  434. align-items: center;
  435. position: relative;
  436. }
  437. .class-info-img {
  438. width: 60px;
  439. height: 60px;
  440. margin-right: 10px;
  441. }
  442. .class-info-content {
  443. flex: 1;
  444. }
  445. .class-info-label {
  446. font-size: 16px;
  447. color: #000000;
  448. word-break: break-all;
  449. margin-bottom: 5px;
  450. }
  451. .class-info-text {
  452. color: #999999;
  453. margin-bottom: 5px;
  454. }
  455. }
  456. .student-box {
  457. max-height: 200px;
  458. padding: 0 15px;
  459. margin: 25px 0 0 0;
  460. box-sizing: border-box;
  461. overflow: auto;
  462. /deep/.u-card__head {
  463. padding-bottom: 0px !important;
  464. }
  465. }
  466. .canvas-container {
  467. width: 100%;
  468. height: 200px;
  469. }
  470. .handle-fix-box {
  471. // height: 85px;
  472. height: 60px;
  473. text-align: center;
  474. .contract-link {
  475. color: $mainColor;
  476. line-height: 25px;
  477. }
  478. }
  479. }
  480. </style>