coupon.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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(){
  104. console.log(999,this.query.storeId,this.info.epId);
  105. let that = this
  106. uni.navigateTo({
  107. url:`/refuel/refuelDetail?id=${this.query.storeId}&epId=${this.info.epId}`,
  108. success: function(res) {
  109. // 通过eventChannel向被打开页面传送数据
  110. res.eventChannel.emit('pay', that.info)
  111. },
  112. complete() {
  113. console.log('跳转完成');
  114. }
  115. })
  116. },
  117. },
  118. created() {
  119. },
  120. onLoad(options) {
  121. this.query.storeId = options.storeId
  122. // this.info.amount = options.amount
  123. // this.info.itemId = options.itemId
  124. // this.info.num = options.num
  125. // this.info.epId = options.epId
  126. let that = this
  127. const eventChannel = this.getOpenerEventChannel();
  128. eventChannel.on('coupon', function(data) {
  129. that.query.orderAmount = data.amount*100
  130. that.info = {...that.info,...data}
  131. console.log(111,that.info);
  132. that.getMyCouponList()
  133. })
  134. }
  135. }
  136. </script>
  137. <style lang="scss" scoped>
  138. .coupon{
  139. background: #f5f5f5;
  140. padding: 20rpx 24rpx 130rpx;
  141. min-height: 100vh;
  142. .tab-group{
  143. display: flex;
  144. align-items: center;
  145. background: #fff;
  146. position: fixed;
  147. height: 80rpx;
  148. top: 0%;
  149. left: 0%;
  150. width: 100%;
  151. z-index: 9;
  152. .tab{
  153. width: 150rpx;
  154. padding: 15rpx 30rpx;
  155. text-align: center;
  156. color: #999999;
  157. font-size: 28rpx;
  158. }
  159. .active{
  160. font-weight: bold;
  161. font-size: 32rpx;
  162. position: relative;
  163. color: #222222;
  164. &::before{
  165. display: block;
  166. content: '';
  167. position: absolute;
  168. left: 50%;
  169. bottom: 0%;
  170. transform: translateX(-50%);
  171. width: 40rpx;
  172. height: 8rpx;
  173. background: linear-gradient(265deg, #FF4A39 0%, #FC8B45 100%);
  174. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255,255,255,0.16);
  175. border-radius: 4rpx 4rpx 4rpx 4rpx;
  176. }
  177. }
  178. }
  179. .discounts-item {
  180. margin-bottom: 20rpx;
  181. display: flex;
  182. align-items: center;
  183. background-color: rgb(239, 239, 239);
  184. background: url('@/static/new-card.png') no-repeat;
  185. background-repeat: no-repeat;
  186. background-size: 100% 144rpx;
  187. border-radius: 16rpx;
  188. height: 144rpx;
  189. padding: 0 24rpx;
  190. box-sizing: border-box;
  191. .type-box{
  192. width: 135rpx;
  193. text-align: center;
  194. .price{
  195. ont-size: 40rpx;
  196. color: #FF4D3A;
  197. }
  198. .type{
  199. font-size: 20rpx;
  200. color: #AAAAAA;
  201. margin-top: 12rpx;
  202. }
  203. }
  204. .info {
  205. flex: 1;
  206. margin-left: 40rpx;
  207. .title {
  208. font-size: 28rpx;
  209. color: #222222;
  210. }
  211. .desc{
  212. font-size: 20rpx;
  213. color: #AAAAAA;
  214. }
  215. .limit{
  216. font-size: 20rpx;
  217. color: #AAAAAA;
  218. margin:10rpx 0;
  219. }
  220. }
  221. .radio-box{
  222. padding-right: 30rpx;
  223. .radio{
  224. width: 40rpx;
  225. height: 40rpx;
  226. vertical-align: bottom;
  227. }
  228. .unChoose{
  229. width: 40rpx;
  230. height: 40rpx;
  231. border-radius: 50%;
  232. box-sizing: border-box;
  233. border: 2rpx solid #FF4D3A;
  234. }
  235. }
  236. .num{
  237. position: absolute;
  238. white-space: nowrap;
  239. bottom: 10rpx;
  240. right: 10rpx;
  241. font-size: 18rpx;
  242. color: #FFFFFF;
  243. }
  244. .card-desc{
  245. font-size: 20rpx;
  246. color: #AAAAAA;
  247. padding: 20rpx 10rpx;
  248. background: #FFFFFF;
  249. border-radius: 0rpx 0rpx 16rpx 16rpx;
  250. .time{
  251. }
  252. .desc{
  253. margin-top: 22rpx;
  254. }
  255. }
  256. }
  257. .btn-box{
  258. position: fixed;
  259. left: 0;
  260. bottom: 0;
  261. width: 100%;
  262. box-sizing: border-box;
  263. background: #fff;
  264. padding: 20rpx 0 40rpx;
  265. .save-btn{
  266. margin: 0 auto;
  267. width: 690rpx;
  268. height: 80rpx;
  269. line-height: 80rpx;
  270. border-radius: 40rpx;
  271. background: $uni-color-primary;
  272. color: #fff;
  273. }
  274. }
  275. }
  276. </style>