openMember.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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.getMemberInfo(1)
  167. // if (options.venueId) {
  168. // this.venueEdit = false
  169. // this.venueId = options.venueId
  170. // this.venueName = options.venueName
  171. // }
  172. // if (options.studentId) {
  173. // this.studentEdit = false
  174. // this.studentId = options.studentId
  175. // this.studentName = options.studentName
  176. // }
  177. // this.memberCardType = options.memberCardType
  178. // if (this.venueId) {
  179. // this.getMemberInfo(1)
  180. // } else {
  181. // this.memberInfo.typeValue = options.typeValue
  182. // }
  183. },
  184. onShow() {
  185. // 场馆信息
  186. // NET.request(API.getAllVenueList, uni.getStorageSync('locationData'), 'POST').then(res => {
  187. // this.venueList = res.data
  188. // }).catch(error => {
  189. // this.$refs.uTips.show({
  190. // title: error.message,
  191. // type: 'warning',
  192. // })
  193. // })
  194. NET.request(API.getAllStudentList, {}, 'POST').then(res => {
  195. this.studentList = res.data
  196. }).catch(error => {
  197. this.$refs.uTips.show({
  198. title: error.message,
  199. type: 'warning',
  200. })
  201. })
  202. // 家长信息
  203. // NET.request(API.getParentInfo, {}, 'POST').then(res => {
  204. // this.form.parentName = res.data.parentName
  205. // this.form.sex = res.data.sex
  206. // }).catch(error => {
  207. // this.$refs.uTips.show({
  208. // title: error.message,
  209. // type: 'warning',
  210. // })
  211. // })
  212. },
  213. methods: {
  214. // 获取数据
  215. getMemberInfo(type) {
  216. NET.request(API.getMemberCardInfo, {
  217. type: this.memberCardType,
  218. venueId: this.venueId,
  219. couponId: this.couponId,
  220. studentId: this.studentId
  221. }, 'POST').then(res => {
  222. this.memberInfo = res.data
  223. if (type == 1) {
  224. this.getCouponList()
  225. }
  226. }).catch(error => {
  227. this.$refs.uTips.show({
  228. title: error.message,
  229. type: 'warning',
  230. })
  231. this.venueId = ''
  232. this.venueName = ''
  233. this.memberInfo = {
  234. id: '',
  235. originalAmount: '',
  236. discountsAmount: '',
  237. realPayAmount: '',
  238. typeValue: this.memberInfo.typeValue,
  239. endDate: '',
  240. startDate: '',
  241. }
  242. })
  243. },
  244. // 获取优惠券
  245. getCouponList() {
  246. // this.couponId = ''
  247. // 仅显示能使用的优惠券
  248. const ids = this.memberCardList.map(item => { return item.id })
  249. NET.request(API.getUsableCouponList, {
  250. ids: ids,
  251. studentId: this.studentId
  252. }, 'POST').then(res => {
  253. this.couponList = res.data.row
  254. }).catch(error => {
  255. this.$refs.uTips.show({
  256. title: error.message,
  257. type: 'warning',
  258. })
  259. })
  260. },
  261. //
  262. handleCouponClick() {
  263. if(!this.studentId) {
  264. this.$refs.uTips.show({
  265. title: '请先选择学员~',
  266. type: 'warning',
  267. })
  268. return
  269. }
  270. this.couponShow = true
  271. },
  272. // 选择优惠券
  273. selectCoupon(item) {
  274. this.couponId = item.id
  275. this.discountsAmount = item.amount
  276. this.couponShow = false
  277. // this.getMemberInfo(2)
  278. },
  279. // 选择场馆
  280. selectVenue(item) {
  281. this.venueId = item.id
  282. this.venueName = item.venueName
  283. this.venueShow = false
  284. this.getMemberInfo(1)
  285. },
  286. // 选择学员
  287. selectStudent(item) {
  288. this.studentId = item.studentId
  289. this.studentName = item.studentName
  290. this.studentShow = false
  291. // this.couponId = ''
  292. // this.getMemberInfo(1)
  293. this.getCouponList()
  294. },
  295. // 设置性别
  296. setSex(index) {
  297. this.form.sex = this.sexList[index].text
  298. },
  299. // 支付
  300. toPay(contractId) {
  301. if (!this.studentId) {
  302. this.$refs.uTips.show({
  303. title: '请选择学员',
  304. type: 'warning',
  305. })
  306. return
  307. }
  308. if (!this.form.parentName) {
  309. this.$refs.uTips.show({
  310. title: '请输入家长姓名',
  311. type: 'warning',
  312. })
  313. return
  314. }
  315. if (!this.form.sex) {
  316. this.$refs.uTips.show({
  317. title: '请选择性别',
  318. type: 'warning',
  319. })
  320. return
  321. }
  322. uni.navigateTo({
  323. url: '/pagesMain/contractInfo?memberCardId=' + this.cardIds + '&couponId=' + this.couponId + '&studentId=' +
  324. this.studentId + '&realPayAmount=' + this.memberInfo.realPayAmount + '&parentName=' + this.form.parentName +
  325. '&sex=' + this.form.sex
  326. });
  327. },
  328. // 跳转支付结果
  329. goToPayResult(oderNo) {
  330. uni.redirectTo({
  331. url: '/pagesMain/payResult?id=' + oderNo
  332. });
  333. },
  334. // 跳转新增学员表单
  335. goToSubscribelForm() {
  336. uni.navigateTo({
  337. url: '/pagesMember/subscribelForm'
  338. });
  339. },
  340. },
  341. }
  342. </script>
  343. <style>
  344. page {
  345. width: 100%;
  346. height: 100%;
  347. }
  348. </style>
  349. <style lang="scss" scoped>
  350. @import "@/static/css/themes.scss";
  351. .content {
  352. width: 100%;
  353. float: left;
  354. // padding: 15px 15px 85px 15px;
  355. padding: 15px 15px 60px 15px;
  356. box-sizing: border-box;
  357. .card-list {
  358. width: 100%;
  359. padding: 15px 20px;
  360. margin-bottom: 15px;
  361. float: left;
  362. background-color: #FFFFFF;
  363. border-radius: 15px;
  364. box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
  365. position: relative;
  366. overflow: hidden;
  367. .card-label {
  368. width: 100%;
  369. margin-bottom: 10px;
  370. float: left;
  371. font-size: 14px;
  372. // font-weight: bold;
  373. // line-height: 20px;
  374. }
  375. .card-num {
  376. width: 100%;
  377. float: left;
  378. font-size: 28px;
  379. line-height: 28px;
  380. color: $mainColor;
  381. }
  382. .card-icon {
  383. font-size: 100px;
  384. color: $mainColor;
  385. position: absolute;
  386. right: -15px;
  387. bottom: -15x;
  388. opacity: 0.5;
  389. }
  390. }
  391. .class-card {
  392. .class-content {
  393. padding: 10px 15px;
  394. display: flex;
  395. align-items: center;
  396. position: relative;
  397. }
  398. .class-info-img {
  399. width: 60px;
  400. height: 60px;
  401. margin-right: 10px;
  402. }
  403. .class-info-content {
  404. flex: 1;
  405. }
  406. .class-info-label {
  407. font-size: 16px;
  408. color: #000000;
  409. word-break: break-all;
  410. margin-bottom: 5px;
  411. }
  412. .class-info-text {
  413. color: #999999;
  414. margin-bottom: 5px;
  415. }
  416. }
  417. .student-box {
  418. max-height: 200px;
  419. padding: 0 15px;
  420. margin: 25px 0 0 0;
  421. box-sizing: border-box;
  422. overflow: auto;
  423. /deep/.u-card__head {
  424. padding-bottom: 0px !important;
  425. }
  426. }
  427. .canvas-container {
  428. width: 100%;
  429. height: 200px;
  430. }
  431. .handle-fix-box {
  432. // height: 85px;
  433. height: 60px;
  434. text-align: center;
  435. .contract-link {
  436. color: $mainColor;
  437. line-height: 25px;
  438. }
  439. }
  440. }
  441. </style>