openMember.vue 11 KB

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