index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <template>
  2. <div id="game_record_container">
  3. <van-tabs :active="active" @change="clearShow" color="#4B3AB0" line-width=54px>
  4. <van-tab title="待领取" name="0">
  5. <div class="quan_list margin-top-sm" v-if="rec_list.length > 0">
  6. <text class="padding-left">共{{rec_list.length}}张</text>
  7. <div v-for="(item,index) in rec_list" :key="index">
  8. <div class="quan_container container" >
  9. <van-row gutter="10">
  10. <van-col span="17" offset="1">
  11. <div class="padding-top">
  12. <text class="title">{{ item.name }}</text>
  13. </div>
  14. <div v-if="item.validity_time.type==0">
  15. <text class="subtitle text-sm">{{ item.validity_time.start_time_format }} 至 {{ item.validity_time.end_time_format }} 领取有效</text>
  16. </div>
  17. <div v-if="item.validity_time.type==1">
  18. <text class="subtitle text-sm">{{ item.validity_time.time_format }} 之前领取有效</text>
  19. </div>
  20. <van-row gutter="9">
  21. <van-col span="17" >
  22. <!-- 核销券 -->
  23. <view style="margin-top:36rpx" v-if="item.type==1">
  24. <text class="time margin-right-xs">{{ item.discount.time }}</text>
  25. <text class="time_text" v-if="item.discount.type==0">分钟</text>
  26. <text class="time_text" v-if="item.discount.type==1">次</text>
  27. </view>
  28. <!-- 满减券 -->
  29. <view style="margin-top:36rpx" v-if="item.type==2">
  30. <text class="time_text">满</text>
  31. <text class="time margin-lr-xs">{{ item.discount.full }}</text>
  32. <text class="time_text">减</text>
  33. <text class="time margin-left-xs">{{ item.discount.reduce }}</text>
  34. </view>
  35. <!-- 折扣券 -->
  36. <view style="margin-top:36rpx" v-if="item.type==3">
  37. <text class="time_text">打</text>
  38. <text class="time margin-lr-xs">{{ item.discount.discount_format }}</text>
  39. <text class="time_text">折</text>
  40. </view>
  41. <!-- 随机券 -->
  42. <view style="margin-top:36rpx" v-if="item.type==4">
  43. <text class="time_text">随机</text>
  44. <text class="time margin-lr-xs">{{ item.discount.start }}</text>
  45. <text class="time_text">至</text>
  46. <text class="time margin-lr-xs">{{ item.discount.end }}</text>
  47. <text class="time_text">元</text>
  48. </view>
  49. </van-col>
  50. <van-col span="7">
  51. <view class="margin-top-xl" @click="ruleShow(item.coupon_category_id)">
  52. <text class="text-sm text-grey rule">使用规则</text>
  53. </view>
  54. </van-col>
  55. </van-row>
  56. </van-col>
  57. <van-col span="5" offset="1" class="" @click="get_ticket(item)">
  58. <view class="get_ticket_text">领取</view>
  59. </van-col>
  60. </van-row>
  61. </div>
  62. <!-- 描述-->
  63. <view v-if="is_ruleShow == item.coupon_category_id">
  64. <view class="flex justify-center">
  65. <view
  66. class="desc"
  67. v-html="item.explain"
  68. >
  69. </view>
  70. </view>
  71. </view>
  72. </div>
  73. </div>
  74. <van-empty image="error" description="暂无可领券" v-else/>
  75. </van-tab>
  76. <van-tab title="已领取" name="1">
  77. <div class="quan_list margin-top-sm ">
  78. <text class="padding-left">共{{cp_list.length}}张</text>
  79. <div v-for="(item,index) in cp_list" :key="index">
  80. <div class="quan_container_get container">
  81. <van-row gutter="10">
  82. <van-col span="17" offset="1">
  83. <div :class="item.type==1?'margin-bottom padding-top':'padding-top'">
  84. <text class="title">{{ item.name }}</text>
  85. </div>
  86. <div>
  87. <text v-if="!(item.type==1)" class="subtitle text-sm">{{ item.start_time }} 至 {{ item.end_time }} 可使用</text>
  88. </div>
  89. <van-row gutter="9">
  90. <van-col span="17" >
  91. <!-- 核销券 -->
  92. <view style="margin-top:36rpx" v-if="item.type==1">
  93. <text class="time margin-right-xs">{{ item.time }}</text>
  94. <text class="time_text" v-if="item.discount_type==0">分钟</text>
  95. <text class="time_text" v-if="item.discount_type==1">次</text>
  96. </view>
  97. <!-- 满减券 -->
  98. <view style="margin-top:36rpx" v-if="item.type==2">
  99. <text class="time_text">满</text>
  100. <text class="time margin-lr-xs">{{ item.full }}</text>
  101. <text class="time_text">减</text>
  102. <text class="time margin-left-xs">{{ item.reduce }}</text>
  103. </view>
  104. <!-- 折扣券 -->
  105. <view style="margin-top:36rpx" v-if="item.type==3">
  106. <text class="time_text">打</text>
  107. <text class="time margin-lr-xs">{{ item.discount_format }}</text>
  108. <text class="time_text">折</text>
  109. </view>
  110. <!-- 随机券 -->
  111. <view style="margin-top:36rpx" v-if="item.type==4">
  112. <text class="time_text">减</text>
  113. <text class="time margin-lr-xs">{{ item.random }}</text>
  114. <text class="time_text">元</text>
  115. </view>
  116. </van-col>
  117. <van-col span="7">
  118. <view class="margin-top-xl" @click="ruleShow(item.coupon_category_id)">
  119. <text class="text-sm text-grey rule">使用规则</text>
  120. </view>
  121. </van-col>
  122. </van-row>
  123. </van-col>
  124. <van-col span="5" offset="0">
  125. <view class="get_ticket_text" v-if="item.status==2">已使用</view>
  126. <view class="get_ticket_text" v-else>已领取</view>
  127. </van-col>
  128. </van-row>
  129. </div>
  130. <!-- 描述-->
  131. <view v-if="is_ruleShow == item.coupon_category_id">
  132. <view class="flex justify-center">
  133. <view
  134. class="desc"
  135. v-html="item.explain"
  136. >
  137. </view>
  138. </view>
  139. </view>
  140. </div>
  141. </div>
  142. </van-tab>
  143. <van-tab title="已过期" name="2">
  144. <div class="quan_list margin-top-sm ">
  145. <text class="padding-left">共{{ov_list.length}}张</text>
  146. <div v-for="(item,index) in ov_list" :key="index">
  147. <div class="quan_container_gray container">
  148. <van-row gutter="10">
  149. <van-col span="17" offset="1">
  150. <div class="padding-top">
  151. <text class="title">{{ item.name }}</text>
  152. </div>
  153. <div>
  154. <text class="subtitle text-sm">{{ item.start_time }} 至 {{ item.end_time }} 可使用</text>
  155. </div>
  156. <van-row gutter="9">
  157. <van-col span="17" >
  158. <!-- 核销券 -->
  159. <view style="margin-top:36rpx" v-if="item.type==1">
  160. <text class="time margin-right-xs">{{ item.time }}</text>
  161. <text class="time_text" v-if="item.discount_type==0">分钟</text>
  162. <text class="time_text" v-if="item.discount_type==1">次</text>
  163. </view>
  164. <!-- 满减券 -->
  165. <view style="margin-top:36rpx" v-if="item.type==2">
  166. <text class="time_text">满</text>
  167. <text class="time margin-lr-xs">{{ item.full }}</text>
  168. <text class="time_text">减</text>
  169. <text class="time margin-left-xs">{{ item.reduce }}</text>
  170. </view>
  171. <!-- 折扣券 -->
  172. <view style="margin-top:36rpx" v-if="item.type==3">
  173. <text class="time_text">打</text>
  174. <text class="time margin-lr-xs">{{ item.discount_format }}</text>
  175. <text class="time_text">折</text>
  176. </view>
  177. <!-- 随机券 -->
  178. <view style="margin-top:36rpx" v-if="item.type==4">
  179. <text class="time_text">减</text>
  180. <text class="time margin-lr-xs">{{ item.random }}</text>
  181. <text class="time_text">元</text>
  182. </view>
  183. </van-col>
  184. <van-col span="7" >
  185. <view class="margin-top-xl" @click="ruleShow(item.coupon_category_id)">
  186. <text class="text-sm text-grey rule">使用规则</text>
  187. </view>
  188. </van-col>
  189. </van-row>
  190. </van-col>
  191. <van-col span="5" offset="0">
  192. <view class="get_ticket_text">已过期</view>
  193. </van-col>
  194. </van-row>
  195. </div>
  196. <!-- 描述-->
  197. <view v-if="is_ruleShow == item.coupon_category_id">
  198. <view class="flex justify-center">
  199. <view
  200. class="desc"
  201. v-html="item.explain"
  202. >
  203. </view>
  204. </view>
  205. </view>
  206. </div>
  207. </div>
  208. </van-tab>
  209. </van-tabs>
  210. <van-toast id="van-toast"/>
  211. </div>
  212. </template>
  213. <script>
  214. import Toast from '../../../static/vant/toast/toast';
  215. import {couponReceive, getCouponList, getCouponReceiveList, getOverdueCouponList} from "../../requests/coupons";
  216. import {timestampTwoNum} from '@/utils/index'
  217. var $this
  218. export default {
  219. name: "game_record_container",
  220. components: {},
  221. data() {
  222. return {
  223. is_ruleShow: 0,
  224. active: '0',
  225. rec_list: [],
  226. cp_list: [],
  227. ov_list:[],
  228. limit: 10
  229. }
  230. },
  231. methods: {
  232. //获取已领取优惠券列表
  233. get_coupon_list() {
  234. getCouponList($this.limit).then((res) => {
  235. let $res = res.data;
  236. $this.cp_list = $res.data;
  237. $this.cp_list.forEach(($val, $index) => {
  238. $val['end_time'] = timestampTwoNum($val['end_time'])
  239. $val['start_time'] = timestampTwoNum($val['start_time'])
  240. $val['random'] = parseInt($val['random'])
  241. $val['discount_format'] = Math.round(($val['discount']*10)*100)/100
  242. })
  243. })
  244. },
  245. //已过期优惠券列表
  246. get_overdue_list() {
  247. getOverdueCouponList($this.limit).then((res) => {
  248. let $res = res.data;
  249. $this.ov_list = $res.data;
  250. $this.ov_list.forEach(($val, $index) => {
  251. $val['end_time'] = timestampTwoNum($val['end_time'])
  252. $val['start_time'] = timestampTwoNum($val['start_time'])
  253. $val['random'] = parseInt($val['random'])
  254. $val['discount_format'] = Math.round(($val['discount']*10)*100)/100
  255. })
  256. })
  257. },
  258. //获取待领取优惠券列表
  259. get_rec_coupon_list() {
  260. getCouponReceiveList($this.limit).then((res) => {
  261. let $res = res.data;
  262. $this.rec_list = $res.data.list;
  263. $this.rec_list.forEach(($val, $index) => {
  264. $val.validity_time['end_time_format'] = timestampTwoNum($val.validity_time['end_time'])
  265. $val.validity_time['start_time_format'] = timestampTwoNum($val.validity_time['start_time'])
  266. $val.validity_time['time_format'] = timestampTwoNum($val.validity_time['time'])
  267. $val.discount['discount_format'] = Math.round(($val.discount['discount']*10)*100)/100
  268. })
  269. })
  270. },
  271. // 领取优惠券
  272. get_ticket($item) {
  273. couponReceive($item).then((res) => {
  274. let $res = res.data;
  275. if ($res.code == 0) {
  276. Toast.success({
  277. message: $res.errmsg,
  278. duration:800,
  279. onClose() {
  280. $this.get_rec_coupon_list()
  281. $this.get_coupon_list()
  282. $this.get_overdue_list()
  283. }
  284. })
  285. // $this.get_rec_coupon_list()
  286. // $this.get_coupon_list()
  287. // $this.get_overdue_list()
  288. } else {
  289. Toast.fail({
  290. message: $res.errmsg,
  291. duration:800,
  292. onClose() {
  293. $this.get_rec_coupon_list()
  294. $this.get_coupon_list()
  295. $this.get_overdue_list()
  296. }
  297. })
  298. // $this.get_rec_coupon_list()
  299. // $this.get_coupon_list()
  300. // $this.get_overdue_list()
  301. }
  302. }).catch((err)=>{
  303. console.log("错误",err)
  304. })
  305. },
  306. //使用规则
  307. ruleShow($id){
  308. // console.log($id);
  309. if ($this.is_ruleShow == $id) {
  310. $this.is_ruleShow = 0;
  311. } else {
  312. $this.is_ruleShow = $id;
  313. }
  314. },
  315. clearShow(){
  316. $this.is_ruleShow = 0;
  317. }
  318. },
  319. mounted() {
  320. $this.get_coupon_list()
  321. $this.get_rec_coupon_list()
  322. $this.get_overdue_list()
  323. },
  324. created() {
  325. $this = this
  326. },
  327. onUnload(){
  328. $this.is_ruleShow = 0
  329. },
  330. }
  331. </script>
  332. <style scoped>
  333. .container{
  334. background-position: center;
  335. background-size: 100% 100%;
  336. width: 340px;
  337. height: 115px;
  338. margin: 3px auto;
  339. }
  340. .quan_container {
  341. background-image: url("https://img.shuimuai.com/web/index_item_quan.png");
  342. }
  343. .quan_container_get{
  344. background-image: url("https://img.shuimuai.com/discount_get.png");
  345. }
  346. .quan_container_gray {
  347. background-image: url("https://img.shuimuai.com/web/quan_huise.png");
  348. }
  349. /*标题*/
  350. .title {
  351. font-size: 15px;
  352. font-weight: 400;
  353. color: #030000;
  354. line-height: 24px;
  355. }
  356. /*子标题*/
  357. .sub-title {
  358. font-size: 10px;
  359. font-weight: 400;
  360. color: #030000;
  361. line-height: 23px;
  362. }
  363. /*分钟数*/
  364. .time {
  365. font-size: 19px;
  366. font-weight: bold;
  367. color: #030000;
  368. line-height: 28px;
  369. display:inline-block;
  370. -webkit-transform:scale(1,1.1);
  371. }
  372. /*分钟二字*/
  373. .time_text {
  374. font-size: 12px;
  375. font-weight: 400;
  376. color: #030000;
  377. line-height: 28px;
  378. }
  379. /*领取二字*/
  380. .get_ticket_text {
  381. font-size: 18px;
  382. font-weight: 400;
  383. color: #FFFFFF;
  384. line-height: 24px;
  385. margin: 45px 0px;
  386. }
  387. /*使用规则*/
  388. .rule{
  389. text-decoration: underline;
  390. }
  391. .desc {
  392. width: 320px;
  393. font-size: 12px;
  394. color: #6B6B6B;
  395. line-height: 18px;
  396. margin-bottom: 26px
  397. }
  398. </style>