openMember.vue 12 KB

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