openMember.vue 8.9 KB

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