bonus.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <extend name="Public:pinduoduobase" />
  2. <block name="content">
  3. <script type="text/javascript">
  4. window.use_screen_base = '750';
  5. (function (a, b) {
  6. var c = "orientationchange" in b ? "orientationchange" : "resize",
  7. d = use_screen_base.indexOf("_mate"),
  8. e = parseInt(use_screen_base),
  9. f = a.documentElement,
  10. g = function () {
  11. var a = f.clientWidth,
  12. c = b.innerWidth;
  13. c >= 750 ? c = 750 : c;
  14. f.style.fontSize = 100 * (c / e) + "px"
  15. };
  16. if (/iPad.*OS|iPhone.*OS/.test(navigator.userAgent) && d > 0) {
  17. var h = a.querySelectorAll("meta[name=viewport]"),
  18. i = b.devicePixelRatio;
  19. i = i != 1 ? 2 : 1, h[0] && h[0].setAttribute("content",
  20. "width=device-width, user-scalable=no, minimum-scale=" + 1 / i + ", maximum-scale=" + 1 / i +
  21. ", initial-scale=" + 1 / i)
  22. }
  23. g(), b.addEventListener(c, g, !1), delete use_screen_base
  24. })(document, window);
  25. </script>
  26. <link rel="stylesheet" href="__PUBLIC__/mogu/bonus/css/index.css">
  27. <div id="main">
  28. <div class="duo-red-packet-container mobile-container" id="app">
  29. <div class="loadding" v-if="isLoading">
  30. <div class="ring-1"></div>
  31. </div>
  32. <div id="loaded" style="display: none;">
  33. <div class="rp-mask" v-if="type">
  34. <div class="rp-container">
  35. <img src="__PUBLIC__/mogu/bonus/image/red_packet_popup_back.png" class="popup-rp-back">
  36. <div class="main-title" style="background-image: url('//pinduoduoimg.yangkeduo.com/jinbao/red_packet_popup_paper.png'); font-size: 0.25rem;">
  37. <p class="main-title-1">恭喜获得</p>
  38. <p class="main-title-2">{{credit}}元现金红包</p>
  39. </div>
  40. <img src="__PUBLIC__/mogu/bonus/image/red_packet_popup_ribbon.png" class="popup-rp-ribbon">
  41. <img src="__PUBLIC__/mogu/bonus/image/red_packet_popup_rps.png" class="popup-rp-rps">
  42. <img src="__PUBLIC__/mogu/bonus/image/red_packet_popup_front.png" class="popup-rp-front">
  43. <div class="coupon-detail">
  44. <div class="coupon-detail-content">
  45. <div class="detail-left">
  46. <p class="price-top"><span class="yuan">¥</span><span class="money">{{credit}}</span></p>
  47. <p class="price-bottom">现金红包</p>
  48. </div>
  49. <div class="detail-right">
  50. <p class="detail-right-desc">全场通用</p>
  51. <div class="count-down"><span class="time-hours time">{{ctime.h}}</span><span class="symbol-colon symbol">:</span><span class="time-minutes time">{{ctime.m}}</span><span class="symbol-colon symbol">:</span><span class="time-seconds time">{{ctime.s}}</span><span class="symbol-dot symbol">.</span><span class="time-milliseconds time">{{ctime.ms}}</span><span class="desc">后过期</span></div>
  52. </div>
  53. </div>
  54. </div><img src="__PUBLIC__/mogu/bonus/image/red_packet_popup_sub_title.png" class="sub-title">
  55. <div class="confirm-button" role="button" @click="handleApply">立即使用</div>
  56. </div>
  57. </div>
  58. <div class="rp-recommend-v2">
  59. <div class="coupon-info-v2">
  60. <img class="img-rectangle" src="__PUBLIC__/mogu/bonus/image/red_packet_result_rectangle_v2.png" alt="">
  61. <img class="img-ribbon1" src="__PUBLIC__/mogu/bonus/image/red_packet_result_ribbon1.png" alt="">
  62. <img class="img-ribbon2" src="__PUBLIC__/mogu/bonus/image/red_packet_result_ribbon2.png" alt="">
  63. <div class="coupon-detail" style="background-image: url('__PUBLIC__/mogu/bonus/image/red_packet_result_bg.png');">
  64. <p class="coupon-detail-price">{{credit}}元现金红包</p>
  65. <div class="coupon-detail-count-down">
  66. <span class="time-hours time">{{ctime.h}}</span>
  67. <span class="symbol-colon symbol">:</span>
  68. <span class="time-minutes time">{{ctime.m}}</span>
  69. <span class="symbol-colon symbol">:</span>
  70. <span class="time-seconds time">{{ctime.s}}</span>
  71. <span class="symbol-dot symbol">.</span>
  72. <span class="time-milliseconds time">{{ctime.ms}}</span>
  73. <span class="desc">后过期</span>
  74. </div>
  75. <p class="coupon-detail-desc">· 仅此会场可用 ·</p>
  76. </div>
  77. </div>
  78. <div class="red-packet-list">
  79. <div id="duo-opt-wrapper" class="duo-opt-wrapper">
  80. <div class="duo-opt-container">
  81. <ul class="duo-opt-list" id="duo-opt-list">
  82. <li :class="['opt-item',curGids == 0?'current':'']" @click="selectCate(0)"><span class="desc">精选</span></li>
  83. <li v-for="item in category_list" @click="selectCate(item.id)" :class="[curGids == item.id ? 'current' : '', 'opt-item']" :data-id="item.id"><span class="desc">{{item.name}}</span></li>
  84. </ul>
  85. </div>
  86. </div>
  87. <ul class="duo-goods-list">
  88. <li>
  89. <div class="react-base-list-wrapper ">
  90. <a :data-id="item.goods" :href="item.url" class="double-grid-one" v-for="(item, idx) of goods_list">
  91. <div :class="['double-grid-item', idx%2==0 ? 'gap-right' : 'gap-left']" role="button">
  92. <div class="std-goods-image-square goods-image">
  93. <img :src="item.image">
  94. <div class="goods-name-bg">
  95. <div class="goods-name">{{item.name}}</div>
  96. </div>
  97. </div>
  98. <div class="detail"><b class="after-price-hint">券后价</b><b class="price-icon">¥</b><b class="after-price">{{item.quan_after_price}}</b>
  99. <div class="info"><del>¥{{item.pinprice}}</del></div>
  100. </div><button class="buy-btn">立即抢购</button>
  101. </div>
  102. </a>
  103. </div>
  104. <div class="no-data" v-if="noData">^_^已经到底了</div>
  105. </li>
  106. </ul>
  107. </div>
  108. <div class="available-coupon" v-if="!type">
  109. <div class="available-coupon-container">
  110. <div class="coupon-info coupon-info-type">
  111. <div class="coupon-info-amount"><span class="amount-icon">¥</span><span class="amount-price">{{credit}}</span></div>
  112. </div>
  113. <div class="coupon-timer">
  114. <div class="count-down"><span class="time-hours time">{{ctime.h}}</span><span class="symbol-colon symbol">:</span><span class="time-minutes time">{{ctime.m}}</span><span class="symbol-colon symbol">:</span><span class="time-seconds time">{{ctime.s}}</span><span class="symbol-dot symbol">.</span><span class="time-milliseconds time">{{ctime.ms}}</span></div>
  115. <div>后过期</div>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. {~W('Share/common_quan_share',array($id))}
  124. <script type="text/javascript" src="__PUBLIC__/mogu/bonus/js/polyfill.min.js"></script>
  125. <script src="https://cdn.jsdelivr.net/npm/vue"></script>
  126. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  127. <script type="text/javascript">
  128. var id = {$id};
  129. var type = {$type};
  130. var eTime; // 结束时间
  131. var nowTime; // 现在时间
  132. var endDate; // 剩余时间
  133. var endDate2 = 0; // 计时毫秒 默认7200*1000 2h
  134. var sw = true;
  135. var app = new Vue({
  136. el: '#app',
  137. data: {
  138. isLoading: true,
  139. noData: false,
  140. credit: 0,
  141. category_list: [],
  142. goods_list: [],
  143. ctime: {
  144. h: 0,
  145. m: 0,
  146. s: 0,
  147. ms: 0
  148. },
  149. curGids: 0,
  150. type: 0,
  151. page: 1
  152. },
  153. created: function() {
  154. this.load_voucher_info();
  155. },
  156. mounted() {
  157. var _this = this;
  158. _this.get_goods_list();
  159. window.addEventListener('scroll', function () {
  160. if (document.body.scrollTop + window.innerHeight >= document.body.offsetHeight) {
  161. // 如果开关打开则加载数据
  162. if (sw == true) {
  163. sw = false;
  164. axios.get('index.php?s=/bonus/get_voucher_goods_list/voucher_id/' + id + '/gid/' + _this.curGids + '/page/' + _this.page)
  165. .then(function (res) {
  166. var resObj = res.data;
  167. if (resObj.code == 1) {
  168. _this.noData = true;
  169. return;
  170. }
  171. if (resObj.code == 0) {
  172. var slist = _this.goods_list;
  173. _this.goods_list = slist.concat(resObj.data);
  174. _this.page +=1;
  175. }
  176. sw = true;
  177. })
  178. .catch(function (error) {
  179. console.log(error);
  180. });
  181. }
  182. }
  183. });
  184. $('#loaded').show();
  185. },
  186. methods: {
  187. load_voucher_info: function () {
  188. var self = this
  189. return axios.get('index.php?s=/bonus/load_voucher_info/voucher_id/'+id)
  190. .then(function (res) {
  191. var resObj = res.data;
  192. if(resObj.code == 1){
  193. alert('优惠券不存在');
  194. window.location.href= '{:U("bonus/index")}';
  195. return;
  196. }
  197. if(resObj.code == 0){
  198. eTime = parseInt(resObj.get_voucher_info.end_time);
  199. nowTime = resObj.cur_time;
  200. if (eTime <= nowTime){
  201. window.location.href= '{:U("bonus/overdue")}';
  202. return;
  203. }
  204. self.credit = parseInt(resObj.get_voucher_info.credit);
  205. endDate = (eTime - nowTime)*1000;
  206. if (endDate >= 0) endDate2 = endDate;
  207. self.count_time();
  208. self.type = type;
  209. self.category_list = resObj.category_list;
  210. }
  211. self.posts = res.data.posts
  212. })
  213. .catch(function (error) {
  214. self.fetchError = error
  215. console.log(error)
  216. })
  217. },
  218. get_goods_list: function () {
  219. var _this = this
  220. return axios.get('index.php?s=/bonus/get_voucher_goods_list/voucher_id/' + id + '/gid/' + _this.curGids)
  221. .then(function (res) {
  222. var resObj = res.data;
  223. if(res.data.code == 1) {
  224. _this.noData = true;
  225. _this.isLoading = false;
  226. return;
  227. }
  228. if(res.data.code == 0) {
  229. _this.goods_list = resObj.data;
  230. _this.page +=1;
  231. }
  232. _this.isLoading = false;
  233. })
  234. .catch(function (error) {
  235. _this.fetchError = error
  236. console.log(error)
  237. })
  238. },
  239. count_time: function () {
  240. var self = this
  241. var leftTime = endDate2;
  242. var h, m, s, ms;
  243. if (leftTime >= 0) {
  244. h = Math.floor(leftTime / 1000 / 60 / 60);
  245. m = Math.floor((leftTime - h * 3600 * 1000) / 60 / 1000);
  246. s = Math.floor((leftTime - h * 3600 * 1000 - m * 60 * 1000) / 1000);
  247. ms = Math.floor(leftTime % 1000 / 100);
  248. s = s < 10 ? "0" + s : s;
  249. m = m < 10 ? "0" + m : m;
  250. h = h < 10 ? "0" + h : h;
  251. this.ctime = {h,m,s,ms}
  252. //递归每秒调用countTime方法,显示动态时间效果
  253. setTimeout(function () {
  254. endDate2 -= 100;
  255. self.count_time();
  256. }, 100);
  257. } else {
  258. console.log('已截止')
  259. window.location.href= '{:U("bonus/overdue")}';
  260. }
  261. },
  262. handleApply: function () {
  263. this.type = 0;
  264. },
  265. selectCate: function (id) {
  266. this.curGids = parseInt(id);
  267. sw = true;
  268. this.page = 1;
  269. this.noData = false;
  270. this.goods_list = [];
  271. this.get_goods_list();
  272. }
  273. }
  274. })
  275. </script>
  276. </block>