openMember.vue 7.3 KB

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