coupon.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <view class="coupon">
  3. <!-- 列表 -->
  4. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  5. <view class="discounts-item" v-for="(item,index) in list" :key="index" >
  6. <view class="type-box">
  7. <view class="price">
  8. {{item | filterPrice}}
  9. </view>
  10. <view class="type">
  11. {{item | filterType}}
  12. </view>
  13. </view>
  14. <view class="info">
  15. <view class="title">
  16. {{item.couponName}}
  17. </view>
  18. <view class="limit">
  19. {{item.useStartTime}}后可用
  20. </view>
  21. <view class="desc">
  22. {{item.usrDetail || '-'}}
  23. </view>
  24. <!-- <view class="desc" :class="[open == index?'open':'']" @click.stop="handleOpen(index,'open')">
  25. 展开详情 <image class="jiantou" src="@/static/jiantou-icon.png" mode=""></image>
  26. </view> -->
  27. </view>
  28. <view class="radio-box">
  29. <image class="radio" @click="handleRadio(item.couponId)" :src="item.couponId == choose?require('@/static/choosed.png'):require('@/static/unChoose.png')" mode=""></image>
  30. </view>
  31. <!-- <view class="card-desc" v-show="open == index">
  32. <view class="time">
  33. {{item.validType | filterType1(item)}}
  34. </view>
  35. <view class="desc">
  36. {{item.goodsDescribe}}
  37. </view>
  38. </view> -->
  39. </view>
  40. </zs-list>
  41. <view class="btn-box">
  42. <button class="save-btn" type="default" @click="save">确定</button>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import {getMyCouponList} from '@/api/coupon.js'
  48. import {couponByUser,claim} from '@/api/coupon.js'
  49. export default {
  50. data() {
  51. return {
  52. that:this,
  53. type:'',//判断是线下支付还是线上支付
  54. choose:'',
  55. open:999,
  56. status:'more',
  57. query:{
  58. currentPage:1,
  59. pageSize:10,
  60. status:1,
  61. // userId: JSON.parse(uni.getStorageSync('userInfo')).userId
  62. },
  63. list:[],
  64. info:{},//订单金额信息,用于返回订单页面传回
  65. }
  66. },
  67. filters: {
  68. filterPrice: function(val) {
  69. if(val.couponType == 1){
  70. return `¥${val.couponDiscount}`
  71. }else if(val.couponType == 2){
  72. return `${val.couponDiscount}折`
  73. }else if(val.couponType == 3){
  74. return `¥${val.couponDiscount}`
  75. }
  76. },
  77. filterType: function(val) {
  78. if(val.couponType == 1){
  79. if(val.couponCondition){
  80. return `满${val.couponCondition}立减`
  81. }else{
  82. return '无门槛立减'
  83. }
  84. }else if(val.couponType == 2){
  85. if(val.couponCondition){
  86. return `满${val.couponCondition}`
  87. }else{
  88. return '无门槛立减'
  89. }
  90. }else if(val.couponType == 3){
  91. if(val.couponCondition){
  92. return `满${val.couponCondition}立减`
  93. }else{
  94. return '无门槛立减'
  95. }
  96. }
  97. },
  98. },
  99. methods: {
  100. handleRadio(id){
  101. if(id == this.choose){
  102. this.choose = -1
  103. }else{
  104. this.choose = id
  105. }
  106. },
  107. handleOpen(val,open){
  108. if(val === this[open]){
  109. this[open] = 999
  110. }else{
  111. this[open] = val
  112. }
  113. },
  114. loadMore(){
  115. this.getMyCouponList()
  116. },
  117. getMyCouponList(){
  118. this.status = 'loading'
  119. couponByUser(this.query).then(res=>{
  120. if(res.state == 'Success'){
  121. this.list = this.list.concat(res.content.records)
  122. this.list.length>= res.content.total?this.status = 'noMore':this.status = 'more'
  123. this.query.currentPage++
  124. }
  125. })
  126. },
  127. save(id){
  128. this.info.couponId = this.choose
  129. let that = this
  130. if(this.type == 'offlinePayment'){//扫码支付
  131. uni.navigateTo({
  132. url:'/pay/offlinePayment?scene='+this.query.shopId,
  133. success: function(res) {
  134. // 通过eventChannel向被打开页面传送数据
  135. res.eventChannel.emit('pay', that.info)
  136. }
  137. })
  138. }else{//线上支付
  139. uni.navigateTo({
  140. url:'./pay',
  141. success: function(res) {
  142. // 通过eventChannel向被打开页面传送数据
  143. res.eventChannel.emit('pay', that.info)
  144. }
  145. })
  146. }
  147. },
  148. },
  149. created() {
  150. let info = JSON.parse(uni.getStorageSync('userInfo'))
  151. this.query.userId = info.userId
  152. },
  153. onLoad(options) {
  154. this.choose = options.couponId
  155. this.type = options.type
  156. let that = this
  157. const eventChannel = this.getOpenerEventChannel();
  158. eventChannel.on('pay', function(data) {
  159. that.info = data
  160. that.query.shopId = data.shopId
  161. })
  162. }
  163. }
  164. </script>
  165. <style lang="scss" scoped>
  166. .coupon{
  167. background: #f5f5f5;
  168. padding: 20rpx 24rpx 130rpx;
  169. min-height: 100vh;
  170. .tab-group{
  171. display: flex;
  172. align-items: center;
  173. background: #fff;
  174. position: fixed;
  175. height: 80rpx;
  176. top: 0%;
  177. left: 0%;
  178. width: 100%;
  179. z-index: 9;
  180. .tab{
  181. width: 150rpx;
  182. padding: 15rpx 30rpx;
  183. text-align: center;
  184. color: #999999;
  185. font-size: 28rpx;
  186. }
  187. .active{
  188. font-weight: bold;
  189. font-size: 32rpx;
  190. position: relative;
  191. color: #222222;
  192. &::before{
  193. display: block;
  194. content: '';
  195. position: absolute;
  196. left: 50%;
  197. bottom: 0%;
  198. transform: translateX(-50%);
  199. width: 40rpx;
  200. height: 8rpx;
  201. background: linear-gradient(265deg, #FF4A39 0%, #FC8B45 100%);
  202. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255,255,255,0.16);
  203. border-radius: 4rpx 4rpx 4rpx 4rpx;
  204. }
  205. }
  206. }
  207. .discounts-item {
  208. margin-bottom: 20rpx;
  209. display: flex;
  210. align-items: center;
  211. background-color: rgb(239, 239, 239);
  212. background: url('@/static/new-card.png') no-repeat;
  213. background-repeat: no-repeat;
  214. background-size: 100% 144rpx;
  215. border-radius: 16rpx;
  216. height: 144rpx;
  217. padding: 0 24rpx;
  218. box-sizing: border-box;
  219. .type-box{
  220. width: 135rpx;
  221. text-align: center;
  222. .price{
  223. ont-size: 40rpx;
  224. color: #FF4D3A;
  225. }
  226. .type{
  227. font-size: 20rpx;
  228. color: #AAAAAA;
  229. margin-top: 12rpx;
  230. }
  231. }
  232. .info {
  233. flex: 1;
  234. margin-left: 40rpx;
  235. .title {
  236. font-size: 28rpx;
  237. color: #222222;
  238. }
  239. .desc{
  240. font-size: 20rpx;
  241. color: #AAAAAA;
  242. }
  243. .limit{
  244. font-size: 20rpx;
  245. color: #AAAAAA;
  246. margin:10rpx 0;
  247. }
  248. }
  249. .radio-box{
  250. padding-right: 30rpx;
  251. .radio{
  252. width: 40rpx;
  253. height: 40rpx;
  254. vertical-align: bottom;
  255. }
  256. .unChoose{
  257. width: 40rpx;
  258. height: 40rpx;
  259. border-radius: 50%;
  260. box-sizing: border-box;
  261. border: 2rpx solid #FF4D3A;
  262. }
  263. }
  264. .num{
  265. position: absolute;
  266. white-space: nowrap;
  267. bottom: 10rpx;
  268. right: 10rpx;
  269. font-size: 18rpx;
  270. color: #FFFFFF;
  271. }
  272. .card-desc{
  273. font-size: 20rpx;
  274. color: #AAAAAA;
  275. padding: 20rpx 10rpx;
  276. background: #FFFFFF;
  277. border-radius: 0rpx 0rpx 16rpx 16rpx;
  278. .time{
  279. }
  280. .desc{
  281. margin-top: 22rpx;
  282. }
  283. }
  284. }
  285. .btn-box{
  286. position: fixed;
  287. left: 0;
  288. bottom: 0;
  289. width: 100%;
  290. box-sizing: border-box;
  291. background: #fff;
  292. padding: 20rpx 0 40rpx;
  293. .save-btn{
  294. margin: 0 auto;
  295. width: 690rpx;
  296. height: 80rpx;
  297. line-height: 80rpx;
  298. border-radius: 40rpx;
  299. background: $uni-color-primary;
  300. color: #fff;
  301. }
  302. }
  303. }
  304. </style>