openMember.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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-cell-group style="width: 100%; float: left;">
  9. <u-cell-item title="使用时间" :value="memberInfo.startDate + '~' + memberInfo.endDate" :arrow="false"></u-cell-item>
  10. <u-cell-item title="优惠金额" :value="couponId ? '-¥' + memberInfo.discountsAmount : ''" @click="couponShow = true"></u-cell-item>
  11. <u-cell-item title="学员姓名" :value="studentName" @click="studentShow = true"></u-cell-item>
  12. <u-cell-item title="实际金额" :value="'¥' + memberInfo.realPayAmount" :arrow="false"></u-cell-item>
  13. </u-cell-group>
  14. <u-popup v-model="couponShow" mode="bottom" border-radius="30" closeable>
  15. <scroll-view scroll-y style="height:300px;margin: 30px 0 15px 0;">
  16. <u-card :show-head="false" :show-foot="false" padding="0px" margin="0px 30px 20px 30px" borderRadius="40" v-for="(item, index) in couponList"
  17. :key="index" class="class-card" @click="selectCoupon(item)">
  18. <view class="class-content" slot="body">
  19. <view class="class-info-img">
  20. <u-image width="60px" height="60px" :src="item.url" shape="circle"></u-image>
  21. </view>
  22. <view class="class-info-content">
  23. <view class="class-info-label">{{item.name}}¥{{item.amount}}</view>
  24. <view class="class-info-text">{{item.typeValue}}&nbsp;&nbsp;{{item.content}}</view>
  25. <view class="class-info-text">{{item.endDate}}&nbsp;&nbsp;到期</view>
  26. </view>
  27. </view>
  28. </u-card>
  29. </scroll-view>
  30. </u-popup>
  31. <view class="handle-fix-box">
  32. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="toPay()">确定支付¥{{memberInfo.realPayAmount}}</u-button>
  33. </view>
  34. <u-popup v-model="studentShow" mode="bottom" border-radius="30">
  35. <scroll-view scroll-y class="student-box">
  36. <u-card :title="item.studentName" title-size="32" :head-style="cardStyle" :head-border-bottom="false" :show-foot="false"
  37. margin="10px" borderRadius="20" v-for="(item, index) in studentList" :key="index" @click="selectStudent(item)">
  38. <view class="student-card" slot="body">
  39. <view class="class-info-text">性别:{{item.sex}}&nbsp;&nbsp;年龄:{{item.age}}</view>
  40. </view>
  41. </u-card>
  42. </scroll-view>
  43. <u-button type="warning" shape="circle" :ripple="true" :custom-style="{...customStyle,margin:'15px'}" @click="goToSubscribelForm()">新增学员</u-button>
  44. </u-popup>
  45. <u-top-tips ref="uTips"></u-top-tips>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. mapGetters
  51. } from 'vuex'
  52. const NET = require('@/utils/request')
  53. const API = require('@/config/api')
  54. export default {
  55. computed: {
  56. ...mapGetters([
  57. 'mainColor',
  58. 'customStyle',
  59. ])
  60. },
  61. data() {
  62. return {
  63. memberCardId: '',
  64. memberInfo: {
  65. originalAmount: '',
  66. discountsAmount: '',
  67. realPayAmount: '',
  68. typeValue: '',
  69. endDate: '',
  70. startDate: '',
  71. },
  72. couponId: '',
  73. couponShow: false,
  74. couponList: [],
  75. cardStyle: {
  76. fontWeight: 'bold'
  77. },
  78. studentId: '',
  79. studentName: '',
  80. studentShow: false,
  81. studentList: [],
  82. }
  83. },
  84. onLoad(options) {
  85. this.memberCardId = options.id
  86. this.getMemberInfo()
  87. },
  88. onShow() {
  89. NET.request(API.getAllStudentList, {}, 'POST').then(res => {
  90. this.studentList = res.data
  91. }).catch(error => {
  92. this.$refs.uTips.show({
  93. title: error.message,
  94. type: 'warning',
  95. })
  96. })
  97. },
  98. methods: {
  99. // 获取数据
  100. getMemberInfo() {
  101. NET.request(API.getMemberCardInfo, {
  102. id: this.memberCardId
  103. }, 'POST').then(res => {
  104. this.memberInfo = res.data
  105. }).catch(error => {
  106. this.$refs.uTips.show({
  107. title: error.message,
  108. type: 'warning',
  109. })
  110. })
  111. NET.request(API.getUsableCouponList, {
  112. id: this.memberCardId
  113. }, 'POST').then(res => {
  114. this.couponList = res.data.row
  115. }).catch(error => {
  116. this.$refs.uTips.show({
  117. title: error.message,
  118. type: 'warning',
  119. })
  120. })
  121. },
  122. // 更新数据
  123. refreshMemberInfo() {
  124. NET.request(API.getMemberCardInfoAfterCoupon, {
  125. memberId: this.memberCardId,
  126. couponId: this.couponId,
  127. studentId: this.studentId
  128. }, 'POST').then(res => {
  129. this.memberInfo = res.data
  130. this.couponShow = false
  131. this.studentShow = false
  132. }).catch(error => {
  133. this.$refs.uTips.show({
  134. title: error.message,
  135. type: 'warning',
  136. })
  137. })
  138. },
  139. // 选择优惠券
  140. selectCoupon(item) {
  141. this.couponId = item.id
  142. this.refreshMemberInfo()
  143. },
  144. // 选择学员
  145. selectStudent(item) {
  146. this.studentId = item.studentId
  147. this.studentName = item.studentName
  148. this.refreshMemberInfo()
  149. },
  150. // 支付
  151. toPay() {
  152. if (!this.studentId) {
  153. this.$refs.uTips.show({
  154. title: '请选择学员',
  155. type: 'warning',
  156. })
  157. return
  158. }
  159. uni.navigateTo({
  160. url: '/pagesMain/contractInfo?memberCardId=' + this.memberCardId + '&couponId=' + this.couponId + '&studentId=' +
  161. this.studentId
  162. });
  163. },
  164. },
  165. }
  166. </script>
  167. <style>
  168. page {
  169. width: 100%;
  170. height: 100%;
  171. }
  172. </style>
  173. <style lang="scss" scoped>
  174. @import "@/static/css/themes.scss";
  175. .content {
  176. width: 100%;
  177. float: left;
  178. padding: 15px 15px 60px 15px;
  179. box-sizing: border-box;
  180. .card-list {
  181. width: 100%;
  182. padding: 15px 20px;
  183. margin-bottom: 15px;
  184. float: left;
  185. background-color: #FFFFFF;
  186. border-radius: 15px;
  187. box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
  188. position: relative;
  189. overflow: hidden;
  190. .card-label {
  191. width: 100%;
  192. margin-bottom: 10px;
  193. float: left;
  194. font-size: 18px;
  195. font-weight: bold;
  196. line-height: 20px;
  197. }
  198. .card-num {
  199. width: 100%;
  200. float: left;
  201. font-size: 28px;
  202. line-height: 28px;
  203. color: $mainColor;
  204. }
  205. .card-icon {
  206. font-size: 80px;
  207. color: $mainColor;
  208. position: absolute;
  209. right: -15px;
  210. bottom: -15x;
  211. opacity: 0.5;
  212. }
  213. }
  214. .class-card {
  215. .class-content {
  216. padding: 10px 15px;
  217. display: flex;
  218. align-items: center;
  219. position: relative;
  220. }
  221. .class-info-img {
  222. width: 60px;
  223. height: 60px;
  224. margin-right: 10px;
  225. }
  226. .class-info-content {
  227. flex: 1;
  228. }
  229. .class-info-label {
  230. font-size: 16px;
  231. color: #000000;
  232. word-break: break-all;
  233. }
  234. .class-info-text {
  235. color: #999999;
  236. margin-bottom: 5px;
  237. }
  238. }
  239. .student-box {
  240. max-height: 200px;
  241. padding: 0 15px;
  242. margin: 25px 0 0 0;
  243. box-sizing: border-box;
  244. overflow: auto;
  245. /deep/.u-card__head {
  246. padding-bottom: 0px !important;
  247. }
  248. }
  249. }
  250. </style>