openMember.vue 11 KB

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