coupon.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <view>
  3. <hx-navbar title="红包卡券" :fixed="true" :backgroundColor="[[255,235,59],[255,193,7]]"></hx-navbar>
  4. <view class="head">
  5. <!-- <view class="item" v-for="(item,i) in navData" :key="i" v-if="item">
  6. <image :src="item.img" mode=""></image>
  7. <text class="txt">{{item.name}}</text>
  8. </view> -->
  9. <view class="item">
  10. <image src="/static/img/coupon_lq.png" mode=""></image>
  11. <text class="txt">免费领券</text>
  12. </view>
  13. <view class="item">
  14. <image src="/static/img/coupon_gq.png" mode=""></image>
  15. <text class="txt">特惠购券</text>
  16. </view>
  17. <view class="item" @click="duihuan">
  18. <image src="/static/img/coupon_dq.png" mode=""></image>
  19. <text class="txt">快捷兑券</text>
  20. </view>
  21. </view>
  22. <view class="main">
  23. <view class="list-box">
  24. <view class="left">
  25. <text>红包/抵用券</text>
  26. </view>
  27. <view class="right">
  28. <text>查看全部</text>
  29. <i class="hxicon-right"></i>
  30. </view>
  31. </view>
  32. <view class="coupon-box">
  33. <view class="row" v-for="(item,i) in couponData" :key="i" v-if="item">
  34. <view class="row-top">
  35. <view class="left">
  36. <view class="top" v-if="item.type==2">
  37. <text class="txt2">{{item.value}}</text>
  38. <text class="txt1">折</text>
  39. </view>
  40. <view class="top" v-else>
  41. <text class="txt1">¥</text>
  42. <text class="txt2">{{item.value}}</text>
  43. </view>
  44. <view class="bottom">
  45. <view class="txt1">
  46. {{item.type_name}}
  47. </view>
  48. </view>
  49. </view>
  50. <view class="center">
  51. <view class="center-row">
  52. <text class="txt4">{{item.type_name}}</text>
  53. </view>
  54. <view class="center-row">
  55. <text class="txt1">{{timeGs(item.end_time)}}</text>
  56. </view>
  57. <view class="center-row" @click="item.hide_rule = !item.hide_rule">
  58. <text class="txt3" >使用规则</text>
  59. <i class="txt3 hxicon" :class="item.hide_rule ? 'icon-unfold' : 'icon-fold'"></i>
  60. </view>
  61. </view>
  62. <view class="right">
  63. <view class="btn" @click="goStroe(item)">立即使用</view>
  64. </view>
  65. </view>
  66. <view class="beyond" v-if="item.hide_rule == false">
  67. <view class="beyond-q beyond-ql"></view>
  68. <view class="beyond-q beyond-qr"></view>
  69. <text class="txt3">满{{item.beyond}}元可使用,{{item.docs}}</text>
  70. </view>
  71. </view>
  72. </view>
  73. <!-- 暂时未规划卡包 -->
  74. <!-- <view class="list-box mt">
  75. <view class="left">
  76. <text>卡包</text>
  77. </view>
  78. <view class="right">
  79. <i class="hxicon-right"></i>
  80. </view>
  81. </view> -->
  82. </view>
  83. <view class="foot">
  84. </view>
  85. <uni-popup ref="popup" type="center" @change="popupChange">
  86. <view class="dh-box">
  87. <view class="title">
  88. <text>快捷兑券</text>
  89. </view>
  90. <view class="row">
  91. <input type="text" value="" v-model="qCode" placeholder="填入券码"/>
  92. </view>
  93. <view class="btn" @click="submitCode">确认兑券</view>
  94. </view>
  95. </uni-popup>
  96. </view>
  97. </template>
  98. <script>
  99. import uniPopup from "@/components/uni-popup/uni-popup.vue"
  100. export default {
  101. components: {uniPopup},
  102. data() {
  103. return {
  104. navData:[
  105. {
  106. img: '/static/img/coupon_lq.png',
  107. name: '免费领券'
  108. },
  109. {
  110. img: '/static/img/coupon_gq.png',
  111. name: '特惠购券'
  112. },
  113. {
  114. img: '/static/img/coupon_dq.png',
  115. name: '快捷兑券'
  116. }
  117. ],
  118. qCode:'',
  119. isBack: true,
  120. couponData: [
  121. {
  122. id: 'MS68941',
  123. // 类型 1优惠券,2折扣券,3抵扣券
  124. type: 1,
  125. type_name: '优惠券',
  126. store_id: '123',
  127. title: '外卖美食红包',
  128. value: 20,
  129. // 满足条件,满xx减xx
  130. beyond: 100,
  131. create_time: '2020-04-17 20:30:11',
  132. end_time: '2021-04-17 20:30:11',
  133. docs: '不可与满减,折扣商品,第二份半价,津贴活动同时享有。在线支付专享。',
  134. hide_rule: true
  135. },
  136. {
  137. id: 'MS68941',
  138. // 类型 1优惠券,2折扣券,3抵扣券
  139. type: 2,
  140. type_name: '折扣券',
  141. title: '外卖美食红包',
  142. store_id: '123',
  143. value: 7.4,
  144. // 满足条件,满xx减xx
  145. beyond: 150,
  146. create_time: '2020-04-17 20:30:11',
  147. end_time: '2021-04-17 20:30:11',
  148. docs: '不可与满减,折扣商品,第二份半价,津贴活动同时享有。在线支付专享。',
  149. hide_rule: true
  150. },
  151. {
  152. id: 'MS68941',
  153. // 类型 1优惠券,2折扣券,3抵扣券
  154. type: 3,
  155. type_name: '抵扣券',
  156. title: '外卖美食红包',
  157. store_id: '123',
  158. value: 66,
  159. // 满足条件,满xx减xx
  160. beyond: 200,
  161. create_time: '2020-04-17 20:30:11',
  162. end_time: '2020-04-19 12:55:11',
  163. docs: '不可与满减,折扣商品,第二份半价,津贴活动同时享有。在线支付专享。',
  164. hide_rule: true
  165. },
  166. {
  167. id: 'MS68941',
  168. // 类型 1优惠券,2折扣券,3抵扣券
  169. type: 1,
  170. type_name: '优惠券',
  171. title: '外卖美食红包',
  172. store_id: '123',
  173. value: 20,
  174. // 满足条件,满xx减xx
  175. beyond: 100,
  176. create_time: '2020-04-17 20:30:11',
  177. end_time: '2020-04-18 23:30:11',
  178. docs: '不可与满减,折扣商品,第二份半价,津贴活动同时享有。在线支付专享。',
  179. hide_rule: true
  180. }
  181. ]
  182. }
  183. },
  184. onBackPress() {
  185. if(!this.isBack){
  186. this.$refs.popup.close()
  187. return true
  188. }
  189. },
  190. methods: {
  191. duihuan(){
  192. this.$refs.popup.open()
  193. },
  194. popupChange(e){
  195. this.isBack = !e.show
  196. },
  197. submitCode(){
  198. if(this.qCode == ''){
  199. return
  200. }
  201. this.$refs.popup.close()
  202. uni.showModal({
  203. showCancel: false,
  204. content: '提交事件,券码为:'+ this.qCode
  205. })
  206. },
  207. goStroe(row){
  208. uni.navigateTo({
  209. url:'/pages/store/index?sid=' + row.store_id
  210. })
  211. },
  212. timeGs(cDate){
  213. var go_time=new Date(cDate.replace(/-/g, '/'));
  214. var now_time=new Date();
  215. if(!go_time.getTime()){
  216. return '已失效'
  217. }
  218. let str = ''
  219. var alltime =go_time.getTime() -now_time.getTime (); //剩余的时间(毫秒)
  220. if(alltime <= 0){
  221. str = "已过期"
  222. return str
  223. }
  224. if(go_time.getYear() == now_time.getYear() && go_time.getMonth() == now_time.getMonth() && go_time.getDay() == now_time.getDay()){
  225. str = "今日" + go_time.getHours() + ':' + go_time.getMinutes() + "到期"
  226. }else{
  227. let day = parseInt(alltime/86400000);
  228. if(day > 1){
  229. str = "还剩" + day + '天到期'
  230. }else{
  231. str = "明日" + go_time.getHours() + ':' + go_time.getMinutes() + "到期"
  232. }
  233. }
  234. return str
  235. }
  236. }
  237. }
  238. </script>
  239. <style lang="scss">
  240. page{
  241. background-color: #f7f8fc;
  242. }
  243. .mt{
  244. margin-top: 15px;
  245. }
  246. .head{
  247. display: flex;
  248. flex-direction: row;
  249. justify-content: center;
  250. align-items: center;
  251. .item{
  252. display: flex;
  253. flex-direction: column;
  254. justify-content: center;
  255. align-items: center;
  256. margin-top: 10px;
  257. padding: 12px 30px;
  258. image{
  259. width: 40px;
  260. height: 40px;
  261. }
  262. .txt{
  263. font-size: 12px;
  264. color: #444;
  265. margin-top: 6px;
  266. }
  267. }
  268. }
  269. .main{
  270. display: flex;
  271. flex-direction: column;
  272. margin: 20px 15px 0;
  273. .list-box{
  274. display: flex;
  275. flex-direction: row;
  276. align-items: center;
  277. justify-content: space-between;
  278. .left{
  279. font-size: 16px;
  280. font-weight: bold;
  281. color: #333;
  282. flex: 1;
  283. }
  284. .right{
  285. font-size: 12px;
  286. color: #555;
  287. }
  288. }
  289. .coupon-box{
  290. display: flex;
  291. flex-direction: column;
  292. .row{
  293. display: flex;
  294. flex-direction: column;
  295. padding: 15px;
  296. background: #fff;
  297. border-radius: 10px;
  298. margin-top: 15px;
  299. .row-top{
  300. display: flex;
  301. flex-direction: row;
  302. .txt1{
  303. font-size: 14px;
  304. color: #FF9800;
  305. }
  306. .txt2{
  307. font-size: 30px;
  308. color: #FF5722;
  309. }
  310. .txt3{
  311. font-size: 12px;
  312. color: #999;
  313. }
  314. .txt4{
  315. font-size: 14px;
  316. color: #333;
  317. }
  318. .left{
  319. padding: 0 20px;
  320. margin-left: -15px;
  321. display: flex;
  322. flex-direction: column;
  323. justify-content: center;
  324. align-items: center;
  325. }
  326. .center{
  327. display: flex;
  328. flex-direction: column;
  329. flex: 1;
  330. .center-row{
  331. display: flex;
  332. flex-wrap: wrap;
  333. margin-bottom: 6px;
  334. align-items: center;
  335. [class*="hxicon-"]{
  336. margin-left: 6px;
  337. }
  338. }
  339. .center-row:last-child{
  340. margin-bottom: 0;
  341. }
  342. }
  343. .right{
  344. display: flex;
  345. justify-content: center;
  346. align-items: center;
  347. .btn{
  348. padding: 5px 12px;
  349. border-radius: 40px;
  350. background: linear-gradient(100deg, #FF9800, #FF5722);
  351. color: #fff;
  352. font-size: 12px;
  353. }
  354. }
  355. }
  356. .beyond{
  357. position: relative;
  358. margin: 12px -15px -15px;
  359. padding: 12px 15px 12px;
  360. background-color: #f5f5f5;
  361. border-radius: 10px;
  362. border-top: 1px dashed #d9d9d9;
  363. .beyond-q{
  364. position: absolute;
  365. width: 20px;
  366. height: 20px;
  367. border-radius: 100%;
  368. background-color: #f7f8fc;
  369. top: -10px;
  370. }
  371. .beyond-ql{
  372. left: -10px;
  373. }
  374. .beyond-qr{
  375. right: -10px;
  376. }
  377. .txt3{
  378. font-size: 12px;
  379. color: #999;
  380. }
  381. }
  382. }
  383. }
  384. }
  385. .foot{
  386. height: 50px;
  387. }
  388. .dh-box{
  389. padding: 15px;
  390. border-radius: 10px;
  391. background: #fff;
  392. display: flex;
  393. flex-direction: column;
  394. justify-content: right;
  395. align-items: center;
  396. .title{
  397. font-size: 14px;
  398. font-weight: bold;
  399. color: #555;
  400. }
  401. .row{
  402. margin-top: 12px;
  403. height: 40px;
  404. border: 1px solid #eee;
  405. background: #eee;
  406. border-radius: 6px;
  407. input{
  408. padding: 0 6px;
  409. background: #eee;
  410. height: 100%;
  411. width: 100%;
  412. }
  413. }
  414. .btn{
  415. margin-top: 10px;
  416. padding: 10px 20px;
  417. border-radius: 6px;
  418. background: linear-gradient(100deg, #FF9800, #FF5722);
  419. color: #fff;
  420. font-size: 12px;
  421. }
  422. .btn:active{
  423. background: linear-gradient(100deg, #da8302, #e04d1e);
  424. color: #f8f8f8;
  425. }
  426. }
  427. </style>