index.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
  6. <title>兑奖中心</title>
  7. <link rel="stylesheet" href="__STATIC__/box/css/_flexible.css?v={:config('js_version')}">
  8. <link rel="stylesheet" href="__STATIC__/box/css/exchange.css?v={:config('js_version')}">
  9. <script src="__STATIC__/box/js/flexible375.js?v={:config('js_version')}"></script>
  10. </head>
  11. <body>
  12. <div class="exchange">
  13. <div class="exchange_top">
  14. 可用金币:{$integral}
  15. </div>
  16. <div class="article">
  17. <foreach name="list" item="vo">
  18. <div class="article_cell <if condition=" $vo.object_type eq 'rp'">article_red<else/>article_entity</if>">
  19. <div class="article_img">
  20. <img id="good_img_{$vo.good_id}" src="{$vo.original_img}" alt="">
  21. <if condition="$vo.object_type eq 'rp'">
  22. <span>{:intval($vo.market_price)}元</span>
  23. </if>
  24. </div>
  25. <p class="article_name" <if
  26. condition="$vo.object_type eq 'rp'">style='display:none;'</if>>{$vo.goods_name}</p>
  27. <p class="article_price">
  28. <img src="__STATIC__/box/images/jinbi.png" alt="">
  29. <span>{:intval($vo.integral)}金币</span>
  30. </p>
  31. <div class="article_exchange">
  32. <button class="js-exchange" name="{$vo.goods_name}" gid="{$vo.good_id}"
  33. integral="{:intval($vo.integral)}"
  34. genre="<if condition=" $vo.object_type eq 'rp'">red<else/>entity</if>">兑换</button>
  35. </div>
  36. </div>
  37. </foreach>
  38. </div>
  39. <div class="exchange_footer">
  40. <a href="{:url('exchange/log/'.$wx_app_id)}?v={:config('js_version')}" class="item f">我的奖品</a>
  41. <a href="{:url('index/settle/'.$wx_app_id)}?v={:config('js_version')}" class="item l">红包提现</a>
  42. </div>
  43. </div>
  44. <div class="dialog js-dialog-error">
  45. <div class="dialog_mask"></div>
  46. <div class="dialog_cnt">
  47. <div class="dialog_red">
  48. <h1 class="title" style="color:#9E9E9E">兑换失败</h1>
  49. <p class="info">
  50. <span id="err_msg"></span>
  51. </p>
  52. <button class="save js-close">确定</button>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="dialog js-dialog-tips">
  57. <div class="dialog_mask"></div>
  58. <div class="dialog_cnt">
  59. <div class="dialog_red">
  60. <h1 class="title" style="color:#9E9E9E">确定要兑换么?</h1>
  61. <p class="info">
  62. <span id="tips_msg">确定要兑换么?</span>
  63. </p>
  64. <div>
  65. <button class="save js-close">确定</button>
  66. <button class="save js-cancel" style="background-color:#9E9E9E;">取消</button>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. <div class="dialog js-dialog-red">
  72. <div class="dialog_mask"></div>
  73. <div class="dialog_cnt">
  74. <div class="dialog_red">
  75. <h1 class="title">恭喜,兑换成功</h1>
  76. <p class="info">
  77. 获得 <img id="red-img" src="__STATIC__/box/images/xiaohongb.png" alt=""> <span id="red-title">100元</span>
  78. </p>
  79. <button class="save js-close">确定</button>
  80. </div>
  81. </div>
  82. </div>
  83. <div class="dialog js-dialog-entity">
  84. <div class="dialog_mask"></div>
  85. <div class="dialog_cnt">
  86. <div class="dialog_entity">
  87. <p class="prompt">请输入您的联系方式,稍后客服将会联系您</p>
  88. <input class="input js-name" type="text" placeholder="姓名:">
  89. <input class="input js-mobile" type="text" placeholder="手机号:">
  90. <div>
  91. <button class="save js-close">确定</button>
  92. <button class="save js-cancel" style="background-color:#9E9E9E;">取消</button>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <div class="pop_outer" id="pop" style="display: none;">
  98. <div class="pop_inner">
  99. <div class="pop_title">温馨提示</div>
  100. <div class="pop_content" id="popContent">
  101. </div>
  102. <div class="pop_btn-group">
  103. <button class="pop_btn pop_btn__block" id="popBtn">确定</button>
  104. </div>
  105. </div>
  106. </div>
  107. <script src="__STATIC__/box/js/jquery.js"></script>
  108. <script>
  109. var total_integral = '{$integral}';
  110. var gid = 0;
  111. var name = '';
  112. $(function () {
  113. $('.article .js-exchange').on('click', function () {
  114. var type = $(this).attr('genre');
  115. var integral = $(this).attr('integral');
  116. gid = $(this).attr('gid');
  117. name = $(this).attr('name');
  118. if (+ total_integral < + integral) {
  119. showError('金币余额不足!');
  120. return false;
  121. }
  122. if (type === 'entity') {
  123. $('.js-dialog-entity').fadeIn(200);
  124. $('.js-cancel').unbind('click').bind('click', function () {
  125. $(this).closest('.dialog').fadeOut(200)
  126. });
  127. $('.js-close').unbind('click').bind('click', function () {
  128. var mobile = $('.js-close').parent().siblings('.js-mobile').val();
  129. var mem = $('.js-close').parent().siblings('.js-name').val();
  130. if (mobile == '' || mem == '') {
  131. $('#popContent').text('请输入您的完整信息!');
  132. $('#pop').show();
  133. return false;
  134. }
  135. var params = {
  136. format: 'json',
  137. mobile: mobile,
  138. mem : mem,
  139. gid : gid,
  140. };
  141. $.ajax({
  142. url : '/exchange/good/{$wx_app_id}',
  143. type : 'post',
  144. data : params,
  145. success: function (res) {
  146. if (res.code === 200) {
  147. var path = $('#good_img_' + gid).attr('src');
  148. $("#red-img").attr('src', path);
  149. $("#red-title").text(name);
  150. $('.js-dialog-red').fadeIn(200);
  151. $('.js-close').unbind('click').bind('click', function () {
  152. $(this).closest('.js-dialog-red').fadeOut(200)
  153. location.href = '/exchange/log/{$wx_app_id}.html'
  154. })
  155. } else {
  156. showError(res.msg);
  157. return false;
  158. }
  159. }
  160. });
  161. $(this).closest('.js-dialog-entity').fadeOut(200)
  162. })
  163. } else if (type === 'red') {
  164. var tips_msg = '您正在花费' + integral + '金币兑换:' + name;
  165. $('#tips_msg').text(tips_msg);
  166. $('.js-dialog-tips').fadeIn(200);
  167. $('.js-cancel').unbind('click').bind('click', function () {
  168. $(this).closest('.dialog').fadeOut(200)
  169. });
  170. $('.js-close').unbind('click').bind('click', function () {
  171. $(this).closest('.dialog').fadeOut(200)
  172. var params = {
  173. format: 'json',
  174. gid : gid,
  175. };
  176. $.ajax({
  177. url : '/exchange/good/{$wx_app_id}',
  178. type : 'post',
  179. data : params,
  180. success: function (res) {
  181. if (res.code === 200) {
  182. $("#red-title").text(name);
  183. $('.js-dialog-red').fadeIn(200);
  184. $('.js-close').unbind('click').bind('click', function () {
  185. $(this).closest('.js-dialog-red').fadeOut(200)
  186. location.href = '/exchange/log/{$wx_app_id}.html'
  187. })
  188. } else {
  189. showError(res.msg);
  190. return false;
  191. }
  192. }
  193. });
  194. });
  195. }
  196. });
  197. $('#popBtn').on('click', function () {
  198. $('#pop').hide()
  199. });
  200. })
  201. function showError(msg) {
  202. $('.js-dialog-error').fadeIn(200);
  203. if (msg != '') {
  204. $('#err_msg').text(msg);
  205. }
  206. $('.js-close').unbind('click').bind('click', function () {
  207. $(this).closest('.js-dialog-error').fadeOut(200)
  208. })
  209. }
  210. </script>
  211. </body>
  212. </html>