coupon.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="coupon_page">
  3. <view class="coupon_box">
  4. <view class="none" v-if="couponList.length == 0">
  5. 暂无优惠券
  6. </view>
  7. <view class="coupon" v-else>
  8. <view class="item" v-for="(item,index) in couponList" :key="item.id">
  9. <view class="left">
  10. <!-- <text v-if="item.discountType==2">折扣</text>
  11. <text v-else> 满减</text> -->
  12. <!-- ¥{{item.discountValue}} <br /> -->
  13. <text v-if="item.discountType == 3">¥{{item.discountValue}}<br/></text>
  14. <text v-else>{{item.rebValue}}折</text>
  15. </view>
  16. <view class="right" v-if="item.discountType == 3">
  17. 满{{item.thresholdAmount}}减{{item.discountValue}} <br/>
  18. 有效期至{{item.expirationTimeString}}
  19. </view>
  20. <view class="right" v-else>
  21. 满{{item.thresholdAmount}}可用 <br/>
  22. 有效期至{{item.expirationTimeString}}
  23. </view>
  24. <view class="one_btn" @click.stop="goIdentify(item)">
  25. <!-- <image src="../../static/index/one.png" mode=""></image> -->
  26. 立即使用
  27. </view>
  28. </view>
  29. </view>
  30. <!-- <view class="coupon" v-for="(item,index) in couponList" :key="index" v-else>
  31. <view class="top">
  32. <view class="left">
  33. ¥<text>{{item.discountValue}}</text>
  34. </view>
  35. <view class="center" v-if="item.discountType === 1">
  36. 无门槛
  37. </view>
  38. <view class="center" v-if="item.discountType ===2">
  39. 折扣
  40. </view>
  41. <view class="center" v-if="item.discountType === 3">
  42. 满减
  43. </view>
  44. <view class="right">
  45. <view class="btn" @click="goIdentify(item)">
  46. 使用
  47. </view>
  48. 有效期至{{item.expirationTimeString}}
  49. </view>
  50. </view>
  51. </view> -->
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. getCoupon
  58. } from '../../api/index'
  59. export default {
  60. data() {
  61. return {
  62. couponList: [],
  63. expirationTime: 0,
  64. title: ''
  65. }
  66. },
  67. methods: {
  68. getCouponList() {
  69. var that = this
  70. var openid = {
  71. openid: uni.getStorageSync('wx_copenid')
  72. }
  73. getCoupon(openid).then(res => {
  74. if (res.data.code == 200) {
  75. this.couponList = res.data.data
  76. }
  77. })
  78. },
  79. goIdentify(item) {
  80. if (this.title == 'select') {
  81. uni.setStorage({
  82. key: 'couponData',
  83. data: item,
  84. success: function() {
  85. uni.navigateBack()
  86. }
  87. });
  88. // uni.navigateTo({
  89. // url: `/pages/identify/pay_order?couponId=${item.id}&couponMoney=${item.discountValue}`
  90. // })
  91. // uni.$emit('returnData', item)
  92. // uni.navigateBack({
  93. // delta: 1
  94. // })
  95. } else {
  96. uni.switchTab({
  97. url: '/pages/identify/identify'
  98. })
  99. }
  100. }
  101. },
  102. onLoad(options) {
  103. if (options) {
  104. this.title = options.title
  105. }
  106. },
  107. onShow() {
  108. this.getCouponList()
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. /* pages/my/coupon/coupon.wxss */
  114. .coupon_page {
  115. width: 100vw;
  116. height: 100vh;
  117. background: linear-gradient(to bottom, #d7f3f9, #f3f3f3);
  118. .coupon_box {
  119. width: 100%;
  120. height: 100%;
  121. // overflow-y: auto;
  122. padding: 20rpx;
  123. box-sizing: border-box;
  124. .none {
  125. // width: 100%;
  126. // height: 100%;
  127. text-align: center;
  128. padding-top: 300rpx;
  129. }
  130. .coupon {
  131. width: 100%;
  132. height: 100%;
  133. // position: absolute;
  134. padding: 10rpx;
  135. // top: 50%;
  136. // left: 50%;
  137. // transform: translate(-50%, -50%);
  138. overflow-y: auto;
  139. box-sizing: border-box;
  140. .item {
  141. width: 92%;
  142. height: 120px;
  143. background-image: url(../../static/index/item.png);
  144. // background-repeat: no-repeat;
  145. background-size: cover;
  146. /* 背景图宽度自适应 */
  147. background-position: center;
  148. /* 背景图居中 */
  149. padding: 10rpx 25rpx;
  150. display: flex;
  151. // justify-content: space-around;
  152. align-items: center;
  153. position: relative;
  154. margin-bottom: 10rpx;
  155. .left {
  156. color: #ff0000;
  157. margin-left: 20px;
  158. font-size: 35rpx;
  159. }
  160. .right {
  161. height: 100%;
  162. margin-left: 100rpx;
  163. padding-top: 120rpx;
  164. font-size: 28rpx;
  165. box-sizing: border-box;
  166. }
  167. .one_btn {
  168. position: absolute;
  169. top: 10%;
  170. right: 2%;
  171. width: 100rpx;
  172. height: 210rpx;
  173. border-radius: 20rpx;
  174. background-color: #fff9cb;
  175. font-size: 46rpx;
  176. display: flex;
  177. justify-content: center;
  178. align-items: center;
  179. writing-mode: vertical-rl; /* 文字从上到下竖排,从右到左 */
  180. image {
  181. width: 100%;
  182. height: 100%;
  183. }
  184. }
  185. }
  186. }
  187. // .coupon {
  188. // width: 95%;
  189. // height: 200rpx;
  190. // box-sizing: border-box;
  191. // background-color: #2cb8d4;
  192. // border-radius: 10rpx;
  193. // padding: 20rpx;
  194. // .top {
  195. // display: flex;
  196. // width: 100%;
  197. // height: 100%;
  198. // align-items: center;
  199. // .left {
  200. // width: 20%;
  201. // height: 100rpx;
  202. // font-size: 40rpx;
  203. // color: #ffffff;
  204. // margin-right: 30rpx;
  205. // display: flex;
  206. // align-items: center;
  207. // text {
  208. // font-size: 80rpx;
  209. // }
  210. // }
  211. // .center {
  212. // width: 30%;
  213. // height: 100rpx;
  214. // font-size: 50rpx;
  215. // color: #ffffff;
  216. // display: flex;
  217. // align-items: center;
  218. // }
  219. // .right {
  220. // height: 100%;
  221. // color: #666;
  222. // padding-top: 120rpx;
  223. // .btn {
  224. // width: 100px;
  225. // height: 30px;
  226. // text-align: center;
  227. // align-items: center;
  228. // border-radius: 10px;
  229. // background: linear-gradient(to bottom, #ead3ba, #ddbe96);
  230. // line-height: 30px;
  231. // margin: 0px auto 10px;
  232. // }
  233. // }
  234. // }
  235. // }
  236. }
  237. }
  238. </style>