buyClient.ftl 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <div class="weui-btn-area">
  2. <div style="display:flex; flex-direction: row; justify-content: space-between">
  3. <div class="weui-flex__item">
  4. <div class="placeholder" style="display: inline;align-items: flex-start">当前参团:</div>
  5. <div style="display: inline;align-items: flex-start" id="Buycount"></div>
  6. </div>
  7. </div>
  8. <div class="weui-flex__item">
  9. <div style="display: inline;align-items: flex-end">状&nbsp;&nbsp;&nbsp;&nbsp;态:</div>
  10. <div style="display: inline;margin-top: 1vh;" id="myStatus"></div>
  11. </div>
  12. <div class="weui-flex__item">
  13. <div style="display: inline;align-items: flex-end">剩余套餐(份):</div>
  14. <div style="display: inline;margin-top: 1vh;" id="tc"></div>
  15. </div>
  16. <div class="weui-flex" style="display:flex; flex-direction: row; justify-content: space-between">
  17. <div class="weui-flex__item">
  18. <div style="display: inline;align-items: flex-start">我的团购:</div>
  19. <div style="display: inline;">
  20. <input type="text" id="buyCount"
  21. style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 5vh; width: 50%;font-size: 16px;margin-top: 1vh;"
  22. onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');" min="1" maxlength="4"
  23. onchange="changeBuy()">
  24. </div>
  25. </div>
  26. </div>
  27. <div class="weui-flex__item">
  28. <div style="display: inline;">金&nbsp;&nbsp;&nbsp;&nbsp;额¥:</div>
  29. <div style="display: inline;font-size: 16px" id="myMenory"></div>
  30. </div>
  31. <div class="weui-flex">
  32. <div class="weui-flex__item">
  33. <div style="display: inline;">联系电话:</div>
  34. <div class="weui-flex__item" style="display: inline;">
  35. <input type="text" maxlength="11" id="myPhone" onkeyup="value=value.replace(/[^\d]/g,'')"
  36. maxlength=11
  37. style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 5vh; width: 50%;font-size: 16px;margin-top: 1vh;">
  38. </div>
  39. </div>
  40. </div>
  41. <div style=" flex-direction: row; justify-content: space-between;">
  42. <div style="display: inline;align-items: flex-start"
  43. ">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:
  44. </div>
  45. <textarea id="Myremarks" class="weui-textarea" placeholder="输入内容(200字内)" rows="3"
  46. style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; margin-top: 1vh;"></textarea>
  47. </div>
  48. <div style="display:flex; flex-direction: row; justify-content: space-between; margin-top: 1vh; margin-bottom: 5vh;">
  49. <#if type==1>
  50. <a onclick="buyBack()" href="javascript:;" class="weui-btn weui-btn_default"
  51. style="margin-top: 0;width: 30%;">返回</a>
  52. <#else>
  53. <a id="MybuyRepeal" onclick="MybuyBack()" href="javascript:;" class="weui-btn weui-btn_default"
  54. style="margin-top: 0;width: 30%;">撤销</a>
  55. <a onclick="buyBack()" href="javascript:;" class="weui-btn weui-btn_default"
  56. style="margin-top: 0;width: 30%;">返回</a>
  57. </#if>
  58. <a id="buyCommit" onclick="buyCommit()" href="javascript:;" class="weui-btn weui-btn_primary"
  59. style="margin-top: 0;width: 30%;">提交</a>
  60. </div>
  61. </div>
  62. <#include "/home/frag.foot.ftl" />
  63. <script>
  64. (function ($) {
  65. $.ajax({
  66. url: '/query/getAll/status',
  67. data: {
  68. jmId: $('#jmBuy').val(),
  69. userId: $('#buyuserId').val(),
  70. },
  71. type: 'GET',
  72. success: function (data) {
  73. console.log(data);
  74. $("#Buycount").html(data.data.count);
  75. $("#myStatus").html(getStatus(data.data.tgStatus));
  76. $("#myPhone").val(data.data.phone);
  77. $("#tc").html(data.data.tgMaxNum - data.data.count);
  78. if (data.data.myRemark != null)
  79. $('#Myremarks').text(data.data.myRemark);
  80. if (data.data.buyMoney != null)
  81. $('#buyCount').val(data.data.buyCount);
  82. if (data.data.buyMoney != null)
  83. $('#myMenory').text(data.data.buyMoney);
  84. },
  85. error: function () {
  86. }
  87. });
  88. })(jQuery);
  89. <#--返回-->
  90. function buyBack() {
  91. // window.history.back();
  92. window.location.href = "/user/homeIndex.html?userId=" + $('#buyuserId').val() + "&userType=" + 1 + "&show=tuangou"+"&type="+2;
  93. }
  94. /*撤销*/
  95. function MybuyBack() {
  96. $.ajax({
  97. url: '/home/back/buyBack',
  98. data: {
  99. userId: $('#buyuserId').val(),
  100. buyCount: $('#buyCount').val(),
  101. phone: $('#myPhone').val(),
  102. myRemark: $('#Myremarks').val(),
  103. buyMoney: $('#myMenory').text(),
  104. jmId: $('#jmBuy').val(),
  105. },
  106. type: 'GET',
  107. success: function (data) {
  108. console.log(data);
  109. if (data.data == 1) {
  110. buyBack();
  111. } else {
  112. $.alert("该套餐已过截止日期或者已发货中不允许撤单");
  113. }
  114. },
  115. error: function () {
  116. }
  117. });
  118. }
  119. //提交
  120. function buyCommit() {
  121. if ($('#buyCount').val() == '' || $('#buyCount').val() == undefined) {
  122. $.alert("请填写团购数量");
  123. return;
  124. }
  125. if ($('#myPhone').val() == undefined || $('#myPhone').val() == '') {
  126. $.alert("请填写联系电话");
  127. return;
  128. }
  129. if (!(/^1[34578]\d{9}$/.test($('#myPhone').val()))) {
  130. $.alert("手机号码有误,请重填");
  131. return false;
  132. }
  133. /* if ($('#Myremarks').val() == undefined || $('#Myremarks').val() == '') {
  134. $.alert("请填写备注");
  135. return;
  136. }*/
  137. changeBuy();
  138. $.ajax({
  139. url: '/home/home/buyGroup',
  140. data: {
  141. userId: $('#buyuserId').val(),
  142. buyCount: $('#buyCount').val(),
  143. phone: $('#myPhone').val(),
  144. myRemark: $('#Myremarks').val(),
  145. buyMoney: $('#myMenory').text(),
  146. jmId: $('#jmBuy').val(),
  147. count: $('#tc').html(),
  148. },
  149. type: 'GET',
  150. async: false,
  151. success: function (data) {
  152. console.log(data.data);
  153. if (data.data == 3) {
  154. $.alert("团购数量已经超过最大上限");
  155. return false;
  156. }
  157. buyBack();
  158. },
  159. error: function () {
  160. }
  161. });
  162. }
  163. //输入购买的数量
  164. function changeBuy() {
  165. if ($('#buyCount').val() < 1) {
  166. $('#buyCount').val('')
  167. $.alert('请输入大于0的整数')
  168. return;
  169. }
  170. $.ajax({
  171. url: '/query/getAll/status',
  172. data: {
  173. jmId: $('#jmBuy').val(),
  174. userId: $('#buyuserId').val(),
  175. },
  176. type: 'GET',
  177. async: false,
  178. success: function (data) {
  179. console.log(data);
  180. $("#myMenory").html($('#buyCount').val() * data.data.tgPrice)
  181. },
  182. error: function () {
  183. }
  184. });
  185. }
  186. //1 在团 2 发货 3完成 4取消',
  187. function getStatus(v) {
  188. if (v == 1) {
  189. return "<span style='color:green;'>在团</span>";
  190. } else if (v == 2) {
  191. return "<span style='color:Black;'>发货</span>";
  192. } else if (v == 3) {
  193. return "完成";
  194. } else if (v == 4) {
  195. return "<span style='color:red;'>取消</span>";
  196. }
  197. }
  198. </script>