openMember.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. selectCoupon(item) {
  124. this.couponId = item.id
  125. NET.request(API.getMemberCardInfoAfterCoupon, {
  126. memberId: this.memberCardId,
  127. couponId: this.couponId
  128. }, 'POST').then(res => {
  129. this.memberInfo = res.data
  130. this.couponShow = false
  131. }).catch(error => {
  132. this.$refs.uTips.show({
  133. title: error.message,
  134. type: 'warning',
  135. })
  136. })
  137. },
  138. // 选择学员
  139. selectStudent(item) {
  140. this.studentId = item.studentId
  141. this.studentName = item.studentName
  142. this.studentShow = false
  143. },
  144. // 支付
  145. toPay() {
  146. NET.request(API.getPayParams, {
  147. id: this.memberCardId,
  148. couponId: this.couponId,
  149. studentId: this.studentId,
  150. }, 'POST').then(res => {
  151. if (this.memberInfo.realPayAmount <= 0) {
  152. this.goToPayResult(res.data.oderNo)
  153. return false
  154. }
  155. uni.requestPayment({
  156. provider: 'wxpay',
  157. timeStamp: res.data.timeStamp,
  158. nonceStr: res.data.nonceStr,
  159. package: res.data.packageString,
  160. signType: res.data.signType,
  161. paySign: res.data.paySign,
  162. success: (payRes) => {
  163. this.goToPayResult(res.data.oderNo)
  164. },
  165. fail: (error) => {
  166. this.$refs.uTips.show({
  167. title: '支付未成功',
  168. type: 'warning',
  169. })
  170. }
  171. })
  172. }).catch(error => {
  173. this.$refs.uTips.show({
  174. title: error.message,
  175. type: 'warning',
  176. })
  177. })
  178. },
  179. // 跳转支付结果
  180. goToPayResult(oderNo) {
  181. uni.redirectTo({
  182. url: '/pagesMain/payResult?id=' + oderNo
  183. });
  184. }
  185. },
  186. }
  187. </script>
  188. <style>
  189. page {
  190. width: 100%;
  191. height: 100%;
  192. }
  193. </style>
  194. <style lang="scss" scoped>
  195. @import "@/static/css/themes.scss";
  196. .content {
  197. width: 100%;
  198. float: left;
  199. padding: 15px 15px 60px 15px;
  200. box-sizing: border-box;
  201. .card-list {
  202. width: 100%;
  203. padding: 15px 20px;
  204. margin-bottom: 15px;
  205. float: left;
  206. background-color: #FFFFFF;
  207. border-radius: 15px;
  208. box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
  209. position: relative;
  210. overflow: hidden;
  211. .card-label {
  212. width: 100%;
  213. margin-bottom: 10px;
  214. float: left;
  215. font-size: 18px;
  216. font-weight: bold;
  217. line-height: 20px;
  218. }
  219. .card-num {
  220. width: 100%;
  221. float: left;
  222. font-size: 28px;
  223. line-height: 28px;
  224. color: $mainColor;
  225. }
  226. .card-icon {
  227. font-size: 80px;
  228. color: $mainColor;
  229. position: absolute;
  230. right: -15px;
  231. bottom: -15x;
  232. opacity: 0.5;
  233. }
  234. }
  235. .class-card {
  236. .class-content {
  237. padding: 10px 15px;
  238. display: flex;
  239. align-items: center;
  240. position: relative;
  241. }
  242. .class-info-img {
  243. width: 60px;
  244. height: 60px;
  245. margin-right: 10px;
  246. }
  247. .class-info-content {
  248. flex: 1;
  249. }
  250. .class-info-label {
  251. font-size: 16px;
  252. color: #000000;
  253. word-break: break-all;
  254. }
  255. .class-info-text {
  256. color: #999999;
  257. margin-bottom: 5px;
  258. }
  259. }
  260. .student-box {
  261. max-height: 200px;
  262. padding: 0 15px;
  263. margin: 25px 0 0 0;
  264. box-sizing: border-box;
  265. overflow: auto;
  266. /deep/.u-card__head {
  267. padding-bottom: 0px !important;
  268. }
  269. }
  270. }
  271. </style>