openMember.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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="arrow-right" @click.native="couponShow = true">
  16. <text>{{couponId ? '-¥' + memberInfo.discountsAmount : ''}}</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="实际金额">
  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}}</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. onShow() {
  151. NET.request(API.getAllVenueList, uni.getStorageSync('locationData'), 'POST').then(res => {
  152. this.venueList = res.data
  153. }).catch(error => {
  154. this.$refs.uTips.show({
  155. title: error.message,
  156. type: 'warning',
  157. })
  158. })
  159. NET.request(API.getAllStudentList, {}, 'POST').then(res => {
  160. this.studentList = res.data
  161. }).catch(error => {
  162. this.$refs.uTips.show({
  163. title: error.message,
  164. type: 'warning',
  165. })
  166. })
  167. },
  168. onReady() {
  169. NET.request(API.getParentInfo, {}, 'POST').then(res => {
  170. this.form.parentName = res.data.parentName
  171. this.form.sex = res.data.sex
  172. }).catch(error => {
  173. this.$refs.uTips.show({
  174. title: error.message,
  175. type: 'warning',
  176. })
  177. })
  178. },
  179. methods: {
  180. // 获取数据
  181. getMemberInfo(type) {
  182. NET.request(API.getMemberCardInfo, {
  183. type: this.memberCardType,
  184. venueId: this.venueId,
  185. couponId: this.couponId,
  186. studentId: this.studentId
  187. }, 'POST').then(res => {
  188. this.memberInfo = res.data
  189. if (type == 1) {
  190. this.getCouponList()
  191. }
  192. }).catch(error => {
  193. this.$refs.uTips.show({
  194. title: error.message,
  195. type: 'warning',
  196. })
  197. })
  198. },
  199. // 获取优惠券
  200. getCouponList() {
  201. this.couponId = ''
  202. NET.request(API.getUsableCouponList, {
  203. id: this.memberInfo.id,
  204. studentId: this.studentId
  205. }, 'POST').then(res => {
  206. this.couponList = res.data.row
  207. }).catch(error => {
  208. this.$refs.uTips.show({
  209. title: error.message,
  210. type: 'warning',
  211. })
  212. })
  213. },
  214. // 选择优惠券
  215. selectCoupon(item) {
  216. this.couponId = item.id
  217. this.couponShow = false
  218. this.getMemberInfo(2)
  219. },
  220. // 选择场馆
  221. selectVenue(item) {
  222. this.venueId = item.id
  223. this.venueName = item.venueName
  224. this.venueShow = false
  225. this.getMemberInfo(1)
  226. },
  227. // 选择学员
  228. selectStudent(item) {
  229. this.studentId = item.studentId
  230. this.studentName = item.studentName
  231. this.studentShow = false
  232. this.getMemberInfo(1)
  233. },
  234. // 设置性别
  235. setSex(index) {
  236. this.form.sex = this.sexList[index].text
  237. },
  238. // 支付
  239. toPay(contractId) {
  240. if (!this.studentId) {
  241. this.$refs.uTips.show({
  242. title: '请选择学员',
  243. type: 'warning',
  244. })
  245. return
  246. }
  247. if (!this.form.parentName) {
  248. this.$refs.uTips.show({
  249. title: '请输入家长姓名',
  250. type: 'warning',
  251. })
  252. return
  253. }
  254. if (!this.form.sex) {
  255. this.$refs.uTips.show({
  256. title: '请选择性别',
  257. type: 'warning',
  258. })
  259. return
  260. }
  261. uni.navigateTo({
  262. url: '/pagesMain/contractInfo?memberCardId=' + this.memberInfo.id + '&couponId=' + this.couponId + '&studentId=' +
  263. this.studentId + '&realPayAmount=' + this.memberInfo.realPayAmount + '&parentName=' + this.form.parentName +
  264. '&sex=' + this.form.sex
  265. });
  266. },
  267. // 跳转支付结果
  268. goToPayResult(oderNo) {
  269. uni.redirectTo({
  270. url: '/pagesMain/payResult?id=' + oderNo
  271. });
  272. },
  273. // 跳转新增学员表单
  274. goToSubscribelForm() {
  275. uni.navigateTo({
  276. url: '/pagesMember/subscribelForm'
  277. });
  278. },
  279. },
  280. }
  281. </script>
  282. <style>
  283. page {
  284. width: 100%;
  285. height: 100%;
  286. }
  287. </style>
  288. <style lang="scss" scoped>
  289. @import "@/static/css/themes.scss";
  290. .content {
  291. width: 100%;
  292. float: left;
  293. // padding: 15px 15px 85px 15px;
  294. padding: 15px 15px 60px 15px;
  295. box-sizing: border-box;
  296. .card-list {
  297. width: 100%;
  298. padding: 15px 20px;
  299. margin-bottom: 15px;
  300. float: left;
  301. background-color: #FFFFFF;
  302. border-radius: 15px;
  303. box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
  304. position: relative;
  305. overflow: hidden;
  306. .card-label {
  307. width: 100%;
  308. margin-bottom: 10px;
  309. float: left;
  310. font-size: 18px;
  311. font-weight: bold;
  312. line-height: 20px;
  313. }
  314. .card-num {
  315. width: 100%;
  316. float: left;
  317. font-size: 28px;
  318. line-height: 28px;
  319. color: $mainColor;
  320. }
  321. .card-icon {
  322. font-size: 80px;
  323. color: $mainColor;
  324. position: absolute;
  325. right: -15px;
  326. bottom: -15x;
  327. opacity: 0.5;
  328. }
  329. }
  330. .class-card {
  331. .class-content {
  332. padding: 10px 15px;
  333. display: flex;
  334. align-items: center;
  335. position: relative;
  336. }
  337. .class-info-img {
  338. width: 60px;
  339. height: 60px;
  340. margin-right: 10px;
  341. }
  342. .class-info-content {
  343. flex: 1;
  344. }
  345. .class-info-label {
  346. font-size: 16px;
  347. color: #000000;
  348. word-break: break-all;
  349. }
  350. .class-info-text {
  351. color: #999999;
  352. margin-bottom: 5px;
  353. }
  354. }
  355. .student-box {
  356. max-height: 200px;
  357. padding: 0 15px;
  358. margin: 25px 0 0 0;
  359. box-sizing: border-box;
  360. overflow: auto;
  361. /deep/.u-card__head {
  362. padding-bottom: 0px !important;
  363. }
  364. }
  365. .canvas-container {
  366. width: 100%;
  367. height: 200px;
  368. }
  369. .handle-fix-box {
  370. // height: 85px;
  371. height: 60px;
  372. text-align: center;
  373. .contract-link {
  374. color: $mainColor;
  375. line-height: 25px;
  376. }
  377. }
  378. }
  379. </style>