openMember.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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="'¥' + memberInfo.realPayAmount" :arrow="false"></u-cell-item>
  12. </u-cell-group>
  13. <u-popup v-model="couponShow" mode="bottom" border-radius="30" closeable>
  14. <scroll-view scroll-y style="height:300px;margin: 30px 0 15px 0;">
  15. <u-card :show-head="false" :show-foot="false" padding="0px" margin="0px 30px 20px 30px" borderRadius="40" v-for="(item, index) in couponList"
  16. :key="index" class="class-card" @click="selectCoupon(item)">
  17. <view class="class-content" slot="body">
  18. <view class="class-info-img">
  19. <u-image width="60px" height="60px" :src="item.url" shape="circle"></u-image>
  20. </view>
  21. <view class="class-info-content">
  22. <view class="class-info-label">{{item.name}}¥{{item.amount}}</view>
  23. <view class="class-info-text">{{item.typeValue}}&nbsp;&nbsp;{{item.content}}</view>
  24. <view class="class-info-text">{{item.endDate}}&nbsp;&nbsp;到期</view>
  25. </view>
  26. </view>
  27. </u-card>
  28. </scroll-view>
  29. </u-popup>
  30. <view class="handle-fix-box">
  31. <u-button type="warning" shape="circle" :ripple="true" :custom-style="customStyle" @click="toPay()">确定支付¥{{memberInfo.realPayAmount}}</u-button>
  32. </view>
  33. <u-top-tips ref="uTips"></u-top-tips>
  34. </view>
  35. </template>
  36. <script>
  37. import {
  38. mapGetters
  39. } from 'vuex'
  40. const NET = require('@/utils/request')
  41. const API = require('@/config/api')
  42. export default {
  43. computed: {
  44. ...mapGetters([
  45. 'mainColor',
  46. 'customStyle',
  47. ])
  48. },
  49. data() {
  50. return {
  51. memberCardId: '',
  52. memberInfo: {
  53. originalAmount: '',
  54. discountsAmount: '',
  55. realPayAmount: '',
  56. typeValue: '',
  57. endDate: '',
  58. startDate: '',
  59. },
  60. couponId: '',
  61. couponShow: false,
  62. couponList: [],
  63. }
  64. },
  65. onLoad(options) {
  66. this.memberCardId = options.id
  67. this.getMemberInfo()
  68. },
  69. onReady() {},
  70. methods: {
  71. // 获取数据
  72. getMemberInfo() {
  73. NET.request(API.getMemberCardInfo, {
  74. id: this.memberCardId
  75. }, 'POST').then(res => {
  76. this.memberInfo = res.data
  77. }).catch(error => {
  78. this.$refs.uTips.show({
  79. title: error.data.msg,
  80. type: 'warning',
  81. })
  82. })
  83. NET.request(API.getUsableCouponList, {
  84. id: this.memberCardId
  85. }, 'POST').then(res => {
  86. this.couponList = res.data
  87. }).catch(error => {
  88. this.$refs.uTips.show({
  89. title: error.data.msg,
  90. type: 'warning',
  91. })
  92. })
  93. },
  94. // 选择优惠券
  95. selectCoupon(item) {
  96. this.couponId = item.id
  97. NET.request(API.getMemberCardInfoAfterCoupon, {
  98. id: this.memberCardId,
  99. couponId: this.couponId
  100. }, 'POST').then(res => {
  101. this.memberInfo = res.data
  102. this.couponShow = false
  103. }).catch(error => {
  104. this.$refs.uTips.show({
  105. title: error.data.msg,
  106. type: 'warning',
  107. })
  108. })
  109. },
  110. // 支付
  111. toPay() {
  112. NET.request(API.getPayParams, {
  113. id: this.memberCardId,
  114. couponId: this.couponId
  115. }, 'POST').then(res => {
  116. uni.requestPayment({
  117. provider: 'wxpay',
  118. timeStamp: res.data.timeStamp,
  119. nonceStr: res.data.nonceStr,
  120. package: res.data.packageString,
  121. signType: res.data.signType,
  122. paySign: res.data.paySign,
  123. success: (payRes) => {
  124. uni.redirectTo({
  125. url: '/pagesMain/payResult?id=' + res.data.oderNo
  126. });
  127. },
  128. fail: (error) => {
  129. this.$refs.uTips.show({
  130. title: '支付未成功',
  131. type: 'warning',
  132. })
  133. }
  134. })
  135. }).catch(error => {
  136. this.$refs.uTips.show({
  137. title: error.data.msg,
  138. type: 'warning',
  139. })
  140. })
  141. },
  142. },
  143. }
  144. </script>
  145. <style>
  146. page {
  147. width: 100%;
  148. height: 100%;
  149. }
  150. </style>
  151. <style lang="scss" scoped>
  152. @import "@/static/css/themes.scss";
  153. .content {
  154. width: 100%;
  155. float: left;
  156. padding: 15px 15px 60px 15px;
  157. box-sizing: border-box;
  158. .card-list {
  159. width: 100%;
  160. padding: 15px 20px;
  161. margin-bottom: 15px;
  162. float: left;
  163. background-color: #FFFFFF;
  164. border-radius: 15px;
  165. box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
  166. position: relative;
  167. overflow: hidden;
  168. .card-label {
  169. width: 100%;
  170. margin-bottom: 10px;
  171. float: left;
  172. font-size: 18px;
  173. font-weight: bold;
  174. line-height: 20px;
  175. }
  176. .card-num {
  177. width: 100%;
  178. float: left;
  179. font-size: 28px;
  180. line-height: 28px;
  181. color: $mainColor;
  182. }
  183. .card-icon {
  184. font-size: 80px;
  185. color: $mainColor;
  186. position: absolute;
  187. right: -15px;
  188. bottom: -15x;
  189. opacity: 0.5;
  190. }
  191. }
  192. .class-card {
  193. .class-content {
  194. padding: 10px 15px;
  195. display: flex;
  196. align-items: center;
  197. position: relative;
  198. }
  199. .class-info-img {
  200. width: 60px;
  201. height: 60px;
  202. margin-right: 10px;
  203. }
  204. .class-info-content {
  205. flex: 1;
  206. }
  207. .class-info-label {
  208. font-size: 16px;
  209. color: #000000;
  210. word-break: break-all;
  211. }
  212. .class-info-text {
  213. color: #999999;
  214. margin-bottom: 5px;
  215. }
  216. }
  217. }
  218. </style>