coupon.vue 7.9 KB

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