openMember.vue 8.6 KB

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