coupon.vue 5.9 KB

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