coupon.vue 6.8 KB

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