openMember.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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">
  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. console.log(item);
  290. this.studentId = item.studentId
  291. this.studentName = item.studentName
  292. this.studentShow = false
  293. this.form.sex = item.sex
  294. // this.couponId = ''
  295. // this.getMemberInfo(1)
  296. this.getCouponList()
  297. },
  298. // 设置性别
  299. setSex(index) {
  300. this.form.sex = this.sexList[index].text
  301. },
  302. // 支付
  303. toPay(contractId) {
  304. if (!this.studentId) {
  305. this.$refs.uTips.show({
  306. title: '请选择学员',
  307. type: 'warning',
  308. })
  309. return
  310. }
  311. if (!this.form.parentName) {
  312. this.$refs.uTips.show({
  313. title: '请输入家长姓名',
  314. type: 'warning',
  315. })
  316. return
  317. }
  318. if (!this.form.sex) {
  319. this.$refs.uTips.show({
  320. title: '请选择性别',
  321. type: 'warning',
  322. })
  323. return
  324. }
  325. uni.navigateTo({
  326. url: '/pagesMain/contractInfo?memberCardId=' + this.cardIds + '&couponId=' + this.couponId + '&studentId=' +
  327. this.studentId + '&realPayAmount=' + this.memberInfo.realPayAmount + '&parentName=' + this.form.parentName +
  328. '&sex=' + this.form.sex
  329. });
  330. },
  331. // 跳转支付结果
  332. goToPayResult(oderNo) {
  333. uni.redirectTo({
  334. url: '/pagesMain/payResult?id=' + oderNo
  335. });
  336. },
  337. // 跳转新增学员表单
  338. goToSubscribelForm() {
  339. uni.navigateTo({
  340. url: '/pagesMember/subscribelForm'
  341. });
  342. },
  343. },
  344. }
  345. </script>
  346. <style>
  347. page {
  348. width: 100%;
  349. height: 100%;
  350. }
  351. </style>
  352. <style lang="scss" scoped>
  353. @import "@/static/css/themes.scss";
  354. .content {
  355. width: 100%;
  356. float: left;
  357. // padding: 15px 15px 85px 15px;
  358. padding: 15px 15px 60px 15px;
  359. box-sizing: border-box;
  360. .card-list {
  361. width: 100%;
  362. padding: 15px 20px;
  363. margin-bottom: 15px;
  364. float: left;
  365. background-color: #FFFFFF;
  366. border-radius: 15px;
  367. box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
  368. position: relative;
  369. overflow: hidden;
  370. .card-label {
  371. width: 100%;
  372. margin-bottom: 10px;
  373. float: left;
  374. font-size: 14px;
  375. // font-weight: bold;
  376. // line-height: 20px;
  377. }
  378. .card-num {
  379. width: 100%;
  380. float: left;
  381. font-size: 28px;
  382. line-height: 28px;
  383. color: $mainColor;
  384. }
  385. .card-icon {
  386. font-size: 100px;
  387. color: $mainColor;
  388. position: absolute;
  389. right: -15px;
  390. bottom: -15x;
  391. opacity: 0.5;
  392. }
  393. }
  394. .class-card {
  395. .class-content {
  396. padding: 10px 15px;
  397. display: flex;
  398. align-items: center;
  399. position: relative;
  400. }
  401. .class-info-img {
  402. width: 60px;
  403. height: 60px;
  404. margin-right: 10px;
  405. }
  406. .class-info-content {
  407. flex: 1;
  408. }
  409. .class-info-label {
  410. font-size: 16px;
  411. color: #000000;
  412. word-break: break-all;
  413. margin-bottom: 5px;
  414. }
  415. .class-info-text {
  416. color: #999999;
  417. margin-bottom: 5px;
  418. }
  419. }
  420. .student-box {
  421. max-height: 200px;
  422. padding: 0 15px;
  423. margin: 25px 0 0 0;
  424. box-sizing: border-box;
  425. overflow: auto;
  426. /deep/.u-card__head {
  427. padding-bottom: 0px !important;
  428. }
  429. }
  430. .canvas-container {
  431. width: 100%;
  432. height: 200px;
  433. }
  434. .handle-fix-box {
  435. // height: 85px;
  436. height: 60px;
  437. text-align: center;
  438. .contract-link {
  439. color: $mainColor;
  440. line-height: 25px;
  441. }
  442. }
  443. }
  444. </style>